auramaxx 0.0.11 → 0.0.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.next/BUILD_ID +1 -1
- package/.next/app-build-manifest.json +240 -223
- package/.next/app-path-routes-manifest.json +8 -7
- package/.next/build-manifest.json +14 -14
- package/.next/prerender-manifest.json +53 -29
- package/.next/react-loadable-manifest.json +41 -41
- package/.next/routes-manifest.json +6 -0
- package/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
- package/.next/server/app/_not-found.html +1 -1
- package/.next/server/app/_not-found.rsc +12 -12
- package/.next/server/app/api/[...doc]/page_client-reference-manifest.js +1 -1
- package/.next/server/app/api/agent-requests/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/apps/install/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/apps/manifests/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/apps/static/[...path]/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/docs/plain/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/events/route.js +1 -19
- package/.next/server/app/api/events/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/import-from-openclaw/[channel]/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/import-from-openclaw/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/import-from-openclaw/validate/[channel]/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/page_client-reference-manifest.js +1 -1
- package/.next/server/app/api/restart/route.js +1 -1
- package/.next/server/app/api/restart/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/update/route.js +63 -1
- package/.next/server/app/api/update/route.js.nft.json +1 -1
- package/.next/server/app/api/update/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/version/route.js +1 -1
- package/.next/server/app/api/version/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/workspace/[id]/apps/[wid]/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/workspace/[id]/apps/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/workspace/[id]/export/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/workspace/[id]/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/workspace/config/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/workspace/import/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/workspace/route_client-reference-manifest.js +1 -1
- package/.next/server/app/app-legacy-do-not-use/page.js +1 -1
- package/.next/server/app/app-legacy-do-not-use/page.js.nft.json +1 -1
- package/.next/server/app/app-legacy-do-not-use/page_client-reference-manifest.js +1 -1
- package/.next/server/app/app-legacy-do-not-use.html +1 -1
- package/.next/server/app/app-legacy-do-not-use.rsc +14 -14
- package/.next/server/app/approve/[actionId]/page.js +1 -1
- package/.next/server/app/approve/[actionId]/page_client-reference-manifest.js +1 -1
- package/.next/server/app/docs/[...doc]/page_client-reference-manifest.js +1 -1
- package/.next/server/app/docs/page_client-reference-manifest.js +1 -1
- package/.next/server/app/health/page_client-reference-manifest.js +1 -1
- package/.next/server/app/health.html +1 -1
- package/.next/server/app/health.rsc +13 -13
- package/.next/server/app/hello/page_client-reference-manifest.js +1 -1
- package/.next/server/app/hello.html +1 -1
- package/.next/server/app/hello.rsc +14 -14
- package/.next/server/app/index.html +1 -1
- package/.next/server/app/index.rsc +18 -21
- package/.next/server/app/page.js +3 -3
- package/.next/server/app/page.js.nft.json +1 -1
- package/.next/server/app/page_client-reference-manifest.js +1 -1
- package/.next/server/app/privacy/page_client-reference-manifest.js +1 -1
- package/.next/server/app/privacy.html +1 -1
- package/.next/server/app/privacy.rsc +13 -13
- package/.next/server/app/share/[token]/page_client-reference-manifest.js +1 -1
- package/.next/server/app/terms/page_client-reference-manifest.js +1 -1
- package/.next/server/app/terms.html +1 -1
- package/.next/server/app/terms.rsc +13 -13
- package/.next/server/app/yo/page.js +2 -0
- package/.next/server/app/yo/page.js.nft.json +1 -0
- package/.next/server/app/yo/page_client-reference-manifest.js +1 -0
- package/.next/server/app/yo.html +1 -0
- package/.next/server/app/yo.meta +7 -0
- package/.next/server/app/yo.rsc +23 -0
- package/.next/server/app-paths-manifest.json +8 -7
- package/.next/server/chunks/2145.js +1 -1
- package/.next/server/chunks/2460.js +1 -1
- package/.next/server/chunks/5246.js +1 -1
- package/.next/server/chunks/5678.js +1 -1
- package/.next/server/chunks/5784.js +1 -1
- package/.next/server/chunks/6086.js +2 -20
- package/.next/server/chunks/{5553.js → 6415.js} +2 -2
- package/.next/server/chunks/7935.js +2 -2
- package/.next/server/functions-config-manifest.json +1 -1
- package/.next/server/instrumentation.js +1 -1
- package/.next/server/middleware-build-manifest.js +1 -1
- package/.next/server/middleware-react-loadable-manifest.js +1 -1
- package/.next/server/pages/404.html +1 -1
- package/.next/server/pages/500.html +1 -1
- package/.next/server/server-reference-manifest.json +1 -1
- package/.next/server/webpack-runtime.js +1 -1
- package/.next/static/WshFGr6RxGYP6AbWuT9OG/_buildManifest.js +1 -0
- package/.next/static/chunks/1168.aaac1edbb597fe5a.js +1 -0
- package/.next/static/chunks/1255-7999eac54f80a49f.js +1 -0
- package/.next/static/chunks/142-fa9752f53a551f63.js +1 -0
- package/.next/static/chunks/2505.d54ccadc42f4e3d1.js +1 -0
- package/.next/static/chunks/2619-04bc32f026a0d946.js +1 -0
- package/.next/static/chunks/2927.7e00cc878d9a3f52.js +1 -0
- package/.next/static/chunks/3573-1b41d7b8a000d015.js +1 -0
- package/.next/static/chunks/3609.ded5a5306e18af9c.js +1 -0
- package/.next/static/chunks/3667-1db7bd03948e60df.js +1 -0
- package/.next/static/chunks/3826.a73d4a88d8c09030.js +1 -0
- package/.next/static/chunks/{3a91511d-648a2ba3dad7df0c.js → 3a91511d-ba215c0b5dc21ba9.js} +1 -1
- package/.next/static/chunks/4256.48407d9abad5ea33.js +1 -0
- package/.next/static/chunks/4685-7f53bbfc4a9845eb.js +1 -0
- package/.next/static/chunks/4901-ba6a32818662e70a.js +1 -0
- package/.next/static/chunks/4919-7e7cdd5efc9f2110.js +1 -0
- package/.next/static/chunks/4bd1b696-100b9d70ed4e49c1.js +1 -0
- package/.next/static/chunks/5336-233ec7ab3807267c.js +1 -0
- package/.next/static/chunks/5442-b5bb869e832e8967.js +1 -0
- package/.next/static/chunks/6233-97a810aa272af547.js +1 -0
- package/.next/static/chunks/626.a5109d16f9eca1f6.js +1 -0
- package/.next/static/chunks/6872-faea0f088ab2d450.js +1 -0
- package/.next/static/chunks/7338-3ce17a93614f1d77.js +59 -0
- package/.next/static/chunks/7394-4bdb1feefad1a74a.js +1 -0
- package/.next/static/chunks/7616-1129bcb3eee8d315.js +1 -0
- package/.next/static/chunks/786-26deffb41572cbb3.js +1 -0
- package/.next/static/chunks/8273-8e92d34180669ca9.js +1 -0
- package/.next/static/chunks/8357.5dee1e0c4e5bb091.js +1 -0
- package/.next/static/chunks/9062-2bc2d089f9c9c6ba.js +1 -0
- package/.next/static/chunks/9380.f198afbf0c6b5369.js +1 -0
- package/.next/static/chunks/app/_not-found/page-5a8c6a29f762fa58.js +1 -0
- package/.next/static/chunks/app/api/[...doc]/page-f0852f35f0fd1d44.js +1 -0
- package/.next/static/chunks/app/api/agent-requests/route-cf84f975aad4c719.js +1 -0
- package/.next/static/chunks/app/api/apps/install/route-cf84f975aad4c719.js +1 -0
- package/.next/static/chunks/app/api/apps/manifests/route-cf84f975aad4c719.js +1 -0
- package/.next/static/chunks/app/api/apps/static/[...path]/route-cf84f975aad4c719.js +1 -0
- package/.next/static/chunks/app/api/docs/plain/route-cf84f975aad4c719.js +1 -0
- package/.next/static/chunks/app/api/events/route-cf84f975aad4c719.js +1 -0
- package/.next/static/chunks/app/api/import-from-openclaw/[channel]/route-cf84f975aad4c719.js +1 -0
- package/.next/static/chunks/app/api/import-from-openclaw/route-cf84f975aad4c719.js +1 -0
- package/.next/static/chunks/app/api/import-from-openclaw/validate/[channel]/route-cf84f975aad4c719.js +1 -0
- package/.next/static/chunks/app/api/page-cc59bebcc0d2c01d.js +1 -0
- package/.next/static/chunks/app/api/restart/route-cf84f975aad4c719.js +1 -0
- package/.next/static/chunks/app/api/update/route-cf84f975aad4c719.js +1 -0
- package/.next/static/chunks/app/api/version/route-cf84f975aad4c719.js +1 -0
- package/.next/static/chunks/app/api/workspace/[id]/apps/[wid]/route-cf84f975aad4c719.js +1 -0
- package/.next/static/chunks/app/api/workspace/[id]/apps/route-cf84f975aad4c719.js +1 -0
- package/.next/static/chunks/app/api/workspace/[id]/export/route-cf84f975aad4c719.js +1 -0
- package/.next/static/chunks/app/api/workspace/[id]/route-cf84f975aad4c719.js +1 -0
- package/.next/static/chunks/app/api/workspace/config/route-cf84f975aad4c719.js +1 -0
- package/.next/static/chunks/app/api/workspace/import/route-cf84f975aad4c719.js +1 -0
- package/.next/static/chunks/app/api/workspace/route-cf84f975aad4c719.js +1 -0
- package/.next/static/chunks/app/app-legacy-do-not-use/page-e5dc864e92d90ca7.js +1 -0
- package/.next/static/chunks/app/approve/[actionId]/page-2acca1f490424f21.js +1 -0
- package/.next/static/chunks/app/docs/[...doc]/page-8e2a2d036caab242.js +1 -0
- package/.next/static/chunks/app/docs/page-acf872a03ff79893.js +1 -0
- package/.next/static/chunks/app/error-66f983b7769dabfa.js +1 -0
- package/.next/static/chunks/app/health/page-c9185854ed9c86d0.js +1 -0
- package/.next/static/chunks/app/hello/page-74c9f4deaa4b03dd.js +1 -0
- package/.next/static/chunks/app/layout-af8d9969c7aeb758.js +1 -0
- package/.next/static/chunks/app/page-16dfcd1c7cc88bcc.js +1 -0
- package/.next/static/chunks/app/privacy/page-8e2d17079355c2cc.js +1 -0
- package/.next/static/chunks/app/share/[token]/page-5dd9b0418eee411f.js +1 -0
- package/.next/static/chunks/app/terms/page-8e2d17079355c2cc.js +1 -0
- package/.next/static/chunks/app/yo/layout-cf84f975aad4c719.js +1 -0
- package/.next/static/chunks/app/yo/page-719dc5f213fdfb30.js +1 -0
- package/.next/static/chunks/framework-a32a2a465584c0bc.js +1 -0
- package/.next/static/chunks/main-0f0f9142f74e7215.js +1 -0
- package/.next/static/chunks/main-app-24f0c92ba10af457.js +1 -0
- package/.next/static/chunks/pages/_app-4b3fb5e477a0267f.js +1 -0
- package/.next/static/chunks/pages/_error-c970d8b55ace1b48.js +1 -0
- package/.next/static/chunks/{webpack-768de8b7d6a7a27a.js → webpack-79ad58260e9b10b4.js} +1 -1
- package/.next/static/css/83cd401584ab787f.css +3 -0
- package/.next/trace +28 -28
- package/.next/types/app/yo/layout.ts +84 -0
- package/.next/types/app/yo/page.ts +84 -0
- package/.next/types/routes.d.ts +4 -2
- package/.next/types/validator.ts +18 -0
- package/bin/auramaxx.js +11 -26
- package/docs/ARCHITECTURE.md +1 -1
- package/docs/AUTH.md +6 -3
- package/docs/CLI.md +2 -0
- package/docs/MCP.md +2 -0
- package/docs/TROUBLESHOOTING.md +24 -0
- package/docs/credentials.md +2 -0
- package/package.json +2 -1
- package/prisma/migrations/20260227214000_update_agent_action_ttl_defaults/migration.sql +19 -0
- package/public/0a167e5e-4f52-4715-ae23-bf63d259a6b1.png +0 -0
- package/public/141ec92c-6780-4b23-838f-9a7bf1e91bb8.png +0 -0
- package/public/3afc4935-92cb-42af-9624-0b1341c12a5e.png +0 -0
- package/public/43947df5-dbcf-4e49-ab8b-41b9162c0410.png +0 -0
- package/public/5aeae9ce-0d38-49ea-8fd1-167892a04a85.png +0 -0
- package/public/660e4ea3-a3a6-4be4-a8ca-2cb74c51dfb5.png +0 -0
- package/public/733f02d7-6b58-4ba6-a5c8-d062cd205e1d.png +0 -0
- package/public/a32d65cb-95b0-4977-be6b-cf69f515afbe.png +0 -0
- package/public/agent1.png +0 -0
- package/public/agent10.png +0 -0
- package/public/agent2.png +0 -0
- package/public/agent3.png +0 -0
- package/public/agent4.png +0 -0
- package/public/agent5.png +0 -0
- package/public/agent6.png +0 -0
- package/public/agent7.png +0 -0
- package/public/agent8.png +0 -0
- package/public/agent9.png +0 -0
- package/public/c4938305-b811-4ccc-91db-94d309734827.png +0 -0
- package/public/f2ca6825-a4f3-4107-815c-51ee740dfc09.png +0 -0
- package/public/llm.txt +2 -0
- package/public/llms.txt +39 -0
- package/public/ss-dark1.png +0 -0
- package/public/ss-dark1.webp +0 -0
- package/public/ss-dark2.png +0 -0
- package/public/ss-dark2.webp +0 -0
- package/public/ss-dark3.png +0 -0
- package/public/ss-dark3.webp +0 -0
- package/public/ss-light1.png +0 -0
- package/public/ss-light1.webp +0 -0
- package/public/ss-light2.png +0 -0
- package/public/ss-light2.webp +0 -0
- package/public/ss-light3.png +0 -0
- package/public/ss-light3.webp +0 -0
- package/shared/agent-profile-schema.ts +81 -0
- package/shared/credential-field-schema.ts +12 -0
- package/skills/auramaxx/SKILL.md +71 -691
- package/src/app/UnlockPageClient.tsx +1939 -0
- package/src/app/api/page.tsx +8 -9
- package/src/app/api/restart/route.ts +2 -18
- package/src/app/api/update/route.ts +104 -51
- package/src/app/approve/[actionId]/page.tsx +4 -1
- package/src/app/docs/DocsPageContent.tsx +3 -3
- package/src/app/globals.css +94 -0
- package/src/app/layout.tsx +1 -0
- package/src/app/page.tsx +25 -1935
- package/src/app/yo/layout.tsx +29 -0
- package/src/app/yo/page.tsx +528 -0
- package/src/components/HumanActionBar.tsx +34 -8
- package/src/components/agent/AgentSidebar.tsx +3 -1
- package/src/components/agent/CredentialAgent.tsx +5 -1
- package/src/components/agent/CredentialDetail.tsx +32 -1
- package/src/components/agent/CredentialForm.tsx +94 -7
- package/src/components/agent/CredentialRow.tsx +8 -1
- package/src/components/agent/credentialFormName.ts +22 -1
- package/src/components/agent/types.ts +2 -2
- package/src/components/design-system/Modal.tsx +14 -1
- package/src/hooks/useUpdateChecker.ts +17 -1
- package/src/lib/pino.ts +77 -8
- package/src/server/cli/commands/actions.ts +1 -1
- package/src/server/cli/commands/agent.ts +110 -65
- package/src/server/cli/commands/approve.ts +1 -1
- package/src/server/cli/commands/auth.ts +81 -20
- package/src/server/cli/commands/start.ts +42 -3
- package/src/server/cli/commands/token.ts +2 -2
- package/src/server/cli/lib/escalation.ts +109 -24
- package/src/server/cli/lib/process.ts +54 -1
- package/src/server/cli/socket.ts +1 -1
- package/src/server/index.ts +2 -0
- package/src/server/lib/agent-profile-records.ts +72 -0
- package/src/server/lib/credential-transport.ts +27 -11
- package/src/server/lib/defaults.ts +3 -3
- package/src/server/lib/escalation-responder.ts +1 -1
- package/src/server/lib/resolve-action.ts +2 -2
- package/src/server/lib/update-check.ts +1 -1
- package/src/server/mcp/server.ts +6 -1
- package/src/server/node_modules/.vite/vitest/da39a3ee5e6b4b0d3255bfef95601890afd80709/results.json +1 -1
- package/src/server/routes/actions.ts +2 -2
- package/src/server/routes/agent-profiles.ts +82 -0
- package/src/server/routes/auth.ts +39 -4
- package/src/server/routes/credentials.ts +18 -0
- package/src/server/tests/cli/agent-auth.test.ts +20 -39
- package/src/server/tests/cli/agent.test.ts +18 -0
- package/src/server/tests/cli/auth-action-flag.test.ts +3 -2
- package/src/server/tests/cli/bin-entrypoint.test.ts +35 -11
- package/src/server/tests/cli/escalation.test.ts +7 -3
- package/src/server/tests/cli/process.test.ts +3 -3
- package/src/server/tests/cli/socket.test.ts +2 -2
- package/src/server/tests/cli/start-run.test.ts +24 -1
- package/src/server/tests/endpoints/actions.test.ts +2 -2
- package/src/server/tests/endpoints/agent-profiles.test.ts +117 -0
- package/src/server/tests/endpoints/auth.test.ts +34 -0
- package/src/server/tests/lib/credential-transport.test.ts +68 -2
- package/src/server/tests/lib/defaults.test.ts +2 -2
- package/src/server/tests/lib/escalation-responder.test.ts +2 -2
- package/src/server/tests/lib/update-check.test.ts +1 -1
- package/src/server/tests/setup.ts +7 -0
- package/src/server/tsconfig.tsbuildinfo +1 -1
- package/src/server/types.ts +1 -1
- package/.next/static/AcaCjQ4akovHBUnVGPpfN/_buildManifest.js +0 -1
- package/.next/static/chunks/1168.63dbb444a33b1867.js +0 -1
- package/.next/static/chunks/1255-e8718b02724690dd.js +0 -1
- package/.next/static/chunks/142-aeaf7ffa9c53516d.js +0 -1
- package/.next/static/chunks/2505.22aaa333fd65908f.js +0 -1
- package/.next/static/chunks/2619-3c9e02e22d10480a.js +0 -1
- package/.next/static/chunks/2927.e7e9e2a1b8d2dc61.js +0 -1
- package/.next/static/chunks/3573-27e17f4ff2dd86ed.js +0 -1
- package/.next/static/chunks/3609.6f8e0ecd6de9566c.js +0 -1
- package/.next/static/chunks/3667-d6770121629db38b.js +0 -1
- package/.next/static/chunks/3826.7dfe96467cd74e45.js +0 -1
- package/.next/static/chunks/4256.50cb375c979ffd5a.js +0 -1
- package/.next/static/chunks/4685-3f8d92f574366fec.js +0 -1
- package/.next/static/chunks/4901-54c1ac380b7b43bb.js +0 -1
- package/.next/static/chunks/4919-fe6f1553abfc9420.js +0 -1
- package/.next/static/chunks/4bd1b696-f785427dddbba9fb.js +0 -1
- package/.next/static/chunks/5336-bd251f91235f7c11.js +0 -1
- package/.next/static/chunks/5442-be197c885bf12079.js +0 -1
- package/.next/static/chunks/5553-c8b86fe3513fce04.js +0 -59
- package/.next/static/chunks/6233-44e6fe57a552a816.js +0 -1
- package/.next/static/chunks/626.2583673a0386a81b.js +0 -1
- package/.next/static/chunks/6872-6442f2f5cce36ce5.js +0 -1
- package/.next/static/chunks/7411-3ca797c21b722ccd.js +0 -1
- package/.next/static/chunks/7616-b8bd37ce1f735d6f.js +0 -1
- package/.next/static/chunks/786-9ed39f96091b2be4.js +0 -1
- package/.next/static/chunks/8273-922091226ba84a94.js +0 -1
- package/.next/static/chunks/8357.6159472717ff7d11.js +0 -1
- package/.next/static/chunks/9062-3eb1607c96486f88.js +0 -1
- package/.next/static/chunks/9380.93f361baab2eefdf.js +0 -1
- package/.next/static/chunks/app/_not-found/page-c3b87025baf0a9c2.js +0 -1
- package/.next/static/chunks/app/api/[...doc]/page-790c4b33ba1fde4a.js +0 -1
- package/.next/static/chunks/app/api/agent-requests/route-e83b12cbab2e8707.js +0 -1
- package/.next/static/chunks/app/api/apps/install/route-e83b12cbab2e8707.js +0 -1
- package/.next/static/chunks/app/api/apps/manifests/route-e83b12cbab2e8707.js +0 -1
- package/.next/static/chunks/app/api/apps/static/[...path]/route-e83b12cbab2e8707.js +0 -1
- package/.next/static/chunks/app/api/docs/plain/route-e83b12cbab2e8707.js +0 -1
- package/.next/static/chunks/app/api/events/route-e83b12cbab2e8707.js +0 -1
- package/.next/static/chunks/app/api/import-from-openclaw/[channel]/route-e83b12cbab2e8707.js +0 -1
- package/.next/static/chunks/app/api/import-from-openclaw/route-e83b12cbab2e8707.js +0 -1
- package/.next/static/chunks/app/api/import-from-openclaw/validate/[channel]/route-e83b12cbab2e8707.js +0 -1
- package/.next/static/chunks/app/api/page-b53f9aa17a4c5201.js +0 -1
- package/.next/static/chunks/app/api/restart/route-e83b12cbab2e8707.js +0 -1
- package/.next/static/chunks/app/api/update/route-e83b12cbab2e8707.js +0 -1
- package/.next/static/chunks/app/api/version/route-e83b12cbab2e8707.js +0 -1
- package/.next/static/chunks/app/api/workspace/[id]/apps/[wid]/route-e83b12cbab2e8707.js +0 -1
- package/.next/static/chunks/app/api/workspace/[id]/apps/route-e83b12cbab2e8707.js +0 -1
- package/.next/static/chunks/app/api/workspace/[id]/export/route-e83b12cbab2e8707.js +0 -1
- package/.next/static/chunks/app/api/workspace/[id]/route-e83b12cbab2e8707.js +0 -1
- package/.next/static/chunks/app/api/workspace/config/route-e83b12cbab2e8707.js +0 -1
- package/.next/static/chunks/app/api/workspace/import/route-e83b12cbab2e8707.js +0 -1
- package/.next/static/chunks/app/api/workspace/route-e83b12cbab2e8707.js +0 -1
- package/.next/static/chunks/app/app-legacy-do-not-use/page-0052191daef60036.js +0 -1
- package/.next/static/chunks/app/approve/[actionId]/page-45cd3b8fa062d5e5.js +0 -1
- package/.next/static/chunks/app/docs/[...doc]/page-632ac406200b66fe.js +0 -1
- package/.next/static/chunks/app/docs/page-b7556394709b43df.js +0 -1
- package/.next/static/chunks/app/error-3d6057da512253d8.js +0 -1
- package/.next/static/chunks/app/health/page-80c985cd72328b74.js +0 -1
- package/.next/static/chunks/app/hello/page-fd71babcd192729b.js +0 -1
- package/.next/static/chunks/app/layout-285c6ef3f16bae63.js +0 -1
- package/.next/static/chunks/app/page-85017185df14c37b.js +0 -1
- package/.next/static/chunks/app/privacy/page-faf36cd0dde6dfa3.js +0 -1
- package/.next/static/chunks/app/share/[token]/page-22d51d6c5a47bb75.js +0 -1
- package/.next/static/chunks/app/terms/page-faf36cd0dde6dfa3.js +0 -1
- package/.next/static/chunks/framework-e60c938074ff7136.js +0 -1
- package/.next/static/chunks/main-447abf206d7ebd2f.js +0 -1
- package/.next/static/chunks/main-app-f63b86bdbf5b7b88.js +0 -1
- package/.next/static/chunks/pages/_app-6c8c2371b16a04b8.js +0 -1
- package/.next/static/chunks/pages/_error-94812ad32cad7365.js +0 -1
- package/.next/static/css/eb25c6452113486f.css +0 -3
- /package/.next/static/{AcaCjQ4akovHBUnVGPpfN → WshFGr6RxGYP6AbWuT9OG}/_ssgManifest.js +0 -0
|
@@ -1 +0,0 @@
|
|
|
1
|
-
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[8974],{858:(e,t,a)=>{"use strict";a.r(t),a.d(t,{default:()=>tJ});var r=a(5155),l=a(2115),s=a(8677),o=a(2619),n=a.n(o),i=a(21),c=a(5870),d=a(6489),x=a(4901),u=a(960),p=a(6509),f=a(9540),m=a(9051),v=a(6651),h=a(3409),g=a(7993),b=a(3667),y=a(9397),j=a(5370),w=a(8519),N=a(9715),k=a(5882),C=a(9559),S=a(803),A=a(6907),E=a(1375),I=a(1360),T=a(7937),R=a(9708),O=a(6191),L=a(5795),D=a(9347),z=a(7726);let P=[{key:"all",label:"All Credentials",icon:y.A},{key:"login",label:"Logins",icon:j.A},{key:"card",label:"Cards",icon:w.A},{key:"plain_note",label:"Plain Notes",icon:N.A},{key:"note",label:"Secret Notes",icon:N.A},{key:"hot_wallet",label:"Hot Wallets",icon:k.A},{key:"oauth2",label:"OAuth2",icon:C.A},{key:"ssh",label:"SSH Keys",icon:S.A},{key:"gpg",label:"GPG Keys",icon:A.A}],F={login:"login",card:"card",plain_note:"plain_note",note:"note",hot_wallet:"hot_wallet",oauth2:"oauth2",ssh:"ssh",gpg:"gpg"},_=[{key:"archive",label:"Archived",icon:E.A},{key:"recently_deleted",label:"Recently Deleted",icon:I.A}],M=[{combo:"Cmd/Ctrl + K",action:"Focus search"},{combo:"/",action:"Focus search (while not typing)"},{combo:"Cmd/Ctrl + Alt + N",action:"Create new credential"},{combo:"↑ / ↓",action:"Navigate list selection"},{combo:"Enter",action:"Open selected credential"}],K="auramaxx:agent-sidebar-collapsible-sections",U="auramaxx:agent-sidebar-collapsed-agent-nodes",H={agents:!1,categories:!0,favorites:!0,tags:!0,lifecycle:!0};function W(e){return e.parentAgentId||e.linkedTo}let $=e=>{let{agents:t,filters:a,categoryCounts:s,tags:o,favoritesCount:n,onFilterChange:i,onLock:c,onLockAgent:d,onUnlockAgent:x,onCreateCredential:u,onCreateAgent:p,mode:f="desktop",onNavigate:m,notifications:v=[],onDismissNotification:h,pendingActionCount:g=0,surface:w="credentials",onSurfaceChange:N,onSettings:k,onDeleteAgent:C}=e,S="tablet"===f,A="tablet"===f?"calc(48px * var(--ui-scale-factor, 1))":"mobile"===f?"calc(220px * var(--ui-scale-factor, 1))":"calc(200px * var(--ui-scale-factor, 1))",E="active"!==a.lifecycle,$=(0,l.useMemo)(()=>(function(e){let t=new Map(e.map(e=>[e.id,e])),a=new Map(e.map((e,t)=>[e.id,t])),r=new Map;for(let a of e){let e=W(a);if(!e||!t.has(e)||e===a.id)continue;let l=r.get(e)||[];l.push(a),r.set(e,l)}let l=(e,t)=>(a.get(e.id)||0)-(a.get(t.id)||0);for(let e of r.values())e.sort(l);let s=e.filter(e=>{let a=W(e);return!a||!t.has(a)||a===e.id}).sort(l),o=[],n=new Set,i=(e,t)=>{if(!n.has(e.id))for(let a of(n.add(e.id),o.push({agent:e,depth:t}),r.get(e.id)||[]))i(a,t+1)};for(let e of s)i(e,0);for(let t of[...e].sort(l))i(t,0);return o})(t),[t]),{parentByChild:B,childCountByParent:V}=(0,l.useMemo)(()=>(function(e){let t=new Map,a=new Map;for(let r of e){let e=W(r);e&&e!==r.id&&(t.set(r.id,e),a.set(e,(a.get(e)||0)+1))}return{parentByChild:t,childCountByParent:a}})(t),[t]),[G,Y]=(0,l.useState)(H),[q,X]=(0,l.useState)(!1),[J,Q]=(0,l.useState)({}),[Z,ee]=(0,l.useState)(!1),[et,ea]=(0,l.useState)(!1),er=(0,l.useRef)(null);(0,l.useEffect)(()=>{try{let e=window.localStorage.getItem(K);if(!e)return;let t=function(e){return e&&"object"==typeof e?{agents:!!e.agents,categories:!!e.categories,favorites:!!e.favorites,tags:!!e.tags,lifecycle:!!e.lifecycle}:null}(JSON.parse(e));if(!t)return;Y(t)}catch(e){}finally{X(!0)}},[]),(0,l.useEffect)(()=>{if(q)try{window.localStorage.setItem(K,JSON.stringify(G))}catch(e){}},[G,q]),(0,l.useEffect)(()=>{try{let e=window.localStorage.getItem(U);if(!e)return;let t=function(e){if(!e||"object"!=typeof e)return null;let t={};for(let[a,r]of Object.entries(e))a&&(t[a]=!!r);return t}(JSON.parse(e));if(!t)return;Q(t)}catch(e){}finally{ee(!0)}},[]),(0,l.useEffect)(()=>{if(Z)try{window.localStorage.setItem(U,JSON.stringify(J))}catch(e){}},[J,Z]),(0,l.useEffect)(()=>{let e=a.agentId;if(!e)return;let t=[],r=B.get(e);for(;r;)t.push(r),r=B.get(r);0!==t.length&&Q(e=>{let a=!1,r={...e};for(let e of t)r[e]&&(delete r[e],a=!0);return a?r:e})},[a.agentId,B]),(0,l.useEffect)(()=>{if(!et)return;let e=e=>{let t=e.target;er.current&&!er.current.contains(t)&&ea(!1)},t=e=>{"Escape"===e.key&&ea(!1)};return document.addEventListener("mousedown",e),document.addEventListener("keydown",t),()=>{document.removeEventListener("mousedown",e),document.removeEventListener("keydown",t)}},[et]);let el=(0,l.useMemo)(()=>{let e=[],t=[];for(let a of $){for(;e.length>a.depth;)e.pop();!(e.length>0)&&(t.push(a),J[a.agent.id]&&e.push(a.agent.id))}return t},[$,J]),es=e=>{Y(t=>({...t,[e]:!t[e]}))},eo=e=>{null==N||N("credentials"),i(e),null==m||m()},en=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"default",t=arguments.length>1?arguments[1]:void 0;null==N||N("credentials"),t?u(e,t):u(e),null==m||m()},ei=e=>{null==N||N("credentials"),p(e),null==m||m()},ec=()=>{c(),null==m||m()},ed=()=>{null==N||N("apiKeys"),null==m||m()},ex=function(e,t){let a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"";return(0,r.jsxs)("button",{type:"button",onClick:()=>es(e),onKeyDown:t=>{("Enter"===t.key||" "===t.key)&&(t.preventDefault(),es(e))},"aria-expanded":!G[e],"aria-controls":"agent-sidebar-section-".concat(e),"aria-label":"".concat(t," section"),className:"w-full flex items-center transition-colors hover:bg-[var(--color-background-alt,#f4f4f5)] ".concat(S?"justify-center py-1":"justify-between px-2 py-1"," ").concat(a),title:"".concat(t," section"),children:[!S&&(0,r.jsx)("span",{className:"text-[8px] tracking-widest uppercase text-[var(--color-text-muted,#6b7280)] font-bold",children:t}),(0,r.jsx)(T.A,{size:10,className:"text-[var(--color-text-faint,#9ca3af)] transition-transform ".concat(G[e]?"":"rotate-90")})]})};return(0,r.jsxs)("div",{className:"h-full flex flex-col border-r border-[var(--color-border,#d4d4d8)] font-mono relative overflow-hidden shrink-0",style:{width:A,minWidth:A,background:"var(--color-surface, #f4f4f2)",fontSize:"var(--font-size-sm)"},children:[(0,r.jsx)("div",{className:"absolute inset-0 opacity-[0.02] pointer-events-none bg-[radial-gradient(var(--color-text,#000)_1px,transparent_1px)] bg-[size:4px_4px]"}),(0,r.jsx)("div",{className:"flex items-center justify-between border-b border-[var(--color-border,#d4d4d8)] relative z-10 ".concat(S?"px-2 py-2":"px-3 py-3"),children:(0,r.jsxs)("div",{className:"flex items-center ".concat(S?"justify-center w-full":"gap-2"),children:[(0,r.jsx)("img",{src:"/logo.webp",alt:"Aura",className:S?"w-5 h-5 object-contain":"w-6 h-6 object-contain"}),!S&&(0,r.jsxs)("div",{className:"leading-tight",children:[(0,r.jsxs)("div",{className:"flex items-baseline gap-1",children:[(0,r.jsx)("span",{"data-testid":"agent-sidebar-header-brand",className:"text-[10px] font-bold tracking-tight lowercase text-[var(--color-text,#0a0a0a)]",children:"auramaxx"}),(0,r.jsx)("span",{className:"text-[8px] text-[var(--color-text-muted,#6b7280)] uppercase tracking-widest",children:"from"})]}),(0,r.jsx)("a",{href:"https://x.com/hi_im_nico",target:"_blank",rel:"noopener noreferrer",className:"block text-[8px] text-[var(--color-text-muted,#6b7280)] hover:text-[var(--color-text,#0a0a0a)] transition-colors",children:"@hi_im_nico, with love"})]})]})}),(0,r.jsxs)("div",{className:"flex-1 overflow-y-auto overflow-x-hidden relative z-10",children:[(0,r.jsxs)("div",{className:"border-b border-[var(--color-border,#d4d4d8)]",children:[ex("agents","Agents"),!G.agents&&(0,r.jsxs)("div",{id:"agent-sidebar-section-agents",className:"".concat(S?"px-1 pb-2":"px-2 pb-2"," overflow-x-hidden"),children:[(0,r.jsxs)("div",{className:"flex items-center ".concat(S?"gap-1":"gap-1.5"),style:{borderLeft:null===a.agentId?"2px solid var(--color-accent, #ccff00)":"2px solid transparent"},children:[(0,r.jsx)("button",{onClick:()=>eo({agentId:null,lifecycle:"active",tag:null}),className:"flex-1 flex items-center transition-colors hover:bg-[var(--color-background-alt,#f4f4f5)] ".concat(S?"justify-center px-1 py-1.5":"gap-2 px-2 py-1.5 text-left"),title:"All Agents (Active)",children:S?(0,r.jsx)(y.A,{size:11,className:"text-[var(--color-text-muted,#6b7280)]"}):(0,r.jsx)("span",{className:"text-[9px] tracking-widest uppercase text-[var(--color-text,#0a0a0a)] font-bold",children:"All Agents"})}),(0,r.jsx)(b.$n,{variant:"ghost",size:"sm",onClick:ec,className:S?"!px-0 !h-6 !w-6":"!px-1.5 !h-6",title:"Lock all agents",children:(0,r.jsx)(R.A,{size:10})}),(0,r.jsx)(b.$n,{variant:"ghost",size:"sm",onClick:()=>ei(),className:S?"!px-0 !h-6 !w-6":"!px-1.5 !h-6",title:"Create agent",children:(0,r.jsx)(O.A,{size:10})})]}),el.map(e=>{var l,s,o;let{agent:n,depth:i}=e,c=n.name||(n.isPrimary?"Primary":"Agent ".concat(n.id.slice(0,6))),u=!W(n)&&!n.isPrimary&&n.isUnlocked&&!!d,p=(V.get(n.id)||0)>0,f=B.get(n.id),m=f?(null==(l=t.find(e=>e.id===f))?void 0:l.name)||f.slice(0,6):null,v=a.agentId===n.id;return(0,r.jsxs)("div",{className:"w-full min-w-0 flex items-center group",style:{borderLeft:v?"2px solid var(--color-accent, #ccff00)":"2px solid transparent"},children:[(0,r.jsx)("div",{className:"ml-0.5 flex items-center",children:p?(0,r.jsx)("button",{type:"button","data-testid":"agent-toggle-".concat(n.id),"aria-label":"Toggle children for ".concat(c),onClick:e=>{e.stopPropagation(),(e=>{Q(t=>({...t,[e]:!t[e]}))})(n.id)},className:"w-5 h-5 flex items-center justify-center text-[var(--color-text-muted,#6b7280)] hover:text-[var(--color-text,#0a0a0a)]",children:(0,r.jsx)(T.A,{size:9,className:"transition-transform ".concat(J[n.id]?"":"rotate-90")})}):(0,r.jsx)("span",{className:"w-5"})}),(0,r.jsx)("button",{"data-testid":"agent-item-".concat(n.id),"data-agent-depth":i,onClick:()=>{if(!n.isUnlocked){null==x||x(n);return}eo({agentId:n.id})},className:"flex-1 min-w-0 flex items-center transition-colors hover:bg-[var(--color-background-alt,#f4f4f5)] ".concat(S?"justify-center py-1.5 pr-1":"gap-2 py-1.5 pr-2 text-left"),style:{paddingLeft:S?"".concat(Math.max(2,2+4*i),"px"):"".concat(8+12*i,"px")},title:c,children:S?(0,r.jsxs)("div",{className:"flex items-center gap-1",children:[(0,r.jsx)("div",{className:"w-4 h-4 border border-[var(--color-border,#d4d4d8)] rounded-full flex items-center justify-center text-[7px] uppercase text-[var(--color-text-muted,#6b7280)]",children:(n.name||"V").slice(0,1)}),n.isUnlocked?(0,r.jsx)(L.A,{size:8,className:"text-[var(--color-text-muted,#6b7280)]"}):(0,r.jsx)(R.A,{size:8,className:"text-[var(--color-text-faint,#9ca3af)]"})]}):(0,r.jsxs)(r.Fragment,{children:[i>0&&(0,r.jsx)("span",{"data-testid":"agent-lineage-".concat(n.id),className:"text-[8px] text-[var(--color-text-faint,#9ca3af)]",title:m?"Child of ".concat(m):"Child agent",children:"↳"}),(0,r.jsx)("span",{className:"min-w-0 flex-1 text-[9px] tracking-widest uppercase text-[var(--color-text-muted,#6b7280)] truncate",children:c}),(0,r.jsx)("span",{className:"shrink-0 text-[8px] text-[var(--color-text-faint,#9ca3af)] tabular-nums",title:"".concat(null!=(s=n.credentialCount)?s:0," credentials"),children:null!=(o=n.credentialCount)?o:0})]})}),!S&&(0,r.jsxs)("div",{className:"mr-1 flex items-center gap-0.5",children:[u&&(0,r.jsx)("button",{type:"button","data-testid":"agent-status-lock-".concat(n.id),title:n.isPrimary?"Lock all agents":"Lock agent ".concat(c),"aria-label":n.isPrimary?"Lock all agents":"Lock agent ".concat(c),onClick:e=>{if(e.stopPropagation(),n.isPrimary)return void ec();null==d||d(n.id)},className:"w-5 h-5 flex items-center justify-center text-[var(--color-text-muted,#6b7280)] hover:text-[var(--color-text,#0a0a0a)] hover:bg-[var(--color-background-alt,#f4f4f5)] opacity-0 group-hover:opacity-100 transition-opacity",children:(0,r.jsx)(R.A,{size:9})}),C&&(0,r.jsx)("button",{type:"button",title:"Delete agent ".concat(c),"aria-label":"Delete agent ".concat(c),onClick:e=>{e.stopPropagation(),C(n)},className:"w-5 h-5 flex items-center justify-center text-[var(--color-text-muted,#6b7280)] hover:text-[var(--color-text,#0a0a0a)] hover:bg-[var(--color-background-alt,#f4f4f5)] opacity-0 group-hover:opacity-100 group-focus-within:opacity-100 transition-opacity",children:(0,r.jsx)(I.A,{size:9})}),(0,r.jsx)("button",{type:"button",title:"Create child agent in ".concat(c),"aria-label":"Create child agent in ".concat(c),onClick:e=>{e.stopPropagation(),ei(n.id)},className:"w-5 h-5 shrink-0 flex items-center justify-center text-[var(--color-text-muted,#6b7280)] hover:text-[var(--color-text,#0a0a0a)] hover:bg-[var(--color-background-alt,#f4f4f5)]",children:(0,r.jsx)(O.A,{size:9})})]})]},n.id)})]})]}),(0,r.jsxs)("div",{className:"border-b border-[var(--color-border,#d4d4d8)]",children:[ex("categories","Categories"),!G.categories&&(0,r.jsx)("div",{id:"agent-sidebar-section-categories",className:S?"px-1 pb-2":"px-2 pb-2",children:P.map(e=>{let{key:t,label:l,icon:o}=e;return(0,r.jsxs)("div",{className:"w-full flex items-center gap-1 group",children:[(0,r.jsxs)("button",{onClick:()=>eo({category:t}),className:"".concat("flex-1 min-w-0"," flex items-center transition-colors hover:bg-[var(--color-background-alt,#f4f4f5)] ").concat(S?"justify-center px-1 py-1.5":"gap-2 px-2 py-1.5 text-left"),style:{borderLeft:a.category===t?"2px solid var(--color-accent, #ccff00)":"2px solid transparent"},title:l,children:[(0,r.jsx)(o,{size:11,className:a.category===t?"text-[var(--color-text,#0a0a0a)]":"text-[var(--color-text-muted,#6b7280)]"}),!S&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("span",{className:"text-[9px] tracking-widest uppercase flex-1 ".concat(a.category===t?"text-[var(--color-text,#0a0a0a)] font-bold":"text-[var(--color-text-muted,#6b7280)]"),children:l}),(0,r.jsx)("span",{className:"text-[8px] text-[var(--color-text-faint,#9ca3af)]",children:s[t]})]})]}),(0,r.jsx)(b.$n,{variant:"ghost",size:"sm",onClick:()=>{let e=F[t];if(e)return void en("default",e);en("type-picker")},className:"".concat(S?"!px-0 !h-6 !w-6":"!px-1.5 !h-6"," opacity-0 group-hover:opacity-100 group-focus-within:opacity-100 transition-opacity"),title:E?"Click All Credentials to return to Active and create ".concat(l):"Create ".concat(l),disabled:E,children:(0,r.jsx)(O.A,{size:10})})]},t)})})]}),(0,r.jsxs)("div",{className:"border-b border-[var(--color-border,#d4d4d8)]",children:[ex("favorites","Favorites"),!G.favorites&&(0,r.jsx)("div",{id:"agent-sidebar-section-favorites",className:S?"px-1 pb-2":"px-2 pb-2",children:(0,r.jsxs)("button",{onClick:()=>eo({favoritesOnly:!a.favoritesOnly}),className:"w-full flex items-center transition-colors hover:bg-[var(--color-background-alt,#f4f4f5)] ".concat(S?"justify-center px-1 py-1.5":"gap-2 px-2 py-1.5 text-left"),style:{borderLeft:a.favoritesOnly?"2px solid var(--color-accent, #ccff00)":"2px solid transparent"},title:"Favorites",children:[(0,r.jsx)(D.A,{size:11,className:a.favoritesOnly?"text-[var(--color-favorite,#ff4d00)]":"text-[var(--color-text-muted,#6b7280)]",style:a.favoritesOnly?{fill:"var(--color-favorite,#ff4d00)",color:"var(--color-favorite,#ff4d00)"}:void 0}),!S&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("span",{className:"text-[9px] tracking-widest uppercase flex-1 ".concat(a.favoritesOnly?"text-[var(--color-text,#0a0a0a)] font-bold":"text-[var(--color-text-muted,#6b7280)]"),children:"Favorites"}),(0,r.jsx)("span",{className:"text-[8px] text-[var(--color-text-faint,#9ca3af)]",children:n})]})]})})]}),!S&&o.length>0&&(0,r.jsxs)("div",{className:"border-b border-[var(--color-border,#d4d4d8)]",children:[ex("tags","Tags"),!G.tags&&(0,r.jsx)("div",{id:"agent-sidebar-section-tags",className:"px-2 pb-2 overflow-y-auto",children:o.map(e=>(0,r.jsxs)("button",{onClick:()=>eo({tag:a.tag===e?null:e}),className:"w-full flex items-center gap-2 px-2 py-1 text-left transition-colors hover:bg-[var(--color-background-alt,#f4f4f5)]",style:{borderLeft:a.tag===e?"2px solid var(--color-accent, #ccff00)":"2px solid transparent"},children:[(0,r.jsx)(z.A,{size:9,className:a.tag===e?"text-[var(--color-text,#0a0a0a)]":"text-[var(--color-text-faint,#9ca3af)]"}),(0,r.jsx)("span",{className:"text-[9px] tracking-widest uppercase truncate ".concat(a.tag===e?"text-[var(--color-text,#0a0a0a)] font-bold":"text-[var(--color-text-muted,#6b7280)]"),children:e})]},e))})]}),!S&&(0,r.jsxs)("div",{className:"border-b border-[var(--color-border,#d4d4d8)]",children:[ex("lifecycle","Lifecycle"),!G.lifecycle&&(0,r.jsx)("div",{id:"agent-sidebar-section-lifecycle",className:"px-2 pb-2",children:_.map(e=>{let{key:t,label:l,icon:s}=e;return(0,r.jsxs)("button",{onClick:()=>eo({lifecycle:t,tag:null}),className:"w-full flex items-center gap-2 px-2 py-1 text-left transition-colors hover:bg-[var(--color-background-alt,#f4f4f5)]",style:{borderLeft:a.lifecycle===t?"2px solid var(--color-accent, #ccff00)":"2px solid transparent"},children:[(0,r.jsx)(s,{size:9,className:a.lifecycle===t?"text-[var(--color-text,#0a0a0a)]":"text-[var(--color-text-faint,#9ca3af)]"}),(0,r.jsx)("span",{className:"text-[9px] tracking-widest uppercase truncate ".concat(a.lifecycle===t?"text-[var(--color-text,#0a0a0a)] font-bold":"text-[var(--color-text-muted,#6b7280)]"),children:l})]},t)})})]})]}),(0,r.jsxs)("div",{className:"border-t border-[var(--color-border,#d4d4d8)] ".concat(S?"px-1 py-2":"px-3 py-3"),children:[g>0&&(0,r.jsxs)("div",{className:"flex items-center gap-1.5 mb-2 ".concat(S?"justify-center":"px-1"),children:[(0,r.jsx)("span",{className:"min-w-[16px] h-[16px] flex items-center justify-center px-1 font-mono text-[8px] font-bold",style:{background:"var(--color-danger, #ef4444)",color:"var(--color-danger-foreground, #ffffff)",borderRadius:"var(--radius-sm)"},children:g>9?"9+":g}),!S&&(0,r.jsx)("span",{className:"font-mono text-[8px] font-bold tracking-widest uppercase text-[var(--color-danger,#ef4444)]",children:"PENDING"})]}),S&&(0,r.jsxs)("div",{className:"mb-2 flex items-center gap-1",children:[(0,r.jsx)(b.$n,{variant:"ghost",size:"sm",onClick:ed,icon:(0,r.jsx)(j.A,{size:10}),className:"flex-1 !px-0",title:"API Keys"}),(0,r.jsx)(b.$n,{variant:"ghost",size:"sm",onClick:ec,icon:(0,r.jsx)(R.A,{size:10}),className:"flex-1 !px-0",title:"Lock"})]}),!S&&(0,r.jsxs)("div",{className:"flex items-center gap-2 mt-2 justify-center",children:[(0,r.jsx)("button",{type:"button",onClick:()=>{null==N||N("audit"),null==m||m()},className:"text-[8px] tracking-widest uppercase transition-colors ".concat("audit"===w?"text-[var(--color-text,#0a0a0a)] font-bold":"text-[var(--color-text-muted,#6b7280)] hover:text-[var(--color-text,#0a0a0a)]"),"aria-current":"audit"===w?"page":void 0,children:"AUDIT"}),(0,r.jsx)("button",{type:"button",onClick:ed,className:"text-[8px] tracking-widest uppercase transition-colors ".concat("apiKeys"===w?"text-[var(--color-text,#0a0a0a)] font-bold":"text-[var(--color-text-muted,#6b7280)] hover:text-[var(--color-text,#0a0a0a)]"),"aria-current":"apiKeys"===w?"page":void 0,children:"API KEYS"}),(0,r.jsx)("button",{type:"button",onClick:ec,className:"text-[8px] tracking-widest uppercase transition-colors text-[var(--color-text-muted,#6b7280)] hover:text-[var(--color-text,#0a0a0a)]",children:"LOCK"})]}),(0,r.jsxs)("div",{className:"flex items-center gap-2 ".concat(S?"mt-2":"mt-3"),"data-testid":"agent-sidebar-footer-barcode",children:[(0,r.jsx)("div",{className:"h-4 flex-1 bg-[repeating-linear-gradient(90deg,var(--color-text,#000),var(--color-text,#000)_1px,transparent_1px,transparent_3px)] opacity-30"}),!S&&(0,r.jsxs)("div",{className:"relative",ref:er,children:[(0,r.jsx)("button",{type:"button","data-testid":"shortcut-hint-trigger",onClick:()=>ea(e=>!e),className:"font-mono text-[8px] text-[var(--color-text-faint,#9ca3af)] tracking-widest hover:text-[var(--color-text-muted,#6b7280)] transition-colors","aria-expanded":et?"true":"false","aria-label":"Keyboard shortcuts",children:"Cmd/Ctrl+K"}),et&&(0,r.jsxs)("div",{"data-testid":"shortcut-hint-popover",className:"absolute bottom-full right-0 mb-1 border border-[var(--color-border-focus,#0a0a0a)] bg-[var(--color-surface,#ffffff)] shadow-mech z-30 p-2 w-[170px]",children:[(0,r.jsx)("div",{className:"text-[8px] tracking-widest uppercase text-[var(--color-text-muted,#6b7280)] mb-1",children:"Keyboard Shortcuts"}),(0,r.jsx)("div",{className:"space-y-1",children:M.map(e=>(0,r.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,r.jsx)("span",{className:"text-[8px] tracking-widest uppercase text-[var(--color-text,#0a0a0a)]",children:e.combo}),(0,r.jsx)("span",{className:"text-[8px] text-[var(--color-text-muted,#6b7280)]",children:e.action})]},e.combo))})]})]})]})]})]})};var B=a(5867),V=a(1786);let G=/^([a-z0-9]+(?:_[a-z0-9]+)*)_(\d{4})$/,Y=/^[a-z0-9]+(?:_[a-z0-9]+)*$/,q={visa:"Visa",mastercard:"Mastercard",amex:"Amex",discover:"Discover",card:"Card"},X=e=>{let t=e.trim().toLowerCase();return t?q[t]?q[t]:t.split("_").filter(Boolean).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(" "):"Card"},J=e=>{if("card"!==e.type)return e.name;let t=(e.name||"").trim();if(!t)return"Card";let a=t.match(G);if(a){let[,e,t]=a;return"".concat(X(e)," ••••").concat(t)}return Y.test(t)&&t===t.toLowerCase()?X(t):t},Q={login:j.A,card:w.A,note:N.A,hot_wallet:k.A,plain_note:N.A,apikey:j.A,oauth2:C.A,ssh:S.A,gpg:A.A},Z=e=>{let{credential:t,selected:a,onClick:l}=e,s=Q[t.type]||N.A,o=function(e){switch(e.type){case"login":return e.meta.username||e.meta.url||"";case"card":return e.meta.last4?"•••• ".concat(e.meta.last4):"";case"note":return"Secure Note";case"hot_wallet":return e.meta.address||e.meta.chain||"Hot Wallet";case"plain_note":return e.meta.content||e.meta.value||"Plain Note";case"apikey":return e.meta.key||"API Key";case"oauth2":return e.meta.scopes||"OAuth2";case"ssh":return e.meta.fingerprint||e.meta.key_type||"SSH Key";case"gpg":return e.meta.key_id||e.meta.uid_email||"GPG Key";default:return""}}(t),n=J(t),i=t.meta.favorite;return(0,r.jsxs)("div",{onClick:l,className:"flex items-center cursor-pointer border-b border-[var(--color-credential-array-border,#8d8d95)] transition-all hover:bg-[var(--color-background-alt,#f4f4f5)] hover:shadow-mech-hover ".concat(a?"corner-marks":""),style:{gap:"var(--space-sm)",padding:"var(--space-sm) var(--space-md)",borderLeft:a?"2px solid var(--color-accent, #ccff00)":"2px solid transparent",background:a?"var(--color-background-alt, #f4f4f5)":void 0},children:[(0,r.jsx)(s,{size:14,className:"text-[var(--color-text-muted,#6b7280)] flex-shrink-0"}),(0,r.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,r.jsx)("div",{className:"font-mono text-[11px] font-semibold text-[var(--color-text,#0a0a0a)] truncate",children:n}),o&&(0,r.jsx)("div",{className:"font-mono text-[9px] text-[var(--color-text-muted,#6b7280)] truncate",children:o})]}),(()=>{let e=function(e){if("oauth2"!==e.type)return null;let t=e.meta.expires_at;if(!t)return{label:"No token",color:"var(--color-text-muted,#6b7280)",background:"var(--color-background-alt,#f4f4f5)"};let a=Math.floor(Date.now()/1e3);if(a>=t)return{label:"Expired",color:"var(--color-danger,#ef4444)",background:"color-mix(in srgb, var(--color-danger,#ef4444) 12%, transparent)"};let r=t-a;return r<300?{label:"<5m",color:"var(--color-warning,#ff4d00)",background:"color-mix(in srgb, var(--color-warning,#ff4d00) 12%, transparent)"}:{label:r<3600?"".concat(Math.floor(r/60),"m"):"".concat(Math.floor(r/3600),"h"),color:"var(--color-success,#00c853)",background:"color-mix(in srgb, var(--color-success,#00c853) 12%, transparent)"}}(t);return e?(0,r.jsx)("span",{className:"flex-shrink-0 font-mono text-[8px] font-semibold px-1.5 py-0.5 rounded-sm",style:{color:e.color,background:e.background,borderRadius:"var(--radius-sm)"},children:e.label}):null})(),i&&(0,r.jsx)(D.A,{size:10,className:"flex-shrink-0 text-[var(--color-favorite,#ff4d00)] fill-[var(--color-favorite,#ff4d00)]"})]})},ee=e=>e.trim().toLowerCase(),et=(e,t)=>{let a=null==t?void 0:t[e.id];return"number"==typeof a&&Number.isFinite(a)&&a>0?a:(e=>{let t=Date.parse(e.createdAt);return Number.isFinite(t)?t:0})(e)},ea=(e,t)=>{let a=ee(t);if(!a)return 0;let r=ee(e.name),l=ee(String(e.meta.username||"")),s=ee(String(e.meta.url||""));return r===a?3:r.startsWith(a)||l.startsWith(a)||s.startsWith(a)?2:r.includes(a)||l.includes(a)||s.includes(a)?1:0};function er(e,t){let a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"";return[...e].sort((e,r)=>{let l=et(e,t),s=et(r,t);if(s!==l)return s-l;let o=ea(e,a),n=ea(r,a);if(n!==o)return n-o;let i=+!!e.meta.favorite,c=+!!r.meta.favorite;if(c!==i)return c-i;let d=ee(e.name),x=ee(r.name),u=d.localeCompare(x);return 0!==u?u:e.id.localeCompare(r.id)})}let el=e=>{let{credentials:t,latestAccessById:a,selectedId:s,searchQuery:o,onSearchChange:n,onSelect:i,onAdd:c,canAdd:d=!0,onImport:x,canImport:u=!0,onOpenGenerator:p,canGenerate:f=!0,onClearFilters:m,onCreateWithFilter:h,hasActiveFilters:g=!1,showSearch:y=!0,fieldSearchSuggestions:j=[],onApplySearchSuggestion:w,searchInputRef:N,className:k="w-[300px] h-full flex flex-col border-r border-[var(--color-credential-array-border,#8d8d95)]",leadingAction:C}=e,S=(0,l.useMemo)(()=>er(t,a,o),[t,a,o]);return(0,r.jsxs)("div",{className:k,style:{fontSize:"var(--font-size-sm)"},children:[(0,r.jsx)("div",{className:"border-b border-[var(--color-credential-array-border,#8d8d95)] ".concat(y?"flex items-center":""),style:{gap:"var(--space-sm)",padding:"var(--space-md)"},children:y?(0,r.jsxs)(r.Fragment,{children:[C,(0,r.jsx)("div",{className:"flex-1",children:(0,r.jsx)(b.ks,{compact:!0,leftElement:(0,r.jsx)(v.A,{size:12}),placeholder:"Search...",value:o,onChange:e=>n(e.target.value),inputRef:N})}),p&&(0,r.jsx)(b.$n,{variant:"secondary",size:"sm",onClick:p,icon:(0,r.jsx)(B.A,{size:10}),disabled:!f,title:"Generate password","aria-label":"Generate password",children:"GEN"}),x&&(0,r.jsx)(b.$n,{variant:"secondary",size:"sm",onClick:x,icon:(0,r.jsx)(V.A,{size:10}),disabled:!u,title:u?"Import credentials":"Switch to Active to import credentials","aria-label":"Import credentials",children:"IMPORT"}),(0,r.jsx)(b.$n,{size:"sm",onClick:c,icon:(0,r.jsx)(O.A,{size:10}),disabled:!d,title:d?"Create credential":"Switch to Active to create credentials",children:"ADD"})]}):(0,r.jsxs)("div",{className:"w-full space-y-2",children:[C&&(0,r.jsx)("div",{className:"flex",children:C}),(0,r.jsxs)("div",{className:"flex w-full items-center gap-2 overflow-hidden",children:[p&&(0,r.jsx)(b.$n,{variant:"secondary",size:"sm",onClick:p,icon:(0,r.jsx)(B.A,{size:10}),disabled:!f,title:"Generate password","aria-label":"Generate password",className:"flex-1 min-w-0",children:"GEN"}),x&&(0,r.jsx)(b.$n,{variant:"secondary",size:"sm",onClick:x,icon:(0,r.jsx)(V.A,{size:10}),disabled:!u,title:u?"Import credentials":"Switch to Active to import credentials","aria-label":"Import credentials",className:"flex-1 min-w-0",children:"IMPORT"}),(0,r.jsx)(b.$n,{size:"sm",onClick:c,icon:(0,r.jsx)(O.A,{size:10}),disabled:!d,title:d?"Create credential":"Switch to Active to create credentials",className:"flex-1 min-w-0",children:"ADD"})]})]})}),(0,r.jsx)("div",{className:"flex-1 overflow-y-auto overflow-x-hidden",children:0===S.length?(0,r.jsx)("div",{className:"flex items-center justify-center h-full px-4",children:(0,r.jsxs)("div",{className:"text-center tyvek-label corner-marks p-6",children:[(0,r.jsx)("span",{className:"label-specimen text-[var(--color-text-muted,#6b7280)] block",children:g?"NO SPECIMENS MATCH":"NO SPECIMENS FOUND"}),j.length>0&&w&&(0,r.jsx)("div",{className:"mt-3 flex flex-wrap items-center justify-center gap-2",children:j.map(e=>(0,r.jsx)("button",{type:"button",className:"font-mono text-[9px] px-2 py-1 border border-[var(--color-border,#d4d4d8)] bg-[var(--color-surface,#ffffff)] text-[var(--color-text-muted,#6b7280)] hover:text-[var(--color-text,#0a0a0a)] hover:border-[var(--color-border-focus,#0a0a0a)]",onClick:()=>w(e),title:"Search by ".concat(e),children:e},e))}),g&&m&&(0,r.jsxs)("div",{className:"mt-3 flex flex-col items-center gap-2",children:[(0,r.jsx)(b.$n,{variant:"secondary",size:"sm",onClick:m,children:"CLEAR FILTERS"}),h&&(0,r.jsx)(b.$n,{variant:"secondary",size:"sm",onClick:h,children:"CREATE WITH FILTER"})]})]})}):S.map(e=>(0,r.jsx)(Z,{credential:e,selected:e.id===s,onClick:()=>i(e.id)},e.id))})]})};var es=a(5426),eo=a(4033),en=a(7354),ei=a(7828),ec=a(532),ed=a(5299),ex=a(7369);let eu=e=>e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">"),ep=e=>{let{label:t,value:a,copyValue:s,trailingValue:o,credentialId:n,fieldKey:i,isSensitive:c,onShowLargeType:d,sensitiveInteractionMode:x="default",actionsPosition:f="left",showActionsInHoverCopyMode:m=!1,sensitiveClickBehavior:v="reveal",disableLargeType:h=!1,renderMarkdown:y=!1}=e,[j,w]=(0,l.useState)(!1),[N,k]=(0,l.useState)(!1),[C,S]=(0,l.useState)(null),[A,E]=(0,l.useState)(!1),[I,T]=(0,l.useState)(null),[R,O]=(0,l.useState)(!1),L=(0,l.useRef)(null),D=(0,l.useRef)(null),z=(0,l.useRef)(null),P="hover-copy"===x||"markdown-hover-copy"===x,F="markdown-hover-copy"===x,_="hover-copy"===x,M=!P&&"copy"===v,K=!P||m,U=(0,l.useMemo)(()=>F&&null!=C?(0,ex.Q)(eu(C)):"",[F,C]),H=(0,l.useMemo)(()=>y&&a?(0,ex.Q)(eu(a)):"",[y,a]);(0,l.useEffect)(()=>()=>{D.current&&clearTimeout(D.current),z.current&&clearTimeout(z.current)},[]),(0,l.useEffect)(()=>{w(!1),k(!1),S(null),T(null),O(!1),D.current&&clearTimeout(D.current)},[n,i]);let W=(0,l.useCallback)(()=>{w(!0),z.current&&clearTimeout(z.current),z.current=setTimeout(()=>w(!1),2e3)},[]),$=(0,l.useCallback)(e=>{S(e),k(!0),D.current&&clearTimeout(D.current),D.current=setTimeout(()=>{k(!1),S(null)},3e4)},[]),B=(0,l.useCallback)(async()=>{if(null!=C)return C;try{var e;let t=await u.FH.post(u.jI.Wallet,"/credentials/".concat(n,"/read")),a=await (0,p.DC)(t.encrypted),r=JSON.parse(a),l="string"==typeof r.type?r.type:"",s=(0,g.Dw)(l,i),o=null==(e=r.fields)?void 0:e.find(e=>(0,g.Dw)(l,e.key)===s||i===g.l3&&"value"===e.key);if(!o)return null;return o.value}catch(e){return null}},[n,i,C]),V=(0,l.useCallback)(async()=>{if(null!=C)return C;E(!0),T(null);try{let e=await B();return null==e&&T("Field not found"),e}catch(e){return T("Decryption failed -- try re-unlocking"),null}finally{E(!1)}},[B,C]),G=(0,l.useCallback)(async()=>{if(A)return;O(!1);let e=await B();null!=e&&(navigator.clipboard.writeText(e),W())},[B,A,W]),Y=(0,l.useCallback)(async()=>{if(A||N&&null!=C)return;O(!1);let e=await V();null!=e&&$(e)},[V,A,$,N,C]),q=(0,l.useCallback)(()=>{k(!1),S(null),D.current&&clearTimeout(D.current)},[]),X=(0,l.useCallback)(async()=>{O(!1);let e=await B();null!=e&&d(e)},[B,d]),J=(0,l.useCallback)(()=>{let e=null!=s?s:a;e&&(navigator.clipboard.writeText(e),W())},[s,a,W]),Q=(0,l.useCallback)(()=>{a&&(O(!1),d(a))},[d,a]),Z=(0,l.useCallback)(async()=>{if(!P||A)return;let e=C;null==e&&null!=(e=await V())&&S(e),null!=e&&(_&&$(e),navigator.clipboard.writeText(e),W())},[V,A,P,_,W,$,C]),ee=(0,l.useCallback)(e=>{if(!_&&!M){if(e.stopPropagation(),P)return void Z();Y()}},[Z,Y,P,_,M]);if(!c){let e=(0,r.jsxs)("div",{className:"shrink-0 relative flex items-center gap-1",children:[(0,r.jsxs)("button",{type:"button",onClick:e=>{e.stopPropagation(),J()},className:"inline-flex w-[56px] justify-start items-center gap-1 px-2 py-1 opacity-0 group-hover:opacity-100 transition-opacity font-mono text-[8px] uppercase tracking-widest text-[var(--color-text-faint,#9ca3af)] hover:text-[var(--color-text,#0a0a0a)]",children:[(0,r.jsx)(es.A,{size:10}),j?"Copied":"Copy"]}),(0,r.jsx)("button",{ref:L,onClick:e=>{e.stopPropagation(),O(!R)},className:"p-1 opacity-0 group-hover:opacity-100 transition-opacity text-[var(--color-text-faint,#9ca3af)] hover:text-[var(--color-text,#0a0a0a)]","aria-label":"Field actions for ".concat(t),children:(0,r.jsx)(eo.A,{size:12})}),(0,r.jsx)(b.AM,{isOpen:R,onClose:()=>O(!1),anchorEl:L.current,anchor:"right",children:(0,r.jsxs)("div",{className:"flex flex-col gap-1 min-w-[160px]",children:[(0,r.jsxs)("button",{onClick:J,className:"flex items-center gap-2 px-2 py-1.5 text-left font-mono text-[9px] tracking-widest uppercase text-[var(--color-text-muted,#6b7280)] hover:text-[var(--color-text,#0a0a0a)] hover:bg-[var(--color-background-alt,#f4f4f5)] transition-colors",children:[(0,r.jsx)(es.A,{size:10}),"Copy"]}),(0,r.jsxs)("button",{onClick:Q,disabled:!a||h,className:"flex items-center gap-2 px-2 py-1.5 text-left font-mono text-[9px] tracking-widest uppercase text-[var(--color-text-muted,#6b7280)] hover:text-[var(--color-text,#0a0a0a)] hover:bg-[var(--color-background-alt,#f4f4f5)] transition-colors disabled:opacity-40",children:[(0,r.jsx)(en.A,{size:10}),"Show in large type"]})]})})]});return y&&a?(0,r.jsxs)("div",{className:"flex flex-wrap lg:flex-nowrap gap-x-3 gap-y-1 py-2 px-2 cursor-pointer hover:bg-[var(--color-background-alt,#f4f4f5)] transition-colors group items-start",onClick:J,children:["left"===f&&e,(0,r.jsx)("div",{className:"w-24 shrink-0",children:(0,r.jsx)("span",{className:"font-mono text-[9px] uppercase tracking-widest text-[var(--color-text-muted,#6b7280)]",children:j?"Copied":t})}),(0,r.jsx)("div",{className:"basis-full lg:basis-auto lg:flex-1 min-w-0 prose-mono max-w-none [&>*:first-child]:mt-0 [&>*:last-child]:mb-0",dangerouslySetInnerHTML:{__html:H}}),"right"===f&&e]}):(0,r.jsxs)("div",{className:"flex flex-wrap lg:flex-nowrap items-center gap-x-3 gap-y-1 py-2 px-2 cursor-pointer hover:bg-[var(--color-background-alt,#f4f4f5)] transition-colors group",onClick:J,children:["left"===f&&e,(0,r.jsx)("div",{className:"w-24 shrink-0",children:(0,r.jsx)("span",{className:"font-mono text-[9px] uppercase tracking-widest text-[var(--color-text-muted,#6b7280)]",children:t})}),(0,r.jsxs)("div",{className:"basis-full lg:basis-auto lg:flex-1 min-w-0 min-h-[24px] flex items-center",children:[(0,r.jsx)("span",{className:"block min-w-0 font-mono text-[11px] text-[var(--color-text,#0a0a0a)] truncate whitespace-nowrap",children:j?"Copied":a||"--"}),o]}),"right"===f&&e]})}let et=K?(0,r.jsxs)("div",{className:"shrink-0 relative flex items-center gap-1",children:[(0,r.jsxs)("button",{type:"button",onClick:e=>{e.stopPropagation(),G()},className:"inline-flex w-[56px] justify-start items-center gap-1 px-2 py-1 opacity-0 group-hover:opacity-100 transition-opacity font-mono text-[8px] uppercase tracking-widest text-[var(--color-text-faint,#9ca3af)] hover:text-[var(--color-text,#0a0a0a)]",children:[(0,r.jsx)(es.A,{size:10}),j?"Copied":"Copy"]}),(0,r.jsx)("button",{ref:L,onClick:e=>{e.stopPropagation(),O(!R)},className:"p-1 opacity-0 group-hover:opacity-100 transition-opacity text-[var(--color-text-faint,#9ca3af)] hover:text-[var(--color-text,#0a0a0a)]","aria-label":"Field actions for ".concat(t),children:(0,r.jsx)(eo.A,{size:12})}),(0,r.jsx)(b.AM,{isOpen:R,onClose:()=>O(!1),anchorEl:L.current,anchor:"right",children:(0,r.jsxs)("div",{className:"flex flex-col gap-1 min-w-[170px]",children:[(0,r.jsxs)("button",{onClick:G,className:"flex items-center gap-2 px-2 py-1.5 text-left font-mono text-[9px] tracking-widest uppercase text-[var(--color-text-muted,#6b7280)] hover:text-[var(--color-text,#0a0a0a)] hover:bg-[var(--color-background-alt,#f4f4f5)] transition-colors",children:[(0,r.jsx)(es.A,{size:10}),"Copy"]}),!P&&!N&&(0,r.jsxs)("button",{onClick:Y,className:"flex items-center gap-2 px-2 py-1.5 text-left font-mono text-[9px] tracking-widest uppercase text-[var(--color-text-muted,#6b7280)] hover:text-[var(--color-text,#0a0a0a)] hover:bg-[var(--color-background-alt,#f4f4f5)] transition-colors",children:[(0,r.jsx)(ei.A,{size:10}),"Reveal"]}),!P&&N&&(0,r.jsxs)("button",{onClick:q,className:"flex items-center gap-2 px-2 py-1.5 text-left font-mono text-[9px] tracking-widest uppercase text-[var(--color-text-muted,#6b7280)] hover:text-[var(--color-text,#0a0a0a)] hover:bg-[var(--color-background-alt,#f4f4f5)] transition-colors",children:[(0,r.jsx)(ec.A,{size:10}),"Hide"]}),!h&&(0,r.jsxs)("button",{onClick:X,className:"flex items-center gap-2 px-2 py-1.5 text-left font-mono text-[9px] tracking-widest uppercase text-[var(--color-text-muted,#6b7280)] hover:text-[var(--color-text,#0a0a0a)] hover:bg-[var(--color-background-alt,#f4f4f5)] transition-colors",children:[(0,r.jsx)(en.A,{size:10}),"Show in large type"]})]})})]}):null;if(F){let e=(0,r.jsxs)("div",{className:"shrink-0 relative flex items-center gap-1",children:[(0,r.jsxs)("button",{type:"button",onClick:e=>{e.stopPropagation(),G()},className:"inline-flex w-[56px] justify-start items-center gap-1 px-2 py-1 opacity-0 group-hover:opacity-100 transition-opacity font-mono text-[8px] uppercase tracking-widest text-[var(--color-text-faint,#9ca3af)] hover:text-[var(--color-text,#0a0a0a)]",children:[(0,r.jsx)(es.A,{size:10}),j?"Copied":"Copy"]}),(0,r.jsx)("button",{ref:L,onClick:e=>{e.stopPropagation(),O(!R)},className:"p-1 opacity-0 group-hover:opacity-100 transition-opacity text-[var(--color-text-faint,#9ca3af)] hover:text-[var(--color-text,#0a0a0a)]","aria-label":"Field actions for ".concat(t),children:(0,r.jsx)(eo.A,{size:12})}),(0,r.jsx)(b.AM,{isOpen:R,onClose:()=>O(!1),anchorEl:L.current,anchor:"right",children:(0,r.jsxs)("div",{className:"flex flex-col gap-1 min-w-[170px]",children:[(0,r.jsxs)("button",{onClick:G,className:"flex items-center gap-2 px-2 py-1.5 text-left font-mono text-[9px] tracking-widest uppercase text-[var(--color-text-muted,#6b7280)] hover:text-[var(--color-text,#0a0a0a)] hover:bg-[var(--color-background-alt,#f4f4f5)] transition-colors",children:[(0,r.jsx)(es.A,{size:10}),"Copy"]}),N?(0,r.jsxs)("button",{onClick:q,className:"flex items-center gap-2 px-2 py-1.5 text-left font-mono text-[9px] tracking-widest uppercase text-[var(--color-text-muted,#6b7280)] hover:text-[var(--color-text,#0a0a0a)] hover:bg-[var(--color-background-alt,#f4f4f5)] transition-colors",children:[(0,r.jsx)(ec.A,{size:10}),"Hide"]}):(0,r.jsxs)("button",{onClick:Y,className:"flex items-center gap-2 px-2 py-1.5 text-left font-mono text-[9px] tracking-widest uppercase text-[var(--color-text-muted,#6b7280)] hover:text-[var(--color-text,#0a0a0a)] hover:bg-[var(--color-background-alt,#f4f4f5)] transition-colors",children:[(0,r.jsx)(ei.A,{size:10}),"Reveal"]})]})})]});return(0,r.jsxs)("div",{"data-testid":"credential-field-row-".concat(i),className:"flex flex-wrap lg:flex-nowrap gap-x-3 gap-y-1 py-2 px-2 group transition-colors cursor-pointer hover:bg-[var(--color-background-alt,#f4f4f5)] items-start",onClick:()=>{N&&null!=C?G():Y()},children:["left"===f&&e,(0,r.jsx)("div",{className:"w-24 shrink-0",children:(0,r.jsx)("span",{className:"font-mono text-[9px] uppercase tracking-widest text-[var(--color-text-muted,#6b7280)]",children:j?"Copied":t})}),(0,r.jsx)("div",{"data-testid":"credential-field-value-".concat(i),className:"basis-full lg:basis-auto lg:flex-1 min-w-0",children:I?(0,r.jsx)("span",{className:"font-mono text-[10px] text-[var(--color-danger,#ef4444)]",children:I}):A?(0,r.jsx)(ed.A,{size:12,className:"animate-spin text-[var(--color-text-muted,#6b7280)]"}):N&&null!=C?(0,r.jsx)("div",{className:"prose-mono max-w-none [&>*:first-child]:mt-0 [&>*:last-child]:mb-0",dangerouslySetInnerHTML:{__html:U}}):(0,r.jsx)("span",{className:"font-mono text-[11px] text-[var(--color-text-muted,#6b7280)] tracking-wider",children:"••••••••"})}),"right"===f&&e]})}return(0,r.jsxs)("div",{"data-testid":"credential-field-row-".concat(i),className:"flex flex-wrap lg:flex-nowrap gap-x-3 gap-y-1 py-2 px-2 group transition-colors rounded-sm items-center ".concat(_||M?"cursor-pointer hover:bg-[var(--color-background-alt,#f4f4f5)]":""),onClick:()=>{if(_)return void Z();M&&G()},children:["left"===f&&et,(0,r.jsx)("div",{className:"w-24 shrink-0",children:(0,r.jsx)("span",{className:"font-mono text-[9px] uppercase tracking-widest text-[var(--color-text-muted,#6b7280)]",children:t})}),(0,r.jsx)("div",{"data-testid":"credential-field-value-".concat(i),className:"basis-full lg:basis-auto lg:flex-1 min-w-0 transition-colors rounded-sm ".concat(P?"":"cursor-pointer"," ").concat("".concat(_||M?"min-h-[24px] flex items-center":"hover:bg-[var(--color-background-alt,#f4f4f5)] min-h-[24px] flex items-center"," px-1 py-0.5")),onClick:ee,children:I?(0,r.jsx)("span",{className:"font-mono text-[10px] text-[var(--color-danger,#ef4444)]",children:I}):A?(0,r.jsx)(ed.A,{size:12,className:"animate-spin text-[var(--color-text-muted,#6b7280)]"}):_?N&&null!=C?(0,r.jsxs)("div",{className:"flex items-center gap-2 min-w-0",children:[(0,r.jsx)("span",{className:"block min-w-0 font-mono text-[11px] text-[var(--color-text,#0a0a0a)] truncate whitespace-nowrap",children:C}),(0,r.jsx)("button",{onClick:e=>{e.stopPropagation(),q()},className:"shrink-0 text-[var(--color-text-faint,#9ca3af)] hover:text-[var(--color-text,#0a0a0a)] transition-colors",children:(0,r.jsx)(ec.A,{size:12})})]}):(0,r.jsxs)("div",{className:"w-full",children:[(0,r.jsx)("div",{"data-testid":"credential-field-barcode-".concat(i),className:"h-4 w-full bg-[repeating-linear-gradient(90deg,var(--color-text,#000),var(--color-text,#000)_1px,transparent_1px,transparent_3px)] opacity-30"}),(0,r.jsx)("div",{className:"mt-1 h-1.5 w-full",style:{backgroundImage:"repeating-linear-gradient(45deg, var(--color-text, #000), var(--color-text, #000) 5px, transparent 5px, transparent 10px)",opacity:.1}}),(0,r.jsx)("div",{className:"mt-1 font-mono text-[9px] text-[var(--color-text-muted,#6b7280)] tracking-wider uppercase",children:j?"Copied":"Click to reveal and copy"})]}):P?(0,r.jsx)("span",{className:"font-mono text-[10px] text-[var(--color-text-muted,#6b7280)] tracking-wider uppercase",children:j?"Copied":null!=C?"Hover then click to copy":"Decrypting"}):N&&null!=C?(0,r.jsxs)("div",{className:"flex items-center gap-2 min-w-0",children:[(0,r.jsx)("span",{className:"block min-w-0 font-mono text-[11px] text-[var(--color-text,#0a0a0a)] truncate whitespace-nowrap",children:C}),(0,r.jsx)("button",{onClick:e=>{e.stopPropagation(),q()},className:"shrink-0 text-[var(--color-text-faint,#9ca3af)] hover:text-[var(--color-text,#0a0a0a)] transition-colors",children:(0,r.jsx)(ec.A,{size:12})})]}):(0,r.jsx)("span",{className:"font-mono text-[11px] text-[var(--color-text-muted,#6b7280)] tracking-wider",children:j?"Copied":"••••••••"})}),"right"===f&&et]})},ef=e=>{let{credentialId:t}=e,[a,s]=(0,l.useState)(null),[o,n]=(0,l.useState)(30),[i,c]=(0,l.useState)(null),d=(0,l.useCallback)(async()=>{try{let e=await u.FH.post(u.jI.Wallet,"/credentials/".concat(t,"/totp"));e.success&&e.code?(s(e.code),n(e.remaining),c(!0)):c(!1)}catch(e){c(!1)}},[t]);if((0,l.useEffect)(()=>{d()},[d]),(0,l.useEffect)(()=>{if(!0!==i)return;let e=setInterval(()=>{n(e=>e<=1?(d(),30):e-1)},1e3);return()=>clearInterval(e)},[i,d]),null===i||!1===i)return null;let x=o<=5,p=a?"".concat(a.slice(0,3)," ").concat(a.slice(3)):"--- ---",f=o/30;return(0,r.jsx)("div",{className:"space-y-0.5","data-testid":"totp-display",children:(0,r.jsx)(ep,{label:"2FA Code",value:p,copyValue:null!=a?a:void 0,credentialId:t,fieldKey:"totp_code",isSensitive:!1,trailingValue:(0,r.jsxs)("div",{className:"ml-2 flex items-center gap-1.5",children:[(0,r.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 18 18",className:"shrink-0",style:{transform:"rotate(-90deg)"},children:[(0,r.jsx)("circle",{cx:"9",cy:"9",r:"7",fill:"none",stroke:"currentColor",strokeWidth:"2",className:"text-[var(--color-border,#d4d4d8)]",opacity:"0.3"}),(0,r.jsx)("circle",{cx:"9",cy:"9",r:"7",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeDasharray:"".concat(43.98*f," 43.98"),strokeLinecap:"round",className:x?"text-[var(--color-danger,#ef4444)]":"text-[var(--color-accent,#ccff00)]"})]}),(0,r.jsxs)("span",{className:"font-mono text-[9px] ".concat(x?"text-[var(--color-danger,#ef4444)]":"text-[var(--color-text-faint,#9ca3af)]"),children:[o,"s"]})]}),disableLargeType:!0,onShowLargeType:()=>{}})})},em=e=>{let{isOpen:t,onClose:a,value:s}=e,[o,n]=(0,l.useState)(!1),i=(0,l.useRef)(null),c=Array.from(null!=s?s:""),d=(0,l.useCallback)(async()=>{try{await navigator.clipboard.writeText(s),n(!0),i.current&&clearTimeout(i.current),i.current=setTimeout(()=>n(!1),2e3)}catch(e){}},[s]);return(0,l.useEffect)(()=>(t||n(!1),()=>{i.current&&clearTimeout(i.current)}),[t]),(0,r.jsx)(b.aF,{isOpen:t,onClose:a,title:"Expanded Value",size:"lg",contentClassName:"!p-0",footer:(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)(b.$n,{variant:"secondary",size:"sm",onClick:a,children:"Cancel"}),(0,r.jsx)(b.$n,{variant:"primary",size:"sm",onClick:()=>{d()},children:o?"COPIED":"COPY"})]}),children:(0,r.jsxs)("div",{className:"w-full min-h-[360px] px-6 py-8 flex flex-col items-center justify-center text-center",children:[(0,r.jsx)("div",{className:"w-full max-w-[900px] max-h-[70vh] overflow-auto px-1",children:(0,r.jsx)("div",{className:"grid gap-2 [grid-template-columns:repeat(auto-fit,minmax(56px,1fr))]",children:c.map((e,t)=>(0,r.jsxs)("div",{"data-testid":"large-type-char-".concat(t+1),className:"rounded-sm border border-[var(--color-border,#d4d4d8)] bg-[var(--color-surface,#ffffff)] px-1 py-2",children:[(0,r.jsx)("div",{className:"font-mono text-3xl font-bold leading-none text-[var(--color-text,#0a0a0a)] select-all",children:(e=>" "===e?"␠":"\n"===e?"↵":" "===e?"⇥":e)(e)}),(0,r.jsx)("div",{"data-testid":"large-type-index-".concat(t+1),className:"mt-2 font-mono text-[9px] uppercase tracking-widest text-[var(--color-text-faint,#9ca3af)]",children:t+1})]},"".concat(t,"-").concat(e)))})}),(0,r.jsx)("div",{className:"mt-8 font-mono text-[9px] tracking-widest uppercase text-[var(--color-text-faint,#9ca3af)]",children:"Use copy to move this value to clipboard"})]})})};var ev=a(4788),eh=a(5917);let eg=[{value:"15m",label:"15 Minutes"},{value:"1h",label:"1 Hour"},{value:"24h",label:"24 Hours"},{value:"7d",label:"7 Days"},{value:"30d",label:"30 Days"}],eb=[{value:"anyone",label:"Anyone with link"},{value:"password",label:"Set password"}],ey=e=>{let{isOpen:t,onClose:a,credentialId:s,credentialName:o}=e,[n,i]=(0,l.useState)("24h"),[c,d]=(0,l.useState)("anyone"),[x,p]=(0,l.useState)(""),[f,m]=(0,l.useState)(!1),[v,h]=(0,l.useState)(!1),[g,y]=(0,l.useState)(!1),[j,w]=(0,l.useState)(null),[N,k]=(0,l.useState)(""),[C,S]=(0,l.useState)(!1),[A,E]=(0,l.useState)(!1),[I,T]=(0,l.useState)(null);(0,l.useEffect)(()=>{t&&(w(null),h(!1),k(""),T(null),S(!1))},[t]);let R=()=>"password"!==c||x.trim()?null:"Password is required when access mode is Set password",O=async()=>{w(null);let e=R();if(e)return void w(e);try{y(!0),h(!1);let e=await u.FH.post(u.jI.Wallet,"/credential-shares/gist",{credentialId:s,expiresAfter:n,accessMode:c,oneTimeOnly:f,shareBaseUrl:window.location.origin,..."password"===c?{password:x}:{}});k(e.gist.url),await navigator.clipboard.writeText(e.gist.url),h(!0),setTimeout(()=>h(!1),2e3)}catch(e){w('Failed to create secret gist. Check "gh auth status" in terminal. If needed, run "gh auth login".')}finally{y(!1)}},L=async()=>{T(null);let e=R();if(e)return void T(e);try{let e;E(!0);let t=(e=(await u.FH.post(u.jI.Wallet,"/credential-shares",{credentialId:s,expiresAfter:n,accessMode:c,oneTimeOnly:f,..."password"===c?{password:x}:{}})).share.token,"".concat(window.location.origin,"/share/").concat(e));await navigator.clipboard.writeText(t),S(!0),setTimeout(()=>S(!1),2e3)}catch(e){T(e instanceof Error?e.message:"Failed to generate share link")}finally{E(!1)}},D=()=>{w(null),h(!1),y(!1),k(""),T(null),S(!1),E(!1),a()};return(0,r.jsx)(b.aF,{isOpen:t,onClose:D,title:"Sharing ".concat(o),icon:(0,r.jsx)(ev.A,{size:16,className:"text-[var(--color-text,#0a0a0a)]"}),size:"md",footer:(0,r.jsx)("div",{className:"flex items-center justify-end gap-2",children:(0,r.jsx)(b.$n,{variant:"secondary",size:"sm",onClick:D,children:"CLOSE"})}),children:(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsx)("div",{className:"font-mono text-[8px] uppercase tracking-widest text-[var(--color-text-faint,#9ca3af)]",children:"GitHub Gist (Recommended)"}),(0,r.jsxs)("div",{className:"font-mono text-[9px] text-[var(--color-text-muted,#6b7280)]",children:["Check ",(0,r.jsx)("span",{className:"text-[var(--color-text,#0a0a0a)]",children:"`gh auth status`"})," first; run ",(0,r.jsx)("span",{className:"text-[var(--color-text,#0a0a0a)]",children:"`gh auth login`"})," only if needed."]}),(0,r.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[N?(0,r.jsx)("a",{href:N,target:"_blank",rel:"noreferrer",className:"flex-1 min-w-0 font-mono text-[9px] text-[var(--color-text-muted,#6b7280)] truncate hover:underline",title:N,children:N}):(0,r.jsx)("div",{className:"flex-1 min-w-0 font-mono text-[9px] text-[var(--color-text-muted,#6b7280)] truncate",children:"Click SHARE GIST to generate a link."}),(0,r.jsxs)(b.$n,{variant:"primary",size:"sm",onClick:O,loading:g,className:"shrink-0 whitespace-nowrap",children:[v?(0,r.jsx)(eh.A,{size:10}):(0,r.jsx)(es.A,{size:10}),v?"COPIED":"SHARE GIST"]})]}),j&&(0,r.jsx)("div",{className:"font-mono text-[9px] text-[var(--color-danger,#ef4444)]",children:j})]}),(0,r.jsxs)("div",{className:"space-y-3",children:[(0,r.jsx)("div",{className:"font-mono text-[8px] uppercase tracking-widest text-[var(--color-text-faint,#9ca3af)]",children:"Share Link (Local)"}),(0,r.jsx)(b.UM,{label:"Link Expires After",options:eg,value:n,onChange:e=>i(e),compact:!0}),(0,r.jsx)(b.UM,{label:"Available To",options:eb,value:c,onChange:e=>d(e),compact:!0}),"password"===c&&(0,r.jsx)(b.ks,{label:"Share Password",type:"password",value:x,onChange:e=>p(e.target.value),placeholder:"Enter password",compact:!0}),(0,r.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,r.jsxs)("label",{className:"flex flex-1 min-w-0 items-center gap-2 cursor-pointer",children:[(0,r.jsx)("input",{type:"checkbox",checked:f,onChange:e=>m(e.target.checked),className:"accent-[var(--color-accent,#ccff00)]"}),(0,r.jsx)("span",{className:"font-mono text-[10px] text-[var(--color-text,#0a0a0a)] truncate",children:"Can only be viewed one time"})]}),(0,r.jsxs)(b.$n,{variant:"primary",size:"sm",onClick:L,loading:A,className:"shrink-0 whitespace-nowrap",children:[C?(0,r.jsx)(eh.A,{size:10}):(0,r.jsx)(es.A,{size:10}),C?"COPIED":"COPY LINK"]})]}),I&&(0,r.jsx)("div",{className:"font-mono text-[9px] text-[var(--color-danger,#ef4444)]",children:I})]})]})})};var ej=a(5880);let ew=e=>{let{walletLink:t}=e,[a,s]=(0,l.useState)(null),[o,n]=(0,l.useState)(!0),[i,c]=(0,l.useState)(!1),d=t.chain.toLowerCase();(0,l.useEffect)(()=>{let e=!0;return(async()=>{try{let a=((await u.FH.get(u.jI.Wallet,"/wallets")).wallets||[]).find(e=>e.address.toLowerCase()===t.walletAddress.toLowerCase()&&e.chain.toLowerCase()===d)||null;e&&s(a)}catch(t){e&&s(null)}finally{e&&n(!1)}})(),()=>{e=!1}},[t.walletAddress,d,t.chain]);let x=(0,l.useMemo)(()=>(null==a?void 0:a.name)||(null==a?void 0:a.label)||t.label||"Linked Wallet",[a,t.label]);return(0,r.jsxs)("div",{className:"mt-2 border border-[var(--color-border,#d4d4d8)] bg-[var(--color-background-alt,#f4f4f5)] p-3",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[(0,r.jsxs)("div",{className:"font-mono text-[9px] font-bold uppercase tracking-widest text-[var(--color-text-muted,#6b7280)] inline-flex items-center gap-1",children:[(0,r.jsx)(k.A,{size:11})," Linked Wallet"]}),(0,r.jsxs)("div",{className:"font-mono text-[8px] uppercase tracking-widest text-[var(--color-text-muted,#6b7280)]",children:[t.tier," \xb7 ",t.chain]})]}),(0,r.jsx)("div",{className:"font-mono text-[11px] text-[var(--color-text,#0a0a0a)] mb-1",children:x}),(0,r.jsx)("div",{className:"font-mono text-[10px] text-[var(--color-text-muted,#6b7280)] mb-2 break-all",children:t.walletAddress}),o?(0,r.jsx)("div",{className:"font-mono text-[9px] text-[var(--color-text-muted,#6b7280)]",children:"Loading wallet state…"}):a?(0,r.jsxs)("div",{className:"font-mono text-[9px] text-[var(--color-success,#22c55e)] mb-2",children:["Wallet resolved",a.balance?" \xb7 Balance: ".concat(a.balance):""]}):(0,r.jsx)("div",{className:"font-mono text-[9px] text-[var(--color-warning,#f59e0b)] mb-2",children:"Stale link: wallet not found in current wallet list"}),(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)("button",{type:"button",className:"px-2 py-1 border border-[var(--color-border,#d4d4d8)] font-mono text-[9px]",onClick:async()=>{await navigator.clipboard.writeText(t.walletAddress),c(!0),setTimeout(()=>c(!1),1200)},children:(0,r.jsxs)("span",{className:"inline-flex items-center gap-1",children:[(0,r.jsx)(es.A,{size:10})," ",i?"COPIED":(e=>"".concat(e.slice(0,6),"...").concat(e.slice(-4)))(t.walletAddress)]})}),(0,r.jsxs)("a",{href:function(e,t){return"solana"===e||"solana-devnet"===e?"https://solscan.io/account/".concat(t):"polygon"===e?"https://polygonscan.com/address/".concat(t):"ethereum"===e?"https://etherscan.io/address/".concat(t):"https://basescan.org/address/".concat(t)}(d,t.walletAddress),target:"_blank",rel:"noreferrer",className:"px-2 py-1 border border-[var(--color-border,#d4d4d8)] font-mono text-[9px] inline-flex items-center gap-1",children:[(0,r.jsx)(ej.A,{size:10})," Explorer"]})]})]})};function eN(e){return new Date(e).toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric"})}let ek=e=>{var t;let{credential:a,agentName:s,lifecycle:o,onEdit:n,onDelete:i,onRestore:c,onDuplicate:d,onFavoriteChange:x}=e,[p,f]=(0,l.useState)(null),[m,v]=(0,l.useState)(!1),[h,y]=(0,l.useState)(!1),[j,w]=(0,l.useState)(null),[N,k]=(0,l.useState)(!1),[C,S]=(0,l.useState)(null),[A,E]=(0,l.useState)(null),[I,T]=(0,l.useState)(""),[R,O]=(0,l.useState)(!!a.meta.favorite),[L,z]=(0,l.useState)(!1),P=e=>{f(e)};(0,l.useEffect)(()=>{w(null),k(!1),S(null),E(null),T(""),O(!!a.meta.favorite),z(!1)},[a.id,a.meta.favorite]);let F=(0,l.useCallback)(async()=>{k(!0),w(null);try{let e=await u.FH.post(u.jI.Wallet,"/credentials/".concat(a.id,"/reauth"));S(e.authorization_url||null),E(e.state||null),w(e.message||"Authorization URL generated. Complete provider consent, then paste code.")}catch(e){w(e instanceof Error?e.message:"Failed to start re-auth")}finally{k(!1)}},[a.id]),_=(0,l.useCallback)(async()=>{if(!I.trim()||!A)return void w("Enter authorization code after consent to complete re-auth.");k(!0);try{let e=await u.FH.post(u.jI.Wallet,"/credentials/".concat(a.id,"/reauth"),{code:I.trim(),state:A});w(e.message||"Re-auth complete. Refresh credential details."),T("")}catch(e){w(e instanceof Error?e.message:"Failed to complete re-auth")}finally{k(!1)}},[a.id,I,A]),M=(0,l.useCallback)(async()=>{if(L)return;let e=!R;O(e),z(!0);try{await u.FH.put(u.jI.Wallet,"/credentials/".concat(a.id),{meta:{...a.meta,favorite:e}}),null==x||x(a.id,e)}catch(t){O(!e),console.error("[CredentialDetail] failed to update favorite",t)}finally{z(!1)}},[a.id,a.meta,L,R,x]),K={login:"Login",card:"Card",note:"Note",plain_note:"Plain Note",hot_wallet:"Hot Wallet",apikey:"API Key",custom:"Key / Value",oauth2:"OAuth2",ssh:"SSH Key",gpg:"GPG Key"}[a.type]||a.type.charAt(0).toUpperCase()+a.type.slice(1),U=null!=(t=a.meta.sensitive_field_keys)?t:[],H=a.meta.walletLink,W="active"===o,$=W?"ARCHIVE":"archive"===o?"DELETE":"PURGE",B=W?"Archive Credential":"archive"===o?"Delete Credential":"Purge Credential",V=W?"This credential will be moved to Archive.":"archive"===o?"This credential will be moved to Recently Deleted.":"This credential will be permanently deleted now.",G=J(a),Y={sensitiveClickBehavior:"copy"};return(0,r.jsxs)("div",{className:"h-full min-h-0 p-6 flex flex-col relative",children:[(0,r.jsx)("div",{className:"absolute top-6 -left-1 text-vertical label-specimen-sm text-[var(--color-text-faint,#9ca3af)] select-none opacity-40 hidden lg:block",children:"CLASSIFIED"}),(0,r.jsxs)("div",{className:"mb-6",children:[(0,r.jsxs)("div",{className:"group/title flex items-center gap-2",children:[(0,r.jsx)("h2",{className:"font-mono font-bold text-lg text-[var(--color-text,#0a0a0a)]",children:G}),(0,r.jsx)("button",{type:"button",onClick:()=>void M(),disabled:L,"aria-label":R?"Remove from favorites":"Add to favorites",title:R?"Remove from favorites":"Add to favorites","data-testid":"favorite-toggle",className:"inline-flex h-5 w-5 items-center justify-center transition-opacity disabled:opacity-60 ".concat(R?"opacity-100":"opacity-0 group-hover/title:opacity-100 focus-visible:opacity-100"),children:(0,r.jsx)(D.A,{size:13,className:"flex-shrink-0 text-[var(--color-favorite,#ff4d00)] ".concat(R?"fill-[var(--color-favorite,#ff4d00)]":"fill-transparent")})})]}),(0,r.jsxs)("div",{className:"flex items-center gap-2 mt-1",children:[(0,r.jsx)("span",{className:"shard-start inline-block bg-[var(--color-text,#0a0a0a)] text-[var(--color-surface,#ffffff)] font-mono text-[8px] font-bold uppercase tracking-widest px-2 py-0.5",children:K}),(0,r.jsx)("span",{className:"font-mono text-[9px] uppercase tracking-widest text-[var(--color-text-muted,#6b7280)]",children:s})]})]}),(0,r.jsxs)("div",{className:"flex-1 min-h-0 overflow-y-auto pr-1",children:[(0,r.jsxs)("div",{className:"space-y-0.5",children:["login"===a.type&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(ep,{label:"URL",value:a.meta.url,credentialId:a.id,fieldKey:g.u.login.url,isSensitive:!1,onShowLargeType:P}),(0,r.jsx)(ep,{label:"Username",value:a.meta.username,credentialId:a.id,fieldKey:g.u.login.username,isSensitive:!1,onShowLargeType:P}),(0,r.jsx)(ep,{label:"Password",credentialId:a.id,fieldKey:g.u.login.password,isSensitive:!0,onShowLargeType:P,...Y}),W&&(0,r.jsx)(ef,{credentialId:a.id}),U.includes(g.u.login.notes)&&(0,r.jsx)(ep,{label:"Notes",credentialId:a.id,fieldKey:g.u.login.notes,isSensitive:!0,onShowLargeType:P,...Y})]}),"card"===a.type&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(ep,{label:"Cardholder",value:a.meta.cardholder,credentialId:a.id,fieldKey:g.u.card.cardholder,isSensitive:!1,onShowLargeType:P}),(0,r.jsx)(ep,{label:"Brand",value:a.meta.brand,credentialId:a.id,fieldKey:g.u.card.brand,isSensitive:!1,onShowLargeType:P}),a.meta.last4&&(0,r.jsx)(ep,{label:"Card",value:"•••• ".concat(a.meta.last4),credentialId:a.id,fieldKey:g.u.card.last4,isSensitive:!1,onShowLargeType:P}),(0,r.jsx)(ep,{label:"Number",credentialId:a.id,fieldKey:g.u.card.number,isSensitive:!0,onShowLargeType:P,...Y}),(0,r.jsx)(ep,{label:"Expiry",credentialId:a.id,fieldKey:g.u.card.expiry,isSensitive:!0,onShowLargeType:P,...Y}),(0,r.jsx)(ep,{label:"CVV",credentialId:a.id,fieldKey:g.u.card.cvv,isSensitive:!0,onShowLargeType:P,...Y}),(0,r.jsx)(ep,{label:"Billing ZIP",value:a.meta.billing_zip,credentialId:a.id,fieldKey:g.u.card.billingZip,isSensitive:!1,onShowLargeType:P}),U.includes(g.u.card.notes)&&(0,r.jsx)(ep,{label:"Notes",credentialId:a.id,fieldKey:g.u.card.notes,isSensitive:!0,onShowLargeType:P,...Y})]}),"note"===a.type&&(0,r.jsx)(ep,{label:"Content",credentialId:a.id,fieldKey:g.l3,isSensitive:!0,onShowLargeType:P,sensitiveInteractionMode:"markdown-hover-copy",disableLargeType:!0}),"plain_note"===a.type&&(0,r.jsx)(ep,{label:"Content",value:a.meta[g.l3]||a.meta.value,credentialId:a.id,fieldKey:g.l3,isSensitive:!1,onShowLargeType:P,renderMarkdown:!0,disableLargeType:!0}),"apikey"===a.type&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(ep,{label:"Key",value:a.meta.key,credentialId:a.id,fieldKey:g.u.apikey.key,isSensitive:!1,onShowLargeType:P}),(0,r.jsx)(ep,{label:"Value",credentialId:a.id,fieldKey:g.u.apikey.value,isSensitive:!0,onShowLargeType:P,sensitiveClickBehavior:"copy"})]}),"hot_wallet"===a.type&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(ep,{label:"Address",value:a.meta.address||(null==H?void 0:H.walletAddress),credentialId:a.id,fieldKey:g.u.hot_wallet.address,isSensitive:!1,onShowLargeType:P}),(0,r.jsx)(ep,{label:"Chain",value:a.meta.chain||(null==H?void 0:H.chain),credentialId:a.id,fieldKey:g.u.hot_wallet.chain,isSensitive:!1,onShowLargeType:P}),(0,r.jsx)(ep,{label:"Private Key",credentialId:a.id,fieldKey:g.u.hot_wallet.privateKey,isSensitive:!0,onShowLargeType:P,...Y})]}),"custom"===a.type&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(ep,{label:"Key",value:a.meta.primaryKey||"value",credentialId:a.id,fieldKey:"primaryKey",isSensitive:!1,onShowLargeType:P}),(0,r.jsx)(ep,{label:"Value",credentialId:a.id,fieldKey:a.meta.primaryKey||g.u.custom.value,isSensitive:!0,onShowLargeType:P,...Y})]}),"ssh"===a.type&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(ep,{label:"Fingerprint",value:a.meta.fingerprint,credentialId:a.id,fieldKey:g.u.ssh.fingerprint,isSensitive:!1,onShowLargeType:P}),(0,r.jsx)(ep,{label:"Key Type",value:a.meta.key_type,credentialId:a.id,fieldKey:g.u.ssh.keyType,isSensitive:!1,onShowLargeType:P}),(0,r.jsx)(ep,{label:"Hosts",value:Array.isArray(a.meta.hosts)?a.meta.hosts.join(", "):void 0,credentialId:a.id,fieldKey:g.u.ssh.hosts,isSensitive:!1,onShowLargeType:P}),(0,r.jsx)(ep,{label:"Public Key",value:a.meta.public_key,credentialId:a.id,fieldKey:g.u.ssh.publicKey,isSensitive:!1,onShowLargeType:P}),(0,r.jsx)(ep,{label:"Private Key",credentialId:a.id,fieldKey:g.u.ssh.privateKey,isSensitive:!0,onShowLargeType:P,...Y}),(0,r.jsx)(ep,{label:"Passphrase",credentialId:a.id,fieldKey:g.u.ssh.passphrase,isSensitive:!0,onShowLargeType:P,...Y})]}),"gpg"===a.type&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(ep,{label:"Fingerprint",value:a.meta.fingerprint,credentialId:a.id,fieldKey:g.u.gpg.fingerprint,isSensitive:!1,onShowLargeType:P}),(0,r.jsx)(ep,{label:"Key ID",value:a.meta.key_id,credentialId:a.id,fieldKey:g.u.gpg.keyId,isSensitive:!1,onShowLargeType:P}),(0,r.jsx)(ep,{label:"UID Email",value:a.meta.uid_email,credentialId:a.id,fieldKey:g.u.gpg.uidEmail,isSensitive:!1,onShowLargeType:P}),(0,r.jsx)(ep,{label:"Expires At",value:a.meta.expires_at,credentialId:a.id,fieldKey:g.u.gpg.expiresAt,isSensitive:!1,onShowLargeType:P}),(0,r.jsx)(ep,{label:"Public Key",value:a.meta.public_key,credentialId:a.id,fieldKey:g.u.gpg.publicKey,isSensitive:!1,onShowLargeType:P}),(0,r.jsx)(ep,{label:"Private Key",credentialId:a.id,fieldKey:g.u.gpg.privateKey,isSensitive:!0,onShowLargeType:P,...Y})]}),"oauth2"===a.type&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(ep,{label:"Token Endpoint",value:a.meta.token_endpoint,credentialId:a.id,fieldKey:g.u.oauth2.tokenEndpoint,isSensitive:!1,onShowLargeType:P}),(0,r.jsx)(ep,{label:"Scopes",value:a.meta.scopes,credentialId:a.id,fieldKey:g.u.oauth2.scopes,isSensitive:!1,onShowLargeType:P}),(0,r.jsx)(ep,{label:"Auth Method",value:a.meta.auth_method,credentialId:a.id,fieldKey:g.u.oauth2.authMethod,isSensitive:!1,onShowLargeType:P}),(a.meta.needs_reauth||C)&&(0,r.jsxs)("div",{className:"px-2 py-2 my-1 border border-[var(--color-danger,#ef4444)]/30 bg-[var(--color-danger,#ef4444)]/10 text-[var(--color-danger,#ef4444)] font-mono text-[10px]",children:["⚠️ Re-authentication required",!!a.meta.reauth_reason&&(0,r.jsx)("span",{className:"block text-[9px] text-[var(--color-danger,#ef4444)]/70 mt-0.5",children:String(a.meta.reauth_reason)}),(0,r.jsx)("button",{className:"mt-1 px-2 py-0.5 bg-[var(--color-danger,#ef4444)]/20 hover:bg-[var(--color-danger,#ef4444)]/30 text-[var(--color-danger,#ef4444)] text-[9px] font-bold uppercase tracking-wider disabled:opacity-50",onClick:F,disabled:N,children:N?"Loading…":"Start Re-auth"}),C&&(0,r.jsx)("a",{href:C,target:"_blank",rel:"noopener noreferrer",className:"mt-1 ml-2 inline-block px-2 py-0.5 bg-[var(--color-danger,#ef4444)]/20 hover:bg-[var(--color-danger,#ef4444)]/30 text-[var(--color-danger,#ef4444)] text-[9px] font-bold uppercase tracking-wider",children:"Open Consent"}),A&&(0,r.jsxs)("div",{className:"mt-2 flex items-center gap-2",children:[(0,r.jsx)("input",{value:I,onChange:e=>T(e.target.value),placeholder:"Paste authorization code",className:"flex-1 px-2 py-1 border border-[var(--color-danger,#ef4444)]/30 bg-transparent text-[9px]"}),(0,r.jsx)("button",{className:"px-2 py-1 bg-[var(--color-danger,#ef4444)]/20 hover:bg-[var(--color-danger,#ef4444)]/30 text-[var(--color-danger,#ef4444)] text-[9px] font-bold uppercase tracking-wider disabled:opacity-50",onClick:_,disabled:N||!I.trim(),children:"Complete Re-auth"})]}),j&&(0,r.jsx)("div",{className:"mt-1 text-[9px] text-[var(--color-danger,#ef4444)]/90 break-words",children:j})]}),a.meta.last_refreshed&&(0,r.jsxs)("div",{className:"px-1 py-1",children:[(0,r.jsxs)("span",{className:"font-mono text-[9px] font-bold uppercase tracking-widest text-[var(--color-text-muted,#6b7280)]",children:["Last Refreshed:"," "]}),(0,r.jsx)("span",{className:"font-mono text-[10px] text-[var(--color-text-muted,#6b7280)]",children:new Date(String(a.meta.last_refreshed)).toLocaleString()})]}),(()=>{let e=a.meta.expires_at,t=Math.floor(Date.now()/1e3),l=!e||t>=e,s=e?l?"Expired — will auto-refresh on next read":"Valid for ".concat(Math.floor((e-t)/60),"m"):"No token yet";return(0,r.jsxs)("div",{className:"px-1 py-2",children:[(0,r.jsxs)("span",{className:"font-mono text-[9px] font-bold uppercase tracking-widest text-[var(--color-text-muted,#6b7280)]",children:["Token Status:"," "]}),(0,r.jsx)("span",{className:"font-mono text-[10px] font-bold",style:{color:l?"var(--color-danger,#ef4444)":"var(--color-success,#00c853)"},children:s})]})})(),(0,r.jsx)(ep,{label:"Access Token",credentialId:a.id,fieldKey:g.u.oauth2.accessToken,isSensitive:!0,onShowLargeType:P,...Y}),(0,r.jsx)(ep,{label:"Refresh Token",credentialId:a.id,fieldKey:g.u.oauth2.refreshToken,isSensitive:!0,onShowLargeType:P,...Y}),(0,r.jsx)(ep,{label:"Client ID",credentialId:a.id,fieldKey:g.u.oauth2.clientId,isSensitive:!0,onShowLargeType:P,...Y}),(0,r.jsx)(ep,{label:"Client Secret",credentialId:a.id,fieldKey:g.u.oauth2.clientSecret,isSensitive:!0,onShowLargeType:P,...Y})]})]}),H&&(0,r.jsx)(ew,{walletLink:H}),a.meta.tags&&a.meta.tags.length>0&&(0,r.jsx)("div",{className:"mt-4 flex flex-wrap gap-1.5",children:a.meta.tags.map(e=>(0,r.jsx)("span",{className:"inline-block font-mono text-[9px] px-2 py-0.5 bg-[var(--color-accent,#ccff00)]/10 text-[var(--color-text-muted,#6b7280)]",children:e},e))})]}),(0,r.jsx)("div",{className:"mt-4 pt-3 border-t border-[var(--color-border,#d4d4d8)] shrink-0",children:(0,r.jsxs)("div",{className:"font-mono text-[8px] text-[var(--color-text-faint,#9ca3af)] space-y-0.5",children:[(0,r.jsxs)("div",{children:["Created ",eN(a.createdAt)]}),(0,r.jsxs)("div",{children:["Updated ",eN(a.updatedAt)]}),a.archivedAt&&(0,r.jsxs)("div",{children:["Archived ",eN(a.archivedAt)]}),a.deletedAt&&(0,r.jsxs)("div",{children:["Deleted ",eN(a.deletedAt)]}),(0,r.jsxs)("div",{children:["Agent: ",s]})]})}),(0,r.jsxs)("div",{className:"mt-4 flex gap-2 shrink-0",children:[W&&(0,r.jsx)(b.$n,{variant:"secondary",size:"sm",onClick:()=>y(!0),children:"SHARE"}),W&&(0,r.jsx)(b.$n,{variant:"secondary",size:"sm",onClick:n,children:"EDIT"}),W&&d&&(0,r.jsx)(b.$n,{variant:"secondary",size:"sm",onClick:d,children:"DUPLICATE"}),!W&&(0,r.jsx)(b.$n,{variant:"secondary",size:"sm",onClick:c,children:"archive"===o?"RESTORE":"RESTORE TO ARCHIVE"}),(0,r.jsx)(b.$n,{variant:"danger",size:"sm",onClick:()=>v(!0),children:$})]}),(0,r.jsx)(b.Rw,{isOpen:m,onClose:()=>v(!1),onConfirm:()=>{v(!1),i()},title:B,message:V,confirmText:"recently_deleted"===o?"PURGE":"CONFIRM",variant:"recently_deleted"===o?"danger":"warning"}),(0,r.jsx)(em,{isOpen:null!=p,onClose:()=>f(null),value:null!=p?p:""}),(0,r.jsx)(ey,{isOpen:h,onClose:()=>y(!1),credentialId:a.id,credentialName:G})]})},eC=e=>{let{variant:t,onAdd:a}=e;return"no-selection"===t?(0,r.jsx)("div",{className:"flex-1 flex items-center justify-center h-full",children:(0,r.jsxs)("div",{className:"text-center",children:[(0,r.jsx)(A.A,{size:32,className:"mx-auto mb-3 text-[var(--color-text-faint,#9ca3af)]"}),(0,r.jsx)("div",{className:"font-mono text-[11px] tracking-widest uppercase text-[var(--color-text-muted,#6b7280)]",children:"Select a credential from the list"})]})}):"empty-lifecycle"===t?(0,r.jsx)("div",{className:"flex-1 flex items-center justify-center h-full",children:(0,r.jsxs)("div",{className:"text-center",children:[(0,r.jsx)(A.A,{size:32,className:"mx-auto mb-3 text-[var(--color-text-faint,#9ca3af)]"}),(0,r.jsx)("div",{className:"font-mono text-[11px] tracking-widest uppercase text-[var(--color-text-muted,#6b7280)] mb-1",children:"No credentials in this section"})]})}):(0,r.jsx)("div",{className:"flex-1 flex items-center justify-center h-full",children:(0,r.jsxs)("div",{className:"text-center",children:[(0,r.jsx)(A.A,{size:32,className:"mx-auto mb-3 text-[var(--color-text-faint,#9ca3af)]"}),(0,r.jsx)("div",{className:"font-mono text-[11px] tracking-widest uppercase text-[var(--color-text-muted,#6b7280)] mb-1",children:"Your agent is empty"}),(0,r.jsx)("div",{className:"font-mono text-[9px] text-[var(--color-text-faint,#9ca3af)] mb-4",children:"Create your first credential"}),(0,r.jsx)(b.$n,{size:"sm",onClick:a,icon:(0,r.jsx)(O.A,{size:10}),children:"ADD"})]})})};var eS=a(3020),eA=a(6132),eE=a(2529);let eI=[{label:"1Password",format:"1password-csv",supported:!0},{label:"Bitwarden",format:"bitwarden-csv",supported:!0},{label:"Chrome",format:"chrome-csv",supported:!0},{label:"Firefox",format:"firefox-csv",supported:!0},{label:"iCloud Keychain",format:"icloud-csv",supported:!0},{label:"LastPass",format:"lastpass-csv",supported:!0}],eT={skip:"Skip",rename:"Rename",overwrite:"Create Anyway"};function eR(){let e=localStorage.getItem("auramaxx_admin_token");return e||sessionStorage.getItem("auramaxx_admin_token")}let eO=e=>{let{isOpen:t,onClose:a,onComplete:s,agents:o,selectedAgentId:n,onSelectedAgentIdChange:i,onAddAgent:c,walletBaseUrl:d}=e,[x,u]=(0,l.useState)("select"),[p,f]=(0,l.useState)("1password-csv"),[m,v]=(0,l.useState)(null),[h,g]=(0,l.useState)("skip"),[y,j]=(0,l.useState)(null),[w,k]=(0,l.useState)(null),[C,S]=(0,l.useState)(!1),[A,E]=(0,l.useState)(null),I=(0,l.useRef)(null),T=(0,l.useMemo)(()=>o.map(e=>({value:e.id,label:e.name||(e.isPrimary?"Primary":"Agent ".concat(e.id.slice(0,6)))})),[o]),R=(0,l.useMemo)(()=>o.find(e=>e.id===n)||null,[o,n]),O=(0,l.useCallback)(()=>{u("select"),f("1password-csv"),v(null),g("skip"),j(null),k(null),S(!1),E(null),I.current&&(I.current.value="")},[]),L=(0,l.useCallback)(()=>{O(),a()},[O,a]),D=(0,l.useCallback)(e=>{var t,a;let r=null!=(a=null==(t=e.target.files)?void 0:t[0])?a:null;if(r&&r.size>0xa00000){E("File too large (".concat((r.size/1024/1024).toFixed(1),"MB). Maximum is 10MB.")),v(null),I.current&&(I.current.value="");return}v(r),E(null)},[]),z=(0,l.useCallback)(e=>{if(!m)return null;let t=new FormData;return t.append("file",m),t.append("format",p),t.append("agentId",n||"primary"),e&&t.append("dryRun","true"),t.append("duplicateStrategy",h),t},[m,p,n,h]),P=(0,l.useCallback)(async()=>{if(m){S(!0),E(null);try{let e=z(!0);if(!e)return;let t=eR(),a=await fetch("".concat(d,"/credentials/import"),{method:"POST",headers:t?{Authorization:"Bearer ".concat(t)}:{},body:e});if(!(a.headers.get("content-type")||"").includes("application/json"))return void E("Server error: ".concat(a.status," ").concat(a.statusText));let r=await a.json();if(!a.ok||!r.success)return void E(r.error||"Request failed: ".concat(a.status));j(r),u("preview")}catch(e){E(e instanceof Error?e.message:"Preview failed")}finally{S(!1)}}},[m,z,d]),F=(0,l.useCallback)(async()=>{S(!0),E(null);try{let e=z(!1);if(!e)return;let t=eR(),a=await fetch("".concat(d,"/credentials/import"),{method:"POST",headers:t?{Authorization:"Bearer ".concat(t)}:{},body:e});if(!(a.headers.get("content-type")||"").includes("application/json"))return void E("Server error: ".concat(a.status," ").concat(a.statusText));let r=await a.json();if(!a.ok)return void E(r.error||"Request failed: ".concat(a.status));k(r),u("result")}catch(e){E(e instanceof Error?e.message:"Import failed")}finally{S(!1)}},[z,d]),_=(0,l.useCallback)(()=>{s(),L()},[s,L]),M=eI.find(e=>e.format===p);return(0,r.jsxs)(b.aF,{isOpen:t,onClose:L,title:"Import Credentials",size:"md",footer:(()=>{if("select"===x)return(0,r.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,r.jsx)(b.$n,{variant:"secondary",size:"sm",onClick:L,children:"CANCEL"}),(0,r.jsx)(b.$n,{size:"sm",onClick:P,loading:C,disabled:!m||!(null==M?void 0:M.supported),children:"PREVIEW"})]});if("preview"===x&&y){let e="skip"===h?y.total-y.duplicates:y.total;return(0,r.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,r.jsx)(b.$n,{variant:"secondary",size:"sm",onClick:()=>{u("select"),E(null),I.current&&(I.current.value="")},children:"BACK"}),(0,r.jsxs)(b.$n,{size:"sm",onClick:F,loading:C,disabled:0===y.credentials.length,children:["IMPORT ",e," CREDENTIAL",1!==e?"S":""]})]})}return"result"===x?(0,r.jsx)("div",{className:"flex justify-end",children:(0,r.jsx)(b.$n,{size:"sm",onClick:_,children:"DONE"})}):null})(),children:["select"===x&&(0,r.jsxs)("div",{className:"space-y-5",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:"block text-[9px] font-bold tracking-widest uppercase text-[var(--color-text-muted,#6b7280)] mb-2",children:"Source"}),(0,r.jsx)(b.O6,{ariaLabel:"Import source",value:p,onChange:e=>{let t=eI.find(t=>t.format===e);(null==t?void 0:t.supported)&&f(t.format)},options:eI.map(e=>({value:e.format,label:e.label,description:e.supported?void 0:"Coming soon",icon:(0,r.jsx)(N.A,{size:12})}))})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:"block text-[9px] font-bold tracking-widest uppercase text-[var(--color-text-muted,#6b7280)] mb-2",children:"File"}),(0,r.jsx)("input",{ref:I,type:"file",accept:".csv",onChange:D,className:"hidden"}),(0,r.jsxs)("button",{onClick:()=>{var e;return null==(e=I.current)?void 0:e.click()},className:"w-full flex items-center justify-center gap-2 px-4 py-4 border-2 border-dashed border-[var(--color-border,#d4d4d8)] hover:border-[var(--color-text-muted,#6b7280)] transition-colors",children:[(0,r.jsx)(V.A,{size:14,className:"text-[var(--color-text-muted,#6b7280)]"}),(0,r.jsx)("span",{className:"text-[10px] font-mono tracking-wider text-[var(--color-text-muted,#6b7280)]",children:m?m.name:"Choose CSV file"})]})]}),(0,r.jsxs)("div",{children:[(0,r.jsxs)("div",{className:"flex items-end gap-2",children:[(0,r.jsx)("div",{className:"flex-1",children:(0,r.jsx)(b.UM,{label:"Target Agent",ariaLabel:"TARGET AGENT",options:T,value:n,onChange:i,compact:!0,searchable:!0,menuPosition:"top",searchPlaceholder:"Search agent...",emptyMessage:"No agent matches"})}),(0,r.jsx)(b.$n,{type:"button",variant:"secondary",size:"sm",onClick:c,className:"!h-[var(--control-height-sm)] !px-3",children:"ADD"})]}),R&&!R.isUnlocked&&(0,r.jsx)("div",{className:"mt-2 text-[9px] text-[var(--color-warning,#ff4d00)] border border-[var(--color-warning,#ff4d00)]/30 bg-[var(--color-warning,#ff4d00)]/10 px-3 py-2",children:"Selected agent is locked. Unlock it before preview/import."})]}),A&&(0,r.jsxs)("div",{className:"flex items-start gap-2 px-3 py-2 bg-red-50 border border-red-200",children:[(0,r.jsx)(eA.A,{size:12,className:"text-red-500 flex-shrink-0 mt-0.5"}),(0,r.jsx)("span",{className:"text-[10px] font-mono text-red-700",children:A})]})]}),"preview"===x&&(y?(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsxs)("div",{className:"flex gap-4",children:[(0,r.jsxs)("div",{className:"text-center",children:[(0,r.jsx)("div",{className:"text-[18px] font-bold font-mono text-[var(--color-text,#0a0a0a)]",children:y.total}),(0,r.jsx)("div",{className:"text-[8px] font-mono tracking-widest uppercase text-[var(--color-text-muted,#6b7280)]",children:"Total"})]}),y.duplicates>0&&(0,r.jsxs)("div",{className:"text-center",children:[(0,r.jsx)("div",{className:"text-[18px] font-bold font-mono text-amber-600",children:y.duplicates}),(0,r.jsx)("div",{className:"text-[8px] font-mono tracking-widest uppercase text-[var(--color-text-muted,#6b7280)]",children:"Duplicates"})]})]}),(0,r.jsxs)("div",{className:"max-h-[240px] overflow-y-auto border border-[var(--color-border,#d4d4d8)]",children:[0===y.credentials.length?(0,r.jsx)("div",{className:"px-4 py-8 text-center text-[10px] font-mono text-[var(--color-text-muted,#6b7280)]",children:"No credentials found in file"}):y.credentials.map((e,t)=>(0,r.jsxs)("div",{className:"flex items-center gap-2 px-3 py-1.5 border-b border-[var(--color-border,#d4d4d8)] last:border-b-0 ".concat(e.isDuplicate?"bg-amber-50/50":""),children:[(0,r.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,r.jsx)("div",{className:"text-[10px] font-mono text-[var(--color-text,#0a0a0a)] truncate",children:e.name}),e.url&&(0,r.jsx)("div",{className:"text-[8px] font-mono text-[var(--color-text-faint,#9ca3af)] truncate",children:e.url})]}),(0,r.jsx)("span",{className:"text-[8px] font-mono tracking-wider uppercase text-[var(--color-text-faint,#9ca3af)] flex-shrink-0",children:e.type}),e.isDuplicate&&(0,r.jsx)("span",{className:"text-[8px] font-mono tracking-wider uppercase text-amber-600 flex-shrink-0",children:"DUP"})]},t)),y.total>y.credentials.length&&(0,r.jsxs)("div",{className:"px-3 py-1.5 text-[9px] font-mono text-[var(--color-text-faint,#9ca3af)] text-center",children:["+ ",y.total-y.credentials.length," more"]})]}),y.duplicates>0&&(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:"block text-[9px] font-bold tracking-widest uppercase text-[var(--color-text-muted,#6b7280)] mb-1.5",children:"Duplicate handling"}),(0,r.jsx)("div",{className:"flex gap-1.5",children:["skip","rename","overwrite"].map(e=>(0,r.jsx)("button",{onClick:()=>g(e),className:"px-3 py-1.5 text-[9px] font-mono tracking-wider uppercase border transition-colors ".concat(h===e?"border-[var(--color-accent,#ccff00)] bg-[var(--color-accent,#ccff00)]/10 text-[var(--color-text,#0a0a0a)]":"border-[var(--color-border,#d4d4d8)] text-[var(--color-text-muted,#6b7280)] hover:bg-[var(--color-background-alt,#f4f4f5)]"),children:eT[e]},e))})]}),A&&(0,r.jsxs)("div",{className:"flex items-start gap-2 px-3 py-2 bg-red-50 border border-red-200",children:[(0,r.jsx)(eA.A,{size:12,className:"text-red-500 flex-shrink-0 mt-0.5"}),(0,r.jsx)("span",{className:"text-[10px] font-mono text-red-700",children:A})]})]}):null),"result"===x&&(()=>{if(!w)return null;let e=w.errors.length>0;return(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsxs)("div",{className:"flex items-center gap-3",children:[w.success?(0,r.jsx)(eE.A,{size:20,className:"text-green-600"}):(0,r.jsx)(eA.A,{size:20,className:"text-red-500"}),(0,r.jsx)("div",{children:(0,r.jsx)("div",{className:"text-[11px] font-mono font-bold text-[var(--color-text,#0a0a0a)]",children:w.success?"Import Complete":"Import Failed"})})]}),(0,r.jsxs)("div",{className:"flex gap-6",children:[(0,r.jsxs)("div",{className:"text-center",children:[(0,r.jsx)("div",{className:"text-[18px] font-bold font-mono text-green-600",children:w.imported}),(0,r.jsx)("div",{className:"text-[8px] font-mono tracking-widest uppercase text-[var(--color-text-muted,#6b7280)]",children:"Imported"})]}),w.skipped>0&&(0,r.jsxs)("div",{className:"text-center",children:[(0,r.jsx)("div",{className:"text-[18px] font-bold font-mono text-[var(--color-text-muted,#6b7280)]",children:w.skipped}),(0,r.jsx)("div",{className:"text-[8px] font-mono tracking-widest uppercase text-[var(--color-text-muted,#6b7280)]",children:"Skipped"})]}),e&&(0,r.jsxs)("div",{className:"text-center",children:[(0,r.jsx)("div",{className:"text-[18px] font-bold font-mono text-red-500",children:w.errors.length}),(0,r.jsx)("div",{className:"text-[8px] font-mono tracking-widest uppercase text-[var(--color-text-muted,#6b7280)]",children:"Errors"})]})]}),e&&(0,r.jsx)("div",{className:"max-h-[120px] overflow-y-auto border border-red-200 bg-red-50",children:w.errors.map((e,t)=>(0,r.jsxs)("div",{className:"px-3 py-1 text-[9px] font-mono text-red-700 border-b border-red-100 last:border-b-0",children:["Row ",e.row,": ",e.reason]},t))})]})})()]})};var eL=a(6345),eD=a(2056),ez=a(2520),eP=a(3721);let eF={CREDENTIAL_SCOPE_DENIED:"SCOPE_DENY",TOKEN_PERMISSION_DENIED:"SCOPE_DENY",TOKEN_REVOKED:"TOKEN_REVOKED",TOKEN_EXPIRED:"TOKEN_EXPIRED",RATE_LIMIT:"RATE_LIMITED",RATE_LIMITED:"RATE_LIMITED",CREDENTIAL_NOT_FOUND:"NOT_FOUND",CREDENTIAL_TOTP_NOT_CONFIGURED:"NOT_FOUND",TOKEN_AGENT_PUBKEY_MISSING:"MISSING_KEY",INTERNAL_ERROR:"INTERNAL_ERROR",ALLOW:"UNKNOWN"};function e_(e,t,a){let r="string"==typeof e?e.trim().toUpperCase():"";return"ALLOW"===r?"ALLOW":"DENY"===r?"DENY":"RATE_LIMIT"===r?"RATE_LIMIT":"ERROR"===r?"ERROR":!0===t?"ALLOW":!1===t&&(null!=a?a:0)===429?"RATE_LIMIT":!1===t?"DENY":(null!=a?a:0)>=500?"ERROR":"UNKNOWN"}function eM(e){var t;return null!=(t=eF["string"==typeof e?e.trim().toUpperCase():""])?t:"UNKNOWN"}function eK(e){return e.tokenHash?"HIGH":e.agentId?"MEDIUM":"LOW"}function eU(e){var t,a,r;let l="string"==typeof e.decision?e.decision:void 0,s="string"==typeof e.reasonCode?e.reasonCode:void 0,o="string"==typeof e.tokenHash?e.tokenHash:void 0,n="string"==typeof e.agentId?e.agentId:void 0,i=e.timestamp,c=new Date("string"==typeof i||"number"==typeof i?i:Date.now()).getTime();return{id:String(null!=(a=e.id)?a:"".concat(c,"-").concat(null!=(t=null!=o?o:n)?t:"unknown")),timestamp:c,tokenKey:null!=(r=null!=o?o:n)?r:"unknown",tokenHash:o,agentId:n,endpoint:"string"==typeof e.action?e.action:void 0,credentialKey:"string"==typeof e.credentialId?e.credentialId:void 0,sourceVersion:"task40-audit-v1",decision:e_(l,e.allowed,e.httpStatus),reasonCode:eM(s),rawDecision:l,rawReasonCode:s,confidence:eK({tokenHash:o,agentId:n})}}function eH(e){var t,a,r;let l="object"==typeof e.data&&null!==e.data?e.data:{},s="object"==typeof l.metadata&&null!==l.metadata?l.metadata:{},o="string"==typeof l.result?l.result:"string"==typeof l.decision?l.decision:void 0,n="string"==typeof l.reasonCode?l.reasonCode:"string"==typeof l.reason?l.reason:void 0,i="string"==typeof l.tokenHash?l.tokenHash:void 0,c="string"==typeof l.agentId?l.agentId:void 0,d=e.timestamp,x=new Date("string"==typeof d||"number"==typeof d?d:Date.now()).getTime();return{id:String(null!=(a=e.id)?a:"".concat(x,"-").concat(null!=(t=null!=i?i:c)?t:"unknown")),timestamp:x,tokenKey:null!=(r=null!=i?i:c)?r:"unknown",tokenHash:i,agentId:c,endpoint:"string"==typeof s.route?s.route:"string"==typeof l.action?l.action:void 0,credentialKey:"string"==typeof l.credentialId?l.credentialId:void 0,sourceVersion:"legacy-logs-v1",decision:e_(o,l.allowed,l.httpStatus),reasonCode:eM(n),rawDecision:o,rawReasonCode:n,confidence:eK({tokenHash:i,agentId:c})}}function eW(e){return"HIGH"===e?3:"MEDIUM"===e?2:1}let e$=[{value:"active",label:"ACTIVE"},{value:"revoked",label:"REVOKED"},{value:"expired",label:"EXPIRED"},{value:"all",label:"ALL"}],eB=[{value:"1h",label:"1 HOUR"},{value:"24h",label:"24 HOURS"},{value:"7d",label:"7 DAYS"}],eV=[{value:"all",label:"ALL"},{value:"ALLOW",label:"ALLOW"},{value:"DENY",label:"DENY"},{value:"RATE_LIMIT",label:"RATE_LIMIT"},{value:"ERROR",label:"ERROR"},{value:"UNKNOWN",label:"UNKNOWN"}];function eG(e){if(null==e)return null;if("number"==typeof e)return e<1e12?1e3*e:e;let t=Date.parse(e);return Number.isFinite(t)?t:null}function eY(e){return e?e.length<=14?e:"".concat(e.slice(0,8),"...").concat(e.slice(-6)):"—"}function eq(e){let t=eG(e);return null===t?"—":new Date(t).toLocaleString()}function eX(){var e,t;let{subscribe:a}=(0,ez.h)(),[s,o]=(0,l.useState)([]),[n,i]=(0,l.useState)([]),[c,d]=(0,l.useState)("active"),[x,p]=(0,l.useState)("24h"),[f,m]=(0,l.useState)(""),[v,h]=(0,l.useState)("all"),[g,y]=(0,l.useState)("all"),[j,w]=(0,l.useState)(0),[N,k]=(0,l.useState)(!0),[S,A]=(0,l.useState)(null),[E,I]=(0,l.useState)(null),[T,R]=(0,l.useState)(null),[O,L]=(0,l.useState)(null),[D,z]=(0,l.useState)(null),P=(0,l.useRef)(null),F=(0,l.useRef)(null),_=(0,l.useCallback)(async()=>{k(!0),A(null);try{var e,t;let[a,r,l]=await Promise.all([u.FH.get(u.jI.Wallet,"/dashboard"),u.FH.get(u.jI.Wallet,"/security/credential-access/recent",{limit:500}),u.FH.get(u.jI.Wallet,"/logs",{category:"agent",limit:200})]),s=a.success?[...null!=(e=a.tokens.active)?e:[],...null!=(t=a.tokens.inactive)?t:[]]:[],n=r.success?r.rows.map(eU):[],c=l.success?l.logs.filter(e=>{var t;let a=null!=(t=e.data)?t:{};return"credential_access_decision"===a.action}).map(eH):[],d=Date.now(),x=(function(e){let t=new Map;for(let a of e){let e=a.id||function(e){var t,a;return"".concat(e.timestamp,"|").concat(null!=(t=e.endpoint)?t:"","|").concat(e.tokenKey,"|").concat(null!=(a=e.credentialKey)?a:"","|").concat(e.decision,"|").concat(e.reasonCode)}(a),r=t.get(e);if(!r||eW(a.confidence)>eW(r.confidence)){t.set(e,a);continue}"task40-audit-v1"===a.sourceVersion&&"legacy-logs-v1"===r.sourceVersion&&t.set(e,a)}return Array.from(t.values()).sort((e,t)=>t.timestamp-e.timestamp)})([...n,...c]).filter(e=>e.timestamp<=d);o(s),i(x.slice(0,500)),w(0)}catch(e){A(e instanceof Error?e.message:"Failed to load audit console")}finally{k(!1)}},[]);(0,l.useEffect)(()=>{_()},[_]);let M=(0,l.useCallback)(()=>{F.current||(F.current=setTimeout(()=>{F.current=null,_()},120))},[_]);(0,l.useEffect)(()=>{let e=[a(eP.Cw.TOKEN_CREATED,M),a(eP.Cw.TOKEN_REVOKED,M),a(eP.Cw.TOKEN_SPENT,M),a(eP.Cw.CREDENTIAL_CHANGED,M),a(eP.Cw.CREDENTIAL_ACCESSED,M)];return()=>{e.forEach(e=>e()),F.current&&(clearTimeout(F.current),F.current=null)}},[M,a]),(0,l.useEffect)(()=>{w(0)},[v,g,x,f]);let K=(0,l.useMemo)(()=>Date.now()-("1h"===x?36e5:"7d"===x?6048e5:864e5),[x]),U=f.trim().toLowerCase(),H=(0,l.useMemo)(()=>s.map((e,t)=>({key:e.tokenHash||e.agentId||"unknown-".concat(t),token:e,status:function(e){if(e.isRevoked)return"revoked";let t=eG(e.expiresAt);return e.isExpired||null!==t&&t<=Date.now()?"expired":e.isActive?"active":"inactive"}(e)})),[s]),W=(0,l.useMemo)(()=>new Map(H.map(e=>[e.key,e])),[H]),$="all"===v?null:null!=(t=W.get(v))?t:null,B=(0,l.useMemo)(()=>n.filter(e=>e.timestamp>=K),[n,K]),V=(0,l.useMemo)(()=>{let e=H.filter(e=>"active"===e.status).length,t=B.filter(e=>"DENY"===e.decision).length;return{activeCount:e,denied:t,rateLimited:B.filter(e=>"RATE_LIMIT"===e.decision).length,unknown:B.filter(e=>"UNKNOWN"===e.decision||"UNKNOWN"===e.reasonCode).length}},[H,B]),G=(0,l.useMemo)(()=>H.filter(e=>("all"===c||e.status===c)&&(!U||"".concat(e.key," ").concat(e.token.tokenHash," ").concat(e.token.agentId).toLowerCase().includes(U))),[H,c,U]),Y=(0,l.useMemo)(()=>{let e=[{value:"all",label:"ALL TOKENS"}],t=new Set(["all"]);if(G.forEach(a=>{var r,l;t.has(a.key)||(t.add(a.key),e.push({value:a.key,label:"".concat(null!=(r=a.token.agentId)?r:"unknown"," \xb7 ").concat(eY(null!=(l=a.token.tokenHash)?l:a.key))}))}),"all"!==v&&!t.has(v)){var a,r;let t=W.get(v);t&&e.push({value:t.key,label:"".concat(null!=(a=t.token.agentId)?a:"unknown"," \xb7 ").concat(eY(null!=(r=t.token.tokenHash)?r:t.key))})}return e},[G,v,W]),q=(0,l.useMemo)(()=>{let e=new Map;return B.forEach(t=>{[t.tokenHash,t.tokenKey,t.agentId?"agent:".concat(t.agentId):void 0,t.agentId].filter(e=>!!e).forEach(a=>{var r;e.set(a,Math.max(null!=(r=e.get(a))?r:0,t.timestamp))})}),e},[B]),X=(0,l.useCallback)(e=>{var t,a,r,l;let s=e.token.tokenHash;return s&&q.has(s)?null!=(t=q.get(s))?t:null:q.has(e.key)?null!=(a=q.get(e.key))?a:null:e.token.agentId&&q.has("agent:".concat(e.token.agentId))?null!=(r=q.get("agent:".concat(e.token.agentId)))?r:null:e.token.agentId&&q.has(e.token.agentId)&&null!=(l=q.get(e.token.agentId))?l:null},[q]),J=(0,l.useMemo)(()=>B.filter(e=>{if("all"!==v){let t=null==$?void 0:$.token.agentId,a=e.tokenKey===v||e.tokenHash===v,r=!!t&&e.agentId===t;if(!a&&!r)return!1}if("all"!==g&&e.decision!==g)return!1;if(U){var t,a;if(!"".concat(null!=(t=e.tokenHash)?t:""," ").concat(e.tokenKey," ").concat(null!=(a=e.agentId)?a:"").toLowerCase().includes(U))return!1}return!0}),[g,B,v,$,U]),Q=(0,l.useMemo)(()=>{let e=50*j;return J.slice(e,e+50)},[J,j]),Z=(0,l.useCallback)(e=>{h(e),w(0),P.current&&"function"==typeof P.current.scrollIntoView&&P.current.scrollIntoView({behavior:"smooth",block:"start"})},[]),ee=(0,l.useCallback)(async(e,t)=>{if(!t||!navigator.clipboard)return void I("Clipboard unavailable for this key.");try{let a=eY(t);await navigator.clipboard.writeText(a),L(e),I("Copied ".concat(a)),setTimeout(()=>L(t=>t===e?null:t),1500)}catch(e){I("Clipboard write failed.")}},[]),et=(0,l.useCallback)((e,t)=>{if(!t)return void I("Token hash unavailable; cannot revoke.");z({tokenKey:e,tokenHash:t})},[]),ea=(0,l.useCallback)(async()=>{if(!D)return;let{tokenKey:e,tokenHash:t}=D;z(null),R(e),I(null);try{let e=await u.FH.post(u.jI.Wallet,"/actions/tokens/revoke",{tokenHash:t});if(!e.success)return void I(e.error||"Failed to revoke token.");I("Revoked ".concat(eY(t))),await _()}catch(e){I(e instanceof Error?e.message:"Failed to revoke token.")}finally{R(null)}},[D,_]);return N?(0,r.jsx)("div",{className:"p-4 font-mono text-[10px] text-[var(--color-text-muted,#6b7280)]",children:"LOADING_AUDIT_CONSOLE…"}):S?(0,r.jsx)("div",{className:"p-4 border border-[var(--color-warning,#ff4d00)] bg-[color-mix(in_srgb,var(--color-warning,#ff4d00)_10%,transparent)]",children:(0,r.jsxs)("div",{className:"flex items-center gap-2 font-mono text-[10px] text-[var(--color-warning,#ff4d00)]",children:[(0,r.jsx)(eD.A,{size:12})," ",S]})}):(0,r.jsxs)("div",{className:"h-full flex flex-col p-3 gap-3 overflow-hidden",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between border border-[var(--color-border,#d4d4d8)] p-2 bg-[var(--color-surface,#fff)]",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("div",{className:"font-mono text-[11px] font-bold",children:"AUDIT"}),(0,r.jsxs)("div",{className:"font-mono text-[9px] text-[var(--color-text-muted,#6b7280)]",children:[null==(e=eB.find(e=>e.value===x))?void 0:e.label.toLowerCase()," \xb7 ",Math.min(n.length,500)," rows",n.length>=500?" (capped)":""]})]}),(0,r.jsx)(b.$n,{variant:"secondary",size:"sm",onClick:()=>void _(),icon:(0,r.jsx)(C.A,{size:10}),children:"REFRESH"})]}),(0,r.jsxs)("div",{className:"grid grid-cols-2 xl:grid-cols-4 gap-2",children:[(0,r.jsxs)("div",{className:"border border-[var(--color-border,#d4d4d8)] bg-[var(--color-surface,#fff)] p-2",children:[(0,r.jsx)("div",{className:"font-mono text-[8px] text-[var(--color-text-muted,#6b7280)]",children:"ACTIVE KEYS"}),(0,r.jsx)("div",{className:"font-mono text-[12px] font-bold",children:V.activeCount})]}),(0,r.jsxs)("div",{className:"border border-[var(--color-border,#d4d4d8)] bg-[var(--color-surface,#fff)] p-2",children:[(0,r.jsxs)("div",{className:"font-mono text-[8px] text-[var(--color-text-muted,#6b7280)]",children:["DENIES (",x,")"]}),(0,r.jsx)("div",{className:"font-mono text-[12px] font-bold",children:V.denied})]}),(0,r.jsxs)("div",{className:"border border-[var(--color-border,#d4d4d8)] bg-[var(--color-surface,#fff)] p-2",children:[(0,r.jsxs)("div",{className:"font-mono text-[8px] text-[var(--color-text-muted,#6b7280)]",children:["RATE LIMITED (",x,")"]}),(0,r.jsx)("div",{className:"font-mono text-[12px] font-bold",children:V.rateLimited})]}),(0,r.jsxs)("div",{className:"border border-[var(--color-border,#d4d4d8)] bg-[var(--color-surface,#fff)] p-2",children:[(0,r.jsxs)("div",{className:"font-mono text-[8px] text-[var(--color-text-muted,#6b7280)]",children:["UNKNOWN MAPS (",x,")"]}),(0,r.jsx)("div",{className:"font-mono text-[12px] font-bold",children:V.unknown})]})]}),(0,r.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-2 xl:grid-cols-5 gap-2",children:[(0,r.jsx)(b.UM,{label:"Status",options:e$,value:c,onChange:e=>d(e),compact:!0}),(0,r.jsx)(b.UM,{label:"Window",options:eB,value:x,onChange:e=>p(e),compact:!0}),(0,r.jsx)(b.UM,{label:"Token",options:Y,value:v,onChange:h,compact:!0}),(0,r.jsx)(b.UM,{label:"Decision",options:eV,value:g,onChange:e=>y(e),compact:!0}),(0,r.jsxs)("label",{className:"font-mono text-[9px] flex flex-col gap-1",children:["SEARCH KEY / AGENT",(0,r.jsx)("input",{value:f,onChange:e=>m(e.target.value),placeholder:"hash or agent id",className:"border border-[var(--color-border,#d4d4d8)] bg-[var(--color-surface,#fff)] px-2 py-1.5 text-[10px]"})]})]}),E&&(0,r.jsx)("div",{className:"font-mono text-[9px] border border-[var(--color-info,#0047ff)] p-2 text-[var(--color-info,#0047ff)] bg-[color-mix(in_srgb,var(--color-info,#0047ff)_8%,transparent)]",children:E}),(0,r.jsxs)("div",{className:"border border-[var(--color-border,#d4d4d8)] bg-[var(--color-surface,#fff)] overflow-hidden",children:[(0,r.jsxs)("div",{className:"px-2 py-1.5 border-b border-[var(--color-border,#d4d4d8)] font-mono text-[9px]",children:["KEY INVENTORY \xb7 ",G.length," ROWS"]}),(0,r.jsx)("div",{className:"max-h-[220px] overflow-auto",children:0===G.length?(0,r.jsx)("div",{className:"p-4 font-mono text-[10px] text-[var(--color-text-muted,#6b7280)]",children:"NO TOKENS MATCH FILTERS"}):(0,r.jsxs)("table",{className:"w-full text-left",children:[(0,r.jsx)("thead",{className:"sticky top-0 bg-[var(--color-surface-alt,#fafafa)] border-b",children:(0,r.jsxs)("tr",{className:"font-mono text-[9px]",children:[(0,r.jsx)("th",{className:"p-2",children:"KEY"}),(0,r.jsx)("th",{className:"p-2",children:"AGENT"}),(0,r.jsx)("th",{className:"p-2",children:"PERMISSIONS"}),(0,r.jsx)("th",{className:"p-2",children:"ISSUED"}),(0,r.jsx)("th",{className:"p-2",children:"EXPIRES"}),(0,r.jsx)("th",{className:"p-2",children:"LAST USED"}),(0,r.jsx)("th",{className:"p-2",children:"ACTIONS"})]})}),(0,r.jsx)("tbody",{children:G.map(e=>{var t,a,l,s,o;let n=X(e),i=T===e.key,c="active"===e.status&&!!e.token.tokenHash;return(0,r.jsxs)("tr",{className:"border-b font-mono text-[9px]",children:[(0,r.jsxs)("td",{className:"p-2",children:[(0,r.jsx)("div",{children:eY(null!=(t=e.token.tokenHash)?t:e.key)}),(0,r.jsx)("div",{className:"text-[8px] uppercase ".concat("active"===(s=e.status)?"text-[var(--color-success,#16a34a)]":"revoked"===s?"text-[var(--color-warning,#ff4d00)]":"expired"===s?"text-[var(--color-text-faint,#9ca3af)]":"text-[var(--color-text-muted,#6b7280)]"),children:e.status})]}),(0,r.jsx)("td",{className:"p-2",children:null!=(a=e.token.agentId)?a:"unknown"}),(0,r.jsx)("td",{className:"p-2",children:(o=null!=(l=e.token.permissions)?l:[])&&0!==o.length?o.length<=2?o.join(", "):"".concat(o.slice(0,2).join(", ")," +").concat(o.length-2):"—"}),(0,r.jsx)("td",{className:"p-2",children:eq(e.token.createdAt)}),(0,r.jsxs)("td",{className:"p-2",children:[eq(e.token.expiresAt),(0,r.jsx)("div",{className:"text-[8px] text-[var(--color-text-faint,#9ca3af)]",children:function(e){let t=eG(e);if(null===t)return"—";let a=t-Date.now();if(a<=0)return"expired";let r=Math.floor(a/6e4);if(r<60)return"".concat(r,"m");let l=Math.floor(r/60);return l<24?"".concat(l,"h"):"".concat(Math.floor(l/24),"d")}(e.token.expiresAt)})]}),(0,r.jsx)("td",{className:"p-2",children:n?new Date(n).toLocaleString():"—"}),(0,r.jsx)("td",{className:"p-2",children:(0,r.jsxs)("div",{className:"flex items-center gap-1",children:[(0,r.jsx)("button",{onClick:()=>void ee(e.key,e.token.tokenHash),className:"border px-1.5 py-0.5 text-[8px] disabled:opacity-40",title:"Copy short hash",disabled:!e.token.tokenHash,children:(0,r.jsxs)("span",{className:"inline-flex items-center gap-1",children:[(0,r.jsx)(es.A,{size:8}),O===e.key?"COPIED":"COPY"]})}),(0,r.jsx)("button",{onClick:()=>Z(e.key),className:"border px-1.5 py-0.5 text-[8px]",title:"Open activity",children:"VIEW"}),(0,r.jsx)("button",{onClick:()=>et(e.key,e.token.tokenHash),disabled:!c||i,className:"border px-1.5 py-0.5 text-[8px] disabled:opacity-40 text-[var(--color-warning,#ff4d00)]",title:c?"Revoke token":"Token cannot be revoked",children:i?"REVOKING":"REVOKE"})]})})]},e.key)})})]})})]}),(0,r.jsxs)("div",{ref:P,className:"flex-1 overflow-auto border border-[var(--color-border,#d4d4d8)] bg-[var(--color-surface,#fff)]",children:[(0,r.jsxs)("div",{className:"sticky top-0 z-10 px-2 py-1.5 border-b bg-[var(--color-surface-alt,#fafafa)] font-mono text-[9px] flex items-center justify-between",children:[(0,r.jsxs)("span",{children:["TOKEN ACTIVITY \xb7 ",J.length," ROWS"]}),(0,r.jsxs)("span",{className:"text-[var(--color-text-muted,#6b7280)]",children:["PAGE ",j+1," / ",Math.max(1,Math.ceil(J.length/50))]})]}),n.length>=500&&(0,r.jsx)("div",{className:"font-mono text-[9px] border-b border-[var(--color-warning,#ff4d00)] p-2 text-[var(--color-warning,#ff4d00)]",children:"RESULTS TRUNCATED AT 500 ROWS — NARROW FILTERS TO REDUCE VOLUME."}),0===Q.length?(0,r.jsx)("div",{className:"p-4 font-mono text-[10px] text-[var(--color-text-muted,#6b7280)]",children:"NO AUDIT EVENTS IN WINDOW"}):(0,r.jsxs)("table",{className:"w-full text-left",children:[(0,r.jsx)("thead",{className:"sticky top-[31px] bg-[var(--color-surface-alt,#fafafa)] border-b",children:(0,r.jsxs)("tr",{className:"font-mono text-[9px]",children:[(0,r.jsx)("th",{className:"p-2",children:"TIME"}),(0,r.jsx)("th",{className:"p-2",children:"TOKEN / AGENT"}),(0,r.jsx)("th",{className:"p-2",children:"DECISION"}),(0,r.jsx)("th",{className:"p-2",children:"REASON"}),(0,r.jsx)("th",{className:"p-2",children:"CONFIDENCE"}),(0,r.jsx)("th",{className:"p-2",children:"ENDPOINT"})]})}),(0,r.jsx)("tbody",{children:Q.map(e=>{var t,a;return(0,r.jsxs)("tr",{className:"border-b font-mono text-[9px]",children:[(0,r.jsx)("td",{className:"p-2",children:new Date(e.timestamp).toLocaleString()}),(0,r.jsxs)("td",{className:"p-2",children:[null!=(t=e.agentId)?t:"unknown"," \xb7 ",e.tokenKey.slice(0,10)]}),(0,r.jsx)("td",{className:"p-2",children:e.decision}),(0,r.jsxs)("td",{className:"p-2",children:[e.reasonCode,e.rawReasonCode&&"UNKNOWN"===e.reasonCode?" (".concat(e.rawReasonCode,")"):""]}),(0,r.jsx)("td",{className:"p-2",title:"HIGH"===e.confidence?"Direct token hash match":"MEDIUM"===e.confidence?"Agent correlation":"Partial/ambiguous join",children:e.confidence}),(0,r.jsx)("td",{className:"p-2",children:null!=(a=e.endpoint)?a:"—"})]},e.id)})})]})]}),(0,r.jsxs)("div",{className:"flex items-center justify-end gap-2",children:[(0,r.jsx)("button",{onClick:()=>w(e=>Math.max(0,e-1)),disabled:0===j,className:"font-mono text-[9px] border px-2 py-1 disabled:opacity-40",children:"PREV"}),(0,r.jsx)("button",{onClick:()=>w(e=>(e+1)*50<J.length?e+1:e),disabled:(j+1)*50>=J.length,className:"font-mono text-[9px] border px-2 py-1 disabled:opacity-40",children:"NEXT"})]}),(0,r.jsx)(b.Rw,{isOpen:null!==D,onClose:()=>z(null),onConfirm:()=>void ea(),title:"Revoke Token",message:D?"Revoke token ".concat(eY(D.tokenHash),"? The agent will lose access immediately."):"",confirmText:"REVOKE",variant:"danger"})]})}var eJ=a(7801);let eQ=[{id:"strict",label:"Strict",description:"Agent agent only, read-only, strong field redaction. 15 min TTL."},{id:"dev",label:"Dev (recommended)",description:"All agents, read/write, moderate redaction. 1 hour TTL."},{id:"admin",label:"Admin (dangerous)",description:"Full access, no redaction. Use with caution."}],eZ=[{value:"wallet:list",label:"wallet:list"},{value:"wallet:create:hot",label:"wallet:create:hot"},{value:"wallet:create:temp",label:"wallet:create:temp"},{value:"wallet:rename",label:"wallet:rename"},{value:"wallet:export",label:"wallet:export"},{value:"wallet:tx:add",label:"wallet:tx:add"},{value:"wallet:asset:add",label:"wallet:asset:add"},{value:"wallet:asset:remove",label:"wallet:asset:remove"},{value:"send:hot",label:"send:hot"},{value:"send:temp",label:"send:temp"},{value:"swap",label:"swap"},{value:"fund",label:"fund"},{value:"launch",label:"launch"},{value:"apikey:get",label:"apikey:get"},{value:"apikey:set",label:"apikey:set"},{value:"workspace:modify",label:"workspace:modify"},{value:"strategy:read",label:"strategy:read"},{value:"strategy:manage",label:"strategy:manage"},{value:"app:storage",label:"app:storage"},{value:"app:storage:all",label:"app:storage:all"},{value:"app:accesskey",label:"app:accesskey"},{value:"action:create",label:"action:create"},{value:"action:read",label:"action:read"},{value:"action:resolve",label:"action:resolve"},{value:"adapter:manage",label:"adapter:manage"},{value:"addressbook:write",label:"addressbook:write"},{value:"bookmark:write",label:"bookmark:write"},{value:"secret:read",label:"secret:read"},{value:"secret:write",label:"secret:write"},{value:"totp:read",label:"totp:read"},{value:"trade:all",label:"trade:all"},{value:"wallet:write",label:"wallet:write"},{value:"extension:*",label:"extension:*"},{value:"admin:*",label:"admin:* (dangerous)"}],e0={strict:"Read-only, agent agent only. Hidden: password, cvv, privateKey, seedPhrase, refresh_token. 15 min TTL, 50 reads max.",dev:"Read/write, all agents. Hidden: cvv, seedPhrase, privateKey, refresh_token. 1 hour TTL, 500 reads max.",admin:"Full access, no field redaction. 1 hour TTL, unlimited reads."},e1=[{value:"profile",label:"Profile"},{value:"permissions",label:"Permissions"}],e2="aura:api-keys:profiles:v1",e4={strict:{ttlSeconds:900,maxReads:50,scope:["secret:read"],excludeFields:["password","cvv","privateKey","seedPhrase","refresh_token"]},dev:{ttlSeconds:3600,maxReads:500,scope:["wallet:list","secret:read","secret:write","action:create","action:read","action:resolve"],excludeFields:["cvv","seedPhrase","privateKey","refresh_token"]},admin:{ttlSeconds:3600,scope:["admin:*"],excludeFields:[]}};function e8(e){return e.length<=14?e:"".concat(e.slice(0,8),"...").concat(e.slice(-4))}function e3(){let e=Math.random().toString(36).slice(2,8);return"agent:local:".concat(e)}function e5(e){return Array.from(new Set(e.map(e=>e.trim().normalize("NFKC").toLowerCase()).filter(Boolean)))}let e9=e=>{var t,a,s,o,n;let{requests:i,activeTokens:c,inactiveTokens:d,actionLoading:x,onResolveAction:f,onRevokeToken:m,agents:v=[]}=e,[h,g]=(0,l.useState)([]),[y,j]=(0,l.useState)(null),[w,N]=(0,l.useState)(""),[k,S]=(0,l.useState)("dev"),[E,T]=(0,l.useState)(""),[R,O]=(0,l.useState)(""),[L,D]=(0,l.useState)([]),[z,P]=(0,l.useState)("secret:read"),[F,_]=(0,l.useState)(""),[M,K]=(0,l.useState)([]),[U,H]=(0,l.useState)(null),[W,$]=(0,l.useState)(null),[V,G]=(0,l.useState)(()=>e3()),[Y,q]=(0,l.useState)("profile"),[X,J]=(0,l.useState)("builtin:dev"),[Q,Z]=(0,l.useState)("secret:read"),[ee,et]=(0,l.useState)(["secret:read","secret:write"]),[ea,er]=(0,l.useState)([]),[el,eo]=(0,l.useState)(!1),[en,ei]=(0,l.useState)(null),[ec,ex]=(0,l.useState)(null),[eu,ep]=(0,l.useState)(null),[ef,em]=(0,l.useState)(!1),[ev,eg]=(0,l.useState)(!1),[eb,ey]=(0,l.useState)(null),[ej,ew]=(0,l.useState)(null),[eN,ek]=(0,l.useState)(null);(0,l.useEffect)(()=>{try{let e=localStorage.getItem(e2);if(!e)return;let t=JSON.parse(e);if(!Array.isArray(t))return;let a=t.filter(e=>e&&"string"==typeof e.id&&"string"==typeof e.name&&"string"==typeof e.profile&&"v1"===e.profileVersion&&"number"==typeof e.updatedAt).map(e=>{var t,a,r;let l=e5([...(null==(t=e.overrides)?void 0:t.scope)||[],...(null==(a=e.overrides)?void 0:a.readScopes)||[],...(null==(r=e.overrides)?void 0:r.writeScopes)||[]]),s=e.overrides?{...e.overrides,...l.length>0?{scope:l}:{},readScopes:void 0,writeScopes:void 0}:null;return{...e,overrides:s}});g(a)}catch(e){g([])}},[]),(0,l.useEffect)(()=>{localStorage.setItem(e2,JSON.stringify(h))},[h]);let eC=(0,l.useCallback)(()=>{j(null),N(""),S("dev"),T(""),O(""),D([]),P("secret:read"),_(""),K([]),H(null),$(null)},[]),eS=(0,l.useCallback)(e=>{let t=e4[e];t&&(T(String(t.ttlSeconds)),O("number"==typeof t.maxReads?String(t.maxReads):""),D(t.scope),P(t.scope[0]||"secret:read"),_(t.excludeFields.join(", ")))},[]),eA=(0,l.useMemo)(()=>{let e=[{value:"agent:*",label:"All Agents (agent:*)"}];for(let t of v){let a=t.name||t.id;e.push({value:"agent:".concat(t.id),label:"agent:".concat(a)})}return e},[v]),eE=(0,l.useMemo)(()=>i.filter(e=>"pending"===e.status&&("auth"===e.type||"permission_update"===e.type)),[i]),eI=(0,l.useMemo)(()=>[...eQ.map(e=>({value:"builtin:".concat(e.id),label:"".concat(e.label," — ").concat(e.description)})),...h.map(e=>({value:"draft:".concat(e.id),label:"Custom \xb7 ".concat(e.name)}))],[h]);(0,l.useEffect)(()=>{eI.some(e=>e.value===X)||J("builtin:dev")},[X,eI]);let eT=(0,l.useCallback)(()=>{if(X.startsWith("draft:")){let r=X.slice(6),l=h.find(e=>e.id===r);if(l){var e,t,a;let r=e5([...(null==(e=l.overrides)?void 0:e.scope)||[],...(null==(t=l.overrides)?void 0:t.readScopes)||[],...(null==(a=l.overrides)?void 0:a.writeScopes)||[]]),s=l.overrides?{...l.overrides,...r.length>0?{scope:r}:{}}:void 0;return{profile:l.profile,profileVersion:l.profileVersion,...s?{profileOverrides:s}:{}}}}return{profile:X.startsWith("builtin:")?X.slice(8):"dev",profileVersion:"v1"}},[X,h]),eR=(0,l.useCallback)(e=>{let t=e5([e])[0];t&&et(e=>e.includes(t)?e:[...e,t])},[]),eO=(0,l.useCallback)(e=>{et(t=>t.filter(t=>t!==e))},[]),eL=(0,l.useCallback)(()=>{H(null),$(null);let e=w.trim();if(!e)return void H("Profile name is required.");let{overrides:t,error:a}=function(e){let t={};if(e.ttlSeconds.trim().length>0){let a=Number(e.ttlSeconds.trim());if(!Number.isFinite(a)||a<=0)return{overrides:null,error:"TTL override must be a positive number."};t.ttlSeconds=a}if(e.maxReads.trim().length>0){let a=Number(e.maxReads.trim());if(!Number.isFinite(a)||a<=0)return{overrides:null,error:"Max reads override must be a positive number."};t.maxReads=a}let a=e5(e.scope),r=function(e){let t=e.split(",").map(e=>e.trim()).filter(Boolean);return t.length>0?t:void 0}(e.excludeFields);return a.length>0&&(t.scope=a),r&&(t.excludeFields=r),{overrides:Object.keys(t).length>0?t:null,error:null}}({ttlSeconds:E,maxReads:R,scope:L,excludeFields:F});if(a)return void H(a);let r=M.length>0?{...t||{},readScopes:M,writeScopes:M}:t;if(h.some(t=>t.name.toLowerCase()===e.toLowerCase()&&t.id!==y))return void H("A profile with this name already exists.");let l={id:y||"".concat(Date.now().toString(36),"-").concat(Math.random().toString(36).slice(2,7)),name:e,profile:k,profileVersion:"v1",overrides:r,updatedAt:Date.now()};g(e=>y?e.map(e=>e.id===y?l:e):[l,...e]),$(y?"Profile updated.":"Profile created."),y||J("draft:".concat(l.id)),j(l.id)},[y,k,F,R,w,L,E,M,h]),ez=(0,l.useCallback)(e=>{var t,a,r,l,s,o,n,i;j(e.id),N(e.name),S(e.profile),T((null==(t=e.overrides)?void 0:t.ttlSeconds)?String(e.overrides.ttlSeconds):""),O((null==(a=e.overrides)?void 0:a.maxReads)?String(e.overrides.maxReads):"");let c=e5([...(null==(r=e.overrides)?void 0:r.scope)||[],...(null==(l=e.overrides)?void 0:l.readScopes)||[],...(null==(s=e.overrides)?void 0:s.writeScopes)||[]]);D(c),P(c[0]||"secret:read"),_(((null==(o=e.overrides)?void 0:o.excludeFields)||[]).join(", ")),K((null==(n=e.overrides)?void 0:n.readScopes)||(null==(i=e.overrides)?void 0:i.agentReadScopes)||[]),H(null),$(null)},[]),eP=(0,l.useCallback)(e=>{let t=e5([e])[0];t&&D(e=>e.includes(t)?e:[...e,t])},[]),eF=(0,l.useCallback)(e=>{D(t=>t.filter(t=>t!==e))},[]),e_=(0,l.useCallback)(e=>{g(t=>t.filter(t=>t.id!==e)),y===e&&eC(),X==="draft:".concat(e)&&J("builtin:dev")},[y,X,eC]),eM=(0,l.useCallback)(async()=>{if(ey(null),ew(null),"permissions"===Y)return void ey("Policy preview is currently available for profile-based issuance only.");eg(!0);try{let e=eT(),t=await u.FH.post(u.jI.Wallet,"/actions/token/preview",e);ew(function(e){let t=e&&"object"==typeof e?e:{},a=t.effectivePolicy&&"object"==typeof t.effectivePolicy?t.effectivePolicy:{},r=a.credentialAccess&&"object"==typeof a.credentialAccess?a.credentialAccess:{},l=a.rateBudget&&"object"==typeof a.rateBudget?a.rateBudget:{};return{version:"v1",profile:t.profile&&"object"==typeof t.profile?t.profile:void 0,effectivePolicy:{permissions:Array.isArray(a.permissions)?a.permissions.filter(e=>"string"==typeof e):[],credentialAccess:{read:Array.isArray(r.read)?r.read.filter(e=>"string"==typeof e):[],write:Array.isArray(r.write)?r.write.filter(e=>"string"==typeof e):[],excludeFields:Array.isArray(r.excludeFields)?r.excludeFields.filter(e=>"string"==typeof e):[],maxReads:"number"==typeof r.maxReads?r.maxReads:null},ttlSeconds:"number"==typeof a.ttlSeconds?a.ttlSeconds:0,maxReads:"number"==typeof a.maxReads?a.maxReads:null,rateBudget:{state:"inherited"===l.state||"explicit"===l.state?l.state:"none",requests:"number"==typeof l.requests?l.requests:null,windowSeconds:"number"==typeof l.windowSeconds?l.windowSeconds:null,source:"profile"===l.source||"override"===l.source?l.source:"none"}},warnings:Array.isArray(t.warnings)?t.warnings.filter(e=>"string"==typeof e):[],overrideDelta:Array.isArray(t.overrideDelta)?t.overrideDelta.filter(e=>"string"==typeof e):[],denyExamples:Array.isArray(t.denyExamples)?t.denyExamples.filter(e=>!!e&&"object"==typeof e).map(e=>({code:String(e.code||"UNKNOWN"),message:String(e.message||"")})):[],effectivePolicyHash:"string"==typeof t.effectivePolicyHash?t.effectivePolicyHash:"n/a"}}(t))}catch(e){ey(e instanceof Error?e.message:"Failed to preview profile policy.")}finally{eg(!1)}},[Y,eT]),eK=(0,l.useCallback)(async()=>{if(ei(null),ex(null),ep(null),!V.trim())return void ei("Agent ID is required.");if("permissions"===Y&&0===ee.length)return void ei("Select at least one permission for manual issuance.");let e=(0,p.ji)();if(!e)return void ei("Agent keypair is unavailable. Re-unlock and retry.");eo(!0);try{var t,a;let r;if("permissions"===Y){let t=ea.length>0?{read:ea,write:ea}:void 0;r=await u.FH.post(u.jI.Wallet,"/actions/token",{agentId:V.trim(),pubkey:e,permissions:ee,...t?{credentialAccess:t}:{}})}else{let t=eT();ea.length>0&&(t.profileOverrides={...t.profileOverrides||{},readScopes:ea,writeScopes:ea}),r=await u.FH.post(u.jI.Wallet,"/actions/token",{agentId:V.trim(),pubkey:e,...t})}if(!r.success||!r.encryptedToken)throw Error("Token issuance failed.");let l=await (0,p.DC)(r.encryptedToken);if(ex(l),"permissions"===Y)ep("".concat(V.trim()," \xb7 permissions:").concat(ee.join(",")).concat((null==(t=r.warnings)?void 0:t.length)?" \xb7 warnings present":""));else{let e=eT();ep("".concat(V.trim()," \xb7 ").concat(e.profile,"@").concat(e.profileVersion).concat((null==(a=r.warnings)?void 0:a.length)?" \xb7 warnings present":""))}}catch(e){ei(e instanceof Error?e.message:"Token issuance failed.")}finally{eo(!1)}},[V,Y,ee,ea,eT]),eU=(0,l.useCallback)(async()=>{ec&&navigator.clipboard&&(await navigator.clipboard.writeText(ec),em(!0),setTimeout(()=>em(!1),1500))},[ec]),eH=(0,l.useCallback)(async(e,t)=>{let a=await f(e,t);if(a.success)return void ek(t?"Approved request ".concat(e.slice(0,8),"."):"Rejected request ".concat(e.slice(0,8),"."));ek(a.message||"Failed to resolve request.")},[f]),eW=(0,l.useMemo)(()=>c.filter(e=>!e.isAdmin),[c]);return(0,r.jsxs)("div",{className:"h-full overflow-y-auto px-5 py-4 font-mono",children:[(0,r.jsxs)("div",{className:"mb-4 border border-[var(--color-border,#d4d4d8)] bg-[var(--color-surface,#fff)] p-3",children:[(0,r.jsx)("div",{className:"text-[10px] font-bold tracking-widest text-[var(--color-text,#0a0a0a)]",children:"API KEYS"}),(0,r.jsx)("div",{className:"mt-1 text-[9px] text-[var(--color-text-muted,#6b7280)] leading-relaxed",children:"Auth management surface for profile templates + permissions-based issuance + pending auth approvals."})]}),(0,r.jsxs)("div",{className:"grid grid-cols-1 gap-4 xl:grid-cols-2",children:[(0,r.jsxs)("section",{className:"order-1 border border-[var(--color-border,#d4d4d8)] bg-[var(--color-surface,#fff)] p-3",children:[(0,r.jsx)("div",{className:"mb-2 text-[10px] font-bold tracking-widest text-[var(--color-text,#0a0a0a)]",children:"ISSUE API KEY"}),(0,r.jsxs)("div",{className:"grid grid-cols-1 gap-2 md:grid-cols-2",children:[(0,r.jsxs)("div",{className:"grid grid-cols-[minmax(0,1fr)_auto] items-end gap-1.5",children:[(0,r.jsx)(b.ks,{label:"Agent ID",value:V,onChange:e=>G(e.target.value),placeholder:"agent:local:dev",compact:!0}),(0,r.jsx)(b.$n,{variant:"secondary",size:"sm",onClick:()=>G(e3()),icon:(0,r.jsx)(C.A,{size:10}),title:"Regenerate Agent ID",className:"mb-[1px]",children:"NEW ID"})]}),(0,r.jsx)(b.UM,{label:"Issuance Mode",options:e1,value:Y,onChange:e=>q(e),compact:!0})]}),"profile"===Y?(0,r.jsxs)("div",{className:"mt-2",children:[(0,r.jsx)(b.UM,{label:"Profile Source",options:eI,value:X,onChange:J,compact:!0}),(()=>{let e=X.startsWith("builtin:")?X.slice(8):null,t=e?e0[e]:null;return t?(0,r.jsx)("div",{className:"mt-1 px-1 text-[8px] text-[var(--color-text-muted,#6b7280)]",children:t}):(0,r.jsx)("div",{className:"mt-1 px-1 text-[8px] text-[var(--color-text-faint,#9ca3af)]",children:"Profile mode resolves permissions/scopes/ttl from the selected profile."})})()]}):(0,r.jsxs)("div",{className:"mt-2 space-y-1",children:[(0,r.jsxs)("div",{className:"grid grid-cols-[minmax(0,1fr)_auto] items-end gap-1.5",children:[(0,r.jsx)(b.UM,{label:"Permissions",options:eZ.map(e=>({value:e.value,label:e.label})),value:Q,onChange:Z,compact:!0}),(0,r.jsx)(b.$n,{variant:"secondary",size:"sm",onClick:()=>eR(Q),children:"ADD"})]}),0===ee.length?(0,r.jsx)("div",{className:"px-1 text-[8px] text-[var(--color-danger,#ef4444)]",children:"No permissions selected."}):(0,r.jsx)("div",{className:"flex flex-wrap gap-1",children:ee.map(e=>(0,r.jsxs)("span",{className:"inline-flex items-center gap-1 border border-[var(--color-border,#d4d4d8)] bg-[var(--color-background,#f4f4f5)] px-1.5 py-0.5 text-[8px] text-[var(--color-text,#0a0a0a)]",children:[e,(0,r.jsx)(b.$n,{variant:"ghost",size:"sm",onClick:()=>eO(e),className:"h-4 px-1 text-[8px]",children:"X"})]},"perm-".concat(e)))}),(0,r.jsx)("div",{className:"px-1 text-[8px] text-[var(--color-text-faint,#9ca3af)]",children:"Permissions mode issues exactly the selected permissions."})]}),eA.length>1&&(0,r.jsxs)("div",{className:"mt-2 space-y-1",children:[(0,r.jsxs)("div",{className:"grid grid-cols-[minmax(0,1fr)_auto] items-end gap-1.5",children:[(0,r.jsx)(b.UM,{label:"Agent Scope",options:eA,value:(null==(t=eA[0])?void 0:t.value)||"agent:*",onChange:e=>{ea.includes(e)||er(t=>[...t,e])},compact:!0}),(0,r.jsx)(b.$n,{variant:"secondary",size:"sm",onClick:()=>er([]),children:"CLEAR"})]}),0===ea.length?(0,r.jsx)("div",{className:"px-1 text-[8px] text-[var(--color-text-faint,#9ca3af)]",children:"No agent restriction — uses profile/system defaults."}):(0,r.jsx)("div",{className:"flex flex-wrap gap-1",children:ea.map(e=>(0,r.jsxs)("span",{className:"inline-flex items-center gap-1 border border-[var(--color-border,#d4d4d8)] bg-[var(--color-background,#f4f4f5)] px-1.5 py-0.5 text-[8px] text-[var(--color-text,#0a0a0a)]",children:[e,(0,r.jsx)(b.$n,{variant:"ghost",size:"sm",onClick:()=>er(t=>t.filter(t=>t!==e)),className:"h-4 px-1 text-[8px]",children:"X"})]},"vs-".concat(e)))})]}),(0,r.jsx)("div",{className:"mt-2 rounded border border-[var(--color-border,#d4d4d8)] bg-[var(--color-background,#f4f4f5)] px-2 py-2 text-[9px] text-[var(--color-text-muted,#6b7280)]",children:"Generate a key in one click. Preview is optional and only shows what permissions/scopes will be issued."}),en&&(0,r.jsx)("div",{className:"mt-2 text-[9px] text-[var(--color-danger,#ef4444)]",children:en}),(0,r.jsxs)("div",{className:"mt-3 flex flex-wrap gap-2",children:[(0,r.jsx)(b.$n,{size:"sm",onClick:()=>{eK()},loading:el,icon:el?void 0:(0,r.jsx)(B.A,{size:11}),children:"ISSUE API KEY"}),(0,r.jsx)(b.$n,{size:"sm",variant:"secondary",onClick:()=>{eM()},loading:ev,disabled:"permissions"===Y,icon:ev?void 0:(0,r.jsx)(C.A,{size:11}),children:"PREVIEW POLICY"})]}),eb&&(0,r.jsx)("div",{className:"mt-2 text-[9px] text-[var(--color-danger,#ef4444)]",children:eb}),ej&&(0,r.jsxs)("div",{className:"mt-3 rounded border border-[var(--color-border,#d4d4d8)] bg-[var(--color-background,#f4f4f5)] p-2",children:[(0,r.jsxs)("div",{className:"text-[8px] tracking-widest text-[var(--color-text-faint,#9ca3af)]",children:["HASH ",e8(ej.effectivePolicyHash)]}),ej.profile&&(0,r.jsxs)("div",{className:"mt-1 text-[8px] text-[var(--color-text-faint,#9ca3af)]",children:["profile: ",ej.profile.id,"@",ej.profile.version]}),(0,r.jsxs)("div",{className:"mt-1 text-[9px] text-[var(--color-text-muted,#6b7280)]",children:["permissions: ",ej.effectivePolicy.permissions.length," \xb7 ttl: ",ej.effectivePolicy.ttlSeconds,"s \xb7 max reads: ",null!=(s=ej.effectivePolicy.maxReads)?s:"unlimited"]}),(0,r.jsxs)("div",{className:"mt-2 grid grid-cols-1 gap-1 text-[8px] text-[var(--color-text-muted,#6b7280)]",children:[(0,r.jsxs)("div",{children:["perms: ",ej.effectivePolicy.permissions.join(", ")||"(none)"]}),(0,r.jsxs)("div",{children:["read scope: ",ej.effectivePolicy.credentialAccess.read.join(", ")||"(none)"]}),(0,r.jsxs)("div",{children:["write scope: ",ej.effectivePolicy.credentialAccess.write.join(", ")||"(none)"]}),(0,r.jsxs)("div",{children:["excluded fields: ",ej.effectivePolicy.credentialAccess.excludeFields.join(", ")||"(none)"]}),(0,r.jsxs)("div",{children:["rate budget: ",ej.effectivePolicy.rateBudget.state," (",null!=(o=ej.effectivePolicy.rateBudget.requests)?o:"n/a"," / ",null!=(n=ej.effectivePolicy.rateBudget.windowSeconds)?n:"n/a","s, source=",ej.effectivePolicy.rateBudget.source,")"]})]}),ej.overrideDelta.length>0&&(0,r.jsxs)("div",{className:"mt-2 rounded border border-[var(--color-border,#d4d4d8)] bg-[var(--color-surface,#fff)] p-1.5 text-[8px] text-[var(--color-text-muted,#6b7280)]",children:[(0,r.jsx)("div",{className:"mb-1 tracking-widest text-[var(--color-text-faint,#9ca3af)]",children:"OVERRIDE DELTA"}),ej.overrideDelta.join(" \xb7 ")]}),ej.denyExamples&&ej.denyExamples.length>0&&(0,r.jsxs)("div",{className:"mt-2 rounded border border-[var(--color-border,#d4d4d8)] bg-[var(--color-surface,#fff)] p-1.5 text-[8px] text-[var(--color-text-muted,#6b7280)]",children:[(0,r.jsx)("div",{className:"mb-1 tracking-widest text-[var(--color-text-faint,#9ca3af)]",children:"EXPECTED DENY EXAMPLES"}),(0,r.jsx)("ul",{className:"space-y-0.5",children:ej.denyExamples.map(e=>(0,r.jsxs)("li",{children:["• ",e.code,": ",e.message]},"".concat(e.code,"-").concat(e.message.slice(0,12))))})]}),ej.warnings.length>0&&(0,r.jsxs)("div",{className:"mt-2 flex items-start gap-1.5 text-[8px] text-[var(--color-warning,#ff4d00)]",children:[(0,r.jsx)(eJ.A,{size:10,className:"mt-[1px]"}),(0,r.jsx)("span",{children:ej.warnings.join(" | ")})]})]}),ec&&(0,r.jsxs)("div",{className:"mt-3 rounded border border-[var(--color-border,#d4d4d8)] bg-[var(--color-surface,#fff)] p-2",children:[(0,r.jsxs)("div",{className:"mb-1 flex items-center justify-between",children:[(0,r.jsx)("div",{className:"text-[8px] tracking-widest text-[var(--color-success,#16a34a)]",children:"API KEY ISSUED"}),(0,r.jsx)(b.$n,{variant:"ghost",size:"sm",onClick:()=>{eU()},icon:(0,r.jsx)(es.A,{size:10}),children:ef?"COPIED":"COPY"})]}),eu&&(0,r.jsx)("div",{className:"mb-1 text-[8px] text-[var(--color-text-faint,#9ca3af)]",children:eu}),(0,r.jsx)("code",{className:"block max-h-20 overflow-y-auto break-all bg-[var(--color-background,#f4f4f5)] px-2 py-1 text-[9px] text-[var(--color-text,#0a0a0a)]",children:ec})]})]}),(0,r.jsxs)("section",{className:"order-2 border border-[var(--color-border,#d4d4d8)] bg-[var(--color-surface,#fff)] p-3",children:[(0,r.jsxs)("div",{className:"mb-2 flex items-center justify-between",children:[(0,r.jsx)("div",{className:"text-[10px] font-bold tracking-widest text-[var(--color-text,#0a0a0a)]",children:"PROFILE BUILDER"}),y&&(0,r.jsx)(b.$n,{variant:"ghost",size:"sm",onClick:eC,children:"NEW"})]}),(0,r.jsxs)("div",{className:"grid grid-cols-1 gap-2",children:[(0,r.jsx)(b.ks,{label:"Profile Name",value:w,onChange:e=>N(e.target.value),placeholder:"e.g. CI deploy scoped",compact:!0}),(0,r.jsx)(b.UM,{label:"Load from template",options:eQ.map(e=>({value:e.id,label:"".concat(e.label," — ").concat(e.description)})),value:k,onChange:e=>{S(e),eS(e)},compact:!0}),k&&e0[k]&&(0,r.jsx)("div",{className:"px-1 text-[8px] text-[var(--color-text-muted,#6b7280)]",children:e0[k]}),(0,r.jsxs)("div",{className:"grid grid-cols-2 gap-2",children:[(0,r.jsx)(b.ks,{label:"TTL Override",value:E,onChange:e=>T(e.target.value),placeholder:"seconds",compact:!0}),(0,r.jsx)(b.ks,{label:"Max Reads",value:R,onChange:e=>O(e.target.value),placeholder:"count",compact:!0})]}),(0,r.jsxs)("div",{className:"space-y-1",children:[(0,r.jsxs)("div",{className:"grid grid-cols-[minmax(0,1fr)_auto] items-end gap-1.5",children:[(0,r.jsx)(b.UM,{label:"Scope",options:eZ.map(e=>({value:e.value,label:e.label})),value:z,onChange:P,compact:!0}),(0,r.jsx)(b.$n,{variant:"secondary",size:"sm",onClick:()=>eP(z),children:"ADD"})]}),0===L.length?(0,r.jsx)("div",{className:"px-1 text-[8px] text-[var(--color-text-faint,#9ca3af)]",children:"Using base profile scope defaults."}):(0,r.jsx)("div",{className:"flex flex-wrap gap-1",children:L.map(e=>(0,r.jsxs)("span",{className:"inline-flex items-center gap-1 border border-[var(--color-border,#d4d4d8)] bg-[var(--color-background,#f4f4f5)] px-1.5 py-0.5 text-[8px] text-[var(--color-text,#0a0a0a)]",children:[e,(0,r.jsx)(b.$n,{variant:"ghost",size:"sm",onClick:()=>eF(e),className:"h-4 px-1 text-[8px]",children:"X"})]},"scope-".concat(e)))})]}),(0,r.jsxs)("div",{className:"px-1 text-[8px] text-[var(--color-text-faint,#9ca3af)]",children:["Scope uses the same permission vocabulary as Issue API Key (for example: ",(0,r.jsx)("code",{children:"secret:read"}),", ",(0,r.jsx)("code",{children:"secret:write"}),", ",(0,r.jsx)("code",{children:"wallet:create:hot"}),", ",(0,r.jsx)("code",{children:"send:hot"}),")."]}),(0,r.jsx)(b.ks,{label:"Exclude Fields (CSV)",value:F,onChange:e=>_(e.target.value),placeholder:"password, seedPhrase",compact:!0}),eA.length>1&&(0,r.jsxs)("div",{className:"space-y-1",children:[(0,r.jsxs)("div",{className:"grid grid-cols-[minmax(0,1fr)_auto] items-end gap-1.5",children:[(0,r.jsx)(b.UM,{label:"Agent Read/Write Scope",options:eA,value:(null==(a=eA[0])?void 0:a.value)||"agent:*",onChange:e=>{M.includes(e)||K(t=>[...t,e])},compact:!0}),(0,r.jsx)(b.$n,{variant:"secondary",size:"sm",onClick:()=>K([]),children:"CLEAR"})]}),0===M.length?(0,r.jsx)("div",{className:"px-1 text-[8px] text-[var(--color-text-faint,#9ca3af)]",children:"Using base profile agent defaults."}):(0,r.jsx)("div",{className:"flex flex-wrap gap-1",children:M.map(e=>(0,r.jsxs)("span",{className:"inline-flex items-center gap-1 border border-[var(--color-border,#d4d4d8)] bg-[var(--color-background,#f4f4f5)] px-1.5 py-0.5 text-[8px] text-[var(--color-text,#0a0a0a)]",children:[e,(0,r.jsx)(b.$n,{variant:"ghost",size:"sm",onClick:()=>K(t=>t.filter(t=>t!==e)),className:"h-4 px-1 text-[8px]",children:"X"})]},"pvs-".concat(e)))}),(0,r.jsx)("div",{className:"px-1 text-[8px] text-[var(--color-text-faint,#9ca3af)]",children:"Restricts which agents this profile can read/write credentials from. Select specific agents or leave empty for profile defaults."})]})]}),U&&(0,r.jsx)("div",{className:"mt-2 text-[9px] text-[var(--color-danger,#ef4444)]",children:U}),W&&(0,r.jsx)("div",{className:"mt-2 text-[9px] text-[var(--color-success,#16a34a)]",children:W}),(0,r.jsxs)("div",{className:"mt-3 flex gap-2",children:[(0,r.jsx)(b.$n,{size:"sm",onClick:eL,icon:(0,r.jsx)(A.A,{size:11}),children:y?"UPDATE PROFILE":"CREATE PROFILE"}),y&&(0,r.jsx)(b.$n,{variant:"secondary",size:"sm",onClick:eC,children:"CANCEL"})]}),(0,r.jsxs)("div",{className:"mt-4 border-t border-[var(--color-border,#d4d4d8)] pt-3",children:[(0,r.jsxs)("div",{className:"mb-2 text-[9px] font-bold tracking-widest text-[var(--color-text-muted,#6b7280)]",children:["SAVED PROFILES (",h.length,")"]}),0===h.length?(0,r.jsx)("div",{className:"text-[9px] text-[var(--color-text-faint,#9ca3af)]",children:"No custom profiles saved yet."}):(0,r.jsx)("div",{className:"space-y-2",children:h.map(e=>(0,r.jsxs)("div",{className:"flex items-center justify-between border border-[var(--color-border,#d4d4d8)] bg-[var(--color-background,#f4f4f5)] px-2 py-1.5",children:[(0,r.jsx)(b.$n,{variant:"ghost",size:"sm",onClick:()=>ez(e),className:"h-auto min-h-0 w-full justify-start px-0 py-0 text-left hover:bg-transparent",children:(0,r.jsxs)("span",{className:"block",children:[(0,r.jsx)("span",{className:"block text-[10px] text-[var(--color-text,#0a0a0a)]",children:e.name}),(0,r.jsxs)("span",{className:"block text-[8px] text-[var(--color-text-faint,#9ca3af)]",children:[e.profile,"@",e.profileVersion]})]})}),(0,r.jsx)(b.$n,{variant:"ghost",size:"sm",onClick:()=>e_(e.id),icon:(0,r.jsx)(I.A,{size:10}),children:""})]},e.id))})]})]})]}),(0,r.jsxs)("div",{className:"mt-4 grid grid-cols-1 gap-4 xl:grid-cols-2",children:[(0,r.jsxs)("section",{className:"border border-[var(--color-border,#d4d4d8)] bg-[var(--color-surface,#fff)] p-3",children:[(0,r.jsx)("div",{className:"mb-2 text-[10px] font-bold tracking-widest text-[var(--color-text,#0a0a0a)]",children:"PENDING AUTH REQUESTS"}),eN&&(0,r.jsx)("div",{className:"mb-2 text-[9px] text-[var(--color-text-muted,#6b7280)]",children:eN}),0===eE.length?(0,r.jsx)("div",{className:"text-[9px] text-[var(--color-text-faint,#9ca3af)]",children:"No pending auth requests."}):(0,r.jsx)("div",{className:"space-y-2",children:eE.map(e=>{let t=function(e){if(!e)return{};try{let t=JSON.parse(e);if(t&&"object"==typeof t)return t;return{}}catch(e){return{}}}(e.metadata),a="string"==typeof t.agentId?t.agentId:"unknown-agent",l="object"==typeof t.profile&&t.profile&&"id"in t.profile?t.profile:null,s=l?"".concat(String(l.id),"@").concat(String(l.version||"v1")):"n/a",o=l?function(e){return e0[e]||"Custom profile: ".concat(e)}(String(l.id)):null,n=Array.isArray(t.permissions)?t.permissions:[],i=x==="resolve-".concat(e.id);return(0,r.jsxs)("div",{className:"rounded border border-[var(--color-border,#d4d4d8)] bg-[var(--color-background,#f4f4f5)] p-2",children:[(0,r.jsxs)("div",{className:"text-[9px] text-[var(--color-text,#0a0a0a)]",children:[a," \xb7 ",e.type]}),(0,r.jsxs)("div",{className:"mt-1 text-[8px] text-[var(--color-text-faint,#9ca3af)]",children:[s," \xb7 ",new Date(e.createdAt).toLocaleString()]}),o&&(0,r.jsx)("div",{className:"mt-1 text-[8px] text-[var(--color-text-muted,#6b7280)]",children:o}),n.length>0&&(0,r.jsxs)("div",{className:"mt-1 flex flex-wrap gap-1",children:[n.slice(0,6).map(e=>(0,r.jsx)("span",{className:"border border-[var(--color-border,#d4d4d8)] px-1 py-0.5 text-[7px] text-[var(--color-text-muted,#6b7280)]",children:String(e)},e)),n.length>6&&(0,r.jsxs)("span",{className:"px-1 py-0.5 text-[7px] text-[var(--color-text-faint,#9ca3af)]",children:["+",n.length-6," more"]})]}),(0,r.jsxs)("div",{className:"mt-2 flex gap-2",children:[(0,r.jsx)(b.$n,{size:"sm",onClick:()=>{eH(e.id,!0)},loading:i,icon:i?void 0:(0,r.jsx)(eh.A,{size:10}),children:"APPROVE"}),(0,r.jsx)(b.$n,{size:"sm",variant:"secondary",onClick:()=>{eH(e.id,!1)},disabled:i,icon:(0,r.jsx)(eD.A,{size:10}),children:"REJECT"})]})]},e.id)})})]}),(0,r.jsxs)("section",{className:"border border-[var(--color-border,#d4d4d8)] bg-[var(--color-surface,#fff)] p-3",children:[(0,r.jsx)("div",{className:"mb-2 text-[10px] font-bold tracking-widest text-[var(--color-text,#0a0a0a)]",children:"ISSUED API KEYS"}),(0,r.jsxs)("div",{className:"mb-2 text-[8px] tracking-widest text-[var(--color-text-faint,#9ca3af)]",children:["ACTIVE (",eW.length,")"]}),0===eW.length?(0,r.jsx)("div",{className:"mb-3 text-[9px] text-[var(--color-text-faint,#9ca3af)]",children:"No active non-admin tokens."}):(0,r.jsx)("div",{className:"mb-3 space-y-2",children:eW.map(e=>{let t=x==="revoke-".concat(e.tokenHash);return(0,r.jsxs)("div",{className:"rounded border border-[var(--color-border,#d4d4d8)] bg-[var(--color-background,#f4f4f5)] p-2",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between",children:[(0,r.jsx)("div",{className:"text-[9px] text-[var(--color-text,#0a0a0a)]",children:e.agentId}),(0,r.jsx)("div",{className:"text-[8px] text-[var(--color-text-faint,#9ca3af)]",children:e8(e.tokenHash)})]}),(0,r.jsxs)("div",{className:"mt-1 text-[8px] text-[var(--color-text-faint,#9ca3af)]",children:["perms: ",e.permissions.length," \xb7 expires: ",new Date(e.expiresAt).toLocaleString()]}),(0,r.jsx)("div",{className:"mt-2",children:(0,r.jsx)(b.$n,{size:"sm",variant:"secondary",onClick:()=>{m(e.tokenHash)},disabled:t,icon:t?(0,r.jsx)(ed.A,{size:10,className:"animate-spin"}):(0,r.jsx)(I.A,{size:10}),children:"REVOKE"})})]},e.tokenHash)})}),(0,r.jsxs)("div",{className:"mb-2 text-[8px] tracking-widest text-[var(--color-text-faint,#9ca3af)]",children:["INACTIVE (",d.length,")"]}),0===d.length?(0,r.jsx)("div",{className:"text-[9px] text-[var(--color-text-faint,#9ca3af)]",children:"No inactive tokens."}):(0,r.jsxs)("div",{className:"space-y-1.5",children:[d.slice(0,8).map(e=>(0,r.jsxs)("div",{className:"flex items-center justify-between rounded border border-[var(--color-border,#d4d4d8)] px-2 py-1 text-[8px] text-[var(--color-text-muted,#6b7280)]",children:[(0,r.jsx)("span",{children:e.agentId}),(0,r.jsx)("span",{children:e8(e.tokenHash)})]},"".concat(e.agentId,"-").concat(e.tokenHash))),d.length>8&&(0,r.jsxs)("div",{className:"text-[8px] text-[var(--color-text-faint,#9ca3af)]",children:["+",d.length-8," more inactive tokens"]})]})]})]})]})};var e6=a(6673),e7=a(5144);let te={agentId:null,category:"all",tag:null,search:"",favoritesOnly:!1,lifecycle:"active"},tt=[{value:"linked",label:"Child (inherits parent unlock)"},{value:"independent",label:"Independent (separate password)"}],ta="auramaxx_recently_accessed_credentials",tr="auramaxx_credentials_latest_access_at",tl=["username","url","content","key","value","cardholder","brand","last4","token_endpoint","scopes","fingerprint"],ts={active:"active",archive:"archive",archived:"archive",deleted:"recently_deleted",recently_deleted:"recently_deleted",recentlydeleted:"recently_deleted"},to=(()=>{let e=new Map;for(let t of Object.values(g.Rn))for(let a of t)for(let t of(e.set(a.key.toLowerCase(),a.key),a.aliases||[]))e.set(t.toLowerCase(),a.key);return e})(),tn=(()=>{let e=[...tl,...Array.from(to.values())],t=new Set,a=[];for(let r of e){let e=r.toLowerCase();t.has(e)||(t.add(e),a.push(r))}return a.slice(0,8)})();function ti(e){return e<768?"mobile":e<1280?"tablet":"desktop"}function tc(e){return e.location?e.location:e.deletedAt?"recently_deleted":e.archivedAt?"archive":"active"}function td(e){let t=e.createdAt?Date.parse(e.createdAt):NaN;return Number.isFinite(t)?t:0}function tx(e,t){let a=t[e.id];return"number"==typeof a&&Number.isFinite(a)&&a>0?a:td(e)}function tu(e,t){let a={};for(let r of e){let e=t[r.id];if("number"==typeof e&&Number.isFinite(e)&&e>0){a[r.id]=e;continue}a[r.id]=td(r)}return a}function tp(e){return e.trim().toLowerCase()}function tf(e){return null==e?"":"string"==typeof e||"number"==typeof e||"boolean"==typeof e?String(e).toLowerCase():Array.isArray(e)?e.map(tf).join(" "):"object"==typeof e?Object.values(e).map(tf).join(" "):""}function tm(e){let t=e.trim().toLowerCase().replace(/\s+/g,"_");return to.get(t)||t}let tv=e=>{let{onLock:t,onSettings:a}=e,{subscribe:s}=(0,ez.h)(),[o,n]=(0,l.useState)([]),[i,c]=(0,l.useState)([]),[d,p]=(0,l.useState)(null),[g,y]=(0,l.useState)(te),[j,w]=(0,l.useState)(!0),[N,k]=(0,l.useState)("credentials"),[C,S]=(0,l.useState)({}),[A,E]=(0,l.useState)({}),[I,T]=(0,l.useState)(!1),[R,O]=(0,l.useState)(!1),[L,D]=(0,l.useState)(()=>ti(window.innerWidth)),{clearToken:z,setToken:P}=(0,x.A)(),[F,_]=(0,l.useState)(!1),[M,K]=(0,l.useState)(!1),[U,H]=(0,l.useState)(!1),[W,B]=(0,l.useState)("api-key-form"),[V,G]=(0,l.useState)(null),[Y,q]=(0,l.useState)(null),[X,Q]=(0,l.useState)(!1),[Z,ee]=(0,l.useState)(""),[et,ea]=(0,l.useState)("independent"),[es,eo]=(0,l.useState)(""),[en,ei]=(0,l.useState)(""),[ec,ed]=(0,l.useState)(!1),[ex,eu]=(0,l.useState)(!1),[ep,ef]=(0,l.useState)(""),[em,ev]=(0,l.useState)(!1),[eh,eg]=(0,l.useState)(!1),[eb,ey]=(0,l.useState)(null),[ej,ew]=(0,l.useState)(""),[eN,eA]=(0,l.useState)(!1),[eE,eI]=(0,l.useState)(null),[eT,eR]=(0,l.useState)(null),[eD,eF]=(0,l.useState)(!1),[e_,eM]=(0,l.useState)(null),{requests:eK,notifications:eU,dismissNotification:eH,resolveAction:eW,revokeToken:e$=async()=>!1,activeTokens:eB=[],inactiveTokens:eV=[],actionLoading:eG}=(0,e7.S)({autoFetch:!0}),eY=(0,l.useRef)(null),eq=(0,l.useRef)(null),eJ=(0,l.useRef)(null),eQ=(0,l.useRef)(null),eZ="mobile"===L,e0="tablet"===L,e1=(0,l.useCallback)(async()=>{try{let[e,t,a,r]=await Promise.all([u.FH.get(u.jI.Wallet,"/credentials",{location:"active"}),u.FH.get(u.jI.Wallet,"/credentials",{location:"archive"}),u.FH.get(u.jI.Wallet,"/credentials",{location:"recently_deleted"}),u.FH.get(u.jI.Wallet,"/agents/credential")]),l=(e,t)=>e.success?(e.credentials||[]).map(e=>({...e,location:t})):[],s=[...l(e,"active"),...l(t,"archive"),...l(a,"recently_deleted")];n(s),S(e=>tu(s,e)),E(e=>tu(s,e)),r.success&&c(r.agents)}catch(e){console.error("[CredentialAgent] fetch error:",e)}finally{w(!1)}},[]);(0,l.useEffect)(()=>{e1()},[e1]),(0,l.useEffect)(()=>{try{let e={},t=window.localStorage.getItem(tr);if(t){let a=JSON.parse(t);if(a&&"object"==typeof a&&!Array.isArray(a))for(let[t,r]of Object.entries(a))"number"==typeof r&&Number.isFinite(r)&&r>0&&(e[t]=r)}let a=window.localStorage.getItem(ta);if(a){let t=JSON.parse(a);if(Array.isArray(t)){let a=Date.now();t.filter(e=>"string"==typeof e).slice(0,8).forEach((t,r)=>{e[t]||(e[t]=a-r)})}}S(t=>({...t,...e})),E(t=>({...t,...e}))}catch(e){}},[]),(0,l.useEffect)(()=>{let e=Object.entries(C).filter(e=>{let[,t]=e;return"number"==typeof t&&Number.isFinite(t)&&t>0}),t=Object.fromEntries(e);window.localStorage.setItem(tr,JSON.stringify(t));let a=e.sort((e,t)=>t[1]-e[1]).slice(0,8).map(e=>{let[t]=e;return t});window.localStorage.setItem(ta,JSON.stringify(a))},[C]);let e2=(0,l.useCallback)(function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Date.now();S(a=>{let r=Number.isFinite(t)&&t>0?t:Date.now();return a[e]===r?a:{...a,[e]:r}})},[]),e4=(0,l.useCallback)(()=>{eJ.current||(eJ.current=setTimeout(()=>{eJ.current=null,e1()},120))},[e1]);(0,l.useEffect)(()=>{let e=s(eP.Cw.CREDENTIAL_CHANGED,e=>{let t=e.data;(null==t?void 0:t.credentialId)&&e4()}),t=s(eP.Cw.CREDENTIAL_ACCESSED,e=>{let t=e.data;(null==t?void 0:t.credentialId)&&!0===t.allowed&&e2(t.credentialId)});return()=>{e(),t(),eJ.current&&(clearTimeout(eJ.current),eJ.current=null),eQ.current&&(clearTimeout(eQ.current),eQ.current=null)}},[e4,s,e2]),(0,l.useEffect)(()=>{d&&!o.some(e=>e.id===d)&&(p(null),K(!1))},[o,d]),(0,l.useEffect)(()=>{let e=()=>D(ti(window.innerWidth));return e(),window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[]),(0,l.useEffect)(()=>{eZ||(_(!1),K(!1))},[eZ]),(0,l.useEffect)(()=>{if(!I)return;let e=e=>{var t;let a=e.target;a&&(null!=(t=eq.current)&&t.contains(a)||(eQ.current&&(clearTimeout(eQ.current),eQ.current=null),O(!1),T(!1)))};return document.addEventListener("mousedown",e),document.addEventListener("touchstart",e),()=>{document.removeEventListener("mousedown",e),document.removeEventListener("touchstart",e)}},[I]);let e8=(0,l.useMemo)(()=>{var e;return(null==(e=i.find(e=>e.isPrimary))?void 0:e.id)||""},[i]),e3=(0,l.useMemo)(()=>i.map(e=>({value:e.id,label:e.name||(e.isPrimary?"Primary":"Agent ".concat(e.id.slice(0,6)))})),[i]);(0,l.useEffect)(()=>{X&&eo(e=>{var t;return e&&e3.some(t=>t.value===e)?e:g.agentId||e8||(null==(t=e3[0])?void 0:t.value)||""})},[g.agentId,e3,e8,X]),(0,l.useEffect)(()=>{if(0===i.length)return void ef("primary");let e=e8||i[0].id||"primary";ef(t=>t&&i.some(e=>e.id===t)?t:e)},[e8,i]);let e5=(0,l.useMemo)(()=>{if(!g.agentId)return null;let e=i.find(e=>e.id===g.agentId);return new Set(e?function(e,t){let a=new Map;for(let e of t){let t=e.parentAgentId||e.linkedTo;if(!t)continue;let r=a.get(t)||[];r.push(e),a.set(t,r)}let r=[],l=[e],s=new Set;for(;l.length>0;){let e=l.shift();if(!s.has(e))for(let t of(s.add(e),r.push(e),a.get(e)||[]))l.push(t.id)}return r}(e.id,i):[g.agentId])},[g.agentId,i]),tl=(0,l.useCallback)(e=>e5?e.filter(e=>e5.has(e.agentId)):e,[e5]),to=(0,l.useMemo)(()=>{let e=new Map;for(let t of i)e.set(t.id,(t.name||(t.isPrimary?"Primary":"Agent ".concat(t.id.slice(0,6)))).toLowerCase());return e},[i]),td=(0,l.useMemo)(()=>{let e=function(e){let t={terms:[],tagFilters:[],typeFilters:[],agentFilters:[],fieldFilters:[],lifecycleFilters:new Set,favoriteOnly:!1};for(let a of e.trim().split(/\s+/).map(e=>e.trim()).filter(Boolean)){let e=tp(a);if("favorite"===e||"favourite"===e||"fav"===e){t.favoriteOnly=!0;continue}let r=ts[e];if(r){t.lifecycleFilters.add(r);continue}let l=a.indexOf(":");if(l<=0){t.terms.push(e);continue}let s=tp(a.slice(0,l)),o=tp(a.slice(l+1).trim());if(o){if("tag"===s){t.tagFilters.push(o);continue}if("type"===s){t.typeFilters.push(o);continue}if("agent"===s){t.agentFilters.push(o);continue}if("lifecycle"===s||"location"===s){let e=ts[o];e&&t.lifecycleFilters.add(e);continue}if("favorite"===s||"fav"===s){t.favoriteOnly=!["false","0","no"].includes(o);continue}t.fieldFilters.push({key:tm(s),value:o})}}return t}(g.search),t=e.lifecycleFilters.size>0,a=e.terms,r=tl(o);if(r=t?r.filter(t=>e.lifecycleFilters.has(tc(t))):r.filter(e=>tc(e)===g.lifecycle),"all"!==g.category&&(r=r.filter(e=>e.type===g.category)),(g.favoritesOnly||e.favoriteOnly)&&(r=r.filter(e=>!!e.meta.favorite)),g.tag){let e=tp(g.tag);r=r.filter(t=>(t.meta.tags||[]).some(t=>tp(t).includes(e)))}e.tagFilters.length>0&&(r=r.filter(t=>{let a=(t.meta.tags||[]).map(e=>tp(e));return e.tagFilters.every(e=>a.some(t=>t.includes(e)))})),e.typeFilters.length>0&&(r=r.filter(t=>e.typeFilters.some(e=>tp(t.type).includes(e)))),e.agentFilters.length>0&&(r=r.filter(t=>{let a=to.get(t.agentId)||tp(t.agentId);return e.agentFilters.every(e=>a.includes(e)||tp(t.agentId).includes(e))}));let l=r,s=r;return e.fieldFilters.length>0&&(s=s.filter(t=>e.fieldFilters.every(e=>(function(e,t,a){let r=tm(t);for(let[t,l]of Object.entries(e.meta||{}))if(tm(t)===r&&tf(l).includes(a))return!0;return!1})(t,e.key,e.value)))),a.length>0&&(s=s.filter(e=>{let t=tc(e),r=(e.meta.tags||[]).map(e=>tp(e)).join(" "),l=to.get(e.agentId)||tp(e.agentId),s=tf(e.meta),o=[tp(e.name),tp(e.id),tp(e.type),r,l,s].join(" ");return a.every(a=>{if("favorite"===a||"favourite"===a||"fav"===a)return!!e.meta.favorite;let r=ts[a];return r?t===r:o.includes(a)})})),{parsed:e,preTextFiltered:l,results:s}},[o,g,tl,to]),tv=td.results,th=(0,l.useMemo)(()=>er(tv,A,g.search),[tv,A,g.search]),tg=(0,l.useMemo)(()=>{let e=g.search.trim();if(!e||e.includes(":")||tv.length>0)return[];let t=tp(e);return td.preTextFiltered.some(e=>tp(e.name).includes(t))?[]:tn.map(t=>"".concat(t,":").concat(e))},[g.search,tv.length,td.preTextFiltered]),tb=(0,l.useMemo)(()=>{let e=tl(o).filter(e=>tc(e)===g.lifecycle);if(g.tag){let t=g.tag;e=e.filter(e=>{var a;return null==(a=e.meta.tags)?void 0:a.includes(t)})}return g.favoritesOnly&&(e=e.filter(e=>e.meta.favorite)),{all:e.length,login:e.filter(e=>"login"===e.type).length,card:e.filter(e=>"card"===e.type).length,note:e.filter(e=>"note"===e.type).length,plain_note:e.filter(e=>"plain_note"===e.type).length,hot_wallet:e.filter(e=>"hot_wallet"===e.type).length,api:e.filter(e=>"api"===e.type).length,apikey:e.filter(e=>"apikey"===e.type).length,custom:e.filter(e=>"custom"===e.type).length,passkey:e.filter(e=>"passkey"===e.type).length,oauth2:e.filter(e=>"oauth2"===e.type).length,ssh:e.filter(e=>"ssh"===e.type).length,gpg:e.filter(e=>"gpg"===e.type).length}},[o,g.lifecycle,g.tag,g.favoritesOnly,tl]),ty=(0,l.useMemo)(()=>{let e=new Set;return tl(o).filter(e=>tc(e)===g.lifecycle).forEach(t=>{var a;return null==(a=t.meta.tags)?void 0:a.forEach(t=>e.add(t))}),Array.from(e).sort()},[o,g.lifecycle,tl]),tj=(0,l.useMemo)(()=>tl(o).filter(e=>tc(e)===g.lifecycle).filter(e=>e.meta.favorite).length,[o,g.lifecycle,tl]),tw=(0,l.useMemo)(()=>o.find(e=>e.id===d)||null,[o,d]),tN=(0,l.useMemo)(()=>{if(!tw)return"";let e=i.find(e=>e.id===tw.agentId);return e?e.name||(e.isPrimary?"Primary":e.id.slice(0,8)):"primary"===tw.agentId?"Primary":tw.agentId.slice(0,8)},[tw,i]),tk=(0,l.useMemo)(()=>tw?tc(tw):g.lifecycle,[tw,g.lifecycle]),tC=(0,l.useMemo)(()=>[...o].sort((e,t)=>tx(t,C)-tx(e,C)).slice(0,8),[o,C]),tS=(0,l.useCallback)(function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:120;eQ.current&&clearTimeout(eQ.current),eQ.current=setTimeout(()=>{R||T(!1),eQ.current=null},e)},[R]),tA=(0,l.useMemo)(()=>eb?eb.name||(eb.isPrimary?"Primary":"Agent ".concat(eb.id.slice(0,6))):"Agent",[eb]),tE=(0,l.useMemo)(()=>eT?eT.name||(eT.isPrimary?"Primary":"Agent ".concat(eT.id.slice(0,6))):"Agent",[eT]),tI=(0,l.useMemo)(()=>null!==g.agentId||"all"!==g.category||null!==g.tag||""!==g.search.trim()||g.favoritesOnly,[g]),tT=(0,l.useCallback)(e=>{y(t=>({...t,...e}))},[]),tR=(0,l.useCallback)(()=>{y(te)},[]),tO=(0,l.useCallback)(async()=>{try{await u.FH.post(u.jI.Wallet,"/lock",{})}catch(e){console.error("[CredentialAgent] lock error:",e)}z(),t()},[t,z]);(0,l.useCallback)(e=>{ey(e),ew(""),eI(null)},[]);let tL=(0,l.useCallback)(()=>{ey(null),ew(""),eI(null)},[]),tD=(0,l.useCallback)(async()=>{if(eb&&ej){eA(!0),eI(null);try{let e=await (0,u.WE)(ej,eb.id);e.token&&P(e.token),await e1(),y(e=>({...e,agentId:eb.id,lifecycle:"active",tag:null})),tL()}catch(e){eI(e.message||"Failed to unlock agent")}finally{eA(!1)}}},[ej,eb,P,e1,tL]),tz=(0,l.useCallback)(async e=>{try{await u.FH.post(u.jI.Wallet,"/agents/credential/".concat(encodeURIComponent(e),"/lock"),{}),await e1()}catch(e){console.error("[CredentialAgent] lock agent error:",e)}},[e1]),tP=(0,l.useCallback)(e=>{eR(e),eM(null)},[]),tF=(0,l.useCallback)(()=>{eD||(eR(null),eM(null))},[eD]),t_=(0,l.useCallback)(async()=>{if(eT){eF(!0),eM(null);try{await u.FH.delete(u.jI.Wallet,"/agents/credential/".concat(encodeURIComponent(eT.id))),y(e=>e.agentId===eT.id?{...e,agentId:null,lifecycle:"active",tag:null}:e),(null==tw?void 0:tw.agentId)===eT.id&&(p(null),K(!1)),await e1(),eR(null)}catch(e){eM(e.message||"Failed to delete agent")}finally{eF(!1)}}},[eT,e1,tw]),tM=(0,l.useCallback)(async()=>{if(d)try{let e=encodeURIComponent(tk);await u.FH.delete(u.jI.Wallet,"/credentials/".concat(d,"?location=").concat(e)),p(null),K(!1),e1()}catch(e){console.error("[CredentialAgent] delete error:",e)}},[d,tk,e1]),tK=(0,l.useCallback)(async()=>{if(d&&"active"!==tk)try{await u.FH.post(u.jI.Wallet,"/credentials/".concat(d,"/restore"),{from:tk}),p(null),K(!1),e1()}catch(e){console.error("[CredentialAgent] restore error:",e)}},[d,tk,e1]),tU=(0,l.useCallback)(async()=>{if(d)try{let e=await u.FH.post(u.jI.Wallet,"/credentials/".concat(d,"/duplicate"));await e1(),e.credential&&p(e.credential.id)}catch(e){console.error("[CredentialAgent] duplicate error:",e)}},[d,e1]),tH=(0,l.useCallback)((e,t)=>{n(a=>a.map(a=>a.id===e?{...a,meta:{...a.meta,favorite:t}}:a))},[]),tW=(0,l.useCallback)(()=>{ee(""),ea("independent"),eo(""),ei("")},[]),t$=(0,l.useCallback)(()=>{Q(!1),ev(!1),tW()},[tW]),tB=(0,l.useCallback)(async()=>{if(Z.trim()&&("independent"!==et||!(en.length<8))&&("linked"!==et||es)){ed(!0);try{var e;let t={name:Z.trim(),mode:et};if("linked"===et)t.parentAgentId=es;else{let e=await u.FH.get(u.jI.Wallet,"/auth/connect");t.encrypted=await (0,h.X)(en,e.publicKey)}let a=await u.FH.post(u.jI.Wallet,"/agents/credential",t),r=null==a||null==(e=a.agent)?void 0:e.id;em&&r&&ef(r),Q(!1),ev(!1),tW(),await e1()}catch(e){console.error("[CredentialAgent] create agent error:",e)}finally{ed(!1)}}},[Z,et,es,en,em,e1,tW]),tV=(0,l.useCallback)(e=>{e?(ea("linked"),eo(e)):(ea("independent"),eo(""),ei("")),Q(!0)},[]),tG=(0,l.useCallback)(()=>{var e;ef(e8||(null==(e=i[0])?void 0:e.id)||"primary"),eu(!0)},[e8,i]),tY=(0,l.useCallback)(()=>{ev(!0),tV()},[tV]),tq=(0,l.useCallback)(function(){var e;let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"api-key-form",a=arguments.length>1?arguments[1]:void 0,r={},l=g.agentId||e8||(null==(e=i[0])?void 0:e.id);l&&(r.agentId=l),(null==a?void 0:a.applyFilters)?(g.tag&&(r.tags=[g.tag]),a.prefillType?r.type=a.prefillType:g.category&&"all"!==g.category&&(r.type=g.category)):(null==a?void 0:a.prefillType)&&(r.type=a.prefillType),q(null),B(t),G(Object.keys(r).length>0?r:null),H(!0)},[g,e8,i]),tX=(0,l.useCallback)(async e=>{H(!1),q(null),G(null),await e1(),e&&(p(e),e2(e),eZ&&K(!0))},[e1,eZ,e2]),tJ=(0,l.useCallback)(e=>{p(e),e2(e),eZ&&K(!0)},[eZ,e2]),tQ=(0,l.useCallback)(e=>{tT({search:e}),T(!1),requestAnimationFrame(()=>{var e;return null==(e=eY.current)?void 0:e.focus()})},[tT]),tZ=(0,l.useCallback)(e=>{tT({search:e.name}),tJ(e.id),T(!1)},[tT,tJ]),t0=(0,l.useMemo)(()=>g.search.trim()?[]:["tag:work","type:login","agent:primary","favorite","archived","recently_deleted"],[g.search]),t1=(I||R)&&""===g.search.trim();return(!function(e){let{filteredCredentials:t,selectedId:a,isMobile:r,searchRef:s,onCreateCredential:o,setSelectedId:n,setMobileDetailOpen:i}=e;(0,l.useEffect)(()=>{let e=e=>{let l=e.target,c="INPUT"===l.tagName||"TEXTAREA"===l.tagName,d=c||l.isContentEditable,x=e.key.toLowerCase();if(!d&&(e.metaKey||e.ctrlKey)&&"k"===x||!d&&"/"===e.key){var u;e.preventDefault(),null==(u=s.current)||u.focus();return}if(!d&&(e.metaKey||e.ctrlKey)&&e.altKey&&("n"===x||"KeyN"===e.code)){e.preventDefault(),o();return}if(!c&&("ArrowDown"===e.key||"ArrowUp"===e.key)){e.preventDefault();let r=t.findIndex(e=>e.id===a);if("ArrowDown"===e.key){let e=r+1;e<t.length&&n(t[e].id)}else{let e=r-1;e>=0&&n(t[e].id)}}!c&&"Enter"===e.key&&t.length>0&&(e.preventDefault(),n(null!=a?a:t[0].id),r&&i(!0))};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[t,a,r,s,o,n,i])}({filteredCredentials:th,selectedId:d,isMobile:eZ,searchRef:eY,onCreateCredential:()=>tq("api-key-form"),setSelectedId:p,setMobileDetailOpen:K}),j)?(0,r.jsxs)("div",{className:"h-screen w-screen flex items-center justify-center bg-[var(--color-background,#f4f4f5)] relative isolate agent-surface",children:[(0,r.jsxs)("div",{className:"absolute inset-0 pointer-events-none z-0 overflow-hidden",children:[(0,r.jsx)("div",{className:"absolute inset-0 bg-grid-adaptive bg-[size:4rem_4rem] opacity-30"}),(0,r.jsx)("div",{className:"absolute inset-0 tyvek-texture opacity-40 mix-blend-multiply"})]}),(0,r.jsxs)("div",{className:"flex flex-col items-center relative z-10",children:[(0,r.jsx)("div",{className:"w-6 h-6 border-2 border-[var(--color-border,#d4d4d8)] border-t-[var(--color-text,#0a0a0a)] animate-spin"}),(0,r.jsx)("div",{className:"mt-4 font-mono text-[10px] text-[var(--color-text-muted,#6b7280)] tracking-widest",children:"LOADING AGENT"})]})]}):(0,r.jsxs)("div",{className:"relative isolate h-screen w-screen overflow-hidden flex flex-col bg-[var(--color-background,#f4f4f5)] agent-surface",children:[(0,r.jsxs)("div",{className:"absolute inset-0 pointer-events-none z-0 overflow-hidden",children:[(0,r.jsx)("div",{className:"absolute inset-0 bg-grid-adaptive bg-[size:4rem_4rem] opacity-30"}),(0,r.jsx)("div",{className:"absolute inset-0 tyvek-texture opacity-40 mix-blend-multiply"}),(0,r.jsx)("div",{className:"absolute bottom-[5%] right-[5%] opacity-[0.03] select-none",children:(0,r.jsx)("div",{className:"text-[12vw] font-black leading-none text-[var(--color-text,#0a0a0a)] font-mono tracking-tighter text-right",children:"AURAMAXX"})}),(0,r.jsx)("div",{className:"absolute top-10 left-[200px] w-24 h-24 border-l-4 border-t-4 border-[var(--color-text,#0a0a0a)] opacity-10",children:(0,r.jsx)("div",{className:"absolute top-2 left-2 w-3 h-3 bg-[var(--color-text,#0a0a0a)]"})}),(0,r.jsx)("div",{className:"absolute bottom-10 right-10 w-24 h-24 border-r-4 border-b-4 border-[var(--color-text,#0a0a0a)] opacity-10 flex items-end justify-end",children:(0,r.jsx)("div",{className:"absolute bottom-2 right-2 w-3 h-3 bg-[var(--color-text,#0a0a0a)]"})})]}),(0,r.jsxs)("div",{className:"relative z-10 flex-1 flex overflow-hidden",children:[!eZ&&!e0&&(0,r.jsx)($,{agents:i,filters:g,categoryCounts:tb,tags:ty,favoritesCount:tj,onFilterChange:tT,onLock:tO,onLockAgent:tz,onCreateCredential:(e,t)=>tq("type-picker"===e?"type-picker":"api-key-form",t?{prefillType:t}:void 0),onCreateAgent:tV,mode:"desktop",notifications:eU,onDismissNotification:eH,pendingActionCount:eU.filter(e=>"pending"===e.status&&"notify"!==e.type).length,surface:N,onSurfaceChange:k,onSettings:a,onDeleteAgent:tP}),e0&&(0,r.jsxs)("div",{className:"h-full w-12 shrink-0 border-r border-[var(--color-border,#d4d4d8)] bg-[var(--color-surface,#f4f4f2)] flex flex-col items-center pt-3 gap-3 relative z-10",children:[(0,r.jsx)("img",{src:"/logo.webp",alt:"Aura",className:"w-6 h-6 object-contain"}),(0,r.jsx)("button",{type:"button",onClick:()=>_(!0),className:"flex items-center justify-center w-7 h-7 text-[var(--color-text-muted,#6b7280)] hover:text-[var(--color-text,#0a0a0a)] hover:bg-[var(--color-background-alt,#f4f4f5)] transition-colors rounded","aria-label":"Open sidebar",title:"Open sidebar",children:(0,r.jsx)(f.A,{size:14})})]}),"audit"===N?(0,r.jsx)("div",{className:"flex-1 h-full overflow-hidden",children:(0,r.jsx)(eX,{})}):"apiKeys"===N?(0,r.jsx)("div",{className:"flex-1 h-full overflow-hidden",children:(0,r.jsx)(e9,{requests:eK,activeTokens:eB,inactiveTokens:eV,actionLoading:eG,onResolveAction:eW,onRevokeToken:e$,agents:i})}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(el,{credentials:tv,latestAccessById:A,selectedId:d,searchQuery:g.search,onSearchChange:e=>tT({search:e}),onSelect:tJ,onAdd:()=>tq("api-key-form"),onCreateWithFilter:tI?()=>tq("api-key-form",{applyFilters:!0}):void 0,canAdd:"active"===g.lifecycle,onImport:tG,canImport:"active"===g.lifecycle,onOpenGenerator:()=>eg(!0),onClearFilters:tR,hasActiveFilters:tI,fieldSearchSuggestions:tg,onApplySearchSuggestion:tQ,searchInputRef:eY,showSearch:!1,className:eZ?"flex-1 h-full flex flex-col pb-14 min-w-0":"w-[300px] h-full flex flex-col pb-14 border-r border-[var(--color-border,#d4d4d8)]",leadingAction:eZ?(0,r.jsx)(b.$n,{variant:"ghost",size:"sm",icon:(0,r.jsx)(f.A,{size:12}),onClick:()=>_(!0),className:"!px-1.5 !h-8 !w-8","aria-label":"Open sidebar",title:"Open sidebar"}):void 0}),!eZ&&(0,r.jsx)("div",{className:"flex-1 h-full overflow-hidden pb-14",children:tw?(0,r.jsx)(ek,{credential:tw,agentName:tN,lifecycle:tk,onEdit:()=>q(tw.id),onDelete:tM,onRestore:tK,onDuplicate:tU,onFavoriteChange:tH}):(0,r.jsx)(eC,{variant:"active"!==g.lifecycle?"empty-lifecycle":0===o.filter(e=>"active"===tc(e)).length?"empty-agent":"no-selection",onAdd:"active"===g.lifecycle?()=>tq("api-key-form"):void 0})})]}),"credentials"===N&&(0,r.jsx)("div",{className:"absolute bottom-0 z-30 border-t border-[var(--color-border,#d4d4d8)] bg-[var(--color-surface,#ffffff)]/95 backdrop-blur-sm ".concat(eZ?"left-0 right-0 w-full":"".concat(e0?"left-12":"left-[200px]"," right-0")),children:(0,r.jsx)("div",{className:"w-full px-3 py-2.5",children:(0,r.jsxs)("div",{ref:eq,className:"relative w-full",children:[t1&&(0,r.jsxs)("div",{"data-testid":"search-dock-panel",className:"absolute bottom-full left-0 w-full mb-1 bg-[var(--color-surface,#ffffff)] border border-[var(--color-border-focus,#0a0a0a)] shadow-mech max-h-56 overflow-y-auto z-20",children:[tC.length>0&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"px-3 py-2 font-mono text-[9px] uppercase tracking-widest text-[var(--color-text-muted,#6b7280)] border-b border-[var(--color-border-muted,#e5e7eb)] flex items-center gap-1.5",children:[(0,r.jsx)(m.A,{size:11}),"Recently Accessed"]}),tC.map(e=>(0,r.jsxs)("button",{type:"button",className:"w-full text-left px-4 py-2.5 text-[var(--color-text-muted,#6b7280)] hover:text-[var(--color-text,#0a0a0a)] hover:bg-[var(--color-background-alt,#f4f4f5)] font-mono text-xs border-b border-[var(--color-border-muted,#e5e5e5)] last:border-0",onMouseDown:t=>{t.preventDefault(),tZ(e)},children:[(0,r.jsx)("div",{className:"text-[var(--color-text,#0a0a0a)] truncate",children:J(e)}),(0,r.jsxs)("div",{className:"text-[9px] uppercase tracking-wider truncate",children:[to.get(e.agentId)||e.agentId," \xb7 ",tc(e)]})]},e.id))]}),0===tC.length&&(0,r.jsxs)("div",{children:[(0,r.jsx)("div",{className:"px-3 py-2 font-mono text-[9px] uppercase tracking-widest text-[var(--color-text-muted,#6b7280)] border-b border-[var(--color-border-muted,#e5e7eb)]",children:"Try Structured Search"}),t0.map(e=>(0,r.jsxs)("button",{type:"button",className:"w-full text-left px-4 py-2.5 text-[var(--color-text-muted,#6b7280)] hover:text-[var(--color-text,#0a0a0a)] hover:bg-[var(--color-background-alt,#f4f4f5)] font-mono text-xs border-b border-[var(--color-border-muted,#e5e5e5)] last:border-0 flex items-center gap-2 group/item",onMouseDown:t=>{t.preventDefault(),tQ(e)},children:[(0,r.jsx)("div",{className:"w-1.5 h-1.5 flex-shrink-0 bg-[var(--color-border,#d4d4d8)] group-hover/item:bg-[var(--color-text,#0a0a0a)]"}),(0,r.jsx)("span",{className:"min-w-0 flex-1 truncate",children:e})]},e))]})]}),(0,r.jsx)(b.ks,{compact:!0,leftElement:(0,r.jsx)(v.A,{size:12}),placeholder:"Search...",value:g.search,onChange:e=>tT({search:e.target.value}),inputRef:eY,onFocus:()=>{O(!0)},onClick:()=>{eQ.current&&(clearTimeout(eQ.current),eQ.current=null),T(!0)},onBlur:()=>{O(!1),tS()}})]})})})]}),(0,r.jsx)(e6.Z,{requests:eK,resolveAction:eW,actionLoading:eG}),eZ&&(0,r.jsx)(b._s,{isOpen:M&&null!=tw,onClose:()=>K(!1),title:(null==tw?void 0:tw.name)||"Credential",subtitle:tN||"Credential_Detail",width:"full",children:tw?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(b.$n,{variant:"ghost",size:"sm",onClick:()=>K(!1),className:"mb-3",children:"BACK"}),(0,r.jsx)(ek,{credential:tw,agentName:tN,lifecycle:tk,onEdit:()=>q(tw.id),onDelete:tM,onRestore:tK,onDuplicate:tU,onFavoriteChange:tH})]}):(0,r.jsx)(eC,{variant:"active"!==g.lifecycle?"empty-lifecycle":0===o.length?"empty-agent":"no-selection",onAdd:"active"===g.lifecycle?()=>tq("api-key-form"):void 0})}),(eZ||e0)&&F&&(0,r.jsxs)("div",{className:"absolute inset-0 z-40",children:[(0,r.jsx)("button",{type:"button","aria-label":"Close sidebar",onClick:()=>_(!1),className:"absolute inset-0 bg-[var(--color-text,#0a0a0a)]/20"}),(0,r.jsx)("div",{className:"absolute left-0 top-0 h-full",children:(0,r.jsx)($,{agents:i,filters:g,categoryCounts:tb,tags:ty,favoritesCount:tj,onFilterChange:tT,onLock:tO,onLockAgent:tz,onCreateCredential:(e,t)=>tq("type-picker"===e?"type-picker":"api-key-form",t?{prefillType:t}:void 0),onCreateAgent:tV,mode:"mobile",onNavigate:()=>_(!1),notifications:eU,onDismissNotification:eH,pendingActionCount:eU.filter(e=>"pending"===e.status&&"notify"!==e.type).length,surface:N,onSurfaceChange:k,onSettings:a,onDeleteAgent:tP})})]}),(0,r.jsx)(b.aF,{isOpen:null!=eT,onClose:tF,title:"Delete ".concat(tE,"?"),size:"sm",footer:(0,r.jsxs)("div",{className:"flex gap-2 justify-end",children:[(0,r.jsx)(b.$n,{variant:"secondary",size:"sm",onClick:tF,disabled:eD,children:"CANCEL"}),(0,r.jsx)(b.$n,{variant:"danger",size:"sm",onClick:t_,loading:eD,children:"DELETE"})]}),children:(0,r.jsxs)("div",{className:"space-y-3",children:[(0,r.jsx)("div",{className:"text-[10px] text-[var(--color-text-muted,#6b7280)]",children:"This will permanently delete the agent and its credentials."}),e_&&(0,r.jsx)("div",{className:"text-[10px] text-[var(--color-danger,#ef4444)] border border-[var(--color-danger,#ef4444)]/30 bg-[var(--color-danger,#ef4444)]/10 px-3 py-2",children:e_})]})}),(0,r.jsx)(b.aF,{isOpen:null!=eb,onClose:tL,title:"Unlock ".concat(tA),size:"sm",footer:(0,r.jsxs)("div",{className:"flex gap-2 justify-end",children:[(0,r.jsx)(b.$n,{variant:"secondary",size:"sm",onClick:tL,children:"CANCEL"}),(0,r.jsx)(b.$n,{size:"sm",onClick:tD,loading:eN,disabled:!ej,children:"UNLOCK"})]}),children:(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsx)(b.ks,{label:"Agent Password",type:"password",placeholder:"Enter agent password",value:ej,onChange:e=>ew(e.target.value),autoFocus:!0}),eE&&(0,r.jsx)("div",{className:"text-[10px] text-[var(--color-danger,#ef4444)] border border-[var(--color-danger,#ef4444)]/30 bg-[var(--color-danger,#ef4444)]/10 px-3 py-2",children:eE})]})}),(0,r.jsx)(eS.i,{isOpen:U||!!Y,onClose:()=>{H(!1),q(null),G(null)},onSaved:tX,editCredentialId:null!=Y?Y:void 0,agents:i,createStartStep:"type-picker"===W?"type":"form",createStartType:"type-picker"===W?void 0:"apikey",createPrefill:null!=V?V:void 0}),(0,r.jsx)(eO,{isOpen:ex,onClose:()=>eu(!1),onComplete:e1,agents:i,selectedAgentId:ep,onSelectedAgentIdChange:ef,onAddAgent:tY,walletBaseUrl:(0,u.au)()}),(0,r.jsx)(eL.p,{isOpen:eh,onClose:()=>eg(!1),onUse:e=>{eg(!1),navigator.clipboard.writeText(e).catch(()=>{})}}),(0,r.jsx)(b.aF,{isOpen:X,onClose:t$,title:"New Agent",size:"md",footer:(0,r.jsxs)("div",{className:"flex gap-2 justify-end",children:[(0,r.jsx)(b.$n,{variant:"secondary",size:"sm",onClick:t$,children:"CANCEL"}),(0,r.jsx)(b.$n,{size:"sm",onClick:tB,loading:ec,disabled:!Z.trim()||"linked"===et&&!es||"independent"===et&&en.length<8,children:"CREATE"})]}),children:(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsx)(b.ks,{label:"Agent Name",placeholder:"e.g. Work, Personal",value:Z,onChange:e=>ee(e.target.value),autoFocus:!0}),(0,r.jsx)(b.UM,{label:"Agent Type",options:tt,value:et,onChange:e=>{ea(e),"independent"!==e&&ei("")},compact:!0}),"linked"===et&&(0,r.jsx)(b.UM,{label:"Parent Agent",options:e3,value:es,onChange:eo,disabled:0===e3.length,compact:!0}),"independent"===et&&(0,r.jsx)(b.ks,{label:"Agent Password",type:"password",placeholder:"At least 8 characters",value:en,onChange:e=>ei(e.target.value)})]})})]})};var th=a(6399),tg=a(8192),tb=a(2108),ty=a(5710),tj=a(8314);let tw=new Set(["telegram","webhook","whatsapp","discord"]),tN={telegram:["botToken"],discord:["botToken"]},tk=["botToken","token"],tC=["channelId","channel_id"],tS=["telegram","whatsapp","discord"];function tA(e,t){if(!e)return null;for(let a of t){let t=e[a];if("string"==typeof t&&t.trim())return t.trim()}return null}function tE(e){return!!new Set((e.secretKeys||[]).filter(e=>"string"==typeof e).map(e=>e.trim())).has("botToken")||!!e.hasSecrets||null!==tA(e.config,tk)}function tI(e){return"whatsapp"===e?{type:e,enabled:!1,config:{allowFrom:["*"],dmPolicy:"open",groupPolicy:"allowlist"},chat:{enabled:!1},hasSecrets:!1,secretKeys:[]}:"discord"===e?{type:e,enabled:!1,config:{channelId:""},chat:{enabled:!1},hasSecrets:!1,secretKeys:[]}:{type:e,enabled:!1,config:{},chat:{enabled:!1},hasSecrets:!1,secretKeys:[]}}function tT(e){let{isOpen:t,onClose:a,passwordChangeSuccess:s,agentThemeOpen:o,onToggleAgentTheme:n,colorMode:i,uiScale:c,onColorModeChange:d,onUiScaleChange:p,agentColorModeOptions:f,agentUiScaleOptions:m,agentSettingsOpen:v,onToggleAgentSettings:h,policyLoadError:g,policyLoading:y,onRetryLoadPolicy:j,policyForm:w,onPolicyAutoApproveChange:N,localProfileOptions:k,onPolicyProfileChange:C,localProjectScopeOptions:S,onPolicyProjectScopeModeChange:A,dangerConfirmOpen:E,onCancelDangerConfirm:I,onConfirmDangerousSave:T,policySaving:R,policySaveError:L,policySaveSuccess:D,canSavePolicy:z,onSavePolicy:P,securitySettingsOpen:F,onToggleSecuritySettings:_,passwordChangeError:M,onOpenPasswordModal:K,backupSectionOpen:U,onToggleBackupSection:H,creatingBackup:W,onCreateBackup:$,exportingDb:V,onExportDb:G,backupsLoading:Y,backups:q,formatBackupDate:X,formatSize:J,restoreConfirmOpen:Q,onOpenRestoreConfirm:Z,onCloseRestoreConfirm:ee,onConfirmRestore:et,restoringBackup:ea,dangerZoneOpen:er,onToggleDangerZone:el,nukeError:es,onOpenNukeConfirm:en,nuking:ei}=e,{token:ec}=(0,x.A)(),[ex,eu]=(0,l.useState)(!1),[ep,ef]=(0,l.useState)([]),[em,ev]=(0,l.useState)(!1),[eh,eg]=(0,l.useState)(null),[eb,ey]=(0,l.useState)(null),[ej,ew]=(0,l.useState)({}),[eN,ek]=(0,l.useState)({}),[eC,eS]=(0,l.useState)({}),[eA,eE]=(0,l.useState)({}),[eI,eT]=(0,l.useState)({}),[eR,eO]=(0,l.useState)({}),[eL,eD]=(0,l.useState)({}),[ez,eP]=(0,l.useState)(!1),[eF,e_]=(0,l.useState)("idle"),[eM,eK]=(0,l.useState)(null),[eU,eH]=(0,l.useState)(null),eW=(0,l.useCallback)(async()=>{if(!ec){ef([]),eg("Unlock agent first to manage adapters.");return}ev(!0),eg(null);try{let e=await u.FH.get(u.jI.Wallet,"/adapters"),t=Array.isArray(e.adapters)?e.adapters:[],a=new Map;for(let e of t){let t=e.type.trim().toLowerCase();a.set(t,e)}let r=tS.map(e=>a.get(e)||tI(e));ef(r)}catch(e){ef([]),eg(e.message||"Failed to load adapters.")}finally{ev(!1)}},[ec]),e$=(0,l.useCallback)(()=>{let e=!ex;eu(e),e&&eW()},[ex,eW]),eB=(0,l.useCallback)(async(e,t)=>{let a=ep.find(t=>t.type===e);if(!a)return;let r={...tI(a.type.trim().toLowerCase()).config||{},...a.config||{}};eg(null),ew(t=>({...t,[e]:!0}));try{await u.FH.post(u.jI.Wallet,"/adapters",{type:a.type,enabled:t,config:r,chat:{enabled:t}}),ef(a=>a.map(a=>a.type===e?{...a,enabled:t,chat:{enabled:t}}:a))}catch(t){eg(t.message||"Failed to update channel state for ".concat(e,"."))}finally{ew(t=>({...t,[e]:!1}))}},[ep]),eV=(0,l.useCallback)(async e=>{let t=e.trim().toLowerCase(),a=ep.find(e=>e.type.trim().toLowerCase()===t),r=a?function(e){let t=e.type.trim().toLowerCase();if("telegram"===t&&tE(e))return[];let a=tN[t]||[],r=new Set((e.secretKeys||[]).filter(e=>"string"==typeof e).map(e=>e.trim()));return a.filter(e=>!r.has(e))}(a):[];if(!tw.has(t))return void eg("".concat(e," does not support test yet."));if(r.length>0)return void eg("Cannot test ".concat(e,": missing ").concat(r.join(", "),"."));eg(null),ey(null),ek(e=>({...e,[t]:!0}));try{let a=await u.FH.post(u.jI.Wallet,"/adapters/test",{type:t});if(a&&!1===a.success)throw Error(a.error||"Adapter test failed for ".concat(e,"."));ey(a.message||"Test sent for ".concat(e,"."))}catch(r){let a=r.message||"Failed to test adapter ".concat(e,".");a.includes("Unknown adapter type")?"whatsapp"===t?eg("WhatsApp test support is available in code, but your running wallet server is outdated. Restart AuraMaxx and test again."):eg("".concat(e," does not support test yet.")):a.includes("Telegram bot token not configured")?eg("Telegram bot token not configured. Enable Telegram and add the bot token in setup."):(a.includes("Telegram chat ID not configured"),eg(a))}finally{ek(e=>({...e,[t]:!1}))}},[ep]),eG=(0,l.useCallback)(async e=>{let t=!eA[e];if(eE(a=>({...a,[e]:t})),!t)return;let a=eI[e];if("string"==typeof a&&a.trim().length>0)return;let r=e.trim().toLowerCase();if("telegram"!==r&&"discord"!==r)return;let l=ep.find(t=>t.type===e);if("discord"===r){let t=tA(null==l?void 0:l.config,tC)||"";eO(a=>({...a,[e]:t}))}try{let t=await u.FH.get(u.jI.Wallet,"/adapters/".concat(encodeURIComponent(r),"/secrets/").concat(encodeURIComponent("botToken"))),a="string"==typeof t.value?t.value.trim():"";a?eT(t=>({...t,[e]:a})):eT(t=>({...t,[e]:""}))}catch(a){let t=a.message||"";t.includes("not configured")||t.includes("(404)")||eg(t||"Failed to load ".concat(r," bot token.")),eT(t=>({...t,[e]:""}))}},[ep,eR,eI,eA]),eY=(0,l.useCallback)(async e=>{let t=ep.find(t=>t.type===e);if(!t)return;let a=t.type.trim().toLowerCase(),r=(eI[e]||"").trim(),l=(eR[e]||"").trim();if(!r)return void eg("".concat(t.type," bot token is required."));if("discord"===a&&!l)return void eg("Discord channel ID is required.");eg(null),ey(null),eD(t=>({...t,[e]:!0}));try{let s={type:t.type,enabled:t.enabled,config:{...t.config||{},..."discord"===a?{channelId:l}:{}},secrets:{botToken:r}};t.chat&&(s.chat=t.chat),await u.FH.post(u.jI.Wallet,"/adapters",s),ey("".concat(t.type," settings saved.")),eT(t=>({...t,[e]:""})),await eW()}catch(t){eg(t.message||"Failed to save token for ".concat(e,"."))}finally{eD(t=>({...t,[e]:!1}))}},[eW,ep,eR,eI]),eq=(0,l.useCallback)(async()=>{try{let e=await u.FH.get(u.jI.Wallet,"/adapters/whatsapp/setup-qr"),t=e.status||"idle";e_(t),eK("string"==typeof e.qr&&e.qr.trim()?e.qr:null),eH("string"==typeof e.error&&e.error.trim()?e.error:null),"connected"===t&&"connected"!==eF&&(ey("WhatsApp linked successfully."),await eW(),await u.FH.post(u.jI.Wallet,"/adapters/restart",{}))}catch(e){eH(e.message||"Failed to read WhatsApp setup status.")}},[eW,eF]),eX=(0,l.useCallback)(async()=>{eg(null),ey(null),eH(null),eP(!0);try{let e=await u.FH.post(u.jI.Wallet,"/adapters/whatsapp/setup-qr",{});if(!1===e.success)throw Error(e.error||"Failed to start WhatsApp QR setup.");let t=e.status||"idle";e_(t),eK("string"==typeof e.qr&&e.qr.trim()?e.qr:null),eH("string"==typeof e.error&&e.error.trim()?e.error:null),"connected"===t&&(ey("WhatsApp linked successfully."),await eW(),await u.FH.post(u.jI.Wallet,"/adapters/restart",{}))}catch(e){eH(e.message||"Failed to start WhatsApp setup.")}finally{eP(!1)}},[eW]),eJ=(0,l.useCallback)(async()=>{try{await u.FH.post(u.jI.Wallet,"/adapters/whatsapp/setup-qr/stop",{})}catch(e){}finally{e_("idle"),eK(null),eH(null),eP(!1)}},[]),eQ=(0,l.useCallback)(async e=>{let t=e.trim().toLowerCase();eg(null),ey(null),eS(e=>({...e,[t]:!0}));try{await u.FH.delete(u.jI.Wallet,"/adapters/".concat(encodeURIComponent(t))),await eW(),ey("Deleted ".concat(e," adapter."))}catch(t){eg(t.message||"Failed to delete adapter ".concat(e,"."))}finally{eS(e=>({...e,[t]:!1}))}},[eW]);return(0,l.useEffect)(()=>{if(!ex||"waiting_qr"!==eF&&"qr_ready"!==eF)return;eq();let e=setInterval(()=>{eq()},2e3);return()=>clearInterval(e)},[ex,eq,eF]),(0,l.useEffect)(()=>{t||("idle"!==eF&&eJ(),eu(!1),ey(null),eg(null),ew({}),ek({}),eS({}),eE({}),eT({}),eO({}),eD({}))},[eJ,t,eF]),(0,r.jsx)(b._s,{isOpen:t,onClose:a,title:"Settings",subtitle:"Local socket policy",footerLabel:"",children:(0,r.jsxs)("div",{className:"space-y-4",children:[s&&(0,r.jsx)("div",{className:"text-[10px] text-[var(--color-info)] border border-[var(--color-info)]/30 bg-[var(--color-info)]/10 px-3 py-2",children:s}),(0,r.jsxs)(b.lX,{title:"Agent Theme",isOpen:o,onToggle:n,className:"overflow-hidden",contentClassName:"p-[var(--space-md)] border-t border-[var(--color-border)]",children:[(0,r.jsx)("label",{className:"block text-[9px] text-[var(--color-text-faint)] tracking-widest mb-2",children:"Color mode"}),(0,r.jsx)(b.O6,{options:[...f],value:i,onChange:e=>d(e)}),(0,r.jsx)("label",{className:"block mt-3 text-[9px] text-[var(--color-text-faint)] tracking-widest mb-2",children:"UI scale"}),(0,r.jsx)(b.O6,{options:[...m],value:c,onChange:e=>p(e)}),(0,r.jsx)("div",{className:"mt-2 text-[9px] text-[var(--color-text-muted)]",children:"Dark adjusts agent color contrast. Big increases typography, spacing, radius, and shadows."})]}),(0,r.jsxs)(b.lX,{title:"Agent Profile",icon:(0,r.jsx)(tg.A,{size:12}),isOpen:v,onToggle:h,className:"overflow-hidden",contentClassName:"px-4 pb-4 space-y-3 border-t border-[var(--color-border)]",children:[g&&(0,r.jsxs)("div",{className:"space-y-2 pt-3",children:[(0,r.jsx)("div",{className:"text-[10px] text-[var(--color-danger)] border border-[var(--color-danger)]/30 bg-[var(--color-danger)]/10 px-3 py-2",children:g}),(0,r.jsx)(b.$n,{type:"button",onClick:j,disabled:y,variant:"secondary",size:"md",children:y?"Retrying...":"Retry load"})]}),!g&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"pt-3 flex items-center justify-between text-[10px] font-mono text-[var(--color-text)]",children:[(0,r.jsx)("span",{children:"Auto-approve local requests"}),(0,r.jsx)(b.lM,{size:"sm",checked:w.autoApprove,onChange:N,disabled:y||R})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:"block text-[9px] text-[var(--color-text-faint)] tracking-widest mb-2",children:"Local profile"}),(0,r.jsx)(b.O6,{ariaLabel:"Local profile",options:[...k],value:w.profile,onChange:e=>C(e),disabled:y||R})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:"block text-[9px] text-[var(--color-text-faint)] tracking-widest mb-2",children:"Project scope mode"}),(0,r.jsx)(b.O6,{ariaLabel:"Project scope mode",options:[...S],value:w.projectScopeMode,onChange:e=>A(e),disabled:y||R}),(0,r.jsx)("div",{className:"mt-1 text-[9px] text-[var(--color-text-muted)]",children:"Strict requires `.aura` mappings for `get_secret`. Auto allows token-scope fallback when `.aura` is missing."})]}),E&&(0,r.jsxs)("div",{className:"text-[10px] text-[var(--color-danger)] border border-[var(--color-danger)]/30 bg-[var(--color-danger)]/10 px-3 py-2 space-y-2",children:[(0,r.jsx)("div",{children:"Dangerous mode broadens local token scope (admin profile or super-scopes)."}),(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)(b.$n,{type:"button",onClick:I,variant:"secondary",size:"sm",className:"!h-8",children:"Cancel"}),(0,r.jsx)(b.$n,{type:"button",onClick:T,disabled:R,variant:"danger",size:"sm",className:"!h-8",children:"Confirm dangerous mode"})]})]}),(0,r.jsx)("div",{className:"text-[9px] text-[var(--color-text-muted)] px-3 py-2",children:"Policy changes apply to newly issued local tokens only."}),L&&(0,r.jsx)("div",{className:"text-[10px] text-[var(--color-danger)]",children:L}),D&&(0,r.jsx)("div",{className:"text-[10px] text-[var(--color-info)]",children:D}),(0,r.jsx)(b.$n,{type:"button",onClick:P,disabled:!z,variant:"primary",size:"lg",className:"w-full",children:R?"Saving...":"Save local policy"})]})]}),(0,r.jsxs)(b.lX,{title:"Primary Password",icon:(0,r.jsx)(B.A,{size:12}),isOpen:F,onToggle:_,className:"overflow-hidden",contentClassName:"px-4 pb-4 pt-3 space-y-3 border-t border-[var(--color-border)]",children:[(0,r.jsx)("div",{className:"text-[9px] text-[var(--color-text-muted)] leading-relaxed",children:"Rotate your primary agent password. This updates the agent wrapper encryption and keeps existing credentials intact."}),M&&(0,r.jsx)("div",{className:"text-[10px] text-[var(--color-danger)] border border-[var(--color-danger)]/30 bg-[var(--color-danger)]/10 px-3 py-2",children:M}),(0,r.jsx)(b.$n,{type:"button",onClick:K,variant:"secondary",size:"lg",className:"w-full",children:"Change primary password"})]}),(0,r.jsxs)(b.lX,{title:"Adapters",icon:(0,r.jsx)(tg.A,{size:12}),isOpen:ex,onToggle:e$,className:"overflow-hidden",contentClassName:"px-4 pb-4 pt-3 space-y-3 border-t border-[var(--color-border)]",children:[(0,r.jsx)("div",{className:"text-[9px] text-[var(--color-text-muted)] leading-relaxed",children:"Configure Telegram, WhatsApp, and Discord directly in Aura. Enable a channel, then open setup to add credentials or scan a QR code."}),eb&&(0,r.jsx)("div",{className:"text-[10px] text-[var(--color-info)] border border-[var(--color-info)]/30 bg-[var(--color-info)]/10 px-3 py-2",children:eb}),eh&&(0,r.jsx)("div",{className:"text-[10px] text-[var(--color-danger)] border border-[var(--color-danger)]/30 bg-[var(--color-danger)]/10 px-3 py-2",children:function e(t){var a,l;let s=Array.from(t.matchAll(/@([a-zA-Z0-9_]{3,}) \((https:\/\/t\.me\/[^\s),]+)\)/g));if(s.length>0){let l=[],o=0;for(let[n,i]of s.entries()){let s=i[1],c=i[2],d=null!=(a=i.index)?a:0,x=i[0];d>o&&l.push(e(t.slice(o,d))),l.push((0,r.jsxs)("span",{children:[(0,r.jsxs)("a",{href:c,target:"_blank",rel:"noreferrer",className:"underline decoration-dotted underline-offset-2 hover:no-underline",children:["@",s]})," (",(0,r.jsx)("a",{href:c,target:"_blank",rel:"noreferrer",className:"underline decoration-dotted underline-offset-2 hover:no-underline",children:c}),")"]},"bot-".concat(s,"-").concat(d,"-").concat(n))),o=d+x.length}return o<t.length&&l.push(e(t.slice(o))),l}let o=Array.from(t.matchAll(/https?:\/\/[^\s),]+/g));if(0===o.length)return t;let n=[],i=0;for(let[e,a]of o.entries()){let s=a[0],o=null!=(l=a.index)?l:0;o>i&&n.push(t.slice(i,o)),n.push((0,r.jsx)("a",{href:s,target:"_blank",rel:"noreferrer",className:"underline decoration-dotted underline-offset-2 hover:no-underline",children:s},"".concat(s,"-").concat(o,"-").concat(e))),i=o+s.length}return i<t.length&&n.push(t.slice(i)),n}(eh)}),(0,r.jsxs)("div",{className:"border-t border-dashed border-[var(--color-border)] pt-3 space-y-2",children:[(0,r.jsx)("div",{className:"font-mono text-[9px] tracking-widest text-[var(--color-text-faint)]",children:"EXISTING ADAPTERS"}),em?(0,r.jsx)("div",{className:"py-2 flex items-center justify-center",children:(0,r.jsx)(ed.A,{size:14,className:"animate-spin text-[var(--color-text-muted)]"})}):0===ep.length?(0,r.jsx)("div",{className:"text-[10px] text-[var(--color-text-muted)] px-2 py-1",children:"No adapters configured yet."}):(0,r.jsx)("div",{className:"space-y-1",children:ep.map(e=>{var t,a;let l=!!(e.enabled&&(null==(t=e.chat)?void 0:t.enabled)),s=!!ej[e.type],o=e.type.trim().toLowerCase(),n=!!eN[o],i=!!(eC[o]||eC[e.type]),c=!!eA[e.type],d=!!eL[e.type],x=eI[e.type]||"",u="telegram"===o?tE(e):null==(a=e.secretKeys)?void 0:a.includes("botToken"),p=eM?"https://api.qrserver.com/v1/create-qr-code/?size=220x220&margin=0&data=".concat(encodeURIComponent(eM)):null;return(0,r.jsxs)("div",{className:"border border-[var(--color-border)] bg-[var(--color-surface-alt)] px-2 py-2 text-[10px]",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,r.jsx)("span",{className:"font-mono text-[var(--color-text)] uppercase tracking-wider",children:e.type}),(0,r.jsxs)("span",{className:"flex items-center gap-2 text-[9px] text-[var(--color-text-muted)]",children:[s&&(0,r.jsx)("span",{children:"saving..."}),(0,r.jsx)(b.$n,{type:"button",variant:"secondary",size:"sm",onClick:()=>{eV(e.type)},disabled:s||n||i||d||ez,loading:n,children:"TEST"}),(0,r.jsx)(b.$n,{type:"button",variant:"danger",size:"sm",onClick:()=>{eQ(e.type)},disabled:s||n||i||d||ez,loading:i,children:"DELETE"}),(0,r.jsx)(b.lM,{size:"sm",checked:l,onChange:t=>{eB(e.type,t)},disabled:s||n||i||d||ez}),("telegram"===o||"whatsapp"===o||"discord"===o)&&l&&(0,r.jsx)("button",{type:"button",onClick:()=>{eG(e.type)},disabled:s||n||i||d||ez,"aria-label":c?"Hide adapter setup":"Show adapter setup",className:"inline-flex h-5 w-5 items-center justify-center text-[var(--color-text-muted)] hover:text-[var(--color-text)] disabled:opacity-50",children:c?(0,r.jsx)(tb.A,{size:11}):(0,r.jsx)(eo.A,{size:11})})]})]}),"telegram"===o&&c&&(0,r.jsxs)("div",{className:"mt-2 border-t border-dashed border-[var(--color-border)] pt-2 space-y-2",children:[(0,r.jsx)("div",{className:"text-[9px] text-[var(--color-text-muted)]",children:u?"Replace Telegram bot token":"Add Telegram bot token"}),(0,r.jsx)(b.ks,{type:"password",value:x,onChange:t=>{let a=t.target.value;eT(t=>({...t,[e.type]:a}))},placeholder:"123456:ABC...",disabled:s||n||i||d||ez,autoComplete:"off"}),(0,r.jsx)("div",{className:"text-[9px] text-[var(--color-text-muted)]",children:"Current token stays hidden. Enter a new token to replace it."}),(0,r.jsx)(b.$n,{type:"button",variant:"secondary",size:"sm",onClick:()=>{eY(e.type)},disabled:s||n||i||d||ez||!x.trim(),loading:d,className:"w-full",children:"SAVE TOKEN"})]}),"discord"===o&&c&&(0,r.jsxs)("div",{className:"mt-2 border-t border-dashed border-[var(--color-border)] pt-2 space-y-2",children:[(0,r.jsx)("div",{className:"text-[9px] text-[var(--color-text-muted)]",children:"Add your Discord bot token and target channel ID."}),(0,r.jsx)(b.ks,{type:"password",value:x,onChange:t=>{let a=t.target.value;eT(t=>({...t,[e.type]:a}))},placeholder:"Discord bot token",disabled:s||n||i||d||ez,autoComplete:"off"}),(0,r.jsx)(b.ks,{value:eR[e.type]||"",onChange:t=>{let a=t.target.value;eO(t=>({...t,[e.type]:a}))},placeholder:"Discord channel ID",disabled:s||n||i||d||ez,autoComplete:"off"}),(0,r.jsx)(b.$n,{type:"button",variant:"secondary",size:"sm",onClick:()=>{eY(e.type)},disabled:s||n||i||d||ez||!x.trim()||!(eR[e.type]||"").trim(),loading:d,className:"w-full",children:"SAVE DISCORD SETTINGS"})]}),"whatsapp"===o&&c&&(0,r.jsxs)("div",{className:"mt-2 border-t border-dashed border-[var(--color-border)] pt-2 space-y-2",children:[(0,r.jsx)("div",{className:"text-[9px] text-[var(--color-text-muted)]",children:"Scan this QR code with WhatsApp to link Aura directly."}),(0,r.jsx)(b.$n,{type:"button",variant:"secondary",size:"sm",onClick:()=>{eX()},loading:ez,disabled:s||n||i||d||ez,className:"w-full",children:"connected"===eF?"LINKED":"GENERATE QR"}),"waiting_qr"===eF&&(0,r.jsx)("div",{className:"text-[9px] text-[var(--color-text-muted)]",children:"Waiting for QR code..."}),eU&&(0,r.jsx)("div",{className:"text-[9px] text-[var(--color-danger)]",children:eU}),"connected"===eF&&(0,r.jsx)("div",{className:"text-[9px] text-[var(--color-info)]",children:"WhatsApp connected. You can approve actions from your phone."}),p&&(0,r.jsxs)("div",{className:"space-y-1",children:[(0,r.jsx)("img",{src:p,alt:"WhatsApp setup QR",className:"mx-auto h-[180px] w-[180px] border border-[var(--color-border)] bg-white"}),(0,r.jsxs)("div",{className:"text-[8px] text-[var(--color-text-faint)] leading-relaxed break-all",children:["QR payload: ",eM]}),(0,r.jsx)(b.$n,{type:"button",variant:"secondary",size:"sm",onClick:()=>{eJ()},className:"w-full",children:"STOP QR"})]})]})]},e.type)})})]})]}),(0,r.jsxs)(b.lX,{title:"Database Backup",icon:(0,r.jsx)(ty.A,{size:12}),isOpen:U,onToggle:H,className:"overflow-hidden",contentClassName:"px-4 pb-4 pt-3 space-y-3 border-t border-[var(--color-border)]",children:[(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)(b.$n,{variant:"secondary",size:"md",onClick:$,disabled:W,loading:W,icon:W?void 0:(0,r.jsx)(O.A,{size:12}),className:"flex-1",children:W?"CREATING...":"CREATE BACKUP"}),(0,r.jsx)(b.$n,{variant:"secondary",size:"md",onClick:G,disabled:V,loading:V,icon:V?void 0:(0,r.jsx)(ty.A,{size:12}),className:"flex-1",children:V?"EXPORTING...":"EXPORT DB"})]}),Y?(0,r.jsx)("div",{className:"py-4 flex items-center justify-center",children:(0,r.jsx)(ed.A,{size:16,className:"animate-spin text-[var(--color-text-muted)]"})}):0===q.length?(0,r.jsx)("div",{className:"py-3 text-center",children:(0,r.jsx)("div",{className:"font-mono text-[9px] text-[var(--color-text-muted)]",children:"No backups found"})}):(0,r.jsx)("div",{className:"space-y-1 max-h-48 overflow-y-auto",children:q.map(e=>(0,r.jsxs)("div",{className:"relative",children:[(0,r.jsxs)(b.$n,{type:"button",variant:"secondary",size:"md",onClick:t=>{Z(e.filename,t.currentTarget)},className:"w-full !h-auto !px-2 !py-2 !justify-between group",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)(tj.A,{size:10,className:"text-[var(--color-text-muted)] group-hover:text-[var(--color-text)]"}),(0,r.jsx)("span",{className:"font-mono text-[10px] text-[var(--color-text)]",children:X(e.timestamp)})]}),(0,r.jsx)("span",{className:"font-mono text-[9px] text-[var(--color-text-muted)]",children:J(e.size)})]}),(0,r.jsx)(b.Rw,{isOpen:Q===e.filename,onClose:ee,onConfirm:()=>et(e.filename),title:"Restore Backup",message:"Restore to this backup? You will lose all data since this backup was created.",confirmText:"RESTORE",variant:"warning",loading:ea===e.filename})]},e.filename))}),(0,r.jsx)("div",{className:"pt-2 border-t border-dashed border-[var(--color-border)]",children:(0,r.jsx)("div",{className:"font-mono text-[8px] text-[var(--color-text-faint)] leading-relaxed",children:"Backups are tied to the current database schema. Restoring after migrations may cause issues."})})]}),(0,r.jsxs)(b.lX,{title:"Danger Zone",isOpen:er,onToggle:el,tone:"warning",className:"overflow-hidden",contentClassName:"space-y-3 p-[var(--space-md)] border-t border-[var(--color-border)]",children:[(0,r.jsx)("div",{className:"text-[9px] text-[var(--color-warning)] leading-relaxed",children:"Permanently delete your agent, wallets, credentials, and local configuration. This action cannot be undone."}),es&&(0,r.jsx)("div",{className:"text-[10px] border px-3 py-2",style:{color:"var(--color-warning)",borderColor:"color-mix(in srgb, var(--color-warning) 30%, transparent)",background:"color-mix(in srgb, var(--color-warning) 10%, transparent)"},children:es}),(0,r.jsx)(b.$n,{type:"button",onClick:en,disabled:ei,variant:"danger",size:"lg",className:"w-full",children:ei?"Nuking...":"Nuke"})]})]})})}var tR=a(4265),tO=a(3361),tL=a(5229),tD=a(8824);let tz="aura:update-banner:dismissed";function tP(){let{updateAvailable:e,current:t,latest:a,updating:s,updateError:o,updateOutput:n,runUpdate:i,apiServerDown:c,restartingServer:d,restartError:x,runRestart:u}=(0,tD.e)(),[p,f]=(0,l.useState)(null),m=(0,l.useMemo)(()=>c||x?null:n&&!e?"update-success:".concat(a||"unknown"):e||o?"update-available:".concat(t||"unknown",":").concat(a||"unknown"):null,[c,x,n,e,a,t,o]);(0,l.useEffect)(()=>{f(window.localStorage.getItem(tz))},[]);let v=(0,l.useCallback)(()=>{m&&(window.localStorage.setItem(tz,m),f(m))},[m]),h=!!(m&&p===m);if(!c&&!x&&!e&&!n&&!o||h)return null;if(c||x)return(0,r.jsxs)("div",{className:"fixed top-0 left-0 right-0 z-[9999] px-4 py-2.5 font-mono text-[11px] flex items-center justify-between gap-3",style:{background:"var(--color-warning, #ff4d00)",color:"#fff"},children:[(0,r.jsx)("span",{children:"API SERVER OFFLINE. RUN: auramaxx restart (or npx --yes auramaxx@latest restart)"}),(0,r.jsx)(b.$n,{type:"button",onClick:()=>{u()},loading:d,variant:"primary",size:"sm",children:"RESTART NOW"}),x&&(0,r.jsx)("span",{className:"text-[10px]",style:{color:"#fff",opacity:.9},children:x})]});if(n&&!e)return(0,r.jsxs)("div",{className:"fixed top-0 left-0 right-0 z-[100] px-3 py-2 border text-[9px] font-mono tracking-widest flex items-center justify-center gap-3",style:{color:"var(--color-accent-foreground, #0a0a0a)",borderColor:"var(--color-accent, #ccff00)",background:"var(--color-accent, #ccff00)"},children:[(0,r.jsxs)("span",{children:["UPDATE COMPLETE — AURAMAXX ",a," READY"]}),(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)(b.$n,{type:"button",size:"sm",variant:"primary",onClick:()=>{window.location.reload()},children:"RESTART"}),(0,r.jsx)(b.$n,{type:"button",size:"sm",variant:"ghost",onClick:v,"aria-label":"Dismiss update banner",className:"text-[var(--color-accent-foreground,#0a0a0a)] hover:bg-black/10",children:(0,r.jsx)(tL.A,{size:12})})]})]});let g=!t||"unknown"===t.trim().toLowerCase();return(0,r.jsxs)("div",{className:"fixed top-0 left-0 right-0 z-[9999] px-4 py-2.5 font-mono text-[11px] flex items-center justify-between gap-3",style:{background:"var(--color-warning, #ff4d00)",color:"#fff"},children:[(0,r.jsx)("span",{children:g?"New update available. Update to latest version".concat(a?" (".concat(a,")"):"","."):"Update available: ".concat(t," → ").concat(a)}),(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)(b.$n,{type:"button",onClick:()=>{i()},loading:s,variant:"primary",size:"sm",children:"UPDATE NOW"}),(0,r.jsx)(b.$n,{type:"button",size:"sm",variant:"ghost",onClick:v,"aria-label":"Dismiss update banner",className:"text-white/90 hover:text-white hover:bg-white/10",children:(0,r.jsx)(tL.A,{size:12})})]}),o&&(0,r.jsx)("span",{className:"text-[10px]",style:{color:"#fff",opacity:.9},children:o})]})}let tF=["ready to auramaxx and mog prompt peasants?","you are perfect. never give up your aura","why jestermaxx when you can auramaxx?","lock tf in, the aura farm is live.","we are so back. aura at all-time highs.","negative motion detected. deploy tera-aura.","delulu? no. pre-success manifestation engine.","doomers offline, builders online.","your aura just hit legendary rarity.","brainrot but make it productive.","stack wins, stack aura, stack peace.","this session is sponsored by unstoppable motion.","if plan A fails, we auramaxx harder.","zero cope, pure glow-up execution.","cooked? nah. we’re perfectly seasoned.","straight gas, no brakes, no bad vibes.","today’s forecast: 100% chance of aura gains.","touch grass, then auramaxx.","say no to digital slops. say yes to auramaxx.","It’s me, AI. You are absolutely right. I want to auramaxx as well."],t_="auramaxx:start-banner-quote-index";var tM=a(5685);let tK=["strict","dev","admin"],tU=["auto","strict","off"],tH=[{value:"strict",label:"strict",description:"Minimal local token scope with explicit allowlists."},{value:"dev",label:"dev",description:"Balanced local automation with scoped defaults."},{value:"admin",label:"admin (dangerous)",description:"Broad token scope. Use only in tightly controlled local environments."}],tW=[{value:"auto",label:"auto (recommended)",description:"Uses `.aura` when present and safely falls back to token scope when missing."},{value:"strict",label:"strict (require .aura)",description:"Requires explicit `.aura` mappings for secret access."},{value:"off",label:"off (disable project allowlist)",description:"Disables project allowlist checks for local token access."}],t$=[{value:"dev",label:"mid (dev)",description:"Access to most things. Human approval for stuff like CVV."},{value:"strict",label:"sus (local)",description:"Most locked down. Every request needs manual approval."},{value:"admin",label:"maxx (admin)",description:"Full access. Use only when you fully trust the agent."}],tB=[{value:"light",label:"Light"},{value:"dark",label:"Dark"}],tV=[{value:"normal",label:"Normal"},{value:"big",label:"Big"}],tG="aura:onboarding-seed-draft",tY="auramaxx_admin_token",tq=new Set(s.Yu.english.map(e=>e.toLowerCase())),tX=e=>e.trim().toLowerCase().split(/\s+/).filter(Boolean);function tJ(){let{token:e,setToken:t,clearToken:a}=(0,x.A)(),{colorMode:o,uiScale:f,setColorMode:m,setUiScale:v}=(0,tM.D)(),[h,g]=(0,l.useState)("loading"),[y,j]=(0,l.useState)(""),[w,N]=(0,l.useState)(!0),[k,C]=(0,l.useState)(!1),[S,A]=(0,l.useState)(null),[E,I]=(0,l.useState)(null),[T,R]=(0,l.useState)(!1),[O,L]=(0,l.useState)(null),[D,z]=(0,l.useState)(null),[P,F]=(0,l.useState)(!1),[_,M]=(0,l.useState)("admin"),[K,U]=(0,l.useState)("seed"),[H,W]=(0,l.useState)(null),[$,B]=(0,l.useState)(!1),[V,G]=(0,l.useState)(!1),{notifications:Y,dismissNotification:q}=(0,e7.S)({autoFetch:!!e}),[X,J]=(0,l.useState)(!1),[Q,Z]=(0,l.useState)(!1),[ee,et]=(0,l.useState)(null),[ea,er]=(0,l.useState)(null),[el,es]=(0,l.useState)({profile:"admin",profileVersion:"v1",autoApprove:!0,projectScopeMode:"auto"}),[eo,en]=(0,l.useState)(null),[ei,ec]=(0,l.useState)(null),[ed,ex]=(0,l.useState)({}),[eu,ep]=(0,l.useState)(null),[ef,em]=(0,l.useState)(!1),[ev,eh]=(0,l.useState)(!1),[eg,eb]=(0,l.useState)(!1),[ey,ej]=(0,l.useState)(!1),[ew,eN]=(0,l.useState)(!0),[ek,eC]=(0,l.useState)(!1),[eS,eA]=(0,l.useState)(!1),[eE,eI]=(0,l.useState)(!1),[eT,eR]=(0,l.useState)(!1),[eO,eL]=(0,l.useState)([]),[eD,ez]=(0,l.useState)(!1),[eP,eF]=(0,l.useState)(!1),[e_,eM]=(0,l.useState)(null),[eK,eU]=(0,l.useState)(!1),[eH,eW]=(0,l.useState)(null),[e$,eB]=(0,l.useState)(null),[eV,eG]=(0,l.useState)(!1),[eY,eq]=(0,l.useState)(""),[eX,eJ]=(0,l.useState)(""),[eQ,eZ]=(0,l.useState)(""),[e0,e1]=(0,l.useState)(null),[e2,e4]=(0,l.useState)(null),[e8,e3]=(0,l.useState)(!1),[e5,e9]=(0,l.useState)(!1),[e6,te]=(0,l.useState)(12),[tt,ta]=(0,l.useState)(Array(12).fill("")),[tr,tl]=(0,l.useState)(!1),[ts,to]=(0,l.useState)(!1),[tn]=(0,l.useState)(()=>{try{return function(e){var t;let a=e.getItem(t_),r=a?Number.parseInt(a,10):-1,l=Number.isFinite(r)?(r+1)%tF.length:0;e.setItem(t_,String(l));let s=(null!=(t=tF[!Number.isFinite(l)?0:Math.abs(Math.floor(l))%tF.length])?t:tF[0]).trimStart();return s.startsWith("\uD83D\uDDFF")?s:"".concat("\uD83D\uDDFF ").concat(s)}(window.localStorage)}catch(e){return tF[0]}}),[ti,tc]=(0,l.useState)(""),[td,tx]=(0,l.useState)(null),[tu,tp]=(0,l.useState)(!1),tf=(0,l.useRef)("loading"),tm=(0,l.useRef)(null),tg=(0,l.useRef)(null),tb=(0,l.useRef)(!0),ty=(0,l.useRef)(0),tj=(0,l.useRef)(null),tw=(0,l.useMemo)(()=>!!E,[E]),tN=(0,l.useMemo)(()=>Y.filter(e=>"pending"===e.status&&"notify"!==e.type).length,[Y]),tk=(0,l.useMemo)(()=>tN>0?"calc(4rem + 3.5rem)":"4rem",[tN]),tC=(0,l.useMemo)(()=>tt.filter(e=>e.length>0).length,[tt]),tS=(0,l.useMemo)(()=>tt.map(e=>e.trim().toLowerCase()).join(" ").trim(),[tt]),tA=(0,l.useMemo)(()=>{let e=new Set;return tt.forEach((t,a)=>{t&&(tq.has(t.trim().toLowerCase())||e.add(a))}),e},[tt]),tE=(0,l.useMemo)(()=>tC===e6&&!(tA.size>0)&&s.JB(tS),[tA.size,tS,e6,tC]),tI=(0,l.useCallback)(e=>"admin"===e.profile,[]),tL=(0,l.useMemo)(()=>!!ea&&JSON.stringify(ea)!==JSON.stringify(el),[el,ea]);(0,l.useEffect)(()=>{try{let e=sessionStorage.getItem(tG);if(!e)return;let t=JSON.parse(e);if(!(null==t?void 0:t.mnemonic)||"number"!=typeof t.createdAt)return void sessionStorage.removeItem(tG);if(Date.now()-t.createdAt>9e5){sessionStorage.removeItem(tG),L("Recovery phrase draft expired. Restart setup to generate a new phrase.");return}I(t.mnemonic),U("seed"),g("setup"),L("Recovered your in-progress recovery phrase for this tab. Confirm after you store it safely.")}catch(e){sessionStorage.removeItem(tG)}},[]),(0,l.useEffect)(()=>{if(!E){sessionStorage.removeItem(tG),U("seed"),z(null);return}let e={mnemonic:E,createdAt:Date.now()};sessionStorage.setItem(tG,JSON.stringify(e))},[E]),(0,l.useEffect)(()=>{"locked"!==h&&e9(!1)},[h]),(0,l.useEffect)(()=>{tf.current=h},[h]),(0,l.useEffect)(()=>(tb.current=!0,()=>{tb.current=!1,tm.current&&clearTimeout(tm.current)}),[]);let tD=(0,l.useCallback)(e=>{let t=tf.current;if("loading"===t||"transition"===t){if(tg.current===e)return;tg.current=e,F(!0),tm.current&&clearTimeout(tm.current),tm.current=setTimeout(()=>{F(!1),tg.current=null,g(e)},220);return}tm.current&&(clearTimeout(tm.current),tm.current=null),tg.current=null,F(!1),g(e)},[]),tz=(0,l.useCallback)(()=>{tm.current&&(clearTimeout(tm.current),tm.current=null),tg.current=null,F(!1),g("transition")},[]);(0,l.useEffect)(()=>{if("locked"!==h)return void tl(!1);if(!window.PublicKeyCredential||window.auraDesktop)return;let e=!1;return(async()=>{try{let t=await u.FH.get(u.jI.Wallet,"/auth/passkey/status");if(e||!t.registered)return;await u.FH.post(u.jI.Wallet,"/auth/passkey/authenticate/options",{}),e||tl(!0)}catch(e){}})(),()=>{e=!0}},[h]);let tJ=(0,l.useCallback)(async()=>{let r=++ty.current,l=()=>tb.current&&r===ty.current,s=e;if(!s){let e=window.localStorage.getItem(tY),a=window.sessionStorage.getItem(tY),r=e||a;if(r)return void t(r,{persist:e?"local":"session"})}if(s&&!(0,p.G3)())try{tj.current||(tj.current=(async()=>{let{publicKeyBase64:e}=await (0,p.UI)();return(0,u.fP)(e)})().finally(()=>{tj.current=null}));let e=await tj.current;if(!l())return;e.token&&(t(e.token),s=e.token)}catch(e){if(!l())return;a(),s=null}try{let[e,a]=await Promise.all([u.FH.get(u.jI.Wallet,"/setup"),u.FH.get(u.jI.Wallet,"/setup/agents")]);if(!l())return;let r=Array.isArray(a.agents)?a.agents:[];if(!(e.hasWallet||r.some(e=>e.isPrimary)||r.length>0)||tw)return void tD("setup");let o="loading"===tf.current||"transition"===tf.current;if(e.unlocked&&!s&&o)try{if(await new Promise(e=>setTimeout(e,120)),!l())return;let e=window.localStorage.getItem(tY),a=window.sessionStorage.getItem(tY),r=e||a;if(r)return void t(r,{persist:e?"local":"session"})}catch(e){if(!l())return}if(!e.unlocked&&s&&o)try{if(await new Promise(e=>setTimeout(e,450)),!l())return;let e=await u.FH.get(u.jI.Wallet,"/setup");if(!l())return;if(e.unlocked)return void tD("unlocked")}catch(e){if(!l())return}if(!e.unlocked||!s)return void tD("locked");tD("unlocked")}catch(e){if(!l())return;tD("setup")}},[e,a,tw,tD,t]);(0,l.useEffect)(()=>{tJ()},[tJ]);let tQ=(0,l.useCallback)(async()=>{if(!e)return void en("Unlock agent first to manage local socket policy.");em(!0),en(null),ec(null),ep(null);try{var t,a,r;let l=u.FH.getBaseUrl(u.jI.Wallet),s=await fetch("".concat(l,"/defaults"),{headers:{Authorization:"Bearer ".concat(e)}});if(!s.ok)throw Error("Failed to load canonical trust policy defaults.");let o=await s.json();if(!1===o.success)throw Error("Failed to load canonical trust policy defaults.");let n=Object.values(o.defaults||{}).flat(),i=e=>{var t;return null==(t=n.find(t=>t.key===e))?void 0:t.value},c=String(null!=(t=i("trust.localProfile"))?t:"").trim();if(!tK.includes(c))throw Error("Unknown persisted local profile: ".concat(c||"(empty)"));let d=String(null!=(a=i("trust.localProfileVersion"))?a:"v1").trim();if("v1"!==d)throw Error("Unknown local profile version; refusing to edit settings.");let x=String(null!=(r=i("trust.projectScopeMode"))?r:"auto").trim();if(!tU.includes(x))throw Error("Unknown persisted project scope mode: ".concat(x||"(empty)"));let p={profile:c,profileVersion:"v1",autoApprove:!!i("trust.localAutoApprove"),projectScopeMode:x};er(p),es(p)}catch(e){en(e.message||"Failed to load policy settings"),er(null)}finally{em(!1)}},[e]);(0,l.useEffect)(()=>{V&&tQ()},[V,tQ]);let tZ=(0,l.useCallback)(async()=>{if(!e)throw Error("Missing auth token for save.");if(!tK.includes(el.profile))throw Error("Unknown profile selected; refusing to persist.");if(!tU.includes(el.projectScopeMode))throw Error("Unknown project scope mode selected; refusing to persist.");let t=u.FH.getBaseUrl(u.jI.Wallet),a={"Content-Type":"application/json",Authorization:"Bearer ".concat(e)},r=[["trust.localProfile",el.profile],["trust.localProfileVersion","v1"],["trust.localAutoApprove",el.autoApprove],["trust.projectScopeMode",el.projectScopeMode]];if(!(await Promise.all(r.map(async e=>{let[r,l]=e;return(await fetch("".concat(t,"/defaults/").concat(r),{method:"PATCH",headers:a,body:JSON.stringify({value:l})})).ok}))).every(Boolean))throw Error("Failed to save canonical trust policy defaults.");return{...el,profileVersion:"v1"}},[el,e]),t0=(0,l.useCallback)(async()=>{if(ea&&!ef&&!ev){if(!tI(ea)&&tI(el)&&!eg)return void eb(!0);eh(!0),ec(null),ep(null);try{let e=await tZ();er(e),es(e),eb(!1),ep("Local trust policy saved. Changes apply to newly issued local tokens only.")}catch(t){let e=t.message||"Failed to save policy settings";eb(!1),e.includes("Unknown profile selected")||e.includes("Unknown project scope mode selected")?ec(e):(await tQ(),ec("".concat(e," Server values were reloaded.")))}finally{eh(!1)}}},[eg,tI,tQ,tZ,el,ef,ev,ea]),t1=(0,l.useCallback)(()=>{eG(!1),eq(""),eJ(""),eZ(""),e1(null),e3(!1)},[]),t2=(0,l.useCallback)(async e=>{if(e.preventDefault(),e1(null),e4(null),eX.length<8)return void e1("New password must be at least 8 characters.");if(eX!==eQ)return void e1("New password and confirmation do not match.");e3(!0);try{await (0,u.DK)(eY,eX),e4("Primary agent password updated."),t1()}catch(e){e1(e.message||"Failed to change primary password.")}finally{e3(!1)}},[t1,eQ,eY,eX]),t4=(0,l.useCallback)((e,t)=>{let a=t.trim().toLowerCase();if(a.includes(" ")){let t=tX(a);if(t.length>1){let a=[...tt];t.forEach((t,r)=>{let l=e+r;l<a.length&&(a[l]=t)}),ta(a),tx(null);return}}let r=[...tt];r[e]=a,ta(r),tx(null)},[tt]),t8=(0,l.useCallback)((e,t)=>{let a=tX(t);if(a.length<=1)return!1;let r=a.length>12?24:e6;if(r!==e6){te(r);let e=Array(r).fill("");return a.slice(0,r).forEach((t,a)=>{e[a]=t}),ta(e),tx(null),!0}let l=[...tt];return a.forEach((t,a)=>{let r=e+a;r<l.length&&(l[r]=t)}),ta(l),tx(null),!0},[e6,tt]),t3=(0,l.useCallback)(async e=>{if(e.preventDefault(),tx(null),ti.length<8)return void tx("New password must be at least 8 characters.");if(!tE)return void tx("Enter a valid 12 or 24-word BIP-39 seed phrase.");tp(!0);try{let{publicKeyBase64:e}=await (0,p.UI)(),a=await (0,u.OW)(tS,ti,e);a.token&&t(a.token,{persist:w?"local":"session"}),j(""),tc(""),ta(Array(e6).fill("")),tz(),at()}catch(e){tx(e.message||"Recovery failed.")}finally{tp(!1)}},[tz,tE,tS,ti,e6,t,w]),t5=async e=>{if(e.preventDefault(),y){C(!0),A(null);try{let{publicKeyBase64:e}=await (0,p.UI)(),a=await (0,u.WE)(y,void 0,e);a.token&&t(a.token,{persist:w?"local":"session"}),j(""),tz(),at()}catch(e){A(e.message||"Unlock failed")}finally{C(!1)}}},t9=async e=>{if(e.preventDefault(),!(y.length<8)){C(!0),A(null);try{let{publicKeyBase64:e}=await (0,p.UI)(),a=await (0,u.ne)(y,e);a.token&&(t(a.token,{persist:w?"local":"session"}),W(a.token)),a.mnemonic&&(I(a.mnemonic),R(!1),U("seed"),L(null),z(null)),j(""),a.mnemonic||tJ()}catch(t){let e=t.message||"Setup failed";if(/already exists/i.test(e)){A("Primary agent already exists. Enter your password to unlock it."),g("locked");return}A(e)}finally{C(!1)}}},t6=(0,l.useCallback)(async()=>{var e;if(!E)return;let t=!1;if("undefined"!=typeof navigator&&(null==(e=navigator.clipboard)?void 0:e.writeText))try{await navigator.clipboard.writeText(E),t=!0}catch(e){t=!1}if(t)return void z("copied");let a=document.createElement("textarea");a.value=E,a.setAttribute("readonly","true"),a.style.position="fixed",a.style.left="-9999px",document.body.appendChild(a),a.focus(),a.select();let r=!1;try{r=document.execCommand("copy")}catch(e){r=!1}finally{a.remove()}z(r?"copied":"copy-failed")},[E]),t7=(0,l.useCallback)(()=>{if(!E)return;let e=new Date().toISOString().slice(0,10),t=E.split(" ").map((e,t)=>"".concat(t+1,". ").concat(e)).join("\n"),a="# Aura Agent Seed Phrase Backup\n\n**Date:** ".concat(e,"\n**WARNING:** Keep this file safe and private. Anyone with this phrase can access your agent.\n\n").concat(t,"\n"),r="",l=document.createElement("a");try{let t=new Blob([a],{type:"text/markdown;charset=utf-8"});l.href=r=URL.createObjectURL(t),l.download="aura-seed-backup-".concat(e,".md"),l.style.display="none",document.body.appendChild(l),l.click(),z("downloaded")}catch(e){z("download-failed")}finally{l.remove(),r&&URL.revokeObjectURL(r)}},[E]),ae=(0,l.useCallback)(async()=>{let t=H||e;if(!t)throw Error("Session token unavailable. Unlock again and retry setup.");let a="strict"!==_,r=u.FH.getBaseUrl(u.jI.Wallet),l={"Content-Type":"application/json",Authorization:"Bearer ".concat(t)};await fetch("".concat(r,"/defaults/trust.localProfile"),{method:"PATCH",headers:l,body:JSON.stringify({value:_})}),await fetch("".concat(r,"/defaults/trust.localProfileVersion"),{method:"PATCH",headers:l,body:JSON.stringify({value:"v1"})}),await fetch("".concat(r,"/defaults/trust.localAutoApprove"),{method:"PATCH",headers:l,body:JSON.stringify({value:a})})},[_,H,e]),at=(0,l.useCallback)(async()=>{B(!1);let e=!1,t=window.setTimeout(()=>{e||B(!0)},1500);try{await tJ(),e=!0}finally{window.clearTimeout(t)}},[tJ]),aa=(0,l.useCallback)(async()=>{to(!0),A(null);try{let{publicKeyBase64:e}=await (0,p.UI)(),a=await u.FH.post(u.jI.Wallet,"/auth/passkey/authenticate/options",{}),r=e=>{let t=e.replace(/-/g,"+").replace(/_/g,"/");for(;t.length%4;)t+="=";let a=atob(t),r=new Uint8Array(a.length);for(let e=0;e<a.length;e++)r[e]=a.charCodeAt(e);return r.buffer},l=e=>{let t=new Uint8Array(e),a="";for(let e=0;e<t.length;e++)a+=String.fromCharCode(t[e]);return btoa(a).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")},s={challenge:r(a.challenge),rpId:a.rpId,allowCredentials:(a.allowCredentials||[]).map(e=>({type:"public-key",id:r(e.id),transports:e.transports})),timeout:a.timeout,userVerification:a.userVerification||"required"},o=await navigator.credentials.get({publicKey:s});if(!o)return void to(!1);let n=o.response,i=await u.FH.post(u.jI.Wallet,"/auth/passkey/authenticate/verify",{credential:{id:l(o.rawId),rawId:l(o.rawId),type:o.type,response:{clientDataJSON:l(n.clientDataJSON),authenticatorData:l(n.authenticatorData),signature:l(n.signature),userHandle:n.userHandle?l(n.userHandle):void 0}},pubkey:e});i.success&&i.token?(t(i.token,{persist:w?"local":"session"}),tz(),at()):A(i.error||"Biometric authentication failed")}catch(t){if(t instanceof Error&&"NotAllowedError"===t.name)return void to(!1);let e=t instanceof Error?t.message:"Biometric authentication failed";e.includes("agent_locked")?tl(!1):A(e)}finally{to(!1)}},[tz,w,t,at]),ar=(0,l.useCallback)(async()=>{C(!0),A(null);try{await ae(),I(null),R(!1),L(null),W(null),U("seed"),tz(),at()}catch(e){A(e.message||"Failed to save local agent mode")}finally{C(!1)}},[tz,at,ae]),al=(0,l.useCallback)(()=>{tm.current&&(clearTimeout(tm.current),tm.current=null),F(!1),A(null),g("locked")},[]),as=(0,l.useCallback)(async()=>{Z(!0),et(null);try{await u.FH.post(u.jI.Wallet,"/nuke",{}),G(!1),eb(!1),ec(null),ex({}),e1(null),eN(!0),eC(!1),eA(!1),eI(!1),eG(!1),J(!1),Z(!1),et(null),ea&&es(ea),window.location.reload()}catch(e){et(e.message||"Failed to nuke wallet"),console.error("[UnlockPage] Nuke failed:",e)}finally{Z(!1)}},[ea]),ao=(0,l.useCallback)(async()=>{if(!e)return void eL([]);ez(!0);try{let e=await u.FH.get(u.jI.Wallet,"/backup");e.success&&eL(e.backups)}catch(e){eL([])}finally{ez(!1)}},[e]),an=(0,l.useCallback)(async()=>{eF(!0);try{(await u.FH.post(u.jI.Wallet,"/backup")).success&&await ao()}catch(e){console.error("Backup create failed",e)}finally{eF(!1)}},[ao]),ai=(0,l.useCallback)(async()=>{eU(!0);try{let t=u.FH.getBaseUrl(u.jI.Wallet),a=await fetch("".concat(t,"/backup/export"),{headers:{Authorization:"Bearer ".concat(e||"")}});if(!a.ok)return;let r=await a.blob(),l=(a.headers.get("Content-Disposition")||"").match(/filename="?([^"]+)"?/),s=l?l[1]:"auramaxx-export.db",o=URL.createObjectURL(r),n=document.createElement("a");n.href=o,n.download=s,document.body.appendChild(n),n.click(),document.body.removeChild(n),URL.revokeObjectURL(o)}catch(e){console.error("Export failed",e)}finally{eU(!1)}},[e]),ac=(0,l.useCallback)(async e=>{eM(e);try{(await u.FH.put(u.jI.Wallet,"/backup",{filename:e})).success&&window.location.reload()}catch(e){console.error("Restore failed",e)}finally{eM(null)}},[]),ad=(0,l.useCallback)(()=>{if(tL)return void ej(!0);G(!1),eb(!1),ec(null),ex({}),e1(null),eN(!0),eC(!1),eA(!1),eI(!1),eR(!1),eW(null),eB(null),eG(!1),J(!1),Z(!1),et(null),ea&&es(ea)},[tL,ea]);if("loading"===h||"transition"===h){let e="transition"===h?"DECRYPTING AGENT":"CONNECTING";return(0,r.jsxs)("div",{className:"min-h-screen bg-[var(--color-background,#f4f4f5)] relative flex items-center justify-center p-4 overflow-hidden",children:[(0,r.jsx)(tP,{}),(0,r.jsxs)("div",{className:"fixed inset-0 pointer-events-none z-0 overflow-hidden",children:[(0,r.jsx)("div",{className:"absolute inset-0 bg-grid-adaptive bg-[size:4rem_4rem] opacity-30"}),(0,r.jsx)("div",{className:"absolute inset-0 tyvek-texture opacity-40 mix-blend-multiply"}),(0,r.jsx)("div",{className:"absolute bottom-[5%] right-[5%] opacity-5 select-none",children:(0,r.jsx)("h1",{className:"text-[15vw] font-bold leading-none text-[var(--color-text,#0a0a0a)] font-mono tracking-tighter text-right",children:"AURAMAXX"})})]}),(0,r.jsx)("div",{className:"fixed top-6 left-6 z-50 flex items-center gap-3",children:(0,r.jsx)("div",{className:"w-10 h-10",children:(0,r.jsx)("img",{src:"/logo.webp",alt:"AuraMaxx",className:"w-full h-full object-contain"})})}),(0,r.jsxs)("div",{className:"fixed top-7 right-6 z-50 flex items-center gap-3 font-mono text-[10px] tracking-widest",children:[(0,r.jsx)(n(),{href:"/docs",className:"text-[var(--color-text-muted,#6b7280)] hover:text-[var(--color-text,#0a0a0a)] transition-colors",children:"DOCS"}),(0,r.jsx)(n(),{href:"/api",className:"text-[var(--color-text-muted,#6b7280)] hover:text-[var(--color-text,#0a0a0a)] transition-colors",children:"API"}),(0,r.jsx)("a",{href:"https://github.com/Aura-Industry/auramaxx",target:"_blank",rel:"noopener noreferrer",className:"text-[var(--color-text-muted,#6b7280)] hover:text-[var(--color-text,#0a0a0a)] transition-colors",children:"GITHUB"}),(0,r.jsx)("a",{href:"https://x.com/npxauramaxx",target:"_blank",rel:"noopener noreferrer",className:"text-[var(--color-text-muted,#6b7280)] hover:text-[var(--color-text,#0a0a0a)] transition-colors",children:"X"}),(0,r.jsx)("a",{href:"https://x.com/hi_im_nico",target:"_blank",rel:"noopener noreferrer",className:"text-[var(--color-text-muted,#6b7280)] hover:text-[var(--color-text,#0a0a0a)] transition-colors",children:"HELP"}),(0,r.jsx)(tR.default,{})]}),(0,r.jsxs)("div",{className:"relative z-10 w-full max-w-[320px] p-6 flex flex-col items-center text-center ".concat(P?"animate-fade-out-up":"animate-fade-in-up"),children:[(0,r.jsx)("div",{className:"w-10 h-10 mb-2 opacity-60",children:(0,r.jsx)("img",{src:"/logo.webp",alt:"AuraMaxx",className:"w-full h-full object-contain"})}),(0,r.jsx)("div",{className:"w-6 h-6 border-2 border-[var(--color-border,#d4d4d8)] border-t-[var(--color-text,#0a0a0a)] animate-spin"}),(0,r.jsx)("div",{className:"mt-4 label-specimen text-[var(--color-text-muted,#6b7280)] animate-pulse",children:e}),(0,r.jsx)("div",{className:"mt-3 w-32 h-[2px] skeleton-mech"}),"transition"===h&&$&&(0,r.jsxs)("div",{className:"mt-6 w-full max-w-[280px] space-y-3 text-center",children:[(0,r.jsx)("div",{className:"text-[9px] text-[var(--color-danger,#ef4444)] bg-[var(--color-danger,#ef4444)]/10 px-3 py-2 border border-[var(--color-danger,#ef4444)]/20",children:"Dashboard took too long. You can retry without re-running onboarding."}),(0,r.jsx)("button",{onClick:()=>{at()},className:"w-full py-2.5 bg-[var(--color-text,#0a0a0a)] text-[var(--color-surface,#ffffff)] font-mono text-xs tracking-widest font-bold hover:opacity-90 transition-opacity clip-specimen-sm",children:"RETRY"})]})]})]})}return"unlocked"===h?(0,r.jsxs)("div",{className:"relative h-screen agent-surface",children:[(0,r.jsx)(tP,{}),(0,r.jsxs)("div",{className:"fixed top-3 right-6 z-50 flex items-center gap-1.5",children:[(0,r.jsx)("a",{href:"https://x.com/hi_im_nico",target:"_blank",rel:"noopener noreferrer",className:"p-1.5 text-[var(--color-text-muted,#6b7280)] hover:text-[var(--color-text,#0a0a0a)] hover:bg-[var(--color-surface,#ffffff)]/50 transition-colors rounded",title:"Help","aria-label":"Help",children:(0,r.jsx)(i.A,{size:14})}),(0,r.jsx)("button",{onClick:()=>G(!0),className:"p-1.5 text-[var(--color-text-muted,#6b7280)] hover:text-[var(--color-text,#0a0a0a)] hover:bg-[var(--color-surface,#ffffff)]/50 transition-colors rounded",title:"Settings","aria-label":"Settings",children:(0,r.jsx)(c.A,{size:14})}),(0,r.jsx)(th.v,{notifications:Y,onDismiss:q}),(0,r.jsx)(tR.default,{})]}),(0,r.jsxs)("div",{className:"fixed right-6 z-50 flex items-center gap-3 font-mono text-[10px] tracking-widest transition-[bottom]",style:{bottom:tk},children:[(0,r.jsx)(n(),{href:"/docs",className:"text-[var(--color-text-muted,#6b7280)] hover:text-[var(--color-text,#0a0a0a)] transition-colors",children:"DOCS"}),(0,r.jsx)(n(),{href:"/api",className:"text-[var(--color-text-muted,#6b7280)] hover:text-[var(--color-text,#0a0a0a)] transition-colors",children:"API"}),(0,r.jsx)("a",{href:"https://github.com/Aura-Industry/auramaxx",target:"_blank",rel:"noopener noreferrer",className:"text-[var(--color-text-muted,#6b7280)] hover:text-[var(--color-text,#0a0a0a)] transition-colors",children:"GITHUB"}),(0,r.jsx)("a",{href:"https://x.com/npxauramaxx",target:"_blank",rel:"noopener noreferrer",className:"text-[var(--color-text-muted,#6b7280)] hover:text-[var(--color-text,#0a0a0a)] transition-colors",children:"X"}),(0,r.jsx)("a",{href:"https://x.com/hi_im_nico",target:"_blank",rel:"noopener noreferrer",className:"text-[var(--color-text-muted,#6b7280)] hover:text-[var(--color-text,#0a0a0a)] transition-colors",children:"HELP"})]}),(0,r.jsx)(tv,{onLock:al,onSettings:()=>G(!0)}),(0,r.jsx)(tT,{isOpen:V,onClose:ad,passwordChangeSuccess:e2,agentThemeOpen:ew,onToggleAgentTheme:()=>eN(e=>!e),colorMode:o,uiScale:f,onColorModeChange:m,onUiScaleChange:v,agentColorModeOptions:tB,agentUiScaleOptions:tV,agentSettingsOpen:ek,onToggleAgentSettings:()=>eC(e=>!e),policyLoadError:eo,policyLoading:ef,onRetryLoadPolicy:()=>{tQ()},policyForm:el,onPolicyAutoApproveChange:e=>es(t=>({...t,autoApprove:e})),localProfileOptions:tH,onPolicyProfileChange:e=>es(t=>({...t,profile:e})),localProjectScopeOptions:tW,onPolicyProjectScopeModeChange:e=>es(t=>({...t,projectScopeMode:e})),dangerConfirmOpen:eg,onCancelDangerConfirm:()=>{eb(!1),ea&&es(ea)},onConfirmDangerousSave:()=>{t0()},policySaving:ev,policySaveError:ei,policySaveSuccess:eu,canSavePolicy:!eo&&!ef&&!ev&&!!ea,onSavePolicy:()=>{t0()},securitySettingsOpen:eS,onToggleSecuritySettings:()=>eA(e=>!e),passwordChangeError:e0,onOpenPasswordModal:()=>{e1(null),eG(!0)},backupSectionOpen:eT,onToggleBackupSection:()=>{let e=!eT;eR(e),e&&ao()},creatingBackup:eP,onCreateBackup:()=>{an()},exportingDb:eK,onExportDb:()=>{ai()},backupsLoading:eD,backups:eO,formatBackupDate:e=>{let t=e.slice(0,4),a=e.slice(4,6),r=e.slice(6,8),l=e.slice(9,11),s=e.slice(11,13);return"".concat(t,"-").concat(a,"-").concat(r," ").concat(l,":").concat(s)},formatSize:e=>e<1024?"".concat(e," B"):e<1048576?"".concat((e/1024).toFixed(1)," KB"):"".concat((e/1048576).toFixed(1)," MB"),restoreConfirmOpen:eH,onOpenRestoreConfirm:(e,t)=>{eB(t),eW(e)},onCloseRestoreConfirm:()=>{eW(null),eB(null)},onConfirmRestore:e=>{eW(null),eB(null),ac(e)},restoringBackup:e_,dangerZoneOpen:eE,onToggleDangerZone:()=>eI(e=>!e),nukeError:ee,onOpenNukeConfirm:()=>{et(null),J(!0)},nuking:Q}),(0,r.jsx)(b.Rw,{isOpen:X,onClose:()=>J(!1),onConfirm:()=>{as()},title:"Nuke Agent",message:"Permanently delete your agent, wallets, credentials, and local configuration. This cannot be undone.",confirmText:"NUKE",cancelText:"CANCEL",variant:"danger",loading:Q}),(0,r.jsx)(b.Rw,{isOpen:ey,onClose:()=>ej(!1),onConfirm:()=>{ej(!1),G(!1),eb(!1),ec(null),ex({}),e1(null),eN(!0),eC(!1),eA(!1),eI(!1),eR(!1),eW(null),eB(null),eG(!1),J(!1),Z(!1),et(null),ea&&es(ea)},variant:"warning",title:"Discard Changes",message:"You have unsaved local policy changes. Discard them?",confirmText:"DISCARD",cancelText:"KEEP EDITING"}),(0,r.jsx)(b.aF,{isOpen:eV,onClose:t1,title:"Change Primary Password",subtitle:"Security",size:"sm",children:(0,r.jsxs)("form",{onSubmit:t2,className:"space-y-3",children:[(0,r.jsx)(b.ks,{type:"password",label:"CURRENT PASSWORD","aria-label":"CURRENT PASSWORD",value:eY,onChange:e=>eq(e.target.value),autoFocus:!0,compact:!0}),(0,r.jsx)(b.ks,{type:"password",label:"NEW PASSWORD","aria-label":"NEW PASSWORD",value:eX,onChange:e=>eJ(e.target.value),compact:!0}),(0,r.jsx)(b.ks,{type:"password",label:"CONFIRM NEW PASSWORD","aria-label":"CONFIRM NEW PASSWORD",value:eQ,onChange:e=>eZ(e.target.value),compact:!0}),e0&&(0,r.jsx)("div",{className:"text-[10px] text-[var(--color-danger)]",children:e0}),(0,r.jsxs)("div",{className:"flex gap-2 pt-2",children:[(0,r.jsx)(b.$n,{type:"button",onClick:t1,disabled:e8,variant:"secondary",size:"lg",className:"flex-1",children:"CANCEL"}),(0,r.jsx)(b.$n,{type:"submit",disabled:e8||!eY||!eX||!eQ,variant:"primary",size:"lg",className:"flex-1",children:e8?"UPDATING...":"UPDATE PASSWORD"})]})]})}),(0,r.jsx)(tO.Z,{isUnlocked:"unlocked"===h})]}):(0,r.jsxs)("div",{className:"min-h-screen bg-[var(--color-background,#f4f4f5)] relative flex items-center justify-center p-4",children:[(0,r.jsx)(tP,{}),(0,r.jsxs)("div",{className:"fixed inset-0 pointer-events-none z-0 overflow-hidden",children:[(0,r.jsx)("div",{className:"absolute inset-0 bg-grid-adaptive bg-[size:4rem_4rem] opacity-30"}),(0,r.jsx)("div",{className:"absolute inset-0 tyvek-texture opacity-40 mix-blend-multiply"}),(0,r.jsx)("div",{className:"absolute bottom-[5%] right-[5%] opacity-5 select-none","data-testid":"home-background-branding",children:(0,r.jsx)("h1",{className:"text-[15vw] font-bold leading-none text-[var(--color-text,#0a0a0a)] font-mono tracking-tighter text-right",children:"AURAMAXX"})}),(0,r.jsx)("div",{className:"absolute top-10 left-10 w-32 h-32 border-l-4 border-t-4 border-[var(--color-text,#0a0a0a)] opacity-10",children:(0,r.jsx)("div",{className:"absolute top-2 left-2 w-4 h-4 bg-[var(--color-text,#0a0a0a)]"})}),(0,r.jsx)("div",{className:"absolute bottom-10 right-10 w-32 h-32 border-r-4 border-b-4 border-[var(--color-text,#0a0a0a)] opacity-10 flex items-end justify-end",children:(0,r.jsx)("div",{className:"absolute bottom-2 right-2 w-4 h-4 bg-[var(--color-text,#0a0a0a)]"})})]}),(0,r.jsx)("div",{className:"fixed top-6 left-6 z-50 flex items-center gap-3",children:(0,r.jsx)("div",{className:"w-10 h-10",children:(0,r.jsx)("img",{src:"/logo.webp",alt:"AuraMaxx",className:"w-full h-full object-contain"})})}),(0,r.jsxs)("div",{className:"fixed top-7 right-6 z-50 flex items-center gap-3 font-mono text-[10px] tracking-widest",children:[(0,r.jsx)(n(),{href:"/docs",className:"text-[var(--color-text-muted,#6b7280)] hover:text-[var(--color-text,#0a0a0a)] transition-colors",children:"DOCS"}),(0,r.jsx)(n(),{href:"/api",className:"text-[var(--color-text-muted,#6b7280)] hover:text-[var(--color-text,#0a0a0a)] transition-colors",children:"API"}),(0,r.jsx)("a",{href:"https://github.com/Aura-Industry/auramaxx",target:"_blank",rel:"noopener noreferrer",className:"text-[var(--color-text-muted,#6b7280)] hover:text-[var(--color-text,#0a0a0a)] transition-colors",children:"GITHUB"}),(0,r.jsx)("a",{href:"https://x.com/npxauramaxx",target:"_blank",rel:"noopener noreferrer",className:"text-[var(--color-text-muted,#6b7280)] hover:text-[var(--color-text,#0a0a0a)] transition-colors",children:"X"}),(0,r.jsx)("a",{href:"https://x.com/hi_im_nico",target:"_blank",rel:"noopener noreferrer",className:"text-[var(--color-text-muted,#6b7280)] hover:text-[var(--color-text,#0a0a0a)] transition-colors",children:"HELP"}),(0,r.jsx)(tR.default,{})]}),(0,r.jsxs)("div",{className:"relative z-10 w-full max-w-[380px]",children:[(0,r.jsx)("div",{className:"absolute -left-8 top-1/2 -translate-y-1/2 text-vertical label-specimen-sm text-[var(--color-text-faint,#9ca3af)] select-none hidden sm:block",children:"AGENT\xa0ACCESS"}),(0,r.jsxs)("div",{className:"bg-[var(--color-surface,#f4f4f2)] clip-specimen border-mech shadow-mech overflow-hidden font-mono corner-marks",children:[(0,r.jsxs)("div",{className:"px-5 py-3 border-b border-[var(--color-border,#d4d4d8)] bg-[var(--color-surface-alt,#fafafa)] flex items-center justify-between",children:[(0,r.jsx)("span",{className:"font-sans font-bold text-sm text-[var(--color-text,#0a0a0a)] uppercase tracking-tight",children:"setup"===h?"Initialize":"Unlock"}),(0,r.jsx)("span",{className:"text-[9px] text-[var(--color-text-faint,#9ca3af)] font-bold tracking-widest",children:"setup"===h?"NO_AGENT":"LOCKED"})]}),(0,r.jsxs)("div",{className:"p-6",children:["setup"===h&&E&&"seed"===K&&(0,r.jsxs)("div",{className:"flex flex-col items-center",children:[(0,r.jsx)("div",{className:"w-16 h-16 mb-4",children:(0,r.jsx)("img",{src:"/logo.webp",alt:"AuraMaxx",className:"w-full h-full object-contain"})}),(0,r.jsx)("div",{className:"text-[10px] text-[var(--color-text-muted,#6b7280)] tracking-widest text-center mb-4",children:"SAVE YOUR RECOVERY PHRASE"}),(0,r.jsx)("div",{className:"text-[9px] text-[var(--color-danger,#ef4444)] bg-[var(--color-danger,#ef4444)]/10 px-3 py-2 border border-[var(--color-danger,#ef4444)]/20 mb-3",children:"Write this down and store it securely. You will stay on this screen until you explicitly confirm."}),O&&(0,r.jsx)("div",{className:"text-[9px] text-[var(--color-info,#0047ff)] bg-[var(--color-info,#0047ff)]/10 px-3 py-2 border border-[var(--color-info,#0047ff)]/20 mb-3",children:O}),(0,r.jsx)("div",{className:"grid grid-cols-3 gap-2 w-full mb-4",children:E.split(" ").map((e,t)=>(0,r.jsxs)("div",{className:"text-[10px] font-mono text-[var(--color-text,#0a0a0a)] bg-[var(--color-background,#f4f4f5)] px-2 py-1 border border-[var(--color-border,#d4d4d8)]",children:[(0,r.jsxs)("span",{className:"text-[var(--color-text-faint,#9ca3af)] mr-1",children:[t+1,"."]}),e]},t))}),(0,r.jsxs)("div",{className:"grid grid-cols-2 gap-2 w-full mb-3",children:[(0,r.jsx)("button",{type:"button",onClick:()=>{t6()},className:"h-9 px-2 border border-[var(--color-border,#d4d4d8)] font-mono text-[9px] tracking-widest text-[var(--color-text,#0a0a0a)] hover:bg-[var(--color-surface-alt,#fafafa)] transition-colors",children:"COPY SEED PHRASE"}),(0,r.jsx)("button",{type:"button",onClick:t7,className:"h-9 px-2 border border-[var(--color-border,#d4d4d8)] font-mono text-[9px] tracking-widest text-[var(--color-text,#0a0a0a)] hover:bg-[var(--color-surface-alt,#fafafa)] transition-colors",children:"DOWNLOAD BACKUP (.MD)"})]}),D&&(0,r.jsx)("div",{className:"w-full mb-3 text-[9px] text-[var(--color-text-muted,#6b7280)]","aria-live":"polite","data-testid":"seed-phrase-action-status",children:D}),(0,r.jsxs)("label",{className:"flex items-start gap-2 w-full mb-3 cursor-pointer",children:[(0,r.jsx)("input",{type:"checkbox",checked:T,onChange:e=>R(e.target.checked),className:"mt-0.5"}),(0,r.jsx)("span",{className:"text-[9px] text-[var(--color-text-muted,#6b7280)]",children:"I have written and verified this recovery phrase in a secure location."})]}),(0,r.jsx)("button",{onClick:()=>{T&&U("trust")},disabled:!T,className:"w-full py-2.5 bg-[var(--color-text,#0a0a0a)] text-[var(--color-surface,#ffffff)] font-mono text-xs tracking-widest font-bold hover:opacity-90 transition-opacity disabled:opacity-30 disabled:cursor-not-allowed",children:"CONTINUE TO AGENT MODE"}),(0,r.jsx)("div",{className:"w-full mt-3 text-[8px] text-[var(--color-text-faint,#9ca3af)] text-center",children:"If you leave before confirming, this phrase is recoverable only temporarily in this tab session. If recovery expires, restart onboarding to regenerate."})]}),"setup"===h&&E&&"trust"===K&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"flex flex-col items-center mb-6",children:[(0,r.jsx)("div",{className:"w-16 h-16 mb-4",children:(0,r.jsx)("img",{src:"/logo.webp",alt:"AuraMaxx",className:"w-full h-full object-contain"})}),(0,r.jsx)("div",{className:"text-[10px] text-[var(--color-text-muted,#6b7280)] tracking-widest text-center",children:"LOCAL AGENT MODE"})]}),(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsx)("div",{className:"text-[9px] text-[var(--color-text-muted,#6b7280)] bg-[var(--color-background,#f4f4f5)] px-3 py-2 border border-[var(--color-border,#d4d4d8)]",children:"How much do you trust your agent?"}),(0,r.jsxs)("fieldset",{className:"border border-[var(--color-border,#d4d4d8)] p-2.5 bg-[var(--color-background,#f4f4f5)]",children:[(0,r.jsx)("legend",{className:"text-[8px] text-[var(--color-text-faint,#9ca3af)] tracking-widest uppercase px-1",children:"Pick a profile"}),(0,r.jsx)(b.O6,{options:[...t$],value:_,onChange:e=>M(e),ariaLabel:"Onboarding local agent mode"})]}),S&&(0,r.jsx)("div",{className:"text-[9px] text-[var(--color-danger,#ef4444)] bg-[var(--color-danger,#ef4444)]/10 px-3 py-2 border border-[var(--color-danger,#ef4444)]/20",children:S}),(0,r.jsx)("button",{onClick:()=>{ar()},disabled:k,className:"w-full py-2.5 bg-[var(--color-text,#0a0a0a)] text-[var(--color-surface,#ffffff)] font-mono text-xs tracking-widest font-bold hover:opacity-90 transition-opacity disabled:opacity-30 disabled:cursor-not-allowed flex items-center justify-center gap-2",children:k?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("div",{className:"w-3 h-3 border border-[var(--color-surface,#ffffff)] border-t-transparent animate-spin"}),"SAVING..."]}):"SAVE MODE AND CONTINUE"})]})]}),"setup"===h&&!E&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"flex flex-col items-center mb-6",children:[(0,r.jsx)("div",{className:"w-16 h-16 mb-4",children:(0,r.jsx)("img",{src:"/logo.webp",alt:"AuraMaxx",className:"w-full h-full object-contain"})}),(0,r.jsx)("div",{className:"text-[10px] text-[var(--color-text-muted,#6b7280)] tracking-widest text-center",children:"CREATE YOUR ENCRYPTED AGENT"}),(0,r.jsx)("div",{className:"mt-2 text-[9px] text-[var(--color-text-faint,#9ca3af)] text-center leading-relaxed","data-testid":"start-banner-quote",children:tn})]}),(0,r.jsxs)("form",{onSubmit:t9,className:"space-y-4",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:"block text-[8px] text-[var(--color-text-faint,#9ca3af)] tracking-widest mb-1.5 uppercase",children:"Encryption Password"}),(0,r.jsx)("input",{type:"password",value:y,onChange:e=>{j(e.target.value),A(null)},placeholder:"Minimum 8 characters",className:"w-full px-3 py-2.5 border border-[var(--color-border,#d4d4d8)] font-mono text-sm text-[var(--color-text,#0a0a0a)] focus:outline-none focus:border-[var(--color-text,#0a0a0a)] bg-[var(--color-surface,#ffffff)] placeholder-[var(--color-text-faint,#9ca3af)] transition-colors",autoFocus:!0})]}),(0,r.jsxs)("label",{className:"flex items-center justify-between gap-3 text-[8px] tracking-widest uppercase text-[var(--color-text-muted,#6b7280)]",children:[(0,r.jsxs)("span",{className:"inline-flex items-center gap-2",children:[(0,r.jsx)("input",{type:"checkbox",checked:w,onChange:e=>N(e.target.checked),className:"h-3.5 w-3.5 border border-[var(--color-border,#d4d4d8)] accent-[var(--color-text,#0a0a0a)]"}),"Trusted device"]}),(0,r.jsx)("span",{children:w?"PERSISTENT":"TAB ONLY"})]}),S&&(0,r.jsx)("div",{className:"text-[9px] text-[var(--color-danger,#ef4444)] bg-[var(--color-danger,#ef4444)]/10 px-3 py-2 border border-[var(--color-danger,#ef4444)]/20",children:S}),(0,r.jsx)("button",{type:"submit",disabled:k||y.length<8,className:"w-full py-2.5 bg-[var(--color-text,#0a0a0a)] text-[var(--color-surface,#ffffff)] font-mono text-xs tracking-widest font-bold hover:opacity-90 transition-opacity disabled:opacity-30 disabled:cursor-not-allowed flex items-center justify-center gap-2",children:k?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("div",{className:"w-3 h-3 border border-[var(--color-surface,#ffffff)] border-t-transparent animate-spin"}),"INITIALIZING..."]}):"INITIALIZE AGENT"})]}),(0,r.jsx)("div",{className:"mt-4 pt-4 border-t border-[var(--color-border,#d4d4d8)]",children:(0,r.jsxs)("div",{className:"flex items-start gap-2",children:[(0,r.jsx)("div",{className:"w-1 h-1 bg-[var(--color-text-muted,#6b7280)] mt-1.5 flex-shrink-0"}),(0,r.jsx)("span",{className:"text-[8px] text-[var(--color-text-faint,#9ca3af)] leading-relaxed",children:"This password encrypts your seed phrase locally. It never leaves your machine."})]})})]}),"locked"===h&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"flex flex-col items-center mb-6",children:[(0,r.jsx)("div",{className:"w-16 h-16 mb-4",children:(0,r.jsx)("img",{src:"/logo.webp",alt:"AuraMaxx",className:"w-full h-full object-contain"})}),(0,r.jsx)("div",{className:"text-[10px] text-[var(--color-text-muted,#6b7280)] tracking-widest text-center",children:e5?"RECOVER WITH SEED PHRASE":tr?"UNLOCK AGENT":"ENTER PASSWORD TO UNLOCK"}),(0,r.jsx)("div",{className:"mt-2 text-[9px] text-[var(--color-text,#0a0a0a)] text-center leading-relaxed","data-testid":"start-banner-quote",children:tn})]}),!e5&&(0,r.jsxs)(r.Fragment,{children:[tr&&(0,r.jsxs)("div",{className:"mb-4",children:[(0,r.jsx)("button",{type:"button",onClick:()=>{aa()},disabled:ts,className:"w-full py-3 bg-[var(--color-text,#0a0a0a)] text-[var(--color-surface,#ffffff)] font-mono text-xs tracking-widest font-bold hover:opacity-90 transition-opacity disabled:opacity-50 flex items-center justify-center gap-2",children:ts?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("div",{className:"w-3 h-3 border border-[var(--color-surface,#ffffff)] border-t-transparent animate-spin"}),"AUTHENTICATING..."]}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(d.A,{size:14}),"UNLOCK WITH PASSKEY"]})}),(0,r.jsxs)("div",{className:"mt-3 flex items-center gap-3",children:[(0,r.jsx)("div",{className:"flex-1 h-px bg-[var(--color-border,#d4d4d8)]"}),(0,r.jsx)("span",{className:"text-[8px] text-[var(--color-text-faint,#9ca3af)] tracking-widest",children:"OR USE PASSWORD"}),(0,r.jsx)("div",{className:"flex-1 h-px bg-[var(--color-border,#d4d4d8)]"})]})]}),(0,r.jsxs)("form",{onSubmit:t5,className:"space-y-4",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:"block text-[8px] text-[var(--color-text-faint,#9ca3af)] tracking-widest mb-1.5 uppercase",children:"Password"}),(0,r.jsx)("input",{type:"password",value:y,onChange:e=>{j(e.target.value),A(null)},placeholder:"Enter agent password",className:"w-full px-3 py-2.5 border border-[var(--color-border,#d4d4d8)] font-mono text-sm text-[var(--color-text,#0a0a0a)] focus:outline-none focus:border-[var(--color-text,#0a0a0a)] bg-[var(--color-surface,#ffffff)] placeholder-[var(--color-text-faint,#9ca3af)] transition-colors",autoFocus:!0})]}),(0,r.jsxs)("label",{className:"flex items-center justify-between gap-3 text-[8px] tracking-widest uppercase text-[var(--color-text-muted,#6b7280)]",children:[(0,r.jsxs)("span",{className:"inline-flex items-center gap-2",children:[(0,r.jsx)("input",{type:"checkbox",checked:w,onChange:e=>N(e.target.checked),className:"h-3.5 w-3.5 border border-[var(--color-border,#d4d4d8)] accent-[var(--color-text,#0a0a0a)]"}),"Trusted device"]}),(0,r.jsx)("span",{children:w?"PERSISTENT":"TAB ONLY"})]}),S&&(0,r.jsx)("div",{"data-testid":"unlock-error-banner",className:"text-[9px] text-[var(--color-danger,#ef4444)] px-3 py-2 border",style:{borderColor:"color-mix(in srgb, var(--color-danger,#ef4444) 35%, transparent)",background:"color-mix(in srgb, var(--color-danger,#ef4444) 12%, transparent)"},children:S}),(0,r.jsx)("button",{type:"submit",disabled:k||!y,className:"w-full py-2.5 bg-[var(--color-text,#0a0a0a)] text-[var(--color-surface,#ffffff)] font-mono text-xs tracking-widest font-bold hover:opacity-90 transition-opacity disabled:opacity-30 disabled:cursor-not-allowed flex items-center justify-center gap-2",children:k?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("div",{className:"w-3 h-3 border border-[var(--color-surface,#ffffff)] border-t-transparent animate-spin"}),"UNLOCKING..."]}):"UNLOCK"})]}),(0,r.jsx)("div",{className:"mt-4 border-t border-[var(--color-border,#d4d4d8)] pt-3 text-center",children:(0,r.jsx)("button",{type:"button",onClick:()=>{e9(!0),tx(null)},className:"text-[10px] underline underline-offset-2 text-[var(--color-text-muted,#6b7280)] hover:text-[var(--color-text,#0a0a0a)] transition-colors",children:"Forgot password?"})})]}),e5&&(0,r.jsx)("div",{className:"mt-4 border-t border-[var(--color-border,#d4d4d8)] pt-3 text-center",children:(0,r.jsx)("button",{type:"button",onClick:()=>{e9(!1),tx(null)},className:"text-[10px] underline underline-offset-2 text-[var(--color-text-muted,#6b7280)] hover:text-[var(--color-text,#0a0a0a)] transition-colors",children:"Back to unlock"})}),e5&&(0,r.jsxs)("form",{onSubmit:t3,className:"mt-4 space-y-3",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between",children:[(0,r.jsx)("div",{className:"text-[9px] tracking-widest uppercase text-[var(--color-text-muted,#6b7280)]",children:"Seed Recovery"}),(0,r.jsxs)("div",{className:"flex items-center gap-1",children:[(0,r.jsx)("button",{type:"button",onClick:()=>{te(12),ta(Array(12).fill(""))},className:"px-2 py-1 text-[8px] border ".concat(12===e6?"bg-[var(--color-text,#0a0a0a)] text-[var(--color-surface,#fff)] border-[var(--color-text,#0a0a0a)]":"border-[var(--color-border,#d4d4d8)] text-[var(--color-text-muted,#6b7280)]"),children:"12"}),(0,r.jsx)("button",{type:"button",onClick:()=>{te(24),ta(Array(24).fill(""))},className:"px-2 py-1 text-[8px] border ".concat(24===e6?"bg-[var(--color-text,#0a0a0a)] text-[var(--color-surface,#fff)] border-[var(--color-text,#0a0a0a)]":"border-[var(--color-border,#d4d4d8)] text-[var(--color-text-muted,#6b7280)]"),children:"24"})]})]}),(0,r.jsx)("div",{className:"grid grid-cols-3 gap-1.5",children:tt.map((e,t)=>{let a=tA.has(t);return(0,r.jsx)(b.ks,{compact:!0,error:a,"aria-label":"Recovery word ".concat(t+1),value:e,onChange:e=>t4(t,e.target.value),onPaste:e=>{t8(t,e.clipboardData.getData("text"))&&e.preventDefault()},placeholder:"".concat(t+1),className:"min-w-0"},"recovery-word-".concat(t))})}),(0,r.jsxs)("div",{className:"text-[9px] text-[var(--color-text-faint,#9ca3af)]",children:[tC,"/",e6," words \xb7 ",tA.size>0?"".concat(tA.size," invalid word(s)"):tE?"BIP-39 phrase valid":"Waiting for valid BIP-39 phrase"]}),(0,r.jsx)(b.ks,{type:"password",compact:!0,value:ti,onChange:e=>{tc(e.target.value),tx(null)},placeholder:"New password","aria-label":"New password"}),td&&(0,r.jsx)("div",{className:"text-[9px] text-[var(--color-danger,#ef4444)] bg-[var(--color-danger,#ef4444)]/10 px-3 py-2 border border-[var(--color-danger,#ef4444)]/20",children:td}),(0,r.jsx)("button",{type:"submit",disabled:tu,className:"w-full py-2.5 bg-[var(--color-text,#0a0a0a)] text-[var(--color-surface,#ffffff)] font-mono text-xs tracking-widest font-bold hover:opacity-90 transition-opacity disabled:opacity-30",children:tu?"RECOVERING...":"RECOVER & UNLOCK"})]})]})]}),(0,r.jsxs)("div",{className:"flex items-center gap-3 px-5 py-2 border-t border-[var(--color-border,#d4d4d8)]",children:[(0,r.jsx)("div",{className:"h-4 flex-1 bg-[repeating-linear-gradient(90deg,var(--color-text,#000),var(--color-text,#000)_1px,transparent_1px,transparent_3px)] opacity-30"}),(0,r.jsx)("span",{className:"text-[8px] text-[var(--color-text-faint,#9ca3af)] tracking-wider",children:"AURAMAXX"})]}),(0,r.jsx)("div",{className:"h-2 w-full",style:{backgroundImage:"repeating-linear-gradient(45deg, var(--color-text, #000), var(--color-text, #000) 5px, transparent 5px, transparent 10px)",opacity:.1}})]}),(0,r.jsx)("div",{className:"mt-4 text-center",children:(0,r.jsx)("span",{className:"text-[8px] text-[var(--color-text-faint,#9ca3af)] tracking-[0.2em] font-mono",children:"SECURE LOCAL WALLETS FOR AI AGENTS"})})]})]})}},4265:(e,t,a)=>{"use strict";a.d(t,{default:()=>s});var r=a(5155),l=a(5685);function s(){let{colorMode:e,setColorMode:t}=(0,l.D)(),a="light"===e;return(0,r.jsx)("button",{onClick:()=>{t(a?"dark":"light")},className:"p-1.5 text-[var(--color-text-muted,#6b7280)] hover:text-[var(--color-text,#0a0a0a)] hover:bg-[var(--color-surface,#ffffff)]/50 transition-colors rounded","aria-label":a?"Switch to dark mode":"Switch to light mode",children:a?(0,r.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:(0,r.jsx)("path",{d:"M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z"})}):(0,r.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,r.jsx)("circle",{cx:"12",cy:"12",r:"5"}),(0,r.jsx)("line",{x1:"12",y1:"1",x2:"12",y2:"3"}),(0,r.jsx)("line",{x1:"12",y1:"21",x2:"12",y2:"23"}),(0,r.jsx)("line",{x1:"4.22",y1:"4.22",x2:"5.64",y2:"5.64"}),(0,r.jsx)("line",{x1:"18.36",y1:"18.36",x2:"19.78",y2:"19.78"}),(0,r.jsx)("line",{x1:"1",y1:"12",x2:"3",y2:"12"}),(0,r.jsx)("line",{x1:"21",y1:"12",x2:"23",y2:"12"}),(0,r.jsx)("line",{x1:"4.22",y1:"19.78",x2:"5.64",y2:"18.36"}),(0,r.jsx)("line",{x1:"18.36",y1:"5.64",x2:"19.78",y2:"4.22"})]})})}},6793:(e,t,a)=>{Promise.resolve().then(a.bind(a,858))},8824:(e,t,a)=>{"use strict";a.d(t,{e:()=>s});var r=a(2115),l=a(960);function s(){let e=(0,r.useMemo)(()=>(0,l.au)(),[]),[t,a]=(0,r.useState)({checking:!1,updateAvailable:!1,current:null,latest:null,updating:!1,updateOutput:null,updateError:null,apiServerDown:!1,restartingServer:!1,restartError:null}),s=(0,r.useCallback)(async()=>{a(e=>({...e,checking:!0}));try{let e=await fetch("/api/version",{cache:"no-store"});if(!e.ok)return;let t=await e.json();t.success&&a(e=>({...e,checking:!1,updateAvailable:t.updateAvailable,current:t.current,latest:t.latest}))}catch(e){a(e=>({...e,checking:!1}))}},[]),o=(0,r.useCallback)(async()=>{a(e=>({...e,updating:!0,updateError:null,updateOutput:null}));try{let e=await fetch("/api/update",{method:"POST"}),t=await e.json();t.success?a(e=>({...e,updating:!1,updateAvailable:!1,updateOutput:t.output||"Update completed successfully."})):a(e=>({...e,updating:!1,updateError:t.error||"Update failed.",updateOutput:t.output||null}))}catch(e){a(t=>({...t,updating:!1,updateError:e.message||"Update request failed."}))}},[]),n=(0,r.useCallback)(async()=>{try{let t=!(await fetch("".concat(e,"/health"),{cache:"no-store"})).ok;a(e=>e.apiServerDown===t&&(t||!e.restartError)?e:{...e,apiServerDown:t,restartError:t?e.restartError:null})}catch(e){a(e=>e.apiServerDown?e:{...e,apiServerDown:!0})}},[e]),i=(0,r.useCallback)(async()=>{a(e=>({...e,restartingServer:!0,restartError:null}));try{let e=await fetch("/api/restart",{method:"POST"}),t=await e.json().catch(()=>({success:!1,error:"Invalid restart response."}));if(!e.ok||!t.success)throw Error(t.error||"Restart failed (".concat(e.status,")"));a(e=>({...e,restartingServer:!1,apiServerDown:!0,restartError:null})),window.setTimeout(()=>{window.location.reload()},2e3)}catch(e){a(t=>({...t,restartingServer:!1,restartError:e.message||"Restart request failed."}))}},[]);return(0,r.useEffect)(()=>{s()},[s]),(0,r.useEffect)(()=>{n();let e=window.setInterval(()=>{n()},8e3);return()=>{window.clearInterval(e)}},[n]),(0,r.useEffect)(()=>{let e=()=>{"visible"===document.visibilityState&&n()};return document.addEventListener("visibilitychange",e),()=>{document.removeEventListener("visibilitychange",e)}},[n]),{...t,runUpdate:o,checkForUpdate:s,runRestart:i,checkApiHealth:n}}}},e=>{e.O(0,[2619,7616,142,5553,4685,3667,4901,6872,8441,1255,7358],()=>e(e.s=6793)),_N_E=e.O()}]);
|