loki-mode 7.5.28 → 7.5.30

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 (76) hide show
  1. package/SKILL.md +2 -2
  2. package/VERSION +1 -1
  3. package/autonomy/loki +3 -3
  4. package/dashboard/__init__.py +1 -1
  5. package/dashboard/server.py +19 -0
  6. package/docs/INSTALLATION.md +1 -1
  7. package/docs/MERGE-DEDUP-MAP.md +420 -0
  8. package/docs/MERGE-ROUTE-MAP.md +139 -0
  9. package/docs/MERGE3-PLAN.md +119 -0
  10. package/loki-ts/dist/loki.js +2 -2
  11. package/mcp/__init__.py +1 -1
  12. package/package.json +2 -2
  13. package/web-app/dist/assets/{AdminPage-DwVUK4v9.js → AdminPage-CKUOsWZW.js} +3 -3
  14. package/web-app/dist/assets/{Avatar-B7gqhcg3.js → Avatar-CL9Id9Hi.js} +1 -1
  15. package/web-app/dist/assets/{Badge-DA3xNJAS.js → Badge-B12zwlD7.js} +1 -1
  16. package/web-app/dist/assets/{Button-BPXURLaK.js → Button-CFLVoduT.js} +1 -1
  17. package/web-app/dist/assets/{ComparePage-B0JQMhKG.js → ComparePage-Dg0UdZAk.js} +1 -1
  18. package/web-app/dist/assets/{GitHubIssuesPanel-D38-fy29.js → GitHubIssuesPanel-CSitxtAX.js} +2 -2
  19. package/web-app/dist/assets/{GitHubPRsPanel-DLPcW3N0.js → GitHubPRsPanel-BIT06FRo.js} +1 -1
  20. package/web-app/dist/assets/HomePage-pU_0fGny.js +28 -0
  21. package/web-app/dist/assets/{LoginPage-DqCzxsfx.js → LoginPage-DTZtt2Yb.js} +1 -1
  22. package/web-app/dist/assets/MagicPage-10zfra8o.js +31 -0
  23. package/web-app/dist/assets/{MetricsPage-CPYQR0zr.js → MetricsPage-C-wiKUkv.js} +1 -1
  24. package/web-app/dist/assets/NotFoundPage-BDkcmhYe.js +1 -0
  25. package/web-app/dist/assets/{ProjectPage-DNujSl6j.js → ProjectPage-CiCavQ8n.js} +71 -71
  26. package/web-app/dist/assets/ProjectsPage-BLCXQwwC.js +6 -0
  27. package/web-app/dist/assets/{SettingsPage-BaQJbOgL.js → SettingsPage-PkxtaMyg.js} +3 -3
  28. package/web-app/dist/assets/{ShowcasePage-DQR_e-kg.js → ShowcasePage-iECp8Tha.js} +1 -1
  29. package/web-app/dist/assets/SystemSettingsPage-DS6Anno1.js +6 -0
  30. package/web-app/dist/assets/{TeamsPage-DOFErDqX.js → TeamsPage-ls6h6bNL.js} +1 -1
  31. package/web-app/dist/assets/{TemplatesPage-Ty72hILN.js → TemplatesPage-Bk0QzlPt.js} +3 -3
  32. package/web-app/dist/assets/{TerminalOutput-DqOVnR1p.js → TerminalOutput-4-1hWCtZ.js} +1 -1
  33. package/web-app/dist/assets/{activity-BgBZ4s4c.js → activity-DH3ih2nS.js} +1 -1
  34. package/web-app/dist/assets/{bell-C-UezVWi.js → bell-Gn17S6uv.js} +1 -1
  35. package/web-app/dist/assets/{bot-D70fEnm5.js → bot-Cbycc3VE.js} +1 -1
  36. package/web-app/dist/assets/{check-CBohulxQ.js → check-nIAqa-kf.js} +1 -1
  37. package/web-app/dist/assets/{chevron-left-C-emzUhB.js → chevron-left-D2jcWDll.js} +1 -1
  38. package/web-app/dist/assets/{circle-alert-8SRY0_GX.js → circle-alert-CpL4Bhvt.js} +1 -1
  39. package/web-app/dist/assets/{clock-mfq4XnPQ.js → clock-IW4Wq86N.js} +1 -1
  40. package/web-app/dist/assets/{cloud-DpRM7T8t.js → cloud-Cn8nNuH2.js} +1 -1
  41. package/web-app/dist/assets/{code-xml-1N2Ui-4c.js → code-xml-BiJBteXf.js} +1 -1
  42. package/web-app/dist/assets/{copy-LXquTgzI.js → copy-CnqkyNsi.js} +1 -1
  43. package/web-app/dist/assets/{database-S1dyXnuT.js → database-CKSReqa5.js} +1 -1
  44. package/web-app/dist/assets/{dollar-sign-CRqk0dW5.js → dollar-sign-CDzDY64R.js} +1 -1
  45. package/web-app/dist/assets/{file-code-corner-B99CwY_6.js → file-code-corner-Box4IwG1.js} +1 -1
  46. package/web-app/dist/assets/{file-plus-DZ5qnz5b.js → file-plus-DpGqlXF8.js} +1 -1
  47. package/web-app/dist/assets/{folder-open-DBCm7yuF.js → folder-open-B57dAoBv.js} +1 -1
  48. package/web-app/dist/assets/{git-commit-horizontal-DM1ERuNd.js → git-commit-horizontal-BVbucmO5.js} +1 -1
  49. package/web-app/dist/assets/{globe-B7xEJSL_.js → globe-BkOnKl4x.js} +1 -1
  50. package/web-app/dist/assets/{hammer-Cgi3LTuS.js → hammer-DRbIQ4QU.js} +1 -1
  51. package/web-app/dist/assets/{index-BN52-GQT.js → index-CM_b_EhP.js} +77 -77
  52. package/web-app/dist/assets/{layers-Bi8RPIBC.js → layers-B78BiFiU.js} +1 -1
  53. package/web-app/dist/assets/{lightbulb-Doc_n8JX.js → lightbulb-B-Itbm9g.js} +1 -1
  54. package/web-app/dist/assets/{loader-circle-BB932A7A.js → loader-circle-Oq6NQhW2.js} +1 -1
  55. package/web-app/dist/assets/{lock-Bt6gpMrs.js → lock-DbJ9zxbw.js} +1 -1
  56. package/web-app/dist/assets/{mail-BuzAu1IP.js → mail-CzMRod6m.js} +1 -1
  57. package/web-app/dist/assets/{package-BE5FHxQ8.js → package-WZ5osvej.js} +1 -1
  58. package/web-app/dist/assets/{plus-CNqABexN.js → plus-j08lFR-K.js} +1 -1
  59. package/web-app/dist/assets/{refresh-cw-34B13ztx.js → refresh-cw-CIr7E-g2.js} +1 -1
  60. package/web-app/dist/assets/{rotate-ccw-CrD2QB29.js → rotate-ccw-gwoXxDeE.js} +1 -1
  61. package/web-app/dist/assets/{save-DsJcqdnI.js → save-B8fV_ZpE.js} +1 -1
  62. package/web-app/dist/assets/{server-BcgRMArA.js → server-D5dO1paz.js} +1 -1
  63. package/web-app/dist/assets/{shield-alert-DLYLdVJ0.js → shield-alert-Du08zhdg.js} +1 -1
  64. package/web-app/dist/assets/{trash-2-Cc-VTvzt.js → trash-2-DEKSVae5.js} +1 -1
  65. package/web-app/dist/assets/{trending-down-CrDpO2a_.js → trending-down-DBiXUtxJ.js} +1 -1
  66. package/web-app/dist/assets/{trending-up-CNVsmM3G.js → trending-up-BgmK_tHq.js} +1 -1
  67. package/web-app/dist/assets/{upload-LuDuB7Wc.js → upload-IaViyeVD.js} +1 -1
  68. package/web-app/dist/assets/{usePolling-C8rvc-CG.js → usePolling-PiRLqNu6.js} +1 -1
  69. package/web-app/dist/assets/{user-BT79cI-o.js → user-BB5J8wAF.js} +1 -1
  70. package/web-app/dist/index.html +2 -3
  71. package/web-app/server.py +45 -7
  72. package/web-app/dist/assets/HomePage-CzeoS2V_.js +0 -28
  73. package/web-app/dist/assets/MagicPage-CBLqpa55.js +0 -31
  74. package/web-app/dist/assets/NotFoundPage-B62u4iCs.js +0 -1
  75. package/web-app/dist/assets/ProjectsPage-uHG7kxB-.js +0 -6
  76. package/web-app/dist/assets/SystemSettingsPage-C_Q_1WK4.js +0 -6
@@ -0,0 +1,119 @@
1
+ # Phase Merge-3 Implementation Plan: Vite Rebuild with `/lab/` Base
2
+
3
+ **Status:** Architect-approved 2026-05-23. Dev fleet implements per this plan.
4
+ **Owner:** Phase Merge-3 of the v7.5.29+ Purple-Lab-into-Dashboard true-integration arc.
5
+ **Predecessors:** `docs/MERGE-ROUTE-MAP.md` (Merge-1), `docs/MERGE-DEDUP-MAP.md` (Merge-2).
6
+
7
+ ## Binding Decisions
8
+
9
+ 1. **Vite `base: '/lab/'`.** Single config change applies in dev + build.
10
+ 2. **API base via `import.meta.env.BASE_URL`.** No `/lab/` hardcoded in TypeScript -- the env var resolves to `/lab/` at build time and `/` in tests.
11
+ 3. **`loki web` standalone server ALSO mounts its app under `/lab/`.** Same bundle, same routing model as the merged Dashboard. Root `/` redirects to `/lab/`. Rule 0 preserved by URL shift only.
12
+ 4. **No duplicated dist artifacts.** Single `web-app/dist/` shipped to npm + Docker. No `base: '/'` second build.
13
+
14
+ ## File Diffs (concrete)
15
+
16
+ ### 1. `web-app/vite.config.ts`
17
+ ```diff
18
+ export default defineConfig({
19
+ plugins: [react()],
20
+ + base: '/lab/',
21
+ resolve: { alias: { '@': path.resolve(__dirname, './src') } },
22
+ server: {
23
+ port: 5173,
24
+ proxy: {
25
+ - '/api': { target: 'http://localhost:57375', changeOrigin: true },
26
+ - '/proxy': { target: 'http://localhost:57375', changeOrigin: true, ws: true },
27
+ - '/ws': { target: 'ws://localhost:57375', ws: true },
28
+ + '/lab/api': { target: 'http://localhost:57375', changeOrigin: true },
29
+ + '/lab/proxy': { target: 'http://localhost:57375', changeOrigin: true, ws: true },
30
+ + '/lab/ws': { target: 'ws://localhost:57375', ws: true },
31
+ },
32
+ },
33
+ })
34
+ ```
35
+
36
+ ### 2. `web-app/src/api/client.ts` (line 3 + line 7 area)
37
+ ```diff
38
+ -const API_BASE = (import.meta as any).env?.VITE_API_BASE
39
+ - || `${window.location.origin}/api`;
40
+ +const BASE = (import.meta as any).env?.BASE_URL || '/';
41
+ +const API_BASE = (import.meta as any).env?.VITE_API_BASE
42
+ + || `${window.location.origin}${BASE}api`;
43
+ +const WS_BASE = `${window.location.protocol === 'https:' ? 'wss:' : 'ws:'}//${window.location.host}${BASE}ws`;
44
+ ```
45
+ Then export `WS_BASE` and route any other websocket constructor through it.
46
+
47
+ ### 3. `web-app/src/pages/MagicPage.tsx` (4 hardcoded fetches at lines 43, 65, 86, 106)
48
+ Convert each `fetch('/api/magic/...')` to use a shared base. Cleanest fix: import the client API base:
49
+ ```diff
50
+ - const res = await fetch('/api/magic/components');
51
+ + const res = await fetch(`${import.meta.env.BASE_URL}api/magic/components`);
52
+ ```
53
+ Apply to all 4 sites. Or extract a `magicApi` helper in `web-app/src/api/client.ts`.
54
+
55
+ ### 4. `web-app/src/components/TerminalEmulator.tsx` (line 49)
56
+ ```diff
57
+ - const wsUrl = `${protocol}//${window.location.host}/ws/terminal/${sessionId}`;
58
+ + const wsUrl = `${protocol}//${window.location.host}${import.meta.env.BASE_URL}ws/terminal/${sessionId}`;
59
+ ```
60
+
61
+ ### 5. `web-app/server.py` -- standalone mount (added in Merge-4; staged here)
62
+
63
+ The architect's option 2: standalone server self-mounts at `/lab/`. The actual wiring lives in Merge-4, but Merge-3 needs to verify the URL flip works for `loki web`. For Merge-3 alone, we accept the standalone `loki web` URL changes to `http://127.0.0.1:57375/lab/`. Browser-open auto-redirect is added in Merge-4.
64
+
65
+ ### 6. `autonomy/loki` `cmd_web_start` browser-open URL (line ~3694)
66
+ Change the `open` URL from `http://127.0.0.1:${PURPLE_LAB_DEFAULT_PORT}/` to `http://127.0.0.1:${PURPLE_LAB_DEFAULT_PORT}/lab/`.
67
+
68
+ ## Release Pipeline Wiring
69
+
70
+ ### 7. Root `package.json` `prepublishOnly` (line ~106)
71
+ Append `&& cd ../web-app && npm ci && npm run build && test -f dist/index.html` after the existing dashboard-ui build.
72
+
73
+ ### 8. `Dockerfile`
74
+ Add `COPY` for web-app build artifacts + server files. Mirror the `dashboard/` COPY pattern. (Merge-4 owns the actual import; Merge-3 ensures files are in the image.)
75
+
76
+ ### 9. `scripts/local-ci.sh`
77
+ Add a check between existing steps:
78
+ ```bash
79
+ run_check "web-app build produces /lab/-prefixed assets" \
80
+ '(cd web-app && npm ci --silent && npm run build) && grep -q "/lab/assets/" web-app/dist/index.html'
81
+ ```
82
+
83
+ ## Tests (Merge-3 acceptance)
84
+
85
+ | ID | Test | Type |
86
+ |---|---|---|
87
+ | T1 | `grep -q '/lab/assets/' web-app/dist/index.html` after `npm run build` | bash, local-ci |
88
+ | T2 | `grep -q '/lab/api' web-app/dist/assets/index-*.js` (runtime base baked in) | bash, local-ci |
89
+ | T3 | `loki web --no-open; curl -sL http://127.0.0.1:57375/lab/ \| grep -q '<div id="root">'` | bash |
90
+ | T4 | `curl -s http://127.0.0.1:57375/lab/assets/index-*.js` returns JS not 404 | bash |
91
+ | T5 | Playwright: visit `http://127.0.0.1:57375/lab/`, no console 404s, screenshot HomePage baseline | Playwright |
92
+ | T6 | (Post-Merge-4) visit `http://127.0.0.1:57374/lab/`, screenshot diff vs T5 pixel-identical | Playwright |
93
+ | T7 | `curl -s http://127.0.0.1:57374/` returns Dashboard root unchanged | bash |
94
+ | T8 | `npm pack --dry-run \| grep web-app/dist/index.html` succeeds | local-ci |
95
+
96
+ ## Risks (with mitigations)
97
+
98
+ 1. **Hardcoded `/api/` strings drift back over time.** Mitigation: add local-ci grep guard:
99
+ `! grep -rn "['\"]/api\|['\"]/ws" web-app/src/ | grep -v "BASE_URL\|external"`
100
+
101
+ 2. **`/vite.svg` favicon 404 under `/lab/`.** Mitigation: verify `web-app/public/vite.svg` exists; if not, remove the `<link rel="icon" href="/vite.svg">` line from `web-app/index.html`.
102
+
103
+ 3. **Dev workflow break (`http://localhost:5173/` returns 404).** Mitigation: document `http://localhost:5173/lab/` in `web-app/README.md`; optionally add Vite middleware to redirect `/` -> `/lab/` in dev.
104
+
105
+ 4. **Cookies set at root path.** Mitigation: Merge-2 audit confirmed no cookies (Bearer tokens only). Re-verify with curl post-build.
106
+
107
+ 5. **Stale dist in git.** Mitigation: local-ci T1/T2 catch it. Stronger: pre-push hook that runs `npm run build` if src is newer than dist (deferred to follow-up).
108
+
109
+ ## NOT Done In This Phase
110
+
111
+ - Auto-spawn web-app subprocess from `loki dashboard` (Merge-4).
112
+ - Sidebar entry in `dashboard/static/index.html` (Merge-6).
113
+ - Deep state dedup (Merge-5).
114
+ - Deprecation of `loki web` (Merge-7).
115
+ - `vite-plugin-html` dev `/` -> `/lab/` redirect (nice-to-have, not blocking).
116
+
117
+ ## Acceptance Gate
118
+
119
+ Merge-3 ships when: T1-T4 + T7 + T8 green, no `git status` noise outside the planned files, `loki web --no-open` serves the Lab UI at `/lab/` end-to-end with browser-side console clean (verified by Playwright T5).
@@ -451,7 +451,7 @@ Subcommands:
451
451
 
452
452
  This command is invoked by autonomy/run.sh between iterations. Users
453
453
  should not run it directly -- run \`loki start\` instead.
454
- `,iK;var T7=L(()=>{y();_1();iK=o1});y();import{readFileSync as E7}from"fs";import{resolve as x7,dirname as F7}from"path";import{fileURLToPath as w7}from"url";var o=null;function i1(){if(o!==null)return o;let K="7.5.28";if(typeof K==="string"&&K.length>0)return o=K,o;try{let $=F7(w7(import.meta.url)),z=S1($);o=E7(x7(z,"VERSION"),"utf-8").trim()}catch{o="unknown"}return o}function e1(){return process.stdout.write(`Loki Mode v${i1()}
454
+ `,iK;var T7=L(()=>{y();_1();iK=o1});y();import{readFileSync as E7}from"fs";import{resolve as x7,dirname as F7}from"path";import{fileURLToPath as w7}from"url";var o=null;function i1(){if(o!==null)return o;let K="7.5.30";if(typeof K==="string"&&K.length>0)return o=K,o;try{let $=F7(w7(import.meta.url)),z=S1($);o=E7(x7(z,"VERSION"),"utf-8").trim()}catch{o="unknown"}return o}function e1(){return process.stdout.write(`Loki Mode v${i1()}
455
455
  `),0}p();n();y();import{readFileSync as C7,existsSync as h7}from"fs";import{resolve as b7}from"path";var y7=["claude","codex","cline","aider"];function $0(){let K=b7(P(),"state","provider");if(!h7(K))return"";try{return C7(K,"utf-8").trim()}catch{return""}}function v7(K,$){return K||$||process.env.LOKI_PROVIDER||"claude"}function g7(K){let $=$0(),z=v7(K,$);switch(process.stdout.write(`${k}Current Provider${W}
456
456
  `),process.stdout.write(`
457
457
  `),process.stdout.write(`${O}Provider:${W} ${z}
@@ -534,4 +534,4 @@ Set LOKI_LEGACY_BASH=1 to force the bash CLI for every command.
534
534
  `),2}default:return process.stderr.write(`Unknown command: ${$}
535
535
  `),process.stderr.write(A7),2}}process.on("SIGINT",()=>process.exit(130));process.on("SIGTERM",()=>process.exit(143));var $6=await K6(Bun.argv.slice(2));process.exit($6);
536
536
 
537
- //# debugId=5D3D743E0B8B4D5364756E2164756E21
537
+ //# debugId=7C8104E1C877694564756E2164756E21
package/mcp/__init__.py CHANGED
@@ -57,4 +57,4 @@ try:
57
57
  except ImportError:
58
58
  __all__ = ['mcp']
59
59
 
60
- __version__ = '7.5.28'
60
+ __version__ = '7.5.30'
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "loki-mode",
3
- "version": "7.5.28",
3
+ "version": "7.5.30",
4
4
  "description": "Loki Mode by Autonomi. Multi-agent autonomous SDLC framework. Spec to deployed app: PRD, GitHub issue, OpenAPI/JSON/YAML, or one-line brief. 4 AI providers (Claude Code, OpenAI Codex, Cline, Aider). 11 quality gates.",
5
5
  "keywords": [
6
6
  "agent",
@@ -103,7 +103,7 @@
103
103
  ],
104
104
  "scripts": {
105
105
  "prepack": "find . -type d -name __pycache__ -exec rm -rf {} + 2>/dev/null; find . -name '*.pyc' -delete 2>/dev/null; if command -v bun >/dev/null 2>&1; then (cd loki-ts && bun install --production && bun run build) || echo 'WARN: loki-ts build failed, using existing dist if present'; else echo 'WARN: bun not on PATH, skipping loki-ts build (using committed dist if present)'; fi; true",
106
- "prepublishOnly": "cd dashboard-ui && npm ci && npm run build:all && test -f ../dashboard/static/index.html",
106
+ "prepublishOnly": "cd dashboard-ui && npm ci && npm run build:all && test -f ../dashboard/static/index.html && cd ../web-app && npm ci && npm run build && test -f dist/index.html && grep -q /lab/assets/ dist/index.html",
107
107
  "test": "bash -n autonomy/run.sh && bash -n autonomy/loki && bash -n autonomy/completion-council.sh && bash -n autonomy/app-runner.sh && bash -n autonomy/prd-checklist.sh && bash -n autonomy/playwright-verify.sh && node --test tests/protocols/*.test.js && node --test tests/protocols/a2a/*.test.js && node --test tests/observability/*.test.js && node --test tests/policies/*.test.js && node --test tests/audit/*.test.js && node --test tests/integrations/*.test.js && node --test tests/integrations/jira/*.test.js && node --test tests/integrations/github/*.test.js && node --test tests/integrations/slack/*.test.js && bash tests/managed_memory/test_flag_matrix.sh && bash tests/managed_memory/test_sdk_isolation.sh && bash tests/managed_memory/test_kill_switch.sh && python3 -m unittest tests.managed_memory.test_shadow_write_mock tests.managed_memory.test_retrieve_mock && echo 'All checks passed'",
108
108
  "test:visual": "node --experimental-vm-modules node_modules/jest/bin/jest.js dashboard-ui/tests/visual-regression.test.js",
109
109
  "test:parity": "node --experimental-vm-modules dashboard-ui/scripts/check-parity.js",
@@ -1,4 +1,4 @@
1
- import{c as L,j as e,r as m,v as _,Z as Q,m as X,h as ee,b as R,F as ge,U as z,X as te,L as se,w as je,M as fe,T as G,S as be,l as ae,k as ne,x as ve,E as Ee,Q as Ne,Y as re}from"./index-BN52-GQT.js";import{B as w}from"./Button-BPXURLaK.js";import{T as ye}from"./trending-up-CNVsmM3G.js";import{C as I}from"./clock-mfq4XnPQ.js";import{A as ke,U as ie}from"./Avatar-B7gqhcg3.js";import{A as H}from"./activity-BgBZ4s4c.js";import{R as le}from"./refresh-cw-34B13ztx.js";import{G as Ae}from"./globe-B7xEJSL_.js";import{C as we}from"./chevron-left-C-emzUhB.js";import{M as Ce}from"./mail-BuzAu1IP.js";import{C as ce}from"./check-CBohulxQ.js";import{D as W}from"./dollar-sign-CRqk0dW5.js";import{U as Se}from"./user-BT79cI-o.js";import{D as De}from"./database-S1dyXnuT.js";import{L as Fe}from"./lock-Bt6gpMrs.js";import{H as Me}from"./hammer-Cgi3LTuS.js";import{S as Be}from"./shield-alert-DLYLdVJ0.js";import{S as $e}from"./server-BcgRMArA.js";/**
1
+ import{c as L,j as e,r as m,w as _,Z as X,n as Q,i as ee,b as R,F as ge,U as z,X as te,L as se,x as je,M as fe,T as G,S as be,m as ae,l as ne,y as ve,E as Ee,V as Ne,$ as re}from"./index-CM_b_EhP.js";import{B as w}from"./Button-CFLVoduT.js";import{T as ye}from"./trending-up-BgmK_tHq.js";import{C as I}from"./clock-IW4Wq86N.js";import{A as ke,U as ie}from"./Avatar-CL9Id9Hi.js";import{A as H}from"./activity-DH3ih2nS.js";import{R as le}from"./refresh-cw-CIr7E-g2.js";import{G as Ae}from"./globe-BkOnKl4x.js";import{C as we}from"./chevron-left-D2jcWDll.js";import{M as Ce}from"./mail-CzMRod6m.js";import{C as ce}from"./check-nIAqa-kf.js";import{D as W}from"./dollar-sign-CDzDY64R.js";import{U as Se}from"./user-BB5J8wAF.js";import{D as De}from"./database-CKSReqa5.js";import{L as Fe}from"./lock-DbJ9zxbw.js";import{H as Me}from"./hammer-DRbIQ4QU.js";import{S as Be}from"./shield-alert-Du08zhdg.js";import{S as $e}from"./server-D5dO1paz.js";/**
2
2
  * @license lucide-react v0.577.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -28,5 +28,5 @@ import{c as L,j as e,r as m,v as _,Z as Q,m as X,h as ee,b as R,F as ge,U as z,X
28
28
  *
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
- */const Ge=[["circle",{cx:"15",cy:"12",r:"3",key:"1afu0r"}],["rect",{width:"20",height:"14",x:"2",y:"5",rx:"7",key:"g7kal2"}]],He=L("toggle-right",Ge);function We({percentage:n,size:a=64,strokeWidth:t=4,color:l="#553DE9",trackColor:c="rgba(0,0,0,0.08)",className:s="",children:r}){const o=(a-t)/2,g=2*Math.PI*o,j=Math.max(0,Math.min(100,n)),u=g-j/100*g;return e.jsxs("div",{className:`relative inline-flex items-center justify-center ${s}`,style:{width:a,height:a},children:[e.jsxs("svg",{width:a,height:a,className:"transform -rotate-90",children:[e.jsx("circle",{cx:a/2,cy:a/2,r:o,fill:"none",stroke:c,strokeWidth:t}),e.jsx("circle",{cx:a/2,cy:a/2,r:o,fill:"none",stroke:l,strokeWidth:t,strokeLinecap:"round",strokeDasharray:g,strokeDashoffset:u,style:{transition:"stroke-dashoffset 0.6s ease-out"}})]}),r&&e.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:r})]})}function Ve(){const n=Date.now(),a=864e5,t=Array.from({length:30},(r,o)=>({date:new Date(n-(29-o)*a).toISOString().split("T")[0],tokens:Math.floor(Math.random()*5e5)+1e5})),l=[{provider:"Claude",cost:124.5,percentage:62,color:"#553DE9"},{provider:"Codex",cost:48.3,percentage:24,color:"#1FC5A8"},{provider:"Gemini",cost:28.2,percentage:14,color:"#F59E0B"}],c=[{name:"SaaS App",count:45},{name:"CLI Tool",count:32},{name:"Discord Bot",count:28},{name:"REST API",count:21},{name:"Chrome Extension",count:14}],s=Array.from({length:7},()=>Array.from({length:24},(r,o)=>o>=9&&o<=17?Math.floor(Math.random()*80)+20:o>=18&&o<=22?Math.floor(Math.random()*40)+10:Math.floor(Math.random()*15)));return{tokenUsage:t,costBreakdown:l,buildSuccessRate:87,totalBuilds:342,successfulBuilds:298,failedBuilds:44,templateUsage:c,peakHours:s}}function Je({data:n}){const[a,t]=m.useState(null);if(n.length===0)return null;const l=600,c=200,s={top:20,right:20,bottom:30,left:60},r=l-s.left-s.right,o=c-s.top-s.bottom,g=Math.max(...n.map(x=>x.tokens)),j=0,u=g-j||1,b=n.map((x,N)=>({x:s.left+N/(n.length-1)*r,y:s.top+o-(x.tokens-j)/u*o,...x})),h=b.map((x,N)=>`${N===0?"M":"L"} ${x.x} ${x.y}`).join(" "),y=`${h} L ${b[b.length-1].x} ${s.top+o} L ${b[0].x} ${s.top+o} Z`,v=x=>x>=1e6?`${(x/1e6).toFixed(1)}M`:x>=1e3?`${(x/1e3).toFixed(0)}K`:String(x),E=Array.from({length:5},(x,N)=>({value:j+u*N/4,y:s.top+o-N/4*o}));return e.jsxs("svg",{viewBox:`0 0 ${l} ${c}`,className:"w-full",preserveAspectRatio:"xMidYMid meet",children:[E.map((x,N)=>e.jsxs("g",{children:[e.jsx("line",{x1:s.left,y1:x.y,x2:l-s.right,y2:x.y,stroke:"currentColor",strokeOpacity:"0.08",strokeDasharray:"4 4"}),e.jsx("text",{x:s.left-8,y:x.y+4,textAnchor:"end",className:"text-[10px] fill-[#939084]",children:v(x.value)})]},N)),e.jsx("path",{d:y,fill:"url(#tokenGradient)",opacity:"0.15"}),e.jsx("path",{d:h,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"})]})}),b.map((x,N)=>e.jsxs("g",{children:[e.jsx("circle",{cx:x.x,cy:x.y,r:a===N?5:3,fill:a===N?"#553DE9":"white",stroke:"#553DE9",strokeWidth:"2",className:"cursor-pointer transition-all",onMouseEnter:()=>t(N),onMouseLeave:()=>t(null)}),a===N&&e.jsxs("g",{children:[e.jsx("rect",{x:x.x-50,y:x.y-36,width:"100",height:"24",rx:"4",fill:"#36342E"}),e.jsxs("text",{x:x.x,y:x.y-20,textAnchor:"middle",className:"text-[10px] fill-white font-mono",children:[v(x.tokens)," | ",x.date.slice(5)]})]})]},N)),[0,Math.floor(n.length/2),n.length-1].map(x=>e.jsx("text",{x:b[x].x,y:c-4,textAnchor:"middle",className:"text-[10px] fill-[#939084]",children:n[x].date.slice(5)},x))]})}function qe({data:n}){const[a,t]=m.useState(null),l=n.reduce((u,b)=>u+b.cost,0),c=160,s=c/2,r=60,o=40;let g=-90;const j=n.map((u,b)=>{const h=u.percentage/100*360,y=g,v=g+h;g=v;const E=y*Math.PI/180,x=v*Math.PI/180,N=h>180?1:0,f=a===b?r+4:r,D=[`M ${s+o*Math.cos(E)} ${s+o*Math.sin(E)}`,`L ${s+f*Math.cos(E)} ${s+f*Math.sin(E)}`,`A ${f} ${f} 0 ${N} 1 ${s+f*Math.cos(x)} ${s+f*Math.sin(x)}`,`L ${s+o*Math.cos(x)} ${s+o*Math.sin(x)}`,`A ${o} ${o} 0 ${N} 0 ${s+o*Math.cos(E)} ${s+o*Math.sin(E)}`,"Z"].join(" ");return{...u,path:D,index:b}});return e.jsxs("div",{className:"flex items-center gap-6",children:[e.jsxs("svg",{width:c,height:c,viewBox:`0 0 ${c} ${c}`,children:[j.map(u=>e.jsx("path",{d:u.path,fill:u.color,opacity:a!==null&&a!==u.index?.4:1,className:"cursor-pointer transition-opacity",onMouseEnter:()=>t(u.index),onMouseLeave:()=>t(null)},u.index)),e.jsx("text",{x:s,y:s-6,textAnchor:"middle",className:"text-xs fill-[#939084]",children:"Total"}),e.jsxs("text",{x:s,y:s+12,textAnchor:"middle",className:"text-sm fill-[#36342E] dark:fill-[#E8E6E3] font-semibold",children:["$",l.toFixed(0)]})]}),e.jsx("div",{className:"flex flex-col gap-2",children:n.map((u,b)=>e.jsxs("div",{className:"flex items-center gap-2 text-sm",onMouseEnter:()=>t(b),onMouseLeave:()=>t(null),children:[e.jsx("span",{className:"w-3 h-3 rounded-sm flex-shrink-0",style:{backgroundColor:u.color}}),e.jsx("span",{className:"text-[#36342E] dark:text-[#E8E6E3]",children:u.provider}),e.jsxs("span",{className:"text-[#939084] ml-auto font-mono",children:["$",u.cost.toFixed(2)]})]},b))})]})}function Ye({data:n}){const a=["Mon","Tue","Wed","Thu","Fri","Sat","Sun"],t=Math.max(...n.flat()),l=c=>{const s=t>0?c/t:0;return s===0?"bg-[#F8F4F0] dark:bg-[#1A1A1E]":s<.25?"bg-[#553DE9]/10":s<.5?"bg-[#553DE9]/25":s<.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},(c,s)=>e.jsx("div",{className:"w-4 text-center text-[9px] text-[#939084]",children:s%6===0?`${s}`:""},s))}),n.map((c,s)=>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:a[s]}),c.map((r,o)=>e.jsx("div",{className:`w-4 h-4 rounded-sm ${l(r)} transition-colors`,title:`${a[s]} ${o}:00 - ${r} builds`},o))]},s)),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((c,s)=>e.jsx("div",{className:`w-3 h-3 rounded-sm ${c}`},s)),e.jsx("span",{className:"text-[10px] text-[#939084]",children:"More"})]})]})})}function Ze({data:n,className:a=""}){const t=n||Ve(),l=m.useCallback(()=>{const c=new Blob([JSON.stringify(t,null,2)],{type:"application/json"}),s=URL.createObjectURL(c),r=document.createElement("a");r.href=s,r.download=`usage-analytics-${new Date().toISOString().split("T")[0]}.json`,r.click(),URL.revokeObjectURL(s)},[t]);return e.jsxs("div",{className:`space-y-6 ${a}`,children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(_,{size:18,className:"text-[#553DE9]"}),e.jsx("h3",{className:"text-sm font-semibold text-[#201515] dark:text-[#E8E6E3] uppercase tracking-wider",children:"Usage Analytics"})]}),e.jsx(w,{size:"sm",variant:"ghost",icon:V,onClick:l,children:"Export"})]}),e.jsxs("div",{className:"card p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[e.jsx(ye,{size:14,className:"text-[#553DE9]"}),e.jsx("h4",{className:"text-sm font-medium text-[#36342E] dark:text-[#E8E6E3]",children:"Token Usage (30 Days)"})]}),e.jsx(Je,{data:t.tokenUsage})]}),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(Re,{size:14,className:"text-[#553DE9]"}),e.jsx("h4",{className:"text-sm font-medium text-[#36342E] dark:text-[#E8E6E3]",children:"Cost by Provider"})]}),e.jsx(qe,{data:t.costBreakdown})]}),e.jsxs("div",{className:"card p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[e.jsx(Q,{size:14,className:"text-[#553DE9]"}),e.jsx("h4",{className:"text-sm font-medium text-[#36342E] dark:text-[#E8E6E3]",children:"Build Success Rate"})]}),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:[t.buildSuccessRate,"%"]}),e.jsxs("div",{className:"text-xs text-[#939084]",children:[e.jsxs("div",{children:[t.successfulBuilds," passed"]}),e.jsxs("div",{children:[t.failedBuilds," failed"]}),e.jsxs("div",{children:[t.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:`${t.buildSuccessRate}%`,background:t.buildSuccessRate>=80?"#1FC5A8":t.buildSuccessRate>=60?"#F59E0B":"#C45B5B"}})}),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"}),e.jsx("div",{className:"space-y-2",children:t.templateUsage.slice(0,5).map((c,s)=>e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("span",{className:"text-sm text-[#36342E] dark:text-[#E8E6E3]",children:[s+1,". ",c.name]}),e.jsxs("span",{className:"text-xs font-mono text-[#939084]",children:[c.count," builds"]})]},s))})]})]})]}),e.jsxs("div",{className:"card p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[e.jsx(I,{size:14,className:"text-[#553DE9]"}),e.jsx("h4",{className:"text-sm font-medium text-[#36342E] dark:text-[#E8E6E3]",children:"Peak Usage Hours"})]}),e.jsx(Ye,{data:t.peakHours})]})]})}const Y=["user.login","user.logout","user.invited","project.created","project.deleted","project.deployed","key.created","key.revoked","role.changed","settings.updated","build.started","build.completed","build.failed"];function Ke(){const n=["admin@company.com","dev@company.com","lead@company.com","ops@company.com"],a=["192.168.1.10","10.0.0.42","172.16.0.5","192.168.1.22"],t=["my-saas-app","cli-tool","api-service","staging","production"],l=["auth","project","admin","deploy","api","system"];return Array.from({length:50},(c,s)=>{const r=Y[Math.floor(Math.random()*Y.length)],o=r.startsWith("user")?"auth":r.startsWith("project")?"project":r.startsWith("key")?"api":r.startsWith("build")?"deploy":r.startsWith("role")||r.startsWith("settings")?"admin":l[Math.floor(Math.random()*l.length)];return{id:`evt-${s}`,timestamp:new Date(Date.now()-s*18e5-Math.random()*6e5).toISOString(),user:n[Math.floor(Math.random()*n.length)],action:r,target:t[Math.floor(Math.random()*t.length)],details:`${r.replace(".",": ")} by user on ${t[Math.floor(Math.random()*t.length)]}`,ip:a[Math.floor(Math.random()*a.length)],category:o}})}const Z={auth:"#553DE9",project:"#1FC5A8",admin:"#F59E0B",deploy:"#C45B5B",api:"#6366F1",system:"#939084"};function Qe({category:n}){return e.jsx("span",{className:"px-1.5 py-0.5 rounded text-[10px] font-medium uppercase tracking-wide",style:{backgroundColor:`${Z[n]}15`,color:Z[n]},children:n})}function Xe({events:n,onFetch:a,pollInterval:t=3e4,className:l=""}){const[c,s]=m.useState(n||Ke()),[r,o]=m.useState(""),[g,j]=m.useState(""),[u,b]=m.useState(""),[h,y]=m.useState(""),[v,E]=m.useState(""),[x,N]=m.useState(!1),[f,D]=m.useState(null),[d,p]=m.useState(1),[A,C]=m.useState(!1),B=m.useRef(null),T=15;m.useEffect(()=>{if(!a||t<=0)return;const i=async()=>{try{const k=await a({search:r,user:g,actionType:u,dateFrom:h,dateTo:v});s(k)}catch{}};return B.current=setInterval(i,t),()=>{B.current&&clearInterval(B.current)}},[a,t,r,g,u,h,v]);const de=[...new Set(c.map(i=>i.user))].sort(),xe=[...new Set(c.map(i=>i.action))].sort(),M=c.filter(i=>{if(r){const k=r.toLowerCase();if(!(i.action.toLowerCase().includes(k)||i.user.toLowerCase().includes(k)||i.target.toLowerCase().includes(k)||i.details.toLowerCase().includes(k)||i.ip.includes(k)))return!1}return!(g&&i.user!==g||u&&i.action!==u||h&&i.timestamp<h||v&&i.timestamp>v+"T23:59:59")}),$=Math.ceil(M.length/T),J=M.slice((d-1)*T,d*T);m.useEffect(()=>{p(1)},[r,g,u,h,v]);const me=m.useCallback(()=>{const i=["Timestamp","User","Action","Target","Details","IP","Category"],k=M.map(F=>[F.timestamp,F.user,F.action,F.target,`"${F.details.replace(/"/g,'""')}"`,F.ip,F.category]),S=[i.join(","),...k.map(F=>F.join(","))].join(`
32
- `),pe=new Blob([S],{type:"text/csv"}),q=URL.createObjectURL(pe),U=document.createElement("a");U.href=q,U.download=`audit-log-${new Date().toISOString().split("T")[0]}.csv`,U.click(),URL.revokeObjectURL(q)},[M]),he=m.useCallback(async()=>{if(a){C(!0);try{const i=await a({search:r,user:g,actionType:u,dateFrom:h,dateTo:v});s(i)}catch{}finally{C(!1)}}},[a,r,g,u,h,v]),ue=i=>new Date(i).toLocaleString("en-US",{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit",hour12:!1});return e.jsxs("div",{className:`space-y-4 ${l}`,children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(H,{size:18,className:"text-[#553DE9]"}),e.jsx("h3",{className:"text-sm font-semibold text-[#201515] dark:text-[#E8E6E3] uppercase tracking-wider",children:"Audit Trail"}),e.jsxs("span",{className:"text-xs text-[#939084] ml-1",children:[M.length," event",M.length!==1?"s":""]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(w,{size:"sm",variant:"ghost",icon:le,onClick:he,loading:A,children:"Refresh"}),e.jsx(w,{size:"sm",variant:"ghost",icon:V,onClick:me,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(X,{size:14,className:"absolute left-3 top-1/2 -translate-y-1/2 text-[#939084]"}),e.jsx("input",{type:"text",value:r,onChange:i=>o(i.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(w,{size:"sm",variant:x?"secondary":"ghost",icon:Pe,onClick:()=>N(!x),children:"Filters"})]}),x&&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:g,onChange:i=>j(i.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"}),de.map(i=>e.jsx("option",{value:i,children:i},i))]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-[#6B6960] mb-1",children:"Action"}),e.jsxs("select",{value:u,onChange:i=>b(i.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"}),xe.map(i=>e.jsx("option",{value:i,children:i},i))]})]}),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:h,onChange:i=>y(i.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:v,onChange:i=>E(i.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:[J.map(i=>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:()=>D(f===i.id?null:i.id),children:[e.jsx("td",{className:"px-2 py-2.5 text-center",children:f===i.id?e.jsx(ee,{size:12,className:"text-[#939084]"}):e.jsx(R,{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(I,{size:12}),e.jsx("span",{className:"font-mono",children:ue(i.timestamp)})]})}),e.jsx("td",{className:"px-3 py-2.5",children:e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(ke,{name:i.user.split("@")[0],size:"sm"}),e.jsx("span",{className:"text-[#201515] dark:text-[#E8E6E3] truncate max-w-[150px]",children:i.user})]})}),e.jsx("td",{className:"px-3 py-2.5",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Qe,{category:i.category}),e.jsx("span",{className:"text-[#201515] dark:text-[#E8E6E3] font-medium",children:i.action})]})}),e.jsx("td",{className:"px-3 py-2.5",children:e.jsx("span",{className:"text-[#6B6960] truncate max-w-[120px] block",children:i.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(Ae,{size:12}),e.jsx("span",{className:"font-mono",children:i.ip})]})})]},i.id),f===i.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(ge,{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:i.details}),e.jsxs("div",{className:"flex items-center gap-4 mt-2 text-xs text-[#939084]",children:[e.jsxs("span",{children:["Event ID: ",i.id]}),e.jsxs("span",{children:["Full timestamp: ",new Date(i.timestamp).toISOString()]}),e.jsxs("span",{children:["IP: ",i.ip]})]})]})]})})},`${i.id}-details`)]})),J.length===0&&e.jsx("tr",{children:e.jsx("td",{colSpan:6,className:"px-4 py-8 text-center text-sm text-[#939084]",children:"No events match your filters."})})]})]})}),$>1&&e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("span",{className:"text-xs text-[#939084]",children:["Showing ",(d-1)*T+1,"-",Math.min(d*T,M.length)," of ",M.length]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("button",{onClick:()=>p(i=>Math.max(1,i-1)),disabled:d===1,className:"p-1.5 rounded-lg text-[#939084] hover:bg-[#F8F4F0] dark:hover:bg-[#222228] disabled:opacity-40 transition-colors",children:e.jsx(we,{size:16})}),Array.from({length:Math.min($,5)},(i,k)=>{let S;return $<=5||d<=3?S=k+1:d>=$-2?S=$-4+k:S=d-2+k,e.jsx("button",{onClick:()=>p(S),className:`w-8 h-8 rounded-lg text-xs font-medium transition-colors ${d===S?"bg-[#553DE9] text-white":"text-[#939084] hover:bg-[#F8F4F0] dark:hover:bg-[#222228]"}`,children:S},S)}),e.jsx("button",{onClick:()=>p(i=>Math.min($,i+1)),disabled:d===$,className:"p-1.5 rounded-lg text-[#939084] hover:bg-[#F8F4F0] dark:hover:bg-[#222228] disabled:opacity-40 transition-colors",children:e.jsx(R,{size:16})})]})]})]})}const et=[{id:"u-1",name:"Alex Chen",email:"alex@company.com",role:"admin",status:"active",lastActive:new Date(Date.now()-3e5).toISOString(),joinedAt:new Date(Date.now()-180*864e5).toISOString()},{id:"u-2",name:"Sarah Johnson",email:"sarah@company.com",role:"editor",status:"active",lastActive:new Date(Date.now()-36e5).toISOString(),joinedAt:new Date(Date.now()-90*864e5).toISOString()},{id:"u-3",name:"Mike Davis",email:"mike@company.com",role:"editor",status:"active",lastActive:new Date(Date.now()-864e5).toISOString(),joinedAt:new Date(Date.now()-60*864e5).toISOString()},{id:"u-4",name:"Emily Park",email:"emily@company.com",role:"viewer",status:"inactive",lastActive:new Date(Date.now()-30*864e5).toISOString(),joinedAt:new Date(Date.now()-120*864e5).toISOString()},{id:"u-5",name:"Jordan Lee",email:"jordan@company.com",role:"editor",status:"invited",lastActive:null,joinedAt:new Date(Date.now()-2*864e5).toISOString()}],P={admin:{label:"Admin",color:"#553DE9"},editor:{label:"Editor",color:"#1FC5A8"},viewer:{label:"Viewer",color:"#939084"}},K={active:{label:"Active",color:"#1FC5A8"},inactive:{label:"Inactive",color:"#939084"},invited:{label:"Invited",color:"#F59E0B"}};function O(n){if(!n)return"Never";const a=Date.now()-new Date(n).getTime(),t=Math.floor(a/6e4);if(t<1)return"Just now";if(t<60)return`${t}m ago`;const l=Math.floor(t/60);if(l<24)return`${l}h ago`;const c=Math.floor(l/24);return c<30?`${c}d ago`:`${Math.floor(c/30)}mo ago`}function oe(n){return n.split(" ").map(a=>a[0]).join("").toUpperCase().slice(0,2)}function tt({onSubmit:n,onCancel:a}){const[t,l]=m.useState(""),[c,s]=m.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(Ce,{size:14,className:"absolute left-3 top-1/2 -translate-y-1/2 text-[#939084]"}),e.jsx("input",{type:"email",value:t,onChange:r=>l(r.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:c,onChange:r=>s(r.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(w,{size:"sm",icon:ie,onClick:()=>n(t,c),disabled:!t.trim()||!t.includes("@"),children:"Send Invite"}),e.jsx(w,{size:"sm",variant:"ghost",onClick:a,children:"Cancel"})]})]})}function st({user:n,onClose:a,onChangeRole:t,onToggleStatus:l}){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:[n.avatar_url?e.jsx("img",{src:n.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:oe(n.name)}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium text-[#201515] dark:text-[#E8E6E3]",children:n.name}),e.jsx("p",{className:"text-xs text-[#939084]",children:n.email})]})]}),e.jsx("button",{onClick:a,className:"p-1 rounded-lg text-[#939084] hover:bg-[#F8F4F0] dark:hover:bg-[#222228]",children:e.jsx(te,{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:n.role,onChange:c=>t(c.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:l,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:n.status==="active"?e.jsxs(e.Fragment,{children:[e.jsx(He,{size:16,className:"text-[#1FC5A8]"}),e.jsx("span",{className:"text-[#1FC5A8]",children:"Active"})]}):e.jsxs(e.Fragment,{children:[e.jsx(_e,{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(I,{size:12}),e.jsxs("span",{children:["Last active: ",O(n.lastActive)]})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(I,{size:12}),e.jsxs("span",{children:["Joined: ",O(n.joinedAt)]})]})]})]})}function at({users:n,onChangeRole:a,onToggleStatus:t,onInviteUser:l,className:c=""}){const[s,r]=m.useState(n||et),[o,g]=m.useState(""),[j,u]=m.useState(""),[b,h]=m.useState(!1),[y,v]=m.useState(null),E=s.filter(d=>{if(o){const p=o.toLowerCase();if(!d.name.toLowerCase().includes(p)&&!d.email.toLowerCase().includes(p))return!1}return!(j&&d.role!==j)}),x=s.find(d=>d.id===y)||null,N=m.useCallback(async(d,p)=>{l&&await l(d,p);const A={id:`u-${Date.now()}`,name:d.split("@")[0],email:d,role:p,status:"invited",lastActive:null,joinedAt:new Date().toISOString()};r(C=>[...C,A]),h(!1)},[l]),f=m.useCallback(async(d,p)=>{a&&await a(d,p),r(A=>A.map(C=>C.id===d?{...C,role:p}:C))},[a]),D=m.useCallback(async d=>{const p=s.find(C=>C.id===d);if(!p)return;const A=p.status!=="active";t&&await t(d,A),r(C=>C.map(B=>B.id===d?{...B,status:A?"active":"inactive"}:B))},[s,t]);return e.jsxs("div",{className:`space-y-4 ${c}`,children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(z,{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:[s.length," users"]})]}),!b&&e.jsx(w,{size:"sm",variant:"secondary",icon:ie,onClick:()=>h(!0),children:"Invite User"})]}),b&&e.jsx(tt,{onSubmit:N,onCancel:()=>h(!1)}),x&&e.jsx(st,{user:x,onClose:()=>v(null),onChangeRole:d=>f(x.id,d),onToggleStatus:()=>D(x.id)}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(X,{size:14,className:"absolute left-3 top-1/2 -translate-y-1/2 text-[#939084]"}),e.jsx("input",{type:"text",value:o,onChange:d=>g(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:j,onChange:d=>u(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:[E.map(d=>e.jsxs("button",{type:"button",onClick:()=>v(y===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 ${y===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:oe(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:`${P[d.role].color}15`,color:P[d.role].color},children:P[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:K[d.status].color}}),e.jsx("span",{className:"text-xs text-[#939084] hidden md:inline",children:K[d.status].label})]}),e.jsx("span",{className:"text-xs text-[#939084] flex-shrink-0 hidden lg:inline w-16 text-right",children:O(d.lastActive)}),e.jsx(R,{size:14,className:"text-[#939084] flex-shrink-0"})]},d.id)),E.length===0&&e.jsx("div",{className:"px-4 py-8 text-center text-sm text-[#939084]",children:"No users match your search."})]})]})}const nt=[{id:"proj-1",name:"Customer Portal v2",submittedBy:"sarah@company.com",template:"SaaS App",provider:"Claude",estimatedCost:12.5,estimatedIterations:15,submittedAt:new Date(Date.now()-36e5).toISOString(),description:"Complete redesign of the customer-facing portal with new billing integration.",status:"pending"},{id:"proj-2",name:"Internal CLI Tools",submittedBy:"mike@company.com",template:"CLI Tool",provider:"Claude",estimatedCost:4.2,estimatedIterations:8,submittedAt:new Date(Date.now()-72e5).toISOString(),description:"Set of internal CLI tools for deployment automation.",status:"pending"},{id:"proj-3",name:"Analytics Dashboard",submittedBy:"jordan@company.com",template:"SaaS App",provider:"Codex",estimatedCost:8.9,estimatedIterations:12,submittedAt:new Date(Date.now()-144e5).toISOString(),description:"Real-time analytics dashboard for product metrics.",status:"pending"}],rt=[{projectId:"p-1",projectName:"Main Platform",budgetLimit:100,budgetUsed:67.4,alertThreshold:80},{projectId:"p-2",projectName:"Mobile App",budgetLimit:50,budgetUsed:12.3,alertThreshold:75},{projectId:"p-3",projectName:"Data Pipeline",budgetLimit:30,budgetUsed:28.5,alertThreshold:90}],it=["SaaS App","CLI Tool","REST API","Discord Bot","Chrome Extension","Mobile App","Data Pipeline","Landing Page","Docs Site"];function lt({project:n,onApprove:a,onReject:t}){const[l,c]=m.useState(!1),[s,r]=m.useState(""),[o,g]=m.useState(!1);return e.jsxs("div",{className:"border border-[#ECEAE3] dark:border-[#2A2A30] rounded-lg overflow-hidden",children:[e.jsxs("button",{type:"button",onClick:()=>c(!l),className:"w-full flex items-center gap-3 px-4 py-3 text-left hover:bg-[#F8F4F0] dark:hover:bg-[#222228] transition-colors",children:[l?e.jsx(ee,{size:14,className:"text-[#939084]"}):e.jsx(R,{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:n.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(Se,{size:10}),n.submittedBy]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(se,{size:10}),n.template]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(W,{size:10}),"~$",n.estimatedCost.toFixed(2)]})]})]}),e.jsx("span",{className:"text-xs text-[#939084] flex-shrink-0",children:new Date(n.submittedAt).toLocaleString("en-US",{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit",hour12:!1})})]}),l&&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:n.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:n.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:["$",n.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:n.estimatedIterations})]})]}),e.jsx("p",{className:"text-sm text-[#6B6960]",children:n.description}),o?e.jsxs("div",{className:"space-y-2",children:[e.jsx("textarea",{value:s,onChange:j=>r(j.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(w,{size:"sm",icon:ce,onClick:()=>a(s),children:"Approve"}),e.jsx(w,{size:"sm",variant:"danger",icon:te,onClick:()=>t(s),children:"Reject"}),e.jsx(w,{size:"sm",variant:"ghost",onClick:()=>g(!1),children:"Cancel"})]})]}):e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(w,{size:"sm",variant:"secondary",icon:fe,onClick:()=>g(!0),children:"Review"})})]})]})}function ct({configs:n}){return e.jsx("div",{className:"space-y-3",children:n.map(a=>{const t=a.budgetLimit>0?a.budgetUsed/a.budgetLimit*100:0,l=t>=a.alertThreshold,c=t>=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:a.projectName}),e.jsxs("div",{className:"flex items-center gap-2",children:[l&&e.jsx(G,{size:14,className:c?"text-[#C45B5B]":"text-[#F59E0B]"}),e.jsxs("span",{className:"text-xs font-mono text-[#939084]",children:["$",a.budgetUsed.toFixed(2)," / $",a.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(t,100)}%`,background:c?"#C45B5B":l?"#F59E0B":"#1FC5A8"}})}),e.jsxs("div",{className:"flex items-center justify-between mt-1",children:[e.jsxs("span",{className:"text-[10px] text-[#939084]",children:[t.toFixed(0),"% used"]}),e.jsxs("span",{className:"text-[10px] text-[#939084]",children:["Alert at ",a.alertThreshold,"%"]})]})]},a.projectId)})})}function ot({allTemplates:n}){const[a,t]=m.useState({Engineering:new Set(["SaaS App","CLI Tool","REST API","Data Pipeline"]),Design:new Set(["SaaS App","Landing Page","Mobile App"]),Marketing:new Set(["Landing Page","Docs Site"])}),l=Object.keys(a),c=(s,r)=>{t(o=>{const g={...o},j=new Set(g[s]);return j.has(r)?j.delete(r):j.add(r),g[s]=j,g})};return 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:"text-left px-3 py-2 text-xs font-medium text-[#6B6960]",children:"Template"}),l.map(s=>e.jsx("th",{className:"text-center px-3 py-2 text-xs font-medium text-[#6B6960]",children:s},s))]})}),e.jsx("tbody",{children:n.map(s=>e.jsxs("tr",{className:"border-t border-[#ECEAE3] dark:border-[#2A2A30] hover:bg-[#F8F4F0] dark:hover:bg-[#222228] transition-colors",children:[e.jsx("td",{className:"px-3 py-2 text-[#201515] dark:text-[#E8E6E3]",children:s}),l.map(r=>{var o;return e.jsx("td",{className:"text-center px-3 py-2",children:e.jsx("input",{type:"checkbox",checked:((o=a[r])==null?void 0:o.has(s))||!1,onChange:()=>c(r,s),className:"rounded border-[#ECEAE3] text-[#553DE9] focus:ring-[#553DE9]"})},r)})]},s))})]})})}function dt({pendingProjects:n,budgetConfigs:a,className:t=""}){const[l,c]=m.useState(n||nt),[s]=m.useState(a||rt),[r,o]=m.useState("approvals"),g=l.filter(h=>h.status==="pending").length,j=m.useCallback((h,y)=>{c(v=>v.map(E=>E.id===h?{...E,status:"approved"}:E))},[]),u=m.useCallback((h,y)=>{c(v=>v.map(E=>E.id===h?{...E,status:"rejected"}:E))},[]),b=[{id:"approvals",label:"Approvals",icon:ce,count:g},{id:"budgets",label:"Budgets",icon:W},{id:"templates",label:"Templates",icon:se}];return e.jsxs("div",{className:`space-y-4 ${t}`,children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Le,{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:b.map(h=>e.jsxs("button",{onClick:()=>o(h.id),className:`flex items-center gap-1.5 px-3 py-2 text-xs font-medium border-b-2 transition-colors ${r===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.count!==void 0&&h.count>0&&e.jsx("span",{className:"ml-1 px-1.5 py-0.5 rounded-full text-[10px] bg-[#553DE9]/10 text-[#553DE9]",children:h.count})]},h.id))}),r==="approvals"&&e.jsx("div",{className:"space-y-3",children:l.filter(h=>h.status==="pending").length===0?e.jsxs("div",{className:"text-center py-8",children:[e.jsx(je,{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."})]}):l.filter(h=>h.status==="pending").map(h=>e.jsx(lt,{project:h,onApprove:y=>j(h.id,y),onReject:y=>u(h.id,y)},h.id))}),r==="budgets"&&e.jsx(ct,{configs:s}),r==="templates"&&e.jsx(ot,{allTemplates:it})]})}function xt(){return[{id:"c-1",title:"API Keys Rotated Within 90 Days",description:"All active API keys should be rotated at least every 90 days to minimize exposure risk.",status:"warning",category:"security",lastChecked:new Date(Date.now()-36e5).toISOString(),remediationUrl:"/admin/settings",details:"2 of 3 keys are within 90 days. 1 key (Production CI/CD) is 120 days old."},{id:"c-2",title:"All Users Have MFA Enabled",description:"Multi-factor authentication should be enabled for all user accounts.",status:"fail",category:"access",lastChecked:new Date(Date.now()-36e5).toISOString(),remediationUrl:"/admin/settings",details:"3 of 5 users have MFA enabled. 2 users need to enable MFA."},{id:"c-3",title:"Audit Logging Enabled",description:"All user actions should be captured in the audit log.",status:"pass",category:"audit",lastChecked:new Date(Date.now()-36e5).toISOString(),details:"Audit logging is active. 1,247 events captured in the last 30 days."},{id:"c-4",title:"Data Retention Policy Set",description:"A data retention policy must be configured specifying how long logs and data are kept.",status:"pass",category:"data",lastChecked:new Date(Date.now()-36e5).toISOString(),details:"Retention policy: 90 days for logs, 365 days for audit events."},{id:"c-5",title:"Access Review Completed",description:"User access should be reviewed quarterly to ensure least-privilege principle.",status:"warning",category:"access",lastChecked:new Date(Date.now()-36e5).toISOString(),remediationUrl:"/admin",details:"Last access review was 85 days ago. Due for review within 5 days."},{id:"c-6",title:"Encryption at Rest Enabled",description:"All stored data including project files and secrets must be encrypted at rest.",status:"pass",category:"security",lastChecked:new Date(Date.now()-36e5).toISOString(),details:"AES-256 encryption enabled for all storage backends."},{id:"c-7",title:"Session Timeout Configured",description:"User sessions should expire after a configured period of inactivity.",status:"pass",category:"security",lastChecked:new Date(Date.now()-36e5).toISOString(),details:"Session timeout set to 30 minutes of inactivity."},{id:"c-8",title:"Rate Limiting Active",description:"API rate limiting should be enabled to prevent abuse and ensure fair usage.",status:"pass",category:"security",lastChecked:new Date(Date.now()-36e5).toISOString(),details:"Rate limit: 100 requests/minute per API key."}]}function mt({status:n}){switch(n){case"pass":return e.jsx(ae,{size:18,className:"text-[#1FC5A8]"});case"fail":return e.jsx(ne,{size:18,className:"text-[#C45B5B]"});case"warning":return e.jsx(G,{size:18,className:"text-[#F59E0B]"})}}const ht={security:Fe,access:z,data:De,audit:ve};function ut({score:n}){const s=2*Math.PI*56,o=270/360*s,g=n/100*o,j=n>=80?"#1FC5A8":n>=60?"#F59E0B":"#C45B5B",u=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} ${s}`,strokeLinecap:"round",transform:`rotate(${u} 70 70)`}),e.jsx("circle",{cx:70,cy:70,r:56,fill:"none",stroke:j,strokeWidth:10,strokeDasharray:`${g} ${s}`,strokeLinecap:"round",transform:`rotate(${u} 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:[n,"%"]}),e.jsx("span",{className:"text-xs text-[#939084]",children:"Compliant"})]})]})}function pt({items:n,onRefresh:a,className:t=""}){const[l,c]=m.useState(n||xt()),[s,r]=m.useState(!1),[o,g]=m.useState(null),[j,u]=m.useState(!1),b=l.filter(f=>f.status==="pass").length,h=l.filter(f=>f.status==="warning").length,y=l.filter(f=>f.status==="fail").length,v=l.length>0?Math.round(b/l.length*100):0,E=m.useCallback(async()=>{r(!0);try{if(a){const f=await a();c(f)}}catch{}finally{r(!1)}},[a]),x=m.useCallback(()=>{u(!0);const f={generatedAt:new Date().toISOString(),overallScore:v,summary:{pass:b,warning:h,fail:y,total:l.length},items:l.map(A=>({title:A.title,status:A.status,category:A.category,details:A.details,lastChecked:A.lastChecked}))},D=new Blob([JSON.stringify(f,null,2)],{type:"application/json"}),d=URL.createObjectURL(D),p=document.createElement("a");p.href=d,p.download=`compliance-report-${new Date().toISOString().split("T")[0]}.json`,p.click(),URL.revokeObjectURL(d),setTimeout(()=>u(!1),1e3)},[l,v,b,h,y]),N=["security","access","data","audit"];return e.jsxs("div",{className:`space-y-6 ${t}`,children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(be,{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:[e.jsx(w,{size:"sm",variant:"ghost",icon:le,onClick:E,loading:s,children:"Refresh"}),e.jsx(w,{size:"sm",variant:"secondary",icon:V,onClick:x,loading:j,children:"Generate Report"})]})]}),e.jsx("div",{className:"card p-6",children:e.jsxs("div",{className:"flex items-center gap-8",children:[e.jsx(ut,{score:v}),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(ae,{size:16,className:"text-[#1FC5A8]"}),e.jsxs("div",{children:[e.jsx("span",{className:"text-lg font-bold text-[#36342E] dark:text-[#E8E6E3]",children:b}),e.jsx("span",{className:"text-xs text-[#939084] ml-1",children:"Passing"})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(G,{size:16,className:"text-[#F59E0B]"}),e.jsxs("div",{children:[e.jsx("span",{className:"text-lg font-bold text-[#36342E] dark:text-[#E8E6E3]",children:h}),e.jsx("span",{className:"text-xs text-[#939084] ml-1",children:"Warnings"})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ne,{size:16,className:"text-[#C45B5B]"}),e.jsxs("div",{children:[e.jsx("span",{className:"text-lg font-bold text-[#36342E] dark:text-[#E8E6E3]",children:y}),e.jsx("span",{className:"text-xs text-[#939084] ml-1",children:"Failing"})]})]})]})]})]})}),N.map(f=>{const D=l.filter(p=>p.category===f);if(D.length===0)return null;const d=ht[f];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:f})]}),e.jsx("div",{className:"border border-[#ECEAE3] dark:border-[#2A2A30] rounded-lg overflow-hidden divide-y divide-[#ECEAE3] dark:divide-[#2A2A30]",children:D.map(p=>e.jsxs("div",{children:[e.jsxs("button",{type:"button",onClick:()=>g(o===p.id?null:p.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(mt,{status:p.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:p.title}),e.jsx("p",{className:"text-xs text-[#939084] truncate",children:p.description})]}),e.jsxs("div",{className:"flex items-center gap-1 text-[10px] text-[#939084] flex-shrink-0",children:[e.jsx(I,{size:10}),"Checked ",new Date(p.lastChecked).toLocaleString("en-US",{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit",hour12:!1})]})]}),o===p.id&&e.jsxs("div",{className:"px-4 pb-3 pt-1 bg-[#F8F4F0] dark:bg-[#222228]",children:[p.details&&e.jsx("p",{className:"text-sm text-[#6B6960] mb-2",children:p.details}),p.remediationUrl&&p.status!=="pass"&&e.jsxs("a",{href:p.remediationUrl,className:"inline-flex items-center gap-1 text-xs text-[#553DE9] hover:underline",children:[e.jsx(Ee,{size:12}),"Fix this issue"]})]})]},p.id))})]},f)})]})}function gt(){return[{label:"Total Users",value:"24",change:"+3 this month",changePositive:!0,icon:z,color:"#553DE9"},{label:"Active Projects",value:"18",change:"+5 this week",changePositive:!0,icon:re,color:"#1FC5A8"},{label:"Total Builds",value:"342",change:"+47 this week",changePositive:!0,icon:Me,color:"#F59E0B"},{label:"Monthly Cost",value:"$201.00",change:"-12% vs last month",changePositive:!0,icon:W,color:"#C45B5B"}]}function jt(){return[{name:"API Server",status:"healthy",latency:45},{name:"Claude Provider",status:"healthy",latency:230},{name:"Codex Provider",status:"degraded",latency:890},{name:"Gemini Provider",status:"healthy",latency:310},{name:"Task Queue",status:"healthy",latency:12},{name:"WebSocket",status:"healthy",latency:8}]}function ft(){return[{user:"alex@company.com",action:"started build",target:"customer-portal"},{user:"sarah@company.com",action:"deployed",target:"analytics-dashboard"},{user:"mike@company.com",action:"created project",target:"cli-tools"},{user:"jordan@company.com",action:"completed build",target:"api-service"},{user:"alex@company.com",action:"updated settings",target:"provider config"},{user:"emily@company.com",action:"invited user",target:"new-dev@company.com"},{user:"sarah@company.com",action:"rotated API key",target:"production"},{user:"mike@company.com",action:"started build",target:"mobile-app"},{user:"jordan@company.com",action:"approved project",target:"data-pipeline"},{user:"alex@company.com",action:"failed build",target:"legacy-service"},{user:"sarah@company.com",action:"created checkpoint",target:"analytics-dashboard"},{user:"emily@company.com",action:"changed role",target:"mike -> editor"},{user:"mike@company.com",action:"deployed",target:"cli-tools"},{user:"alex@company.com",action:"started build",target:"landing-page"},{user:"jordan@company.com",action:"reviewed project",target:"api-service"},{user:"sarah@company.com",action:"completed build",target:"analytics-dashboard"},{user:"emily@company.com",action:"updated template",target:"saas-app"},{user:"mike@company.com",action:"started build",target:"discord-bot"},{user:"alex@company.com",action:"approved project",target:"chrome-ext"},{user:"jordan@company.com",action:"deployed",target:"data-pipeline"}].map((a,t)=>({id:`act-${t}`,...a,timestamp:new Date(Date.now()-t*9e5).toISOString()}))}function bt(){return[{name:"Alex C.",builds:87},{name:"Sarah J.",builds:64},{name:"Mike D.",builds:52},{name:"Jordan L.",builds:41},{name:"Emily P.",builds:38},{name:"Others",builds:60}]}function vt({cards:n}){return e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-4",children:n.map(a=>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:a.label}),e.jsx("p",{className:"text-2xl font-bold text-[#36342E] dark:text-[#E8E6E3] mt-1",children:a.value}),a.change&&e.jsx("p",{className:`text-xs mt-1 ${a.changePositive?"text-[#1FC5A8]":"text-[#C45B5B]"}`,children:a.change})]}),e.jsx("div",{className:"p-2 rounded-lg",style:{backgroundColor:`${a.color}10`,color:a.color},children:e.jsx(a.icon,{size:20})})]})},a.label))})}function Et({data:n}){const a=Math.max(...n.map(t=>t.builds));return e.jsxs("div",{className:"card p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[e.jsx(_,{size:14,className:"text-[#553DE9]"}),e.jsx("h4",{className:"text-sm font-medium text-[#36342E] dark:text-[#E8E6E3]",children:"Builds per User"})]}),e.jsx("div",{className:"space-y-3",children:n.map(t=>e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"text-xs text-[#6B6960] w-16 text-right flex-shrink-0",children:t.name}),e.jsx("div",{className:"flex-1 h-6 bg-[#F8F4F0] dark:bg-[#1A1A1E] rounded-full overflow-hidden",children:e.jsx("div",{className:"h-full rounded-full bg-[#553DE9] transition-all duration-500 flex items-center justify-end pr-2",style:{width:`${t.builds/a*100}%`},children:e.jsx("span",{className:"text-[10px] text-white font-mono",children:t.builds})})})]},t.name))})]})}function Nt({health:n}){const a={healthy:"#1FC5A8",degraded:"#F59E0B",down:"#C45B5B"};return e.jsxs("div",{className:"card p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[e.jsx($e,{size:14,className:"text-[#553DE9]"}),e.jsx("h4",{className:"text-sm font-medium text-[#36342E] dark:text-[#E8E6E3]",children:"System Health"})]}),e.jsx("div",{className:"space-y-2",children:n.map(t=>e.jsxs("div",{className:"flex items-center justify-between py-1.5",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"w-2 h-2 rounded-full flex-shrink-0",style:{backgroundColor:a[t.status]}}),e.jsx("span",{className:"text-sm text-[#36342E] dark:text-[#E8E6E3]",children:t.name})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[t.latency!==void 0&&e.jsxs("span",{className:"text-xs font-mono text-[#939084]",children:[t.latency,"ms"]}),e.jsx("span",{className:"text-[10px] font-medium uppercase",style:{color:a[t.status]},children:t.status})]})]},t.name))})]})}function yt({actions:n}){const a=t=>new Date(t).toLocaleString("en-US",{hour:"2-digit",minute:"2-digit",hour12:!1});return e.jsxs("div",{className:"card p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[e.jsx(H,{size:14,className:"text-[#553DE9]"}),e.jsx("h4",{className:"text-sm font-medium text-[#36342E] dark:text-[#E8E6E3]",children:"Recent Activity"})]}),e.jsx("div",{className:"space-y-1 max-h-[400px] overflow-y-auto terminal-scroll",children:n.map(t=>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-10",children:a(t.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:t.user.split("@")[0]}),e.jsxs("span",{className:"text-[#6B6960]",children:[" ",t.action," "]}),e.jsx("span",{className:"text-[#201515] dark:text-[#E8E6E3] font-medium",children:t.target})]})})]},t.id))})]})}function kt(){return e.jsxs("div",{className:"max-w-[500px] mx-auto px-6 py-20 text-center",children:[e.jsx(Be,{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 At=[{id:"overview",label:"Overview",icon:H},{id:"users",label:"Users",icon:z},{id:"analytics",label:"Analytics",icon:_},{id:"governance",label:"Governance",icon:re},{id:"audit",label:"Audit Trail",icon:I},{id:"compliance",label:"Compliance",icon:Q}];function Ht(){const{user:n,isLocalMode:a}=Ne(),[t,l]=m.useState("overview"),c=a||(n==null?void 0:n.authenticated)===!0,[s]=m.useState(gt),[r]=m.useState(jt),[o]=m.useState(ft),[g]=m.useState(bt);return c?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:At.map(j=>e.jsxs("button",{onClick:()=>l(j.id),className:`flex items-center gap-1.5 px-3 py-2 text-xs font-medium border-b-2 transition-colors whitespace-nowrap ${t===j.id?"border-[#553DE9] text-[#553DE9]":"border-transparent text-[#939084] hover:text-[#36342E] dark:hover:text-[#E8E6E3]"}`,children:[e.jsx(j.icon,{size:14}),j.label]},j.id))}),t==="overview"&&e.jsxs("div",{className:"space-y-6",children:[e.jsx(vt,{cards:s}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-4",children:[e.jsxs("div",{className:"card p-4 flex flex-col items-center justify-center",children:[e.jsx("h4",{className:"text-sm font-medium text-[#36342E] dark:text-[#E8E6E3] mb-3",children:"Build Success Rate"}),e.jsx(We,{percentage:94,size:96,strokeWidth:6,color:"#1FC5A8",children:e.jsx("span",{className:"text-lg font-bold text-[#36342E] dark:text-[#E8E6E3]",children:"94%"})}),e.jsx("p",{className:"text-xs text-[#939084] mt-2",children:"342 total builds"})]}),e.jsx("div",{className:"lg:col-span-2",children:e.jsx(Nt,{health:r})})]}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-4",children:[e.jsx(Et,{data:g}),e.jsx(yt,{actions:o})]})]}),t==="users"&&e.jsx(at,{}),t==="analytics"&&e.jsx(Ze,{}),t==="governance"&&e.jsx(dt,{}),t==="audit"&&e.jsx(Xe,{}),t==="compliance"&&e.jsx(pt,{})]}):e.jsx(kt,{})}export{Ht as default};
31
+ */const Ge=[["circle",{cx:"15",cy:"12",r:"3",key:"1afu0r"}],["rect",{width:"20",height:"14",x:"2",y:"5",rx:"7",key:"g7kal2"}]],He=L("toggle-right",Ge);function We({percentage:n,size:a=64,strokeWidth:t=4,color:l="#553DE9",trackColor:c="rgba(0,0,0,0.08)",className:s="",children:r}){const o=(a-t)/2,g=2*Math.PI*o,j=Math.max(0,Math.min(100,n)),u=g-j/100*g;return e.jsxs("div",{className:`relative inline-flex items-center justify-center ${s}`,style:{width:a,height:a},children:[e.jsxs("svg",{width:a,height:a,className:"transform -rotate-90",children:[e.jsx("circle",{cx:a/2,cy:a/2,r:o,fill:"none",stroke:c,strokeWidth:t}),e.jsx("circle",{cx:a/2,cy:a/2,r:o,fill:"none",stroke:l,strokeWidth:t,strokeLinecap:"round",strokeDasharray:g,strokeDashoffset:u,style:{transition:"stroke-dashoffset 0.6s ease-out"}})]}),r&&e.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:r})]})}function Ve(){const n=Date.now(),a=864e5,t=Array.from({length:30},(r,o)=>({date:new Date(n-(29-o)*a).toISOString().split("T")[0],tokens:Math.floor(Math.random()*5e5)+1e5})),l=[{provider:"Claude",cost:124.5,percentage:62,color:"#553DE9"},{provider:"Codex",cost:48.3,percentage:24,color:"#1FC5A8"},{provider:"Gemini",cost:28.2,percentage:14,color:"#F59E0B"}],c=[{name:"SaaS App",count:45},{name:"CLI Tool",count:32},{name:"Discord Bot",count:28},{name:"REST API",count:21},{name:"Chrome Extension",count:14}],s=Array.from({length:7},()=>Array.from({length:24},(r,o)=>o>=9&&o<=17?Math.floor(Math.random()*80)+20:o>=18&&o<=22?Math.floor(Math.random()*40)+10:Math.floor(Math.random()*15)));return{tokenUsage:t,costBreakdown:l,buildSuccessRate:87,totalBuilds:342,successfulBuilds:298,failedBuilds:44,templateUsage:c,peakHours:s}}function Je({data:n}){const[a,t]=m.useState(null);if(n.length===0)return null;const l=600,c=200,s={top:20,right:20,bottom:30,left:60},r=l-s.left-s.right,o=c-s.top-s.bottom,g=Math.max(...n.map(x=>x.tokens)),j=0,u=g-j||1,b=n.map((x,N)=>({x:s.left+N/(n.length-1)*r,y:s.top+o-(x.tokens-j)/u*o,...x})),h=b.map((x,N)=>`${N===0?"M":"L"} ${x.x} ${x.y}`).join(" "),y=`${h} L ${b[b.length-1].x} ${s.top+o} L ${b[0].x} ${s.top+o} Z`,v=x=>x>=1e6?`${(x/1e6).toFixed(1)}M`:x>=1e3?`${(x/1e3).toFixed(0)}K`:String(x),E=Array.from({length:5},(x,N)=>({value:j+u*N/4,y:s.top+o-N/4*o}));return e.jsxs("svg",{viewBox:`0 0 ${l} ${c}`,className:"w-full",preserveAspectRatio:"xMidYMid meet",children:[E.map((x,N)=>e.jsxs("g",{children:[e.jsx("line",{x1:s.left,y1:x.y,x2:l-s.right,y2:x.y,stroke:"currentColor",strokeOpacity:"0.08",strokeDasharray:"4 4"}),e.jsx("text",{x:s.left-8,y:x.y+4,textAnchor:"end",className:"text-[10px] fill-[#939084]",children:v(x.value)})]},N)),e.jsx("path",{d:y,fill:"url(#tokenGradient)",opacity:"0.15"}),e.jsx("path",{d:h,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"})]})}),b.map((x,N)=>e.jsxs("g",{children:[e.jsx("circle",{cx:x.x,cy:x.y,r:a===N?5:3,fill:a===N?"#553DE9":"white",stroke:"#553DE9",strokeWidth:"2",className:"cursor-pointer transition-all",onMouseEnter:()=>t(N),onMouseLeave:()=>t(null)}),a===N&&e.jsxs("g",{children:[e.jsx("rect",{x:x.x-50,y:x.y-36,width:"100",height:"24",rx:"4",fill:"#36342E"}),e.jsxs("text",{x:x.x,y:x.y-20,textAnchor:"middle",className:"text-[10px] fill-white font-mono",children:[v(x.tokens)," | ",x.date.slice(5)]})]})]},N)),[0,Math.floor(n.length/2),n.length-1].map(x=>e.jsx("text",{x:b[x].x,y:c-4,textAnchor:"middle",className:"text-[10px] fill-[#939084]",children:n[x].date.slice(5)},x))]})}function qe({data:n}){const[a,t]=m.useState(null),l=n.reduce((u,b)=>u+b.cost,0),c=160,s=c/2,r=60,o=40;let g=-90;const j=n.map((u,b)=>{const h=u.percentage/100*360,y=g,v=g+h;g=v;const E=y*Math.PI/180,x=v*Math.PI/180,N=h>180?1:0,f=a===b?r+4:r,D=[`M ${s+o*Math.cos(E)} ${s+o*Math.sin(E)}`,`L ${s+f*Math.cos(E)} ${s+f*Math.sin(E)}`,`A ${f} ${f} 0 ${N} 1 ${s+f*Math.cos(x)} ${s+f*Math.sin(x)}`,`L ${s+o*Math.cos(x)} ${s+o*Math.sin(x)}`,`A ${o} ${o} 0 ${N} 0 ${s+o*Math.cos(E)} ${s+o*Math.sin(E)}`,"Z"].join(" ");return{...u,path:D,index:b}});return e.jsxs("div",{className:"flex items-center gap-6",children:[e.jsxs("svg",{width:c,height:c,viewBox:`0 0 ${c} ${c}`,children:[j.map(u=>e.jsx("path",{d:u.path,fill:u.color,opacity:a!==null&&a!==u.index?.4:1,className:"cursor-pointer transition-opacity",onMouseEnter:()=>t(u.index),onMouseLeave:()=>t(null)},u.index)),e.jsx("text",{x:s,y:s-6,textAnchor:"middle",className:"text-xs fill-[#939084]",children:"Total"}),e.jsxs("text",{x:s,y:s+12,textAnchor:"middle",className:"text-sm fill-[#36342E] dark:fill-[#E8E6E3] font-semibold",children:["$",l.toFixed(0)]})]}),e.jsx("div",{className:"flex flex-col gap-2",children:n.map((u,b)=>e.jsxs("div",{className:"flex items-center gap-2 text-sm",onMouseEnter:()=>t(b),onMouseLeave:()=>t(null),children:[e.jsx("span",{className:"w-3 h-3 rounded-sm flex-shrink-0",style:{backgroundColor:u.color}}),e.jsx("span",{className:"text-[#36342E] dark:text-[#E8E6E3]",children:u.provider}),e.jsxs("span",{className:"text-[#939084] ml-auto font-mono",children:["$",u.cost.toFixed(2)]})]},b))})]})}function Ze({data:n}){const a=["Mon","Tue","Wed","Thu","Fri","Sat","Sun"],t=Math.max(...n.flat()),l=c=>{const s=t>0?c/t:0;return s===0?"bg-[#F8F4F0] dark:bg-[#1A1A1E]":s<.25?"bg-[#553DE9]/10":s<.5?"bg-[#553DE9]/25":s<.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},(c,s)=>e.jsx("div",{className:"w-4 text-center text-[9px] text-[#939084]",children:s%6===0?`${s}`:""},s))}),n.map((c,s)=>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:a[s]}),c.map((r,o)=>e.jsx("div",{className:`w-4 h-4 rounded-sm ${l(r)} transition-colors`,title:`${a[s]} ${o}:00 - ${r} builds`},o))]},s)),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((c,s)=>e.jsx("div",{className:`w-3 h-3 rounded-sm ${c}`},s)),e.jsx("span",{className:"text-[10px] text-[#939084]",children:"More"})]})]})})}function Ye({data:n,className:a=""}){const t=n||Ve(),l=m.useCallback(()=>{const c=new Blob([JSON.stringify(t,null,2)],{type:"application/json"}),s=URL.createObjectURL(c),r=document.createElement("a");r.href=s,r.download=`usage-analytics-${new Date().toISOString().split("T")[0]}.json`,r.click(),URL.revokeObjectURL(s)},[t]);return e.jsxs("div",{className:`space-y-6 ${a}`,children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(_,{size:18,className:"text-[#553DE9]"}),e.jsx("h3",{className:"text-sm font-semibold text-[#201515] dark:text-[#E8E6E3] uppercase tracking-wider",children:"Usage Analytics"})]}),e.jsx(w,{size:"sm",variant:"ghost",icon:V,onClick:l,children:"Export"})]}),e.jsxs("div",{className:"card p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[e.jsx(ye,{size:14,className:"text-[#553DE9]"}),e.jsx("h4",{className:"text-sm font-medium text-[#36342E] dark:text-[#E8E6E3]",children:"Token Usage (30 Days)"})]}),e.jsx(Je,{data:t.tokenUsage})]}),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(Re,{size:14,className:"text-[#553DE9]"}),e.jsx("h4",{className:"text-sm font-medium text-[#36342E] dark:text-[#E8E6E3]",children:"Cost by Provider"})]}),e.jsx(qe,{data:t.costBreakdown})]}),e.jsxs("div",{className:"card p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[e.jsx(X,{size:14,className:"text-[#553DE9]"}),e.jsx("h4",{className:"text-sm font-medium text-[#36342E] dark:text-[#E8E6E3]",children:"Build Success Rate"})]}),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:[t.buildSuccessRate,"%"]}),e.jsxs("div",{className:"text-xs text-[#939084]",children:[e.jsxs("div",{children:[t.successfulBuilds," passed"]}),e.jsxs("div",{children:[t.failedBuilds," failed"]}),e.jsxs("div",{children:[t.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:`${t.buildSuccessRate}%`,background:t.buildSuccessRate>=80?"#1FC5A8":t.buildSuccessRate>=60?"#F59E0B":"#C45B5B"}})}),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"}),e.jsx("div",{className:"space-y-2",children:t.templateUsage.slice(0,5).map((c,s)=>e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("span",{className:"text-sm text-[#36342E] dark:text-[#E8E6E3]",children:[s+1,". ",c.name]}),e.jsxs("span",{className:"text-xs font-mono text-[#939084]",children:[c.count," builds"]})]},s))})]})]})]}),e.jsxs("div",{className:"card p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[e.jsx(I,{size:14,className:"text-[#553DE9]"}),e.jsx("h4",{className:"text-sm font-medium text-[#36342E] dark:text-[#E8E6E3]",children:"Peak Usage Hours"})]}),e.jsx(Ze,{data:t.peakHours})]})]})}const Z=["user.login","user.logout","user.invited","project.created","project.deleted","project.deployed","key.created","key.revoked","role.changed","settings.updated","build.started","build.completed","build.failed"];function Ke(){const n=["admin@company.com","dev@company.com","lead@company.com","ops@company.com"],a=["192.168.1.10","10.0.0.42","172.16.0.5","192.168.1.22"],t=["my-saas-app","cli-tool","api-service","staging","production"],l=["auth","project","admin","deploy","api","system"];return Array.from({length:50},(c,s)=>{const r=Z[Math.floor(Math.random()*Z.length)],o=r.startsWith("user")?"auth":r.startsWith("project")?"project":r.startsWith("key")?"api":r.startsWith("build")?"deploy":r.startsWith("role")||r.startsWith("settings")?"admin":l[Math.floor(Math.random()*l.length)];return{id:`evt-${s}`,timestamp:new Date(Date.now()-s*18e5-Math.random()*6e5).toISOString(),user:n[Math.floor(Math.random()*n.length)],action:r,target:t[Math.floor(Math.random()*t.length)],details:`${r.replace(".",": ")} by user on ${t[Math.floor(Math.random()*t.length)]}`,ip:a[Math.floor(Math.random()*a.length)],category:o}})}const Y={auth:"#553DE9",project:"#1FC5A8",admin:"#F59E0B",deploy:"#C45B5B",api:"#6366F1",system:"#939084"};function Xe({category:n}){return e.jsx("span",{className:"px-1.5 py-0.5 rounded text-[10px] font-medium uppercase tracking-wide",style:{backgroundColor:`${Y[n]}15`,color:Y[n]},children:n})}function Qe({events:n,onFetch:a,pollInterval:t=3e4,className:l=""}){const[c,s]=m.useState(n||Ke()),[r,o]=m.useState(""),[g,j]=m.useState(""),[u,b]=m.useState(""),[h,y]=m.useState(""),[v,E]=m.useState(""),[x,N]=m.useState(!1),[f,D]=m.useState(null),[d,p]=m.useState(1),[A,C]=m.useState(!1),B=m.useRef(null),T=15;m.useEffect(()=>{if(!a||t<=0)return;const i=async()=>{try{const k=await a({search:r,user:g,actionType:u,dateFrom:h,dateTo:v});s(k)}catch{}};return B.current=setInterval(i,t),()=>{B.current&&clearInterval(B.current)}},[a,t,r,g,u,h,v]);const de=[...new Set(c.map(i=>i.user))].sort(),xe=[...new Set(c.map(i=>i.action))].sort(),M=c.filter(i=>{if(r){const k=r.toLowerCase();if(!(i.action.toLowerCase().includes(k)||i.user.toLowerCase().includes(k)||i.target.toLowerCase().includes(k)||i.details.toLowerCase().includes(k)||i.ip.includes(k)))return!1}return!(g&&i.user!==g||u&&i.action!==u||h&&i.timestamp<h||v&&i.timestamp>v+"T23:59:59")}),$=Math.ceil(M.length/T),J=M.slice((d-1)*T,d*T);m.useEffect(()=>{p(1)},[r,g,u,h,v]);const me=m.useCallback(()=>{const i=["Timestamp","User","Action","Target","Details","IP","Category"],k=M.map(F=>[F.timestamp,F.user,F.action,F.target,`"${F.details.replace(/"/g,'""')}"`,F.ip,F.category]),S=[i.join(","),...k.map(F=>F.join(","))].join(`
32
+ `),pe=new Blob([S],{type:"text/csv"}),q=URL.createObjectURL(pe),U=document.createElement("a");U.href=q,U.download=`audit-log-${new Date().toISOString().split("T")[0]}.csv`,U.click(),URL.revokeObjectURL(q)},[M]),he=m.useCallback(async()=>{if(a){C(!0);try{const i=await a({search:r,user:g,actionType:u,dateFrom:h,dateTo:v});s(i)}catch{}finally{C(!1)}}},[a,r,g,u,h,v]),ue=i=>new Date(i).toLocaleString("en-US",{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit",hour12:!1});return e.jsxs("div",{className:`space-y-4 ${l}`,children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(H,{size:18,className:"text-[#553DE9]"}),e.jsx("h3",{className:"text-sm font-semibold text-[#201515] dark:text-[#E8E6E3] uppercase tracking-wider",children:"Audit Trail"}),e.jsxs("span",{className:"text-xs text-[#939084] ml-1",children:[M.length," event",M.length!==1?"s":""]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(w,{size:"sm",variant:"ghost",icon:le,onClick:he,loading:A,children:"Refresh"}),e.jsx(w,{size:"sm",variant:"ghost",icon:V,onClick:me,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(Q,{size:14,className:"absolute left-3 top-1/2 -translate-y-1/2 text-[#939084]"}),e.jsx("input",{type:"text",value:r,onChange:i=>o(i.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(w,{size:"sm",variant:x?"secondary":"ghost",icon:Pe,onClick:()=>N(!x),children:"Filters"})]}),x&&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:g,onChange:i=>j(i.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"}),de.map(i=>e.jsx("option",{value:i,children:i},i))]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-[#6B6960] mb-1",children:"Action"}),e.jsxs("select",{value:u,onChange:i=>b(i.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"}),xe.map(i=>e.jsx("option",{value:i,children:i},i))]})]}),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:h,onChange:i=>y(i.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:v,onChange:i=>E(i.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:[J.map(i=>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:()=>D(f===i.id?null:i.id),children:[e.jsx("td",{className:"px-2 py-2.5 text-center",children:f===i.id?e.jsx(ee,{size:12,className:"text-[#939084]"}):e.jsx(R,{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(I,{size:12}),e.jsx("span",{className:"font-mono",children:ue(i.timestamp)})]})}),e.jsx("td",{className:"px-3 py-2.5",children:e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(ke,{name:i.user.split("@")[0],size:"sm"}),e.jsx("span",{className:"text-[#201515] dark:text-[#E8E6E3] truncate max-w-[150px]",children:i.user})]})}),e.jsx("td",{className:"px-3 py-2.5",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Xe,{category:i.category}),e.jsx("span",{className:"text-[#201515] dark:text-[#E8E6E3] font-medium",children:i.action})]})}),e.jsx("td",{className:"px-3 py-2.5",children:e.jsx("span",{className:"text-[#6B6960] truncate max-w-[120px] block",children:i.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(Ae,{size:12}),e.jsx("span",{className:"font-mono",children:i.ip})]})})]},i.id),f===i.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(ge,{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:i.details}),e.jsxs("div",{className:"flex items-center gap-4 mt-2 text-xs text-[#939084]",children:[e.jsxs("span",{children:["Event ID: ",i.id]}),e.jsxs("span",{children:["Full timestamp: ",new Date(i.timestamp).toISOString()]}),e.jsxs("span",{children:["IP: ",i.ip]})]})]})]})})},`${i.id}-details`)]})),J.length===0&&e.jsx("tr",{children:e.jsx("td",{colSpan:6,className:"px-4 py-8 text-center text-sm text-[#939084]",children:"No events match your filters."})})]})]})}),$>1&&e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("span",{className:"text-xs text-[#939084]",children:["Showing ",(d-1)*T+1,"-",Math.min(d*T,M.length)," of ",M.length]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("button",{onClick:()=>p(i=>Math.max(1,i-1)),disabled:d===1,className:"p-1.5 rounded-lg text-[#939084] hover:bg-[#F8F4F0] dark:hover:bg-[#222228] disabled:opacity-40 transition-colors",children:e.jsx(we,{size:16})}),Array.from({length:Math.min($,5)},(i,k)=>{let S;return $<=5||d<=3?S=k+1:d>=$-2?S=$-4+k:S=d-2+k,e.jsx("button",{onClick:()=>p(S),className:`w-8 h-8 rounded-lg text-xs font-medium transition-colors ${d===S?"bg-[#553DE9] text-white":"text-[#939084] hover:bg-[#F8F4F0] dark:hover:bg-[#222228]"}`,children:S},S)}),e.jsx("button",{onClick:()=>p(i=>Math.min($,i+1)),disabled:d===$,className:"p-1.5 rounded-lg text-[#939084] hover:bg-[#F8F4F0] dark:hover:bg-[#222228] disabled:opacity-40 transition-colors",children:e.jsx(R,{size:16})})]})]})]})}const et=[{id:"u-1",name:"Alex Chen",email:"alex@company.com",role:"admin",status:"active",lastActive:new Date(Date.now()-3e5).toISOString(),joinedAt:new Date(Date.now()-180*864e5).toISOString()},{id:"u-2",name:"Sarah Johnson",email:"sarah@company.com",role:"editor",status:"active",lastActive:new Date(Date.now()-36e5).toISOString(),joinedAt:new Date(Date.now()-90*864e5).toISOString()},{id:"u-3",name:"Mike Davis",email:"mike@company.com",role:"editor",status:"active",lastActive:new Date(Date.now()-864e5).toISOString(),joinedAt:new Date(Date.now()-60*864e5).toISOString()},{id:"u-4",name:"Emily Park",email:"emily@company.com",role:"viewer",status:"inactive",lastActive:new Date(Date.now()-30*864e5).toISOString(),joinedAt:new Date(Date.now()-120*864e5).toISOString()},{id:"u-5",name:"Jordan Lee",email:"jordan@company.com",role:"editor",status:"invited",lastActive:null,joinedAt:new Date(Date.now()-2*864e5).toISOString()}],P={admin:{label:"Admin",color:"#553DE9"},editor:{label:"Editor",color:"#1FC5A8"},viewer:{label:"Viewer",color:"#939084"}},K={active:{label:"Active",color:"#1FC5A8"},inactive:{label:"Inactive",color:"#939084"},invited:{label:"Invited",color:"#F59E0B"}};function O(n){if(!n)return"Never";const a=Date.now()-new Date(n).getTime(),t=Math.floor(a/6e4);if(t<1)return"Just now";if(t<60)return`${t}m ago`;const l=Math.floor(t/60);if(l<24)return`${l}h ago`;const c=Math.floor(l/24);return c<30?`${c}d ago`:`${Math.floor(c/30)}mo ago`}function oe(n){return n.split(" ").map(a=>a[0]).join("").toUpperCase().slice(0,2)}function tt({onSubmit:n,onCancel:a}){const[t,l]=m.useState(""),[c,s]=m.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(Ce,{size:14,className:"absolute left-3 top-1/2 -translate-y-1/2 text-[#939084]"}),e.jsx("input",{type:"email",value:t,onChange:r=>l(r.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:c,onChange:r=>s(r.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(w,{size:"sm",icon:ie,onClick:()=>n(t,c),disabled:!t.trim()||!t.includes("@"),children:"Send Invite"}),e.jsx(w,{size:"sm",variant:"ghost",onClick:a,children:"Cancel"})]})]})}function st({user:n,onClose:a,onChangeRole:t,onToggleStatus:l}){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:[n.avatar_url?e.jsx("img",{src:n.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:oe(n.name)}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium text-[#201515] dark:text-[#E8E6E3]",children:n.name}),e.jsx("p",{className:"text-xs text-[#939084]",children:n.email})]})]}),e.jsx("button",{onClick:a,className:"p-1 rounded-lg text-[#939084] hover:bg-[#F8F4F0] dark:hover:bg-[#222228]",children:e.jsx(te,{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:n.role,onChange:c=>t(c.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:l,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:n.status==="active"?e.jsxs(e.Fragment,{children:[e.jsx(He,{size:16,className:"text-[#1FC5A8]"}),e.jsx("span",{className:"text-[#1FC5A8]",children:"Active"})]}):e.jsxs(e.Fragment,{children:[e.jsx(_e,{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(I,{size:12}),e.jsxs("span",{children:["Last active: ",O(n.lastActive)]})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(I,{size:12}),e.jsxs("span",{children:["Joined: ",O(n.joinedAt)]})]})]})]})}function at({users:n,onChangeRole:a,onToggleStatus:t,onInviteUser:l,className:c=""}){const[s,r]=m.useState(n||et),[o,g]=m.useState(""),[j,u]=m.useState(""),[b,h]=m.useState(!1),[y,v]=m.useState(null),E=s.filter(d=>{if(o){const p=o.toLowerCase();if(!d.name.toLowerCase().includes(p)&&!d.email.toLowerCase().includes(p))return!1}return!(j&&d.role!==j)}),x=s.find(d=>d.id===y)||null,N=m.useCallback(async(d,p)=>{l&&await l(d,p);const A={id:`u-${Date.now()}`,name:d.split("@")[0],email:d,role:p,status:"invited",lastActive:null,joinedAt:new Date().toISOString()};r(C=>[...C,A]),h(!1)},[l]),f=m.useCallback(async(d,p)=>{a&&await a(d,p),r(A=>A.map(C=>C.id===d?{...C,role:p}:C))},[a]),D=m.useCallback(async d=>{const p=s.find(C=>C.id===d);if(!p)return;const A=p.status!=="active";t&&await t(d,A),r(C=>C.map(B=>B.id===d?{...B,status:A?"active":"inactive"}:B))},[s,t]);return e.jsxs("div",{className:`space-y-4 ${c}`,children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(z,{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:[s.length," users"]})]}),!b&&e.jsx(w,{size:"sm",variant:"secondary",icon:ie,onClick:()=>h(!0),children:"Invite User"})]}),b&&e.jsx(tt,{onSubmit:N,onCancel:()=>h(!1)}),x&&e.jsx(st,{user:x,onClose:()=>v(null),onChangeRole:d=>f(x.id,d),onToggleStatus:()=>D(x.id)}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(Q,{size:14,className:"absolute left-3 top-1/2 -translate-y-1/2 text-[#939084]"}),e.jsx("input",{type:"text",value:o,onChange:d=>g(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:j,onChange:d=>u(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:[E.map(d=>e.jsxs("button",{type:"button",onClick:()=>v(y===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 ${y===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:oe(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:`${P[d.role].color}15`,color:P[d.role].color},children:P[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:K[d.status].color}}),e.jsx("span",{className:"text-xs text-[#939084] hidden md:inline",children:K[d.status].label})]}),e.jsx("span",{className:"text-xs text-[#939084] flex-shrink-0 hidden lg:inline w-16 text-right",children:O(d.lastActive)}),e.jsx(R,{size:14,className:"text-[#939084] flex-shrink-0"})]},d.id)),E.length===0&&e.jsx("div",{className:"px-4 py-8 text-center text-sm text-[#939084]",children:"No users match your search."})]})]})}const nt=[{id:"proj-1",name:"Customer Portal v2",submittedBy:"sarah@company.com",template:"SaaS App",provider:"Claude",estimatedCost:12.5,estimatedIterations:15,submittedAt:new Date(Date.now()-36e5).toISOString(),description:"Complete redesign of the customer-facing portal with new billing integration.",status:"pending"},{id:"proj-2",name:"Internal CLI Tools",submittedBy:"mike@company.com",template:"CLI Tool",provider:"Claude",estimatedCost:4.2,estimatedIterations:8,submittedAt:new Date(Date.now()-72e5).toISOString(),description:"Set of internal CLI tools for deployment automation.",status:"pending"},{id:"proj-3",name:"Analytics Dashboard",submittedBy:"jordan@company.com",template:"SaaS App",provider:"Codex",estimatedCost:8.9,estimatedIterations:12,submittedAt:new Date(Date.now()-144e5).toISOString(),description:"Real-time analytics dashboard for product metrics.",status:"pending"}],rt=[{projectId:"p-1",projectName:"Main Platform",budgetLimit:100,budgetUsed:67.4,alertThreshold:80},{projectId:"p-2",projectName:"Mobile App",budgetLimit:50,budgetUsed:12.3,alertThreshold:75},{projectId:"p-3",projectName:"Data Pipeline",budgetLimit:30,budgetUsed:28.5,alertThreshold:90}],it=["SaaS App","CLI Tool","REST API","Discord Bot","Chrome Extension","Mobile App","Data Pipeline","Landing Page","Docs Site"];function lt({project:n,onApprove:a,onReject:t}){const[l,c]=m.useState(!1),[s,r]=m.useState(""),[o,g]=m.useState(!1);return e.jsxs("div",{className:"border border-[#ECEAE3] dark:border-[#2A2A30] rounded-lg overflow-hidden",children:[e.jsxs("button",{type:"button",onClick:()=>c(!l),className:"w-full flex items-center gap-3 px-4 py-3 text-left hover:bg-[#F8F4F0] dark:hover:bg-[#222228] transition-colors",children:[l?e.jsx(ee,{size:14,className:"text-[#939084]"}):e.jsx(R,{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:n.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(Se,{size:10}),n.submittedBy]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(se,{size:10}),n.template]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(W,{size:10}),"~$",n.estimatedCost.toFixed(2)]})]})]}),e.jsx("span",{className:"text-xs text-[#939084] flex-shrink-0",children:new Date(n.submittedAt).toLocaleString("en-US",{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit",hour12:!1})})]}),l&&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:n.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:n.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:["$",n.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:n.estimatedIterations})]})]}),e.jsx("p",{className:"text-sm text-[#6B6960]",children:n.description}),o?e.jsxs("div",{className:"space-y-2",children:[e.jsx("textarea",{value:s,onChange:j=>r(j.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(w,{size:"sm",icon:ce,onClick:()=>a(s),children:"Approve"}),e.jsx(w,{size:"sm",variant:"danger",icon:te,onClick:()=>t(s),children:"Reject"}),e.jsx(w,{size:"sm",variant:"ghost",onClick:()=>g(!1),children:"Cancel"})]})]}):e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(w,{size:"sm",variant:"secondary",icon:fe,onClick:()=>g(!0),children:"Review"})})]})]})}function ct({configs:n}){return e.jsx("div",{className:"space-y-3",children:n.map(a=>{const t=a.budgetLimit>0?a.budgetUsed/a.budgetLimit*100:0,l=t>=a.alertThreshold,c=t>=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:a.projectName}),e.jsxs("div",{className:"flex items-center gap-2",children:[l&&e.jsx(G,{size:14,className:c?"text-[#C45B5B]":"text-[#F59E0B]"}),e.jsxs("span",{className:"text-xs font-mono text-[#939084]",children:["$",a.budgetUsed.toFixed(2)," / $",a.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(t,100)}%`,background:c?"#C45B5B":l?"#F59E0B":"#1FC5A8"}})}),e.jsxs("div",{className:"flex items-center justify-between mt-1",children:[e.jsxs("span",{className:"text-[10px] text-[#939084]",children:[t.toFixed(0),"% used"]}),e.jsxs("span",{className:"text-[10px] text-[#939084]",children:["Alert at ",a.alertThreshold,"%"]})]})]},a.projectId)})})}function ot({allTemplates:n}){const[a,t]=m.useState({Engineering:new Set(["SaaS App","CLI Tool","REST API","Data Pipeline"]),Design:new Set(["SaaS App","Landing Page","Mobile App"]),Marketing:new Set(["Landing Page","Docs Site"])}),l=Object.keys(a),c=(s,r)=>{t(o=>{const g={...o},j=new Set(g[s]);return j.has(r)?j.delete(r):j.add(r),g[s]=j,g})};return 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:"text-left px-3 py-2 text-xs font-medium text-[#6B6960]",children:"Template"}),l.map(s=>e.jsx("th",{className:"text-center px-3 py-2 text-xs font-medium text-[#6B6960]",children:s},s))]})}),e.jsx("tbody",{children:n.map(s=>e.jsxs("tr",{className:"border-t border-[#ECEAE3] dark:border-[#2A2A30] hover:bg-[#F8F4F0] dark:hover:bg-[#222228] transition-colors",children:[e.jsx("td",{className:"px-3 py-2 text-[#201515] dark:text-[#E8E6E3]",children:s}),l.map(r=>{var o;return e.jsx("td",{className:"text-center px-3 py-2",children:e.jsx("input",{type:"checkbox",checked:((o=a[r])==null?void 0:o.has(s))||!1,onChange:()=>c(r,s),className:"rounded border-[#ECEAE3] text-[#553DE9] focus:ring-[#553DE9]"})},r)})]},s))})]})})}function dt({pendingProjects:n,budgetConfigs:a,className:t=""}){const[l,c]=m.useState(n||nt),[s]=m.useState(a||rt),[r,o]=m.useState("approvals"),g=l.filter(h=>h.status==="pending").length,j=m.useCallback((h,y)=>{c(v=>v.map(E=>E.id===h?{...E,status:"approved"}:E))},[]),u=m.useCallback((h,y)=>{c(v=>v.map(E=>E.id===h?{...E,status:"rejected"}:E))},[]),b=[{id:"approvals",label:"Approvals",icon:ce,count:g},{id:"budgets",label:"Budgets",icon:W},{id:"templates",label:"Templates",icon:se}];return e.jsxs("div",{className:`space-y-4 ${t}`,children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Le,{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:b.map(h=>e.jsxs("button",{onClick:()=>o(h.id),className:`flex items-center gap-1.5 px-3 py-2 text-xs font-medium border-b-2 transition-colors ${r===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.count!==void 0&&h.count>0&&e.jsx("span",{className:"ml-1 px-1.5 py-0.5 rounded-full text-[10px] bg-[#553DE9]/10 text-[#553DE9]",children:h.count})]},h.id))}),r==="approvals"&&e.jsx("div",{className:"space-y-3",children:l.filter(h=>h.status==="pending").length===0?e.jsxs("div",{className:"text-center py-8",children:[e.jsx(je,{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."})]}):l.filter(h=>h.status==="pending").map(h=>e.jsx(lt,{project:h,onApprove:y=>j(h.id,y),onReject:y=>u(h.id,y)},h.id))}),r==="budgets"&&e.jsx(ct,{configs:s}),r==="templates"&&e.jsx(ot,{allTemplates:it})]})}function xt(){return[{id:"c-1",title:"API Keys Rotated Within 90 Days",description:"All active API keys should be rotated at least every 90 days to minimize exposure risk.",status:"warning",category:"security",lastChecked:new Date(Date.now()-36e5).toISOString(),remediationUrl:"/admin/settings",details:"2 of 3 keys are within 90 days. 1 key (Production CI/CD) is 120 days old."},{id:"c-2",title:"All Users Have MFA Enabled",description:"Multi-factor authentication should be enabled for all user accounts.",status:"fail",category:"access",lastChecked:new Date(Date.now()-36e5).toISOString(),remediationUrl:"/admin/settings",details:"3 of 5 users have MFA enabled. 2 users need to enable MFA."},{id:"c-3",title:"Audit Logging Enabled",description:"All user actions should be captured in the audit log.",status:"pass",category:"audit",lastChecked:new Date(Date.now()-36e5).toISOString(),details:"Audit logging is active. 1,247 events captured in the last 30 days."},{id:"c-4",title:"Data Retention Policy Set",description:"A data retention policy must be configured specifying how long logs and data are kept.",status:"pass",category:"data",lastChecked:new Date(Date.now()-36e5).toISOString(),details:"Retention policy: 90 days for logs, 365 days for audit events."},{id:"c-5",title:"Access Review Completed",description:"User access should be reviewed quarterly to ensure least-privilege principle.",status:"warning",category:"access",lastChecked:new Date(Date.now()-36e5).toISOString(),remediationUrl:"/admin",details:"Last access review was 85 days ago. Due for review within 5 days."},{id:"c-6",title:"Encryption at Rest Enabled",description:"All stored data including project files and secrets must be encrypted at rest.",status:"pass",category:"security",lastChecked:new Date(Date.now()-36e5).toISOString(),details:"AES-256 encryption enabled for all storage backends."},{id:"c-7",title:"Session Timeout Configured",description:"User sessions should expire after a configured period of inactivity.",status:"pass",category:"security",lastChecked:new Date(Date.now()-36e5).toISOString(),details:"Session timeout set to 30 minutes of inactivity."},{id:"c-8",title:"Rate Limiting Active",description:"API rate limiting should be enabled to prevent abuse and ensure fair usage.",status:"pass",category:"security",lastChecked:new Date(Date.now()-36e5).toISOString(),details:"Rate limit: 100 requests/minute per API key."}]}function mt({status:n}){switch(n){case"pass":return e.jsx(ae,{size:18,className:"text-[#1FC5A8]"});case"fail":return e.jsx(ne,{size:18,className:"text-[#C45B5B]"});case"warning":return e.jsx(G,{size:18,className:"text-[#F59E0B]"})}}const ht={security:Fe,access:z,data:De,audit:ve};function ut({score:n}){const s=2*Math.PI*56,o=270/360*s,g=n/100*o,j=n>=80?"#1FC5A8":n>=60?"#F59E0B":"#C45B5B",u=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} ${s}`,strokeLinecap:"round",transform:`rotate(${u} 70 70)`}),e.jsx("circle",{cx:70,cy:70,r:56,fill:"none",stroke:j,strokeWidth:10,strokeDasharray:`${g} ${s}`,strokeLinecap:"round",transform:`rotate(${u} 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:[n,"%"]}),e.jsx("span",{className:"text-xs text-[#939084]",children:"Compliant"})]})]})}function pt({items:n,onRefresh:a,className:t=""}){const[l,c]=m.useState(n||xt()),[s,r]=m.useState(!1),[o,g]=m.useState(null),[j,u]=m.useState(!1),b=l.filter(f=>f.status==="pass").length,h=l.filter(f=>f.status==="warning").length,y=l.filter(f=>f.status==="fail").length,v=l.length>0?Math.round(b/l.length*100):0,E=m.useCallback(async()=>{r(!0);try{if(a){const f=await a();c(f)}}catch{}finally{r(!1)}},[a]),x=m.useCallback(()=>{u(!0);const f={generatedAt:new Date().toISOString(),overallScore:v,summary:{pass:b,warning:h,fail:y,total:l.length},items:l.map(A=>({title:A.title,status:A.status,category:A.category,details:A.details,lastChecked:A.lastChecked}))},D=new Blob([JSON.stringify(f,null,2)],{type:"application/json"}),d=URL.createObjectURL(D),p=document.createElement("a");p.href=d,p.download=`compliance-report-${new Date().toISOString().split("T")[0]}.json`,p.click(),URL.revokeObjectURL(d),setTimeout(()=>u(!1),1e3)},[l,v,b,h,y]),N=["security","access","data","audit"];return e.jsxs("div",{className:`space-y-6 ${t}`,children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(be,{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:[e.jsx(w,{size:"sm",variant:"ghost",icon:le,onClick:E,loading:s,children:"Refresh"}),e.jsx(w,{size:"sm",variant:"secondary",icon:V,onClick:x,loading:j,children:"Generate Report"})]})]}),e.jsx("div",{className:"card p-6",children:e.jsxs("div",{className:"flex items-center gap-8",children:[e.jsx(ut,{score:v}),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(ae,{size:16,className:"text-[#1FC5A8]"}),e.jsxs("div",{children:[e.jsx("span",{className:"text-lg font-bold text-[#36342E] dark:text-[#E8E6E3]",children:b}),e.jsx("span",{className:"text-xs text-[#939084] ml-1",children:"Passing"})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(G,{size:16,className:"text-[#F59E0B]"}),e.jsxs("div",{children:[e.jsx("span",{className:"text-lg font-bold text-[#36342E] dark:text-[#E8E6E3]",children:h}),e.jsx("span",{className:"text-xs text-[#939084] ml-1",children:"Warnings"})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ne,{size:16,className:"text-[#C45B5B]"}),e.jsxs("div",{children:[e.jsx("span",{className:"text-lg font-bold text-[#36342E] dark:text-[#E8E6E3]",children:y}),e.jsx("span",{className:"text-xs text-[#939084] ml-1",children:"Failing"})]})]})]})]})]})}),N.map(f=>{const D=l.filter(p=>p.category===f);if(D.length===0)return null;const d=ht[f];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:f})]}),e.jsx("div",{className:"border border-[#ECEAE3] dark:border-[#2A2A30] rounded-lg overflow-hidden divide-y divide-[#ECEAE3] dark:divide-[#2A2A30]",children:D.map(p=>e.jsxs("div",{children:[e.jsxs("button",{type:"button",onClick:()=>g(o===p.id?null:p.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(mt,{status:p.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:p.title}),e.jsx("p",{className:"text-xs text-[#939084] truncate",children:p.description})]}),e.jsxs("div",{className:"flex items-center gap-1 text-[10px] text-[#939084] flex-shrink-0",children:[e.jsx(I,{size:10}),"Checked ",new Date(p.lastChecked).toLocaleString("en-US",{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit",hour12:!1})]})]}),o===p.id&&e.jsxs("div",{className:"px-4 pb-3 pt-1 bg-[#F8F4F0] dark:bg-[#222228]",children:[p.details&&e.jsx("p",{className:"text-sm text-[#6B6960] mb-2",children:p.details}),p.remediationUrl&&p.status!=="pass"&&e.jsxs("a",{href:p.remediationUrl,className:"inline-flex items-center gap-1 text-xs text-[#553DE9] hover:underline",children:[e.jsx(Ee,{size:12}),"Fix this issue"]})]})]},p.id))})]},f)})]})}function gt(){return[{label:"Total Users",value:"24",change:"+3 this month",changePositive:!0,icon:z,color:"#553DE9"},{label:"Active Projects",value:"18",change:"+5 this week",changePositive:!0,icon:re,color:"#1FC5A8"},{label:"Total Builds",value:"342",change:"+47 this week",changePositive:!0,icon:Me,color:"#F59E0B"},{label:"Monthly Cost",value:"$201.00",change:"-12% vs last month",changePositive:!0,icon:W,color:"#C45B5B"}]}function jt(){return[{name:"API Server",status:"healthy",latency:45},{name:"Claude Provider",status:"healthy",latency:230},{name:"Codex Provider",status:"degraded",latency:890},{name:"Gemini Provider",status:"healthy",latency:310},{name:"Task Queue",status:"healthy",latency:12},{name:"WebSocket",status:"healthy",latency:8}]}function ft(){return[{user:"alex@company.com",action:"started build",target:"customer-portal"},{user:"sarah@company.com",action:"deployed",target:"analytics-dashboard"},{user:"mike@company.com",action:"created project",target:"cli-tools"},{user:"jordan@company.com",action:"completed build",target:"api-service"},{user:"alex@company.com",action:"updated settings",target:"provider config"},{user:"emily@company.com",action:"invited user",target:"new-dev@company.com"},{user:"sarah@company.com",action:"rotated API key",target:"production"},{user:"mike@company.com",action:"started build",target:"mobile-app"},{user:"jordan@company.com",action:"approved project",target:"data-pipeline"},{user:"alex@company.com",action:"failed build",target:"legacy-service"},{user:"sarah@company.com",action:"created checkpoint",target:"analytics-dashboard"},{user:"emily@company.com",action:"changed role",target:"mike -> editor"},{user:"mike@company.com",action:"deployed",target:"cli-tools"},{user:"alex@company.com",action:"started build",target:"landing-page"},{user:"jordan@company.com",action:"reviewed project",target:"api-service"},{user:"sarah@company.com",action:"completed build",target:"analytics-dashboard"},{user:"emily@company.com",action:"updated template",target:"saas-app"},{user:"mike@company.com",action:"started build",target:"discord-bot"},{user:"alex@company.com",action:"approved project",target:"chrome-ext"},{user:"jordan@company.com",action:"deployed",target:"data-pipeline"}].map((a,t)=>({id:`act-${t}`,...a,timestamp:new Date(Date.now()-t*9e5).toISOString()}))}function bt(){return[{name:"Alex C.",builds:87},{name:"Sarah J.",builds:64},{name:"Mike D.",builds:52},{name:"Jordan L.",builds:41},{name:"Emily P.",builds:38},{name:"Others",builds:60}]}function vt({cards:n}){return e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-4",children:n.map(a=>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:a.label}),e.jsx("p",{className:"text-2xl font-bold text-[#36342E] dark:text-[#E8E6E3] mt-1",children:a.value}),a.change&&e.jsx("p",{className:`text-xs mt-1 ${a.changePositive?"text-[#1FC5A8]":"text-[#C45B5B]"}`,children:a.change})]}),e.jsx("div",{className:"p-2 rounded-lg",style:{backgroundColor:`${a.color}10`,color:a.color},children:e.jsx(a.icon,{size:20})})]})},a.label))})}function Et({data:n}){const a=Math.max(...n.map(t=>t.builds));return e.jsxs("div",{className:"card p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[e.jsx(_,{size:14,className:"text-[#553DE9]"}),e.jsx("h4",{className:"text-sm font-medium text-[#36342E] dark:text-[#E8E6E3]",children:"Builds per User"})]}),e.jsx("div",{className:"space-y-3",children:n.map(t=>e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"text-xs text-[#6B6960] w-16 text-right flex-shrink-0",children:t.name}),e.jsx("div",{className:"flex-1 h-6 bg-[#F8F4F0] dark:bg-[#1A1A1E] rounded-full overflow-hidden",children:e.jsx("div",{className:"h-full rounded-full bg-[#553DE9] transition-all duration-500 flex items-center justify-end pr-2",style:{width:`${t.builds/a*100}%`},children:e.jsx("span",{className:"text-[10px] text-white font-mono",children:t.builds})})})]},t.name))})]})}function Nt({health:n}){const a={healthy:"#1FC5A8",degraded:"#F59E0B",down:"#C45B5B"};return e.jsxs("div",{className:"card p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[e.jsx($e,{size:14,className:"text-[#553DE9]"}),e.jsx("h4",{className:"text-sm font-medium text-[#36342E] dark:text-[#E8E6E3]",children:"System Health"})]}),e.jsx("div",{className:"space-y-2",children:n.map(t=>e.jsxs("div",{className:"flex items-center justify-between py-1.5",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"w-2 h-2 rounded-full flex-shrink-0",style:{backgroundColor:a[t.status]}}),e.jsx("span",{className:"text-sm text-[#36342E] dark:text-[#E8E6E3]",children:t.name})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[t.latency!==void 0&&e.jsxs("span",{className:"text-xs font-mono text-[#939084]",children:[t.latency,"ms"]}),e.jsx("span",{className:"text-[10px] font-medium uppercase",style:{color:a[t.status]},children:t.status})]})]},t.name))})]})}function yt({actions:n}){const a=t=>new Date(t).toLocaleString("en-US",{hour:"2-digit",minute:"2-digit",hour12:!1});return e.jsxs("div",{className:"card p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[e.jsx(H,{size:14,className:"text-[#553DE9]"}),e.jsx("h4",{className:"text-sm font-medium text-[#36342E] dark:text-[#E8E6E3]",children:"Recent Activity"})]}),e.jsx("div",{className:"space-y-1 max-h-[400px] overflow-y-auto terminal-scroll",children:n.map(t=>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-10",children:a(t.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:t.user.split("@")[0]}),e.jsxs("span",{className:"text-[#6B6960]",children:[" ",t.action," "]}),e.jsx("span",{className:"text-[#201515] dark:text-[#E8E6E3] font-medium",children:t.target})]})})]},t.id))})]})}function kt(){return e.jsxs("div",{className:"max-w-[500px] mx-auto px-6 py-20 text-center",children:[e.jsx(Be,{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 At=[{id:"overview",label:"Overview",icon:H},{id:"users",label:"Users",icon:z},{id:"analytics",label:"Analytics",icon:_},{id:"governance",label:"Governance",icon:re},{id:"audit",label:"Audit Trail",icon:I},{id:"compliance",label:"Compliance",icon:X}];function Ht(){const{user:n,isLocalMode:a}=Ne(),[t,l]=m.useState("overview"),c=a||(n==null?void 0:n.authenticated)===!0,[s]=m.useState(gt),[r]=m.useState(jt),[o]=m.useState(ft),[g]=m.useState(bt);return c?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:At.map(j=>e.jsxs("button",{onClick:()=>l(j.id),className:`flex items-center gap-1.5 px-3 py-2 text-xs font-medium border-b-2 transition-colors whitespace-nowrap ${t===j.id?"border-[#553DE9] text-[#553DE9]":"border-transparent text-[#939084] hover:text-[#36342E] dark:hover:text-[#E8E6E3]"}`,children:[e.jsx(j.icon,{size:14}),j.label]},j.id))}),t==="overview"&&e.jsxs("div",{className:"space-y-6",children:[e.jsx(vt,{cards:s}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-4",children:[e.jsxs("div",{className:"card p-4 flex flex-col items-center justify-center",children:[e.jsx("h4",{className:"text-sm font-medium text-[#36342E] dark:text-[#E8E6E3] mb-3",children:"Build Success Rate"}),e.jsx(We,{percentage:94,size:96,strokeWidth:6,color:"#1FC5A8",children:e.jsx("span",{className:"text-lg font-bold text-[#36342E] dark:text-[#E8E6E3]",children:"94%"})}),e.jsx("p",{className:"text-xs text-[#939084] mt-2",children:"342 total builds"})]}),e.jsx("div",{className:"lg:col-span-2",children:e.jsx(Nt,{health:r})})]}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-4",children:[e.jsx(Et,{data:g}),e.jsx(yt,{actions:o})]})]}),t==="users"&&e.jsx(at,{}),t==="analytics"&&e.jsx(Ye,{}),t==="governance"&&e.jsx(dt,{}),t==="audit"&&e.jsx(Qe,{}),t==="compliance"&&e.jsx(pt,{})]}):e.jsx(kt,{})}export{Ht as default};
@@ -1,4 +1,4 @@
1
- import{c as h,j as s}from"./index-BN52-GQT.js";/**
1
+ import{c as h,j as s}from"./index-CM_b_EhP.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-BN52-GQT.js";import{C as r}from"./clock-mfq4XnPQ.js";import{C as a}from"./circle-alert-8SRY0_GX.js";import{C as l}from"./check-CBohulxQ.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-CM_b_EhP.js";import{C as r}from"./clock-IW4Wq86N.js";import{C as a}from"./circle-alert-CpL4Bhvt.js";import{C as l}from"./check-nIAqa-kf.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-BN52-GQT.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-CM_b_EhP.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};