trybeacon 0.1.81 → 0.1.83
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/.claude-plugin/plugin.json +1 -1
- package/.next/BUILD_ID +1 -1
- package/.next/app-path-routes-manifest.json +19 -18
- package/.next/build-manifest.json +2 -2
- package/.next/prerender-manifest.json +3 -3
- package/.next/routes-manifest.json +20 -1
- package/.next/server/app/@modal/(.)settings/page.js +2 -0
- package/.next/server/app/@modal/(.)settings/page.js.nft.json +1 -0
- package/.next/server/app/@modal/(.)settings/page_client-reference-manifest.js +1 -0
- package/.next/server/app/_global-error/page.js +3 -3
- package/.next/server/app/_global-error/page_client-reference-manifest.js +1 -1
- package/.next/server/app/_global-error.html +1 -1
- package/.next/server/app/_global-error.rsc +1 -1
- package/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
- package/.next/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +1 -1
- package/.next/server/app/_global-error.segments/_global-error.segment.rsc +1 -1
- package/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
- package/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
- package/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
- package/.next/server/app/_not-found/page.js +2 -2
- package/.next/server/app/_not-found/page.js.nft.json +1 -1
- 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 +27 -26
- package/.next/server/app/_not-found.segments/_full.segment.rsc +27 -26
- package/.next/server/app/_not-found.segments/_head.segment.rsc +1 -1
- package/.next/server/app/_not-found.segments/_index.segment.rsc +16 -15
- package/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
- package/.next/server/app/_not-found.segments/_not-found.segment.rsc +1 -1
- package/.next/server/app/_not-found.segments/_tree.segment.rsc +2 -2
- package/.next/server/app/api/ask/answer/route.js +1 -1
- package/.next/server/app/api/ask/route.js +1 -1
- package/.next/server/app/api/ask/verdict/route.js +1 -1
- package/.next/server/app/api/board-annotations/[id]/route.js +1 -1
- package/.next/server/app/api/board-annotations/route.js +1 -1
- package/.next/server/app/api/board-layout/route.js +1 -1
- package/.next/server/app/api/bug-flags/[id]/route.js +1 -1
- package/.next/server/app/api/bug-flags/route.js +1 -1
- package/.next/server/app/api/changes/comment/answer/route.js +1 -1
- package/.next/server/app/api/changes/comment/claim/route.js +2 -2
- package/.next/server/app/api/changes/comment/route.js +2 -2
- package/.next/server/app/api/changes/quality/route.js +1 -1
- package/.next/server/app/api/changes/route.js +1 -1
- package/.next/server/app/api/changes/viewed/route.js +1 -1
- package/.next/server/app/api/code-graph/position/route.js +1 -1
- package/.next/server/app/api/code-graph/route.js +1 -1
- package/.next/server/app/api/context/feature/route.js +1 -1
- package/.next/server/app/api/context/file/route.js +1 -1
- package/.next/server/app/api/context/route.js +1 -1
- package/.next/server/app/api/db/arrange/route.js +1 -1
- package/.next/server/app/api/db/backfill-access/route.js +1 -1
- package/.next/server/app/api/db/position/route.js +1 -1
- package/.next/server/app/api/db/prune-planned/route.js +1 -1
- package/.next/server/app/api/db/reconcile-endpoints/route.js +1 -1
- package/.next/server/app/api/db/relations/[id]/route.js +1 -1
- package/.next/server/app/api/db/tables/[id]/route.js +1 -1
- package/.next/server/app/api/draft/approve/route.js +1 -1
- package/.next/server/app/api/draft/route.js +1 -1
- package/.next/server/app/api/draft/status/route.js +1 -1
- package/.next/server/app/api/edges/[id]/route.js +1 -1
- package/.next/server/app/api/edges/route.js +1 -1
- package/.next/server/app/api/endpoints/[id]/route.js +1 -1
- package/.next/server/app/api/entities/route.js +1 -1
- package/.next/server/app/api/ingest/route.js +1 -1
- package/.next/server/app/api/init/route.js +1 -1
- package/.next/server/app/api/lesson/close/route.js +1 -1
- package/.next/server/app/api/lesson/presence/route.js +1 -1
- package/.next/server/app/api/lesson/questions/route.js +1 -1
- package/.next/server/app/api/lesson/route.js +1 -1
- package/.next/server/app/api/lesson/save/route.js +1 -1
- package/.next/server/app/api/lesson/verdict/route.js +1 -1
- package/.next/server/app/api/linear/route.js +2 -2
- package/.next/server/app/api/linear/scopes/route.js +1 -1
- package/.next/server/app/api/linear/sync/route.js +2 -2
- package/.next/server/app/api/map/describe/route.js +1 -1
- package/.next/server/app/api/map/files/route.js +1 -1
- package/.next/server/app/api/map/finish/route.js +1 -1
- package/.next/server/app/api/map/route.js +1 -1
- package/.next/server/app/api/map/start/route.js +1 -1
- package/.next/server/app/api/map/touch-active/route.js +1 -1
- package/.next/server/app/api/mention-search/route.js +1 -1
- package/.next/server/app/api/nodes/[id]/position/route.js +1 -1
- package/.next/server/app/api/nodes/[id]/route.js +1 -1
- package/.next/server/app/api/nodes/positions/route.js +1 -1
- package/.next/server/app/api/nodes/route.js +1 -1
- package/.next/server/app/api/nodes/subtasks/route.js +1 -1
- package/.next/server/app/api/notes/[id]/route.js +1 -1
- package/.next/server/app/api/notes/route.js +1 -1
- package/.next/server/app/api/open/route.js +1 -1
- package/.next/server/app/api/plan/annotations/route.js +2 -2
- package/.next/server/app/api/plan/approve/route.js +1 -1
- package/.next/server/app/api/plan/history/route.js +1 -1
- package/.next/server/app/api/plan/markdown/route.js +1 -1
- package/.next/server/app/api/plan/presence/route.js +1 -1
- package/.next/server/app/api/plan/route.js +1 -1
- package/.next/server/app/api/plan/verdict/route.js +1 -1
- package/.next/server/app/api/preferences/route.js +1 -1
- package/.next/server/app/api/project-meta/route.js +1 -1
- package/.next/server/app/api/reset/route.js +1 -1
- package/.next/server/app/api/scope-guard/check/route.js +2 -2
- package/.next/server/app/api/share/create/route.js +1 -1
- package/.next/server/app/api/share/route.js +1 -1
- package/.next/server/app/api/stream/route.js +2 -2
- package/.next/server/app/api/tab/nav/route.js +1 -1
- package/.next/server/app/api/tab/presence/route.js +1 -1
- package/.next/server/app/api/tab/view/route.js +1 -1
- package/.next/server/app/api/telemetry/route.js +1 -1
- package/.next/server/app/api/telemetry/stats/route.js +1 -1
- package/.next/server/app/api/version/route.js +1 -1
- package/.next/server/app/api/workspace/activate/route.js +1 -1
- package/.next/server/app/api/workspace/route.js +1 -1
- package/.next/server/app/apple-icon.png/route.js +1 -1
- package/.next/server/app/docs/page.js +2 -2
- package/.next/server/app/docs/page.js.nft.json +1 -1
- package/.next/server/app/docs/page_client-reference-manifest.js +1 -1
- package/.next/server/app/docs.html +1 -1
- package/.next/server/app/docs.meta +1 -0
- package/.next/server/app/docs.rsc +31 -28
- package/.next/server/app/docs.segments/@modal/__DEFAULT__.segment.rsc +2 -0
- package/.next/server/app/docs.segments/_full.segment.rsc +31 -28
- package/.next/server/app/docs.segments/_head.segment.rsc +1 -1
- package/.next/server/app/docs.segments/_index.segment.rsc +17 -16
- package/.next/server/app/docs.segments/_tree.segment.rsc +2 -2
- package/.next/server/app/docs.segments/docs/__PAGE__.segment.rsc +1 -1
- package/.next/server/app/docs.segments/docs.segment.rsc +1 -1
- package/.next/server/app/help/page.js +2 -2
- package/.next/server/app/help/page.js.nft.json +1 -1
- package/.next/server/app/help/page_client-reference-manifest.js +1 -1
- package/.next/server/app/help.html +1 -1
- package/.next/server/app/help.meta +1 -0
- package/.next/server/app/help.rsc +40 -36
- package/.next/server/app/help.segments/@modal/__DEFAULT__.segment.rsc +2 -0
- package/.next/server/app/help.segments/_full.segment.rsc +40 -36
- package/.next/server/app/help.segments/_head.segment.rsc +1 -1
- package/.next/server/app/help.segments/_index.segment.rsc +17 -16
- package/.next/server/app/help.segments/_tree.segment.rsc +2 -2
- package/.next/server/app/help.segments/help/__PAGE__.segment.rsc +1 -1
- package/.next/server/app/help.segments/help.segment.rsc +1 -1
- package/.next/server/app/icon.svg/route.js +1 -1
- package/.next/server/app/index.html +1 -1
- package/.next/server/app/index.meta +1 -0
- package/.next/server/app/index.rsc +30 -26
- package/.next/server/app/index.segments/@modal/__DEFAULT__.segment.rsc +2 -0
- package/.next/server/app/index.segments/__PAGE__.segment.rsc +2 -2
- package/.next/server/app/index.segments/_full.segment.rsc +30 -26
- package/.next/server/app/index.segments/_head.segment.rsc +1 -1
- package/.next/server/app/index.segments/_index.segment.rsc +17 -16
- package/.next/server/app/index.segments/_tree.segment.rsc +2 -2
- package/.next/server/app/learn/page.js +4 -4
- package/.next/server/app/learn/page.js.nft.json +1 -1
- package/.next/server/app/learn/page_client-reference-manifest.js +1 -1
- package/.next/server/app/map/page.js +2 -2
- package/.next/server/app/map/page.js.nft.json +1 -1
- package/.next/server/app/map/page_client-reference-manifest.js +1 -1
- package/.next/server/app/page.js +2 -2
- 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/plan/page.js +3 -3
- package/.next/server/app/plan/page.js.nft.json +1 -1
- package/.next/server/app/plan/page_client-reference-manifest.js +1 -1
- package/.next/server/app/s/[token]/page.js +2 -2
- package/.next/server/app/s/[token]/page.js.nft.json +1 -1
- package/.next/server/app/s/[token]/page_client-reference-manifest.js +1 -1
- package/.next/server/app/settings/page.js +2 -2
- package/.next/server/app/settings/page.js.nft.json +1 -1
- package/.next/server/app/settings/page_client-reference-manifest.js +1 -1
- package/.next/server/app-paths-manifest.json +19 -18
- package/.next/server/chunks/2025.js +1 -1
- package/.next/server/chunks/2311.js +1 -0
- package/.next/server/chunks/2693.js +5 -5
- package/.next/server/chunks/3237.js +1 -0
- package/.next/server/chunks/3825.js +1 -0
- package/.next/server/chunks/4990.js +1 -0
- package/.next/server/chunks/6819.js +2 -0
- package/.next/server/chunks/{141.js → 7436.js} +3 -3
- package/.next/server/chunks/7999.js +1 -0
- package/.next/server/interception-route-rewrite-manifest.js +1 -1
- package/.next/server/middleware-build-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.js +1 -1
- package/.next/server/server-reference-manifest.json +1 -1
- package/.next/static/BuULrtf1kXZqNPMDIPeVT/_buildManifest.js +1 -0
- package/.next/static/chunks/1569-ea8e739cccfb69b5.js +1 -0
- package/.next/static/chunks/2022-78e7580c848ef6b3.js +1 -0
- package/.next/static/chunks/2114-74736df56930b46c.js +1 -0
- package/.next/static/chunks/4853-251169ab5b4979c2.js +1 -0
- package/.next/static/chunks/{9887-e8954568a4031ed3.js → 5547-2c07851028a9033a.js} +1 -1
- package/.next/static/chunks/569-d0686e63d8510369.js +1 -0
- package/.next/static/chunks/{4674-31ad596c3e856647.js → 6283-20a6abe3453496ae.js} +3 -3
- package/.next/static/chunks/7347-eeea5e910206d07a.js +1 -0
- package/.next/static/chunks/{5957-83f611fcd5a08b45.js → 8710-6b2685272a1e1ff7.js} +1 -1
- package/.next/static/chunks/app/@modal/(.)settings/page-b3f7a82b4124b813.js +1 -0
- package/.next/static/chunks/app/@modal/default-b0a80080b8e8a17d.js +1 -0
- package/.next/static/chunks/app/_global-error/page-b0a80080b8e8a17d.js +1 -0
- package/.next/static/chunks/app/api/ask/answer/route-b0a80080b8e8a17d.js +1 -0
- package/.next/static/chunks/app/api/ask/route-b0a80080b8e8a17d.js +1 -0
- package/.next/static/chunks/app/api/ask/verdict/route-b0a80080b8e8a17d.js +1 -0
- package/.next/static/chunks/app/api/board-annotations/[id]/route-b0a80080b8e8a17d.js +1 -0
- package/.next/static/chunks/app/api/board-annotations/route-b0a80080b8e8a17d.js +1 -0
- package/.next/static/chunks/app/api/board-layout/route-b0a80080b8e8a17d.js +1 -0
- package/.next/static/chunks/app/api/bug-flags/[id]/route-b0a80080b8e8a17d.js +1 -0
- package/.next/static/chunks/app/api/bug-flags/route-b0a80080b8e8a17d.js +1 -0
- package/.next/static/chunks/app/api/changes/comment/answer/route-b0a80080b8e8a17d.js +1 -0
- package/.next/static/chunks/app/api/changes/comment/claim/route-b0a80080b8e8a17d.js +1 -0
- package/.next/static/chunks/app/api/changes/comment/route-b0a80080b8e8a17d.js +1 -0
- package/.next/static/chunks/app/api/changes/quality/route-b0a80080b8e8a17d.js +1 -0
- package/.next/static/chunks/app/api/changes/route-b0a80080b8e8a17d.js +1 -0
- package/.next/static/chunks/app/api/changes/viewed/route-b0a80080b8e8a17d.js +1 -0
- package/.next/static/chunks/app/api/code-graph/position/route-b0a80080b8e8a17d.js +1 -0
- package/.next/static/chunks/app/api/code-graph/route-b0a80080b8e8a17d.js +1 -0
- package/.next/static/chunks/app/api/context/feature/route-b0a80080b8e8a17d.js +1 -0
- package/.next/static/chunks/app/api/context/file/route-b0a80080b8e8a17d.js +1 -0
- package/.next/static/chunks/app/api/context/route-b0a80080b8e8a17d.js +1 -0
- package/.next/static/chunks/app/api/db/arrange/route-b0a80080b8e8a17d.js +1 -0
- package/.next/static/chunks/app/api/db/backfill-access/route-b0a80080b8e8a17d.js +1 -0
- package/.next/static/chunks/app/api/db/position/route-b0a80080b8e8a17d.js +1 -0
- package/.next/static/chunks/app/api/db/prune-planned/route-b0a80080b8e8a17d.js +1 -0
- package/.next/static/chunks/app/api/db/reconcile-endpoints/route-b0a80080b8e8a17d.js +1 -0
- package/.next/static/chunks/app/api/db/relations/[id]/route-b0a80080b8e8a17d.js +1 -0
- package/.next/static/chunks/app/api/db/tables/[id]/route-b0a80080b8e8a17d.js +1 -0
- package/.next/static/chunks/app/api/draft/approve/route-b0a80080b8e8a17d.js +1 -0
- package/.next/static/chunks/app/api/draft/route-b0a80080b8e8a17d.js +1 -0
- package/.next/static/chunks/app/api/draft/status/route-b0a80080b8e8a17d.js +1 -0
- package/.next/static/chunks/app/api/edges/[id]/route-b0a80080b8e8a17d.js +1 -0
- package/.next/static/chunks/app/api/edges/route-b0a80080b8e8a17d.js +1 -0
- package/.next/static/chunks/app/api/endpoints/[id]/route-b0a80080b8e8a17d.js +1 -0
- package/.next/static/chunks/app/api/entities/route-b0a80080b8e8a17d.js +1 -0
- package/.next/static/chunks/app/api/ingest/route-b0a80080b8e8a17d.js +1 -0
- package/.next/static/chunks/app/api/init/route-b0a80080b8e8a17d.js +1 -0
- package/.next/static/chunks/app/api/lesson/close/route-b0a80080b8e8a17d.js +1 -0
- package/.next/static/chunks/app/api/lesson/presence/route-b0a80080b8e8a17d.js +1 -0
- package/.next/static/chunks/app/api/lesson/questions/route-b0a80080b8e8a17d.js +1 -0
- package/.next/static/chunks/app/api/lesson/route-b0a80080b8e8a17d.js +1 -0
- package/.next/static/chunks/app/api/lesson/save/route-b0a80080b8e8a17d.js +1 -0
- package/.next/static/chunks/app/api/lesson/verdict/route-b0a80080b8e8a17d.js +1 -0
- package/.next/static/chunks/app/api/linear/route-b0a80080b8e8a17d.js +1 -0
- package/.next/static/chunks/app/api/linear/scopes/route-b0a80080b8e8a17d.js +1 -0
- package/.next/static/chunks/app/api/linear/sync/route-b0a80080b8e8a17d.js +1 -0
- package/.next/static/chunks/app/api/map/describe/route-b0a80080b8e8a17d.js +1 -0
- package/.next/static/chunks/app/api/map/files/route-b0a80080b8e8a17d.js +1 -0
- package/.next/static/chunks/app/api/map/finish/route-b0a80080b8e8a17d.js +1 -0
- package/.next/static/chunks/app/api/map/route-b0a80080b8e8a17d.js +1 -0
- package/.next/static/chunks/app/api/map/start/route-b0a80080b8e8a17d.js +1 -0
- package/.next/static/chunks/app/api/map/touch-active/route-b0a80080b8e8a17d.js +1 -0
- package/.next/static/chunks/app/api/mention-search/route-b0a80080b8e8a17d.js +1 -0
- package/.next/static/chunks/app/api/nodes/[id]/position/route-b0a80080b8e8a17d.js +1 -0
- package/.next/static/chunks/app/api/nodes/[id]/route-b0a80080b8e8a17d.js +1 -0
- package/.next/static/chunks/app/api/nodes/positions/route-b0a80080b8e8a17d.js +1 -0
- package/.next/static/chunks/app/api/nodes/route-b0a80080b8e8a17d.js +1 -0
- package/.next/static/chunks/app/api/nodes/subtasks/route-b0a80080b8e8a17d.js +1 -0
- package/.next/static/chunks/app/api/notes/[id]/route-b0a80080b8e8a17d.js +1 -0
- package/.next/static/chunks/app/api/notes/route-b0a80080b8e8a17d.js +1 -0
- package/.next/static/chunks/app/api/open/route-b0a80080b8e8a17d.js +1 -0
- package/.next/static/chunks/app/api/plan/annotations/route-b0a80080b8e8a17d.js +1 -0
- package/.next/static/chunks/app/api/plan/approve/route-b0a80080b8e8a17d.js +1 -0
- package/.next/static/chunks/app/api/plan/history/route-b0a80080b8e8a17d.js +1 -0
- package/.next/static/chunks/app/api/plan/markdown/route-b0a80080b8e8a17d.js +1 -0
- package/.next/static/chunks/app/api/plan/presence/route-b0a80080b8e8a17d.js +1 -0
- package/.next/static/chunks/app/api/plan/route-b0a80080b8e8a17d.js +1 -0
- package/.next/static/chunks/app/api/plan/verdict/route-b0a80080b8e8a17d.js +1 -0
- package/.next/static/chunks/app/api/preferences/route-b0a80080b8e8a17d.js +1 -0
- package/.next/static/chunks/app/api/project-meta/route-b0a80080b8e8a17d.js +1 -0
- package/.next/static/chunks/app/api/reset/route-b0a80080b8e8a17d.js +1 -0
- package/.next/static/chunks/app/api/scope-guard/check/route-b0a80080b8e8a17d.js +1 -0
- package/.next/static/chunks/app/api/share/create/route-b0a80080b8e8a17d.js +1 -0
- package/.next/static/chunks/app/api/share/route-b0a80080b8e8a17d.js +1 -0
- package/.next/static/chunks/app/api/stream/route-b0a80080b8e8a17d.js +1 -0
- package/.next/static/chunks/app/api/tab/nav/route-b0a80080b8e8a17d.js +1 -0
- package/.next/static/chunks/app/api/tab/presence/route-b0a80080b8e8a17d.js +1 -0
- package/.next/static/chunks/app/api/tab/view/route-b0a80080b8e8a17d.js +1 -0
- package/.next/static/chunks/app/api/telemetry/route-b0a80080b8e8a17d.js +1 -0
- package/.next/static/chunks/app/api/telemetry/stats/route-b0a80080b8e8a17d.js +1 -0
- package/.next/static/chunks/app/api/version/route-b0a80080b8e8a17d.js +1 -0
- package/.next/static/chunks/app/api/workspace/activate/route-b0a80080b8e8a17d.js +1 -0
- package/.next/static/chunks/app/api/workspace/route-b0a80080b8e8a17d.js +1 -0
- package/.next/static/chunks/app/layout-c893ade848478689.js +1 -0
- package/.next/static/chunks/app/learn/{page-6459c292421bec82.js → page-68eac3b8857f0423.js} +1 -1
- package/.next/static/chunks/app/map/{page-602309791f192143.js → page-ab46c7221b745a2d.js} +1 -1
- package/.next/static/chunks/app/{page-32a051917fc57795.js → page-62c53092bdab1224.js} +1 -1
- package/.next/static/chunks/app/plan/{page-920d4fecdd6dde34.js → page-61029f938a543778.js} +2 -2
- package/.next/static/chunks/app/s/[token]/{page-1df7929974ceeb5a.js → page-698e24680e57e3e1.js} +1 -1
- package/.next/static/chunks/app/settings/page-28f17935e637640f.js +1 -0
- package/.next/static/chunks/main-eef923c08f6b5e3c.js +5 -0
- package/.next/static/chunks/next/dist/client/components/builtin/app-error-b0a80080b8e8a17d.js +1 -0
- package/.next/static/chunks/next/dist/client/components/builtin/default-null-b0a80080b8e8a17d.js +1 -0
- package/.next/static/chunks/next/dist/client/components/builtin/forbidden-b0a80080b8e8a17d.js +1 -0
- package/.next/static/chunks/next/dist/client/components/builtin/not-found-b0a80080b8e8a17d.js +1 -0
- package/.next/static/chunks/next/dist/client/components/builtin/unauthorized-b0a80080b8e8a17d.js +1 -0
- package/.next/static/css/95077158c5710c9e.css +1 -0
- package/.next/trace +47 -47
- package/.next/trace-build +1 -1
- package/.next/types/app/@modal/(.)settings/page.ts +87 -0
- package/.next/types/routes.d.ts +1 -1
- package/.next/types/validator.ts +9 -0
- package/package.json +1 -1
- package/.next/server/chunks/2455.js +0 -1
- package/.next/server/chunks/2994.js +0 -2
- package/.next/server/chunks/3179.js +0 -1
- package/.next/server/chunks/374.js +0 -1
- package/.next/server/chunks/7350.js +0 -1
- package/.next/static/chunks/3908-2ba88cd8ba5dfa2e.js +0 -1
- package/.next/static/chunks/4853-43350f60d0d9135b.js +0 -1
- package/.next/static/chunks/5697-5b9719b81806b4cf.js +0 -1
- package/.next/static/chunks/7424-d7fa15ef452064dd.js +0 -1
- package/.next/static/chunks/9784-880aab43467bf1e0.js +0 -1
- package/.next/static/chunks/app/_global-error/page-18eb7d6678dc0ddd.js +0 -1
- package/.next/static/chunks/app/api/ask/answer/route-18eb7d6678dc0ddd.js +0 -1
- package/.next/static/chunks/app/api/ask/route-18eb7d6678dc0ddd.js +0 -1
- package/.next/static/chunks/app/api/ask/verdict/route-18eb7d6678dc0ddd.js +0 -1
- package/.next/static/chunks/app/api/board-annotations/[id]/route-18eb7d6678dc0ddd.js +0 -1
- package/.next/static/chunks/app/api/board-annotations/route-18eb7d6678dc0ddd.js +0 -1
- package/.next/static/chunks/app/api/board-layout/route-18eb7d6678dc0ddd.js +0 -1
- package/.next/static/chunks/app/api/bug-flags/[id]/route-18eb7d6678dc0ddd.js +0 -1
- package/.next/static/chunks/app/api/bug-flags/route-18eb7d6678dc0ddd.js +0 -1
- package/.next/static/chunks/app/api/changes/comment/answer/route-18eb7d6678dc0ddd.js +0 -1
- package/.next/static/chunks/app/api/changes/comment/claim/route-18eb7d6678dc0ddd.js +0 -1
- package/.next/static/chunks/app/api/changes/comment/route-18eb7d6678dc0ddd.js +0 -1
- package/.next/static/chunks/app/api/changes/quality/route-18eb7d6678dc0ddd.js +0 -1
- package/.next/static/chunks/app/api/changes/route-18eb7d6678dc0ddd.js +0 -1
- package/.next/static/chunks/app/api/changes/viewed/route-18eb7d6678dc0ddd.js +0 -1
- package/.next/static/chunks/app/api/code-graph/position/route-18eb7d6678dc0ddd.js +0 -1
- package/.next/static/chunks/app/api/code-graph/route-18eb7d6678dc0ddd.js +0 -1
- package/.next/static/chunks/app/api/context/feature/route-18eb7d6678dc0ddd.js +0 -1
- package/.next/static/chunks/app/api/context/file/route-18eb7d6678dc0ddd.js +0 -1
- package/.next/static/chunks/app/api/context/route-18eb7d6678dc0ddd.js +0 -1
- package/.next/static/chunks/app/api/db/arrange/route-18eb7d6678dc0ddd.js +0 -1
- package/.next/static/chunks/app/api/db/backfill-access/route-18eb7d6678dc0ddd.js +0 -1
- package/.next/static/chunks/app/api/db/position/route-18eb7d6678dc0ddd.js +0 -1
- package/.next/static/chunks/app/api/db/prune-planned/route-18eb7d6678dc0ddd.js +0 -1
- package/.next/static/chunks/app/api/db/reconcile-endpoints/route-18eb7d6678dc0ddd.js +0 -1
- package/.next/static/chunks/app/api/db/relations/[id]/route-18eb7d6678dc0ddd.js +0 -1
- package/.next/static/chunks/app/api/db/tables/[id]/route-18eb7d6678dc0ddd.js +0 -1
- package/.next/static/chunks/app/api/draft/approve/route-18eb7d6678dc0ddd.js +0 -1
- package/.next/static/chunks/app/api/draft/route-18eb7d6678dc0ddd.js +0 -1
- package/.next/static/chunks/app/api/draft/status/route-18eb7d6678dc0ddd.js +0 -1
- package/.next/static/chunks/app/api/edges/[id]/route-18eb7d6678dc0ddd.js +0 -1
- package/.next/static/chunks/app/api/edges/route-18eb7d6678dc0ddd.js +0 -1
- package/.next/static/chunks/app/api/endpoints/[id]/route-18eb7d6678dc0ddd.js +0 -1
- package/.next/static/chunks/app/api/entities/route-18eb7d6678dc0ddd.js +0 -1
- package/.next/static/chunks/app/api/ingest/route-18eb7d6678dc0ddd.js +0 -1
- package/.next/static/chunks/app/api/init/route-18eb7d6678dc0ddd.js +0 -1
- package/.next/static/chunks/app/api/lesson/close/route-18eb7d6678dc0ddd.js +0 -1
- package/.next/static/chunks/app/api/lesson/presence/route-18eb7d6678dc0ddd.js +0 -1
- package/.next/static/chunks/app/api/lesson/questions/route-18eb7d6678dc0ddd.js +0 -1
- package/.next/static/chunks/app/api/lesson/route-18eb7d6678dc0ddd.js +0 -1
- package/.next/static/chunks/app/api/lesson/save/route-18eb7d6678dc0ddd.js +0 -1
- package/.next/static/chunks/app/api/lesson/verdict/route-18eb7d6678dc0ddd.js +0 -1
- package/.next/static/chunks/app/api/linear/route-18eb7d6678dc0ddd.js +0 -1
- package/.next/static/chunks/app/api/linear/scopes/route-18eb7d6678dc0ddd.js +0 -1
- package/.next/static/chunks/app/api/linear/sync/route-18eb7d6678dc0ddd.js +0 -1
- package/.next/static/chunks/app/api/map/describe/route-18eb7d6678dc0ddd.js +0 -1
- package/.next/static/chunks/app/api/map/files/route-18eb7d6678dc0ddd.js +0 -1
- package/.next/static/chunks/app/api/map/finish/route-18eb7d6678dc0ddd.js +0 -1
- package/.next/static/chunks/app/api/map/route-18eb7d6678dc0ddd.js +0 -1
- package/.next/static/chunks/app/api/map/start/route-18eb7d6678dc0ddd.js +0 -1
- package/.next/static/chunks/app/api/map/touch-active/route-18eb7d6678dc0ddd.js +0 -1
- package/.next/static/chunks/app/api/mention-search/route-18eb7d6678dc0ddd.js +0 -1
- package/.next/static/chunks/app/api/nodes/[id]/position/route-18eb7d6678dc0ddd.js +0 -1
- package/.next/static/chunks/app/api/nodes/[id]/route-18eb7d6678dc0ddd.js +0 -1
- package/.next/static/chunks/app/api/nodes/positions/route-18eb7d6678dc0ddd.js +0 -1
- package/.next/static/chunks/app/api/nodes/route-18eb7d6678dc0ddd.js +0 -1
- package/.next/static/chunks/app/api/nodes/subtasks/route-18eb7d6678dc0ddd.js +0 -1
- package/.next/static/chunks/app/api/notes/[id]/route-18eb7d6678dc0ddd.js +0 -1
- package/.next/static/chunks/app/api/notes/route-18eb7d6678dc0ddd.js +0 -1
- package/.next/static/chunks/app/api/open/route-18eb7d6678dc0ddd.js +0 -1
- package/.next/static/chunks/app/api/plan/annotations/route-18eb7d6678dc0ddd.js +0 -1
- package/.next/static/chunks/app/api/plan/approve/route-18eb7d6678dc0ddd.js +0 -1
- package/.next/static/chunks/app/api/plan/history/route-18eb7d6678dc0ddd.js +0 -1
- package/.next/static/chunks/app/api/plan/markdown/route-18eb7d6678dc0ddd.js +0 -1
- package/.next/static/chunks/app/api/plan/presence/route-18eb7d6678dc0ddd.js +0 -1
- package/.next/static/chunks/app/api/plan/route-18eb7d6678dc0ddd.js +0 -1
- package/.next/static/chunks/app/api/plan/verdict/route-18eb7d6678dc0ddd.js +0 -1
- package/.next/static/chunks/app/api/preferences/route-18eb7d6678dc0ddd.js +0 -1
- package/.next/static/chunks/app/api/project-meta/route-18eb7d6678dc0ddd.js +0 -1
- package/.next/static/chunks/app/api/reset/route-18eb7d6678dc0ddd.js +0 -1
- package/.next/static/chunks/app/api/scope-guard/check/route-18eb7d6678dc0ddd.js +0 -1
- package/.next/static/chunks/app/api/share/create/route-18eb7d6678dc0ddd.js +0 -1
- package/.next/static/chunks/app/api/share/route-18eb7d6678dc0ddd.js +0 -1
- package/.next/static/chunks/app/api/stream/route-18eb7d6678dc0ddd.js +0 -1
- package/.next/static/chunks/app/api/tab/nav/route-18eb7d6678dc0ddd.js +0 -1
- package/.next/static/chunks/app/api/tab/presence/route-18eb7d6678dc0ddd.js +0 -1
- package/.next/static/chunks/app/api/tab/view/route-18eb7d6678dc0ddd.js +0 -1
- package/.next/static/chunks/app/api/telemetry/route-18eb7d6678dc0ddd.js +0 -1
- package/.next/static/chunks/app/api/telemetry/stats/route-18eb7d6678dc0ddd.js +0 -1
- package/.next/static/chunks/app/api/version/route-18eb7d6678dc0ddd.js +0 -1
- package/.next/static/chunks/app/api/workspace/activate/route-18eb7d6678dc0ddd.js +0 -1
- package/.next/static/chunks/app/api/workspace/route-18eb7d6678dc0ddd.js +0 -1
- package/.next/static/chunks/app/layout-ef1edf5ed5839b01.js +0 -1
- package/.next/static/chunks/app/settings/page-f128ae102e013087.js +0 -1
- package/.next/static/chunks/main-4140465958bbcd36.js +0 -5
- package/.next/static/chunks/next/dist/client/components/builtin/app-error-18eb7d6678dc0ddd.js +0 -1
- package/.next/static/chunks/next/dist/client/components/builtin/forbidden-18eb7d6678dc0ddd.js +0 -1
- package/.next/static/chunks/next/dist/client/components/builtin/not-found-18eb7d6678dc0ddd.js +0 -1
- package/.next/static/chunks/next/dist/client/components/builtin/unauthorized-18eb7d6678dc0ddd.js +0 -1
- package/.next/static/css/9301599114d42898.css +0 -1
- package/.next/static/ms-hAcPFSz7LxuiDMzzcP/_buildManifest.js +0 -1
- /package/.next/static/{ms-hAcPFSz7LxuiDMzzcP → BuULrtf1kXZqNPMDIPeVT}/_ssgManifest.js +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[6624],{22137:(e,t,n)=>{Promise.resolve().then(n.bind(n,35230))},35230:(e,t,n)=>{"use strict";n.d(t,{PlanWorkspace:()=>e6});var s=n(95155),r=n(12115),a=n(32159),o=n(6059),l=n(64577),i=n(25640),d=n(34306),c=n(92571),u=n(65408),m=n(45486),x=n(25494),h=n(17356),p=n(9383),f=n(9005),g=n(65738),b=n(8962),v=n(73321),j=n(48484),y=n(99979),k=n(60292),N=n(32133),w=n(38332),C=n(91337);function A(e,t,n,s,r,a,o=8){return{left:Math.max(o,Math.min(e,r-n-o)),top:Math.max(o,Math.min(t,a-s-o))}}var S=n(51909);let z="u">typeof CSS&&"highlights"in CSS&&"u">typeof Highlight,E="beacon-pending",$="beacon-annotation",P="beacon-deletion";function R(){return z?CSS.highlights:null}function M(...e){return new globalThis.Highlight(...e)}function D(e){let t=e.getClientRects(),n=t.length?t[t.length-1]:e.getBoundingClientRect();return{x:n.right,y:n.bottom}}function O({markdown:e,round:t,onApi:n,hideSubmit:a=!1,getExtraSubmitPayload:o}){let[i,d]=(0,r.useState)([]),[c,u]=(0,r.useState)(""),[m,x]=(0,r.useState)(!1),[h,g]=(0,r.useState)(null),[b,v]=(0,r.useState)(null),[j,S]=(0,r.useState)(null),[T,F]=(0,r.useState)(!1),[q,B]=(0,r.useState)(!1),H=(0,r.useRef)(null),U=(0,r.useRef)(null),K=(0,r.useRef)(null);(0,r.useEffect)(()=>{let e=!0;return(async()=>{try{let t=await fetch("/api/plan/annotations",{cache:"no-store",headers:(0,k.dh)((0,y.X0)())});if(!t.ok)return;let n=await t.json();if(!e)return;d(n.annotations??[]),u(n.globalComment??""),B(!!n.submitted)}catch{}})(),()=>{e=!1}},[e,t]),(0,r.useEffect)(()=>{if(q)return;let e=setTimeout(()=>{fetch("/api/plan/annotations",{method:"PUT",headers:{"content-type":"application/json",...(0,k.dh)((0,y.X0)())},body:JSON.stringify({annotations:i,globalComment:c,round:t})}).catch(()=>{})},400);return()=>clearTimeout(e)},[i,c,q,t]);let X=(0,r.useCallback)(()=>{let e=window.getSelection();if(!e||e.isCollapsed)return void g(null);let t=e.toString().trim();if(!t)return void g(null);if(!H.current?.contains(e.anchorNode))return;let{x:n,y:s}=D(e.getRangeAt(0));g({x:n,y:s,excerpt:t})},[]);(0,r.useEffect)(()=>{let e=()=>setTimeout(X,0);return document.addEventListener("mouseup",e),document.addEventListener("selectionchange",e),()=>{document.removeEventListener("mouseup",e),document.removeEventListener("selectionchange",e)}},[X]);let G=(0,r.useCallback)((e,t="comment",n="")=>{let s=`a-${Date.now()}-${Math.floor(1e6*Math.random())}`;d(r=>[...r,{id:s,excerpt:e,comment:n,kind:t}]),"comment"===t&&S(s),g(null),window.getSelection()?.removeAllRanges()},[]);(0,r.useEffect)(()=>{let e=e=>{let t=window.getSelection();if(!t||t.isCollapsed)return;let n=t.toString().trim();if(!n||!H.current?.contains(t.anchorNode))return;let s=document.activeElement;if(s&&/^(TEXTAREA|INPUT)$/.test(s.tagName)||!(1===e.key.length&&!e.metaKey&&!e.ctrlKey&&!e.altKey))return;e.preventDefault();let r=t.getRangeAt(0);K.current=r.cloneRange();let{x:a,y:o}=D(r);v({x:a,y:o,excerpt:n,seed:e.key}),g(null),window.getSelection()?.removeAllRanges()};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[]),(0,r.useEffect)(()=>{let e=R();if(!b||!e)return;let t=K.current;if(t)return e.set(E,M(t)),()=>{e.delete(E)}},[b]),(0,r.useEffect)(()=>{let e=R();if(!e||!H.current)return;let t=[],n=[];for(let e of i){let s=function(e,t){if(!t)return null;let n=document.createTreeWalker(e,NodeFilter.SHOW_TEXT,{acceptNode:e=>e.parentElement?.closest("pre, table")?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT}),s=[],r="";for(let e=n.nextNode();e;e=n.nextNode())s.push({node:e,start:r.length}),r+=e.nodeValue??"";let a=r.indexOf(t);if(a<0)return null;let o=e=>{for(let t=s.length-1;t>=0;t--)if(s[t].start<=e)return{node:s[t].node,offset:e-s[t].start};return null},l=o(a),i=o(a+t.length);if(!l||!i)return null;let d=document.createRange();return d.setStart(l.node,l.offset),d.setEnd(i.node,i.offset),d}(H.current,e.excerpt);s&&((e.kind??"comment")==="deletion"?n:t).push(s)}let s=(t,n)=>n.length?e.set(t,M(...n)):e.delete(t);return s($,t),s(P,n),()=>{e.delete($),e.delete(P)}},[i,e]),(0,r.useEffect)(()=>{if(!m)return;let e=e=>{let t=e.target;!t||U.current?.contains(t)||t.closest("[data-overall-toggle]")||x(!1)},t=e=>{"Escape"===e.key&&x(!1)};return document.addEventListener("mousedown",e),document.addEventListener("keydown",t),()=>{document.removeEventListener("mousedown",e),document.removeEventListener("keydown",t)}},[m]);let _=(e,t)=>d(n=>n.map(n=>n.id===e?{...n,comment:t}:n)),W=e=>d(t=>t.filter(t=>t.id!==e)),V=()=>{d([]),u(""),x(!1),fetch("/api/plan/annotations",{method:"DELETE",headers:(0,k.dh)((0,y.X0)())}).catch(()=>{})},J=async()=>{if(!T){F(!0);try{let e=o?.()??{},n=await fetch("/api/plan/annotations",{method:"POST",headers:{"content-type":"application/json",...(0,k.dh)((0,y.X0)())},body:JSON.stringify({annotations:i,globalComment:c,round:t,...e})});n.ok?B(!0):409===n.status&&window.location.reload()}finally{F(!1)}}},Q=(0,r.useMemo)(()=>i.filter(e=>"deletion"===e.kind||e.comment.trim()).length+ +!!c.trim(),[i,c]);return(0,r.useEffect)(()=>{n?.({liveCount:Q,submitting:T,submitted:q,submit:()=>void J(),clearAll:V,annotationCount:i.length,hasGlobalComment:!!c.trim(),globalOpen:m,toggleOverall:()=>x(e=>!e),annotations:i,updateComment:_,removeAnnotation:W,focusOnAnnotation:e=>S(e),addComment:e=>G(e,"comment")})},[Q,T,q,i,c,m]),(0,s.jsxs)("div",{className:"flex h-full min-h-0 flex-col",children:[(0,s.jsx)("div",{className:"relative shrink-0",children:(0,s.jsxs)("div",{className:"absolute right-3 top-2 z-30 flex items-center gap-1",children:[!a&&(0,s.jsxs)("button",{onClick:()=>void J(),disabled:T||0===Q,className:(0,C.cn)("flex items-center gap-1 rounded-md border px-2 py-1 text-[11px] font-semibold transition-colors",q?"border-emerald-500/40 bg-emerald-500/15 text-emerald-300":0===Q?"border-border text-muted-foreground opacity-50":"border-sky-500/40 bg-sky-500/15 text-sky-300 hover:bg-sky-500/25"),title:q?"Submitted — your terminal session is reading the feedback":"Submit all feedback so the agent can revise the plan",children:[q?(0,s.jsx)(l.A,{className:"size-3"}):(0,s.jsx)(p.A,{className:"size-3"}),q?"Submitted":"Submit feedback"]}),m&&(0,s.jsxs)("div",{ref:U,className:"absolute right-0 top-[calc(100%+6px)] z-50 w-[320px] rounded-md border border-border bg-card p-2 shadow-xl",children:[(0,s.jsxs)("div",{className:"mb-1 flex items-center justify-between",children:[(0,s.jsx)("span",{className:"text-[10px] font-semibold uppercase tracking-wide text-muted-foreground",children:"Overall feedback"}),(0,s.jsx)("button",{onClick:()=>x(!1),title:"Close (Esc)",className:"rounded p-0.5 text-muted-foreground hover:text-foreground",children:(0,s.jsx)(f.A,{className:"size-3"})})]}),(0,s.jsx)("textarea",{autoFocus:!0,value:c,onChange:e=>u(e.target.value),onKeyDown:e=>{e.stopPropagation(),"Enter"===e.key&&(e.metaKey||e.ctrlKey)?(e.preventDefault(),!T&&Q>0&&(J(),x(!1))):"Escape"===e.key&&(e.preventDefault(),x(!1))},placeholder:"Plan-level notes — e.g. 'split this into two phases' or 'wrong abstraction'…",rows:4,className:"w-full resize-y rounded border border-border bg-background px-2 py-1.5 text-[12px] leading-snug outline-none focus:border-sky-400/40"}),(0,s.jsx)("div",{className:"mt-1 text-right text-[9px] text-muted-foreground/70",children:"⌘/Ctrl+Enter to submit \xb7 Esc to close"})]})]})}),(0,s.jsx)("div",{ref:H,className:"min-h-0 flex-1 overflow-y-auto px-5 pb-5 pt-16 text-[15px] leading-[1.6] selection:bg-[var(--accent-2,#ff7a45)]/30",children:(0,s.jsx)(L,{markdown:e,annotations:b&&!z?[...i,{id:"__pending",excerpt:b.excerpt,comment:"",kind:"comment"}]:i,focusOnId:j,onClearFocus:()=>S(null),onUpdate:_,onRemove:W})}),h&&(0,s.jsxs)("div",{style:function(e,t){let{left:n,top:s}=A(e,t,76,34,window.innerWidth,window.innerHeight);return{position:"fixed",left:n,top:s,zIndex:60}}(h.x+4,h.y+6),className:"flex items-center gap-0.5 rounded-md border border-border bg-card/95 p-0.5 shadow-lg backdrop-blur",children:[(0,s.jsx)("button",{onClick:()=>{let e=window.getSelection();K.current=e&&e.rangeCount?e.getRangeAt(0).cloneRange():null,v({...h,seed:""}),g(null),e?.removeAllRanges()},title:"Comment on this text",className:"rounded p-1 text-sky-300 hover:bg-sky-500/15",children:(0,s.jsx)(N.A,{className:"size-3.5"})}),(0,s.jsx)("button",{onClick:()=>G(h.excerpt,"deletion"),title:"Mark this for deletion",className:"rounded p-1 text-red-300 hover:bg-red-500/15",children:(0,s.jsx)(w.A,{className:"size-3.5"})})]}),b&&(0,s.jsx)(I,{excerpt:b.excerpt,x:b.x,y:b.y,seed:b.seed,onConfirm:e=>{G(b.excerpt,"comment",e),v(null)},onCancel:()=>v(null)})]})}function I({excerpt:e,x:t,y:n,seed:a,onConfirm:o,onCancel:i}){let[d,c]=(0,r.useState)(a),u=(0,r.useRef)(null),[m,x]=(0,r.useState)(()=>A(t+4,n+6,256,130,window.innerWidth,window.innerHeight));(0,r.useLayoutEffect)(()=>{let e=u.current;if(!e)return;let{width:s,height:r}=e.getBoundingClientRect();x(A(t+4,n+6,s,r,window.innerWidth,window.innerHeight))},[t,n]);let h=()=>d.trim()?o(d.trim()):i();return(0,s.jsxs)("div",{ref:u,style:{position:"fixed",left:m.left,top:m.top,zIndex:60},className:"w-64 rounded-md border border-border bg-card/95 p-1.5 shadow-xl backdrop-blur",onBlur:e=>{u.current?.contains(e.relatedTarget)||h()},children:[(0,s.jsxs)("div",{className:"mb-1 line-clamp-1 text-[10px] text-muted-foreground",children:["“",e,"”"]}),(0,s.jsx)("textarea",{autoFocus:!0,value:d,onChange:e=>c(e.target.value),onFocus:e=>e.currentTarget.setSelectionRange(d.length,d.length),placeholder:"Comment… (Enter to add \xb7 Esc to discard)",onKeyDown:e=>{e.stopPropagation(),"Enter"!==e.key||e.shiftKey?"Escape"===e.key&&(e.preventDefault(),i()):(e.preventDefault(),h())},className:"h-16 w-full resize-none rounded bg-[var(--ink-hover)] px-1.5 py-1 text-xs outline-none placeholder:text-muted-foreground/50 focus:bg-[var(--ink-active)]"}),(0,s.jsxs)("div",{className:"mt-1 flex items-center justify-end gap-1",children:[(0,s.jsxs)("button",{type:"button",onClick:i,title:"Discard this comment (Esc)",className:"flex items-center gap-1 rounded px-1.5 py-0.5 text-[10px] font-medium text-muted-foreground transition-colors hover:bg-red-500/15 hover:text-red-300",children:[(0,s.jsx)(f.A,{className:"size-3"}),"Discard"]}),(0,s.jsxs)("button",{type:"button",onClick:h,disabled:!d.trim(),title:"Add this comment (Enter)",className:"flex items-center gap-1 rounded bg-sky-500/15 px-1.5 py-0.5 text-[10px] font-semibold text-sky-300 transition-colors hover:bg-sky-500/25 disabled:opacity-40",children:[(0,s.jsx)(l.A,{className:"size-3"}),"Add"]})]})]})}function T({annotations:e,updateComment:t,removeAnnotation:n,focusOnAnnotation:r,onClose:a}){return 0===e.length?(0,s.jsx)("div",{className:"rounded-lg border border-dashed border-border px-3 py-6 text-center text-[11px] text-muted-foreground",children:"Highlight any text in the plan to leave an inline comment."}):(0,s.jsx)("ul",{className:"space-y-1.5",children:e.map(e=>(0,s.jsx)("li",{className:(0,C.cn)("group rounded-md border bg-background/30 px-2 py-1.5 transition-colors hover:bg-background/50","deletion"===e.kind?"border-red-500/25":"border-sky-500/15"),children:(0,s.jsxs)("div",{className:"flex items-start justify-between gap-2",children:[(0,s.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,s.jsxs)("button",{type:"button",onClick:()=>{r(e.id),a?.()},title:"Jump to this excerpt in the plan",className:(0,C.cn)("block w-full truncate text-left text-[10.5px] font-mono","deletion"===e.kind?"text-red-300/90 line-through":"text-foreground/80 hover:text-foreground"),children:["“",e.excerpt,"”"]}),"deletion"!==e.kind&&(0,s.jsx)("textarea",{value:e.comment,onChange:n=>t(e.id,n.target.value),placeholder:"Write your comment…",rows:1,className:"field-sizing-content mt-1 w-full resize-none bg-transparent text-[11px] leading-snug text-foreground/90 outline-none placeholder:text-muted-foreground/60 focus:text-foreground"})]}),(0,s.jsx)("button",{onClick:()=>n(e.id),title:"Remove this annotation",className:"shrink-0 rounded p-1 text-muted-foreground/70 opacity-0 transition-opacity hover:bg-red-500/15 hover:text-red-300 group-hover:opacity-100",children:(0,s.jsx)(g.A,{className:"size-3"})})]})},e.id))})}function L({markdown:e,annotations:t,focusOnId:n,onClearFocus:a,onUpdate:o,onRemove:l}){let i=(0,r.useMemo)(()=>(0,S.n$)(e),[e]);return(0,s.jsx)("div",{className:"mx-auto w-full max-w-[66ch] space-y-4",children:i.map((e,r)=>(0,s.jsx)(F,{block:e,index:r,annotations:t,focusOnId:n,onClearFocus:a,onUpdate:o,onRemove:l},r))})}function F({block:e,index:t,annotations:n,focusOnId:r,onClearFocus:a,onUpdate:o,onRemove:l}){if("code"===e.kind)return(0,s.jsx)(S.NG,{text:e.text});if("table"===e.kind)return(0,s.jsx)(S.QH,{block:e});let i=(0,s.jsx)(q,{text:e.text,annotations:n,focusOnId:r,onClearFocus:a,onUpdate:o,onRemove:l}),d=(0,S.Vq)(e.kind)?(0,S.vB)(t):void 0;return(0,s.jsx)(s.Fragment,{children:(0,S.aM)(e,i,"reading",d)})}function q({text:e,annotations:t,focusOnId:n,onClearFocus:r,onUpdate:a,onRemove:o}){let l=(z?[]:t).map(t=>({a:t,idx:e.indexOf(t.excerpt)})).filter(e=>e.idx>=0).sort((e,t)=>e.idx-t.idx);if(!l.length)return(0,s.jsx)(H,{text:e});let i=[],d=0;for(let{a:t,idx:c}of l)c<d||(c>d&&i.push((0,s.jsx)(H,{text:e.slice(d,c)},`p-${d}`)),i.push((0,s.jsx)(B,{annotation:t,autoFocus:n===t.id,onClearFocus:r,onUpdate:a,onRemove:o},t.id)),d=c+t.excerpt.length);return d<e.length&&i.push((0,s.jsx)(H,{text:e.slice(d)},"p-tail")),(0,s.jsx)(s.Fragment,{children:i})}function B({annotation:e,autoFocus:t,onClearFocus:n,onUpdate:a,onRemove:o}){let l=(0,r.useRef)(null);return((0,r.useEffect)(()=>{if(t&&l.current){l.current.focus();let e=l.current.value;l.current.setSelectionRange(e.length,e.length),n()}},[t,n]),"deletion"===(e.kind??"comment"))?(0,s.jsxs)("span",{className:"relative inline",children:[(0,s.jsx)("span",{className:"rounded bg-red-500/15 px-0.5 text-red-200/90 line-through decoration-red-300/70 decoration-2",children:(0,s.jsx)(H,{text:e.excerpt})}),(0,s.jsx)("button",{type:"button",onClick:()=>o(e.id),title:"Unmark",className:"ml-0.5 inline-flex translate-y-[-1px] items-center text-red-300/70 hover:text-red-300",children:(0,s.jsx)(g.A,{className:"size-3"})})]}):(0,s.jsx)("span",{className:"rounded bg-[var(--accent-2,#ff7a45)]/15 px-0.5","data-annotation-id":e.id,children:(0,s.jsx)(H,{text:e.excerpt})})}function H({text:e}){return(0,s.jsx)(S.cV,{text:e})}var U=n(31966),K=n(69058),X=n(69272),G=n(99784),_=n(44853),W=n(5937),V=n(74350),J=n(89793),Q=n(96719);function Y({planId:e,className:t,title:n="Share a read-only link to this plan"}){let[a,o]=(0,r.useState)(!1),{status:l,url:i,error:d,copied:u,mint:m,copy:x,reset:h}=(0,J.b)();return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("button",{type:"button",title:n,onClick:function(){h(),o(!0),m({kind:"plan",...e?{planId:e}:{}})},className:t??"glass flex size-8 items-center justify-center rounded-lg text-muted-foreground transition-colors hover:text-foreground",children:(0,s.jsx)(W.A,{className:"size-3.5"})}),(0,s.jsx)(V.lG,{open:a,onOpenChange:o,children:(0,s.jsxs)(V.Cf,{children:[(0,s.jsxs)(V.c7,{children:[(0,s.jsx)(V.L3,{children:"Share this plan"}),(0,s.jsx)(V.rr,{children:"Anyone with the link can view this plan and its boards — no Beacon needed. Links expire after 7 days."})]}),"loading"===l&&(0,s.jsxs)("div",{className:"flex items-center gap-2 text-[12px] text-muted-foreground",children:[(0,s.jsx)(c.A,{className:"size-4 animate-spin"})," Creating link…"]}),"done"===l&&(0,s.jsx)(Q.F,{url:i,copied:u,onCopy:x}),"error"===l&&(0,s.jsx)("p",{className:"text-[12px] text-red-400",children:d})]})})]})}var Z=n(66616),ee=n(36849);let et="beacon:plan-history-sidebar";function en({pendingPlan:e=!1,workspaceId:t}){let n=(0,v.useRouter)(),[o,c]=(0,r.useState)([]),[u,m]=(0,r.useState)(null),[x,h]=(0,r.useState)(null),[p,g]=(0,r.useState)(null),[b,j]=(0,r.useState)("map"),[k,N]=(0,r.useState)(()=>{try{return"0"!==window.localStorage.getItem(et)}catch{return!0}}),w=(0,r.useCallback)(()=>{N(e=>{let t=!e;try{localStorage.setItem(et,t?"1":"0")}catch{}return t})},[]),A=(0,r.useCallback)(e=>{m(e);try{window.history.replaceState(window.history.state,"",(0,y.rc)({view:"history",plan:e}))}catch{}},[]);(0,r.useEffect)(()=>{(async()=>{try{let e=await fetch("/api/plan/history");if(!e.ok)return;let t=await e.json();if(c(t.items),g(t.activePlanId??null),t.items.length&&!u){let e=(0,y.d8)();m(e&&t.items.some(t=>t.id===e)?e:t.items[0].id)}}catch{}})()},[]),(0,r.useEffect)(()=>{u&&(async()=>{let e=await fetch(`/api/plan/history?id=${encodeURIComponent(u)}`);e.ok&&h(await e.json())})()},[u]);let z=(0,r.useMemo)(()=>(function(e){let t=new Map;for(let n of e){let e=new Date(n.archivedAt).toLocaleDateString(void 0,{weekday:"short",month:"short",day:"numeric"});t.has(e)||t.set(e,[]),t.get(e).push(n)}return Array.from(t.entries())})(o),[o]),E=(0,r.useMemo)(()=>(function(e){let t=e?.features??[];if(0===t.length)return{nodes:[],edges:[]};let n=new Map;t.forEach((e,t)=>{let s=e.title.trim();n.has(s)||n.set(s,`arch-${t}`)});let s=(e,t)=>n.get(e.title.trim())??`arch-${t}`,r=t.map((e,t)=>({id:s(e,t),parentId:null,cluster:e.cluster??null,status:"PENDING",priority:e.priority??2,title:e.title,role:e.role??null})),a=(0,ee.VI)(r,"cluster"),o=t.map((e,t)=>{let n=s(e,t),r=a.get(n)??{x:0,y:0};return{id:n,view:"ROADMAP",kind:e.kind??"FEATURE",cluster:e.cluster??null,layer:e.layer??null,title:e.title,role:e.role??null,plain:e.plain??null,status:"PENDING",priority:e.priority??2,x:r.x,y:r.y,source:"DRAFT",sourceRef:null,parentId:null,isCriterion:!1,files:[],bugFlags:[]}}),l=[];return t.forEach((e,t)=>{let r=s(e,t);for(let t of e.dependsOn??[]){let e=n.get(t.trim());e&&e!==r&&l.push({id:`arch-edge-${r}-${e}`,fromId:r,toId:e,kind:"DEPENDS",label:"depends on",sourceHandle:null,targetHandle:null})}}),{nodes:o,edges:l}})(x?.featureGraph),[x]),$=E.nodes.length>0,P=(x?.draftDoc?.tables.length??0)>0||(x?.draftDoc?.endpoints.length??0)>0,R=$||P,M="map"!==b||$?"db"!==b||P?b:"map":"db",D=!!x&&""===x.markdown.replace(/^#[^\n]*\n?/,"").trim(),O=e?(0,s.jsxs)("button",{onClick:()=>n.push((0,y.rc)()),className:"glass pointer-events-auto mb-1 ml-3 mt-1 flex h-8 w-fit shrink-0 items-center gap-1.5 rounded-full px-3 text-[11px] font-semibold text-sky-300 transition-colors hover:bg-sky-500/15",title:"Return to the plan that's still pending review",children:[(0,s.jsx)(U.A,{className:"size-3.5"})," Back to current plan"]}):null;return 0===o.length?(0,s.jsxs)("div",{className:"flex h-screen min-h-0 flex-col pt-14",children:[O,(0,s.jsx)("div",{className:"flex flex-1 items-center justify-center px-6 text-center",children:(0,s.jsxs)("div",{className:"max-w-md text-sm text-muted-foreground",children:[(0,s.jsx)(a.A,{className:"mx-auto mb-3 size-7 text-muted-foreground/40"}),(0,s.jsx)("div",{className:"mb-2 text-base font-semibold text-foreground",children:"No plans yet."}),"Ask the agent to propose a feature in your terminal session — it lands here via MCP and you can review + annotate on both sides. Past plans get archived to this page for browsing."]})})]}):(0,s.jsxs)("div",{className:"flex h-screen min-h-0 flex-col pt-14",children:[O,x&&(0,s.jsxs)("div",{className:"glass pointer-events-auto fixed right-3 top-3 z-30 flex h-9 items-center gap-2 rounded-full px-3",children:[(0,s.jsx)("span",{className:(0,C.cn)("rounded px-1.5 py-0.5 text-[9px] font-semibold uppercase tracking-wide","approved"===x.verdict?"bg-emerald-500/15 text-emerald-300":"bg-red-500/15 text-red-300"),children:x.verdict}),(0,s.jsx)("span",{className:"text-[10px] text-muted-foreground",children:new Date(x.archivedAt).toLocaleString()}),(0,s.jsx)("span",{"aria-hidden":!0,className:"h-4 w-px bg-border"}),(0,s.jsx)(Y,{planId:x.id,className:"flex size-6 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-[var(--ink-hover)] hover:text-foreground"})]}),(0,s.jsxs)("div",{className:"flex min-h-0 flex-1",children:[k?(0,s.jsxs)("aside",{className:"flex w-64 min-w-0 shrink-0 flex-col border-r border-border bg-card/30",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between border-b border-border px-3 py-2",children:[(0,s.jsxs)("span",{className:"text-[10.5px] font-semibold uppercase tracking-wide text-muted-foreground",children:["Plan history \xb7 ",o.length]}),(0,s.jsx)("button",{onClick:w,title:"Collapse history",className:"flex size-5 items-center justify-center rounded text-muted-foreground/70 transition-colors hover:bg-[var(--ink-hover)] hover:text-foreground",children:(0,s.jsx)(K.A,{className:"size-3.5"})})]}),(0,s.jsx)("ul",{className:"min-h-0 flex-1 overflow-y-auto",children:z.map(([e,t])=>(0,s.jsxs)("li",{children:[(0,s.jsx)("div",{className:"px-3 pb-1 pt-3 text-[9px] font-semibold uppercase tracking-widest text-muted-foreground/60",children:e}),(0,s.jsx)("ul",{children:t.map(e=>(0,s.jsx)("li",{children:(0,s.jsxs)("button",{onClick:()=>A(e.id),className:(0,C.cn)("flex w-full items-start gap-1.5 px-3 py-1.5 text-left text-[12px] transition-colors",u===e.id?"bg-[var(--ink-active)] text-foreground":"text-muted-foreground hover:bg-[var(--ink-hover)] hover:text-foreground"),children:[(0,s.jsx)("span",{className:(0,C.cn)("mt-0.5 inline-flex size-3.5 shrink-0 items-center justify-center rounded-full","approved"===e.verdict?"bg-emerald-500/15 text-emerald-300":"bg-red-500/15 text-red-300"),title:e.verdict,children:"approved"===e.verdict?(0,s.jsx)(l.A,{className:"size-2.5"}):(0,s.jsx)(f.A,{className:"size-2.5"})}),(0,s.jsx)("span",{className:"line-clamp-2 min-w-0 flex-1",children:e.description}),p===e.id&&(0,s.jsxs)("span",{title:"This plan is currently being executed",className:"mt-0.5 flex shrink-0 items-center gap-1 text-[9px] font-semibold uppercase tracking-wide text-[#ff7a45]",children:[(0,s.jsxs)("span",{className:"relative flex size-1.5",children:[(0,s.jsx)("span",{className:"absolute inline-flex size-full animate-ping rounded-full bg-[#ff7a45] opacity-75"}),(0,s.jsx)("span",{className:"relative inline-flex size-1.5 rounded-full bg-[#ff7a45]"})]}),"Live"]})]})},e.id))})]},e))})]}):(0,s.jsx)("aside",{className:"flex w-10 shrink-0 flex-col items-center border-r border-border bg-card/30 py-2",children:(0,s.jsx)("button",{onClick:w,title:`Show plan history \xb7 ${o.length}`,className:"flex size-7 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-[var(--ink-hover)] hover:text-foreground",children:(0,s.jsx)(X.A,{className:"size-4"})})}),x?(0,s.jsxs)("div",{className:"flex min-h-0 min-w-0 flex-1",children:[(0,s.jsx)("div",{className:(0,C.cn)("relative flex min-h-0 min-w-0 flex-col",!R&&"flex-1"),style:R?{width:"44%"}:void 0,children:(0,s.jsxs)("div",{className:"min-h-0 flex-1 overflow-y-auto px-5 py-4",children:[(0,s.jsx)(S.pO,{markdown:x.markdown}),D&&(0,s.jsx)("p",{className:"mt-2 text-[13px] text-muted-foreground",children:(x.featureGraph?.features?.length??0)===0&&(x.draftDoc?.tables?.length??0)===0&&(x.draftDoc?.endpoints?.length??0)===0?"This plan was approved without a detailed write-up — no features or schema were attached either.":"This plan has no written body. See the Features and Schema canvases for what it proposed."}),x.globalComment&&(0,s.jsxs)("div",{className:"mt-4 rounded-lg border border-border bg-card/40 p-3",children:[(0,s.jsx)("div",{className:"mb-1 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground",children:"Overall feedback"}),(0,s.jsx)("div",{className:"text-[12px] whitespace-pre-wrap",children:x.globalComment})]})]})}),R&&(0,s.jsxs)("div",{className:"relative flex min-h-0 min-w-0 flex-1 flex-col border-l border-border",children:[$&&P&&(0,s.jsx)("div",{className:"pointer-events-none absolute left-3 top-3 z-20",children:(0,s.jsxs)("div",{className:"glass pointer-events-auto flex items-center gap-1 rounded-full p-0.5",children:[(0,s.jsx)(Z.E,{active:"map"===M,onClick:()=>j("map"),icon:(0,s.jsx)(i.A,{className:"size-3"}),children:"Features"}),(0,s.jsx)(Z.E,{active:"db"===M,onClick:()=>j("db"),icon:(0,s.jsx)(d.A,{className:"size-3"}),children:"Schema"})]})}),(0,s.jsx)("div",{className:"min-h-0 flex-1 overflow-hidden bg-background",children:"map"===M?(0,s.jsx)(G.MapClient,{view:"ROADMAP",nodes:E.nodes,edges:E.edges,embedded:!0,readOnly:!0}):(0,s.jsx)(_.DbMapClient,{tables:[],relations:[],endpoints:[],draft:x.draftDoc??null,workspaceId:t,embedded:!0,readOnly:!0})})]})]}):(0,s.jsx)("section",{className:"flex min-h-0 min-w-0 flex-1 items-center justify-center text-sm text-muted-foreground",children:"Select a plan on the left to view it."})]})]})}var es=n(36483),er=n(1275),ea=n(94421),eo=n(36338),el=n(5497),ei=n(9083),ed=n(76721),ec=n(99314),eu=n(11012);function em(e){return"added"===e?"Added":"deleted"===e?"Deleted":"renamed"===e?"Renamed":"Edited"}let ex={Added:"text-emerald-300",Deleted:"text-rose-300",Renamed:"text-sky-300",Edited:"text-foreground/80"};function eh({file:e,view:t,unseen:n,transient:r,commentCount:a=0,quality:o,expanded:l=!1,rank:i,ago:d,onOpen:c,onToggleViewed:u,onFlag:m}){let x=em(e.status),h=e.additions+e.deletions,p=[];e.cues&&(e.cues.todos&&p.push({label:`TODO ${e.cues.todos}`,title:"TODO/FIXME/HACK markers added",prefill:`[quality scan] \`${e.path}\` adds ${e.cues.todos} TODO/FIXME marker(s). Resolve them now or explain why they're deferred.`}),e.cues.consoles&&p.push({label:`log ${e.cues.consoles}`,title:"console.* calls added",prefill:`[quality scan] \`${e.path}\` adds ${e.cues.consoles} console.* call(s). Remove debug logging before finishing.`}),e.cues.anys&&p.push({label:`any ${e.cues.anys}`,title:"`any` types added",prefill:`[quality scan] \`${e.path}\` adds ${e.cues.anys} \`any\` type(s). Replace them with real types.`}),e.cues.maxIndent>=5&&p.push({label:"deep",title:`Deep nesting added (${e.cues.maxIndent} levels)`,prefill:`[quality scan] \`${e.path}\` adds deeply nested code (${e.cues.maxIndent} indent levels). Flatten it — early returns or extracted helpers.`}));let f=o?.clones[0];return(0,s.jsxs)("div",{className:(0,C.cn)("group flex w-full items-center gap-2.5 px-4 py-2.5 text-left transition-colors hover:bg-[var(--ink-hover)]",r&&"animate-[card-arrive_1.6s_ease-out]",l&&"bg-[var(--ink-hover)]","viewed"===t&&!l&&"opacity-50"),children:[(0,s.jsx)("span",{className:(0,C.cn)("size-1.5 shrink-0 rounded-full",n?"bg-[#ff7a45]":"bg-transparent")}),void 0!==i&&(0,s.jsx)("span",{className:"w-5 shrink-0 text-right text-[10px] font-semibold tabular-nums text-muted-foreground/50",title:"Importance rank — size \xd7 how many files import it",children:i}),(0,s.jsxs)("button",{type:"button",onClick:()=>c(e.path),className:"flex min-w-0 flex-1 items-baseline gap-2.5",children:[(0,s.jsx)(ed.A,{className:(0,C.cn)("size-3 shrink-0 self-center text-muted-foreground/40 transition-transform",l&&"rotate-90")}),(0,s.jsx)("span",{className:(0,C.cn)("w-12 shrink-0 text-[9.5px] font-bold uppercase tracking-[0.08em]",ex[x]),children:x}),(0,s.jsx)("span",{className:"truncate font-mono text-[12.5px] text-foreground/90",title:e.path,children:e.oldPath?`${e.oldPath} → ${e.path}`:e.path}),e.symbols.length>0&&(0,s.jsxs)("span",{className:"hidden truncate text-[10.5px] text-muted-foreground/60 md:inline",children:["↳ ",e.symbols.slice(0,3).join(", "),e.symbols.length>3?"…":""]}),d&&(0,s.jsx)("span",{className:"shrink-0 text-[10px] tabular-nums text-muted-foreground/50",children:d})]}),e.formattingOnly&&(0,s.jsx)("span",{className:"shrink-0 rounded-full border border-border px-1.5 py-0.5 text-[9px] uppercase tracking-wide text-muted-foreground/70",children:"formatting"}),p.map(t=>(0,s.jsx)("button",{type:"button",title:`${t.title} — click to flag it to the agent`,onClick:()=>m?.(e,t.prefill),className:"hidden shrink-0 cursor-pointer rounded-full border border-border px-1.5 py-0.5 text-[9px] text-muted-foreground/80 transition-colors hover:border-border hover:text-foreground lg:inline",children:t.label},t.label)),o?.lint&&o.lint.errors+o.lint.warnings>0&&(0,s.jsxs)("button",{type:"button",title:`Repo linter on this file: ${o.lint.errors} error(s), ${o.lint.warnings} warning(s) — click to flag it to the agent`,onClick:()=>m?.(e,`[quality scan] \`${e.path}\` has ${o.lint.errors} lint error(s) and ${o.lint.warnings} warning(s) from the repo's own linter. Run it on this file and fix what it reports.`),className:(0,C.cn)("shrink-0 cursor-pointer rounded-full border px-1.5 py-0.5 text-[9px] font-medium transition-colors",o.lint.errors>0?"border-rose-400/30 bg-rose-400/10 text-rose-300 hover:bg-rose-400/20":"border-amber-400/25 bg-amber-400/10 text-amber-300/90 hover:bg-amber-400/20"),children:["lint ",o.lint.errors>0?`${o.lint.errors}✕`:`${o.lint.warnings}⚠`]}),f&&(0,s.jsxs)("button",{type:"button",title:`Added code resembles ${f.path} ~L${f.line} (${f.hits} matching fingerprints)${o.clones.length>1?` — and ${o.clones.length-1} more`:""} — click to flag it to the agent`,onClick:()=>m?.(e,`[quality scan] The code added to \`${e.path}\` looks duplicated from ${o.clones.map(e=>`\`${e.path}\` ~L${e.line} (${e.hits} matches)`).join(", ")}. Reuse or extract the shared logic instead of duplicating it.`),className:"flex shrink-0 cursor-pointer items-center gap-0.5 rounded-full border border-amber-400/30 bg-amber-400/10 px-1.5 py-0.5 text-[9px] font-medium text-amber-300 transition-colors hover:bg-amber-400/20",children:[(0,s.jsx)(ec.A,{className:"size-2.5"})," dup?"]}),a>0&&(0,s.jsxs)("span",{className:"flex shrink-0 items-center gap-0.5 text-[10px] text-[#ff7a45]",children:[(0,s.jsx)(N.A,{className:"size-3"}),a]}),(e.inDegree??0)>=8&&(0,s.jsxs)("span",{className:"flex shrink-0 items-center gap-0.5 text-[10px] text-amber-300/90",title:`${e.inDegree} files import this — check the blast radius`,children:[(0,s.jsx)(eu.A,{className:"size-3"}),e.inDegree]}),(0,s.jsxs)("span",{className:"w-24 shrink-0 text-right text-[11.5px] tabular-nums",title:`${h} changed lines`,children:[(0,s.jsxs)("span",{className:"text-emerald-400",children:["+",e.additions]})," ",(0,s.jsxs)("span",{className:"text-rose-400",children:["−",e.deletions]})]}),(0,s.jsx)(ep,{view:t,onToggle:t=>u(e,t)})]})}function ep({view:e,onToggle:t}){return(0,s.jsx)("button",{type:"button",onClick:()=>t("viewed"!==e),title:"viewed"===e?"Viewed — click to unmark":"invalidated"===e?"Changed since you viewed it — click to re-mark":"Mark as viewed",className:(0,C.cn)("flex size-5 shrink-0 items-center justify-center rounded border text-[10px] transition-colors","viewed"===e?"border-emerald-400/40 bg-emerald-500/15 text-emerald-300":"invalidated"===e?"border-amber-400/40 bg-amber-500/10 text-amber-300":"border-border text-transparent hover:text-muted-foreground"),children:"invalidated"===e?"!":(0,s.jsx)(l.A,{className:"size-3"})})}var ef=n(92476);n(68091);var eg=n(40006),eb=n(1185),ev=n(30707),ej=n(86272),ey=n(7542);function ek(e,t){let n=null;for(let s of e){let e=t[s.path]?.lastAt??(s.oldPath?t[s.oldPath]?.lastAt:void 0);void 0!==e&&(!n||e>n.lastAt)&&(n={path:s.path,lastAt:e})}return n}let eN={highlight:(e,t)=>eg.L.highlight(e,t).children},ew=`
|
|
1
|
+
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[6624],{22137:(e,t,n)=>{Promise.resolve().then(n.bind(n,35230))},35230:(e,t,n)=>{"use strict";n.d(t,{PlanWorkspace:()=>e6});var s=n(95155),r=n(12115),a=n(32159),o=n(6059),l=n(64577),i=n(25640),d=n(34306),c=n(92571),u=n(65408),m=n(45486),x=n(25494),h=n(17356),p=n(9383),f=n(9005),g=n(65738),b=n(8962),v=n(73321),j=n(48484),y=n(99979),k=n(60292),N=n(32133),w=n(38332),C=n(91337);function A(e,t,n,s,r,a,o=8){return{left:Math.max(o,Math.min(e,r-n-o)),top:Math.max(o,Math.min(t,a-s-o))}}var S=n(51909);let z="u">typeof CSS&&"highlights"in CSS&&"u">typeof Highlight,E="beacon-pending",$="beacon-annotation",P="beacon-deletion";function R(){return z?CSS.highlights:null}function M(...e){return new globalThis.Highlight(...e)}function D(e){let t=e.getClientRects(),n=t.length?t[t.length-1]:e.getBoundingClientRect();return{x:n.right,y:n.bottom}}function O({markdown:e,round:t,onApi:n,hideSubmit:a=!1,getExtraSubmitPayload:o}){let[i,d]=(0,r.useState)([]),[c,u]=(0,r.useState)(""),[m,x]=(0,r.useState)(!1),[h,g]=(0,r.useState)(null),[b,v]=(0,r.useState)(null),[j,S]=(0,r.useState)(null),[T,F]=(0,r.useState)(!1),[q,B]=(0,r.useState)(!1),H=(0,r.useRef)(null),U=(0,r.useRef)(null),K=(0,r.useRef)(null);(0,r.useEffect)(()=>{let e=!0;return(async()=>{try{let t=await fetch("/api/plan/annotations",{cache:"no-store",headers:(0,k.dh)((0,y.X0)())});if(!t.ok)return;let n=await t.json();if(!e)return;d(n.annotations??[]),u(n.globalComment??""),B(!!n.submitted)}catch{}})(),()=>{e=!1}},[e,t]),(0,r.useEffect)(()=>{if(q)return;let e=setTimeout(()=>{fetch("/api/plan/annotations",{method:"PUT",headers:{"content-type":"application/json",...(0,k.dh)((0,y.X0)())},body:JSON.stringify({annotations:i,globalComment:c,round:t})}).catch(()=>{})},400);return()=>clearTimeout(e)},[i,c,q,t]);let X=(0,r.useCallback)(()=>{let e=window.getSelection();if(!e||e.isCollapsed)return void g(null);let t=e.toString().trim();if(!t)return void g(null);if(!H.current?.contains(e.anchorNode))return;let{x:n,y:s}=D(e.getRangeAt(0));g({x:n,y:s,excerpt:t})},[]);(0,r.useEffect)(()=>{let e=()=>setTimeout(X,0);return document.addEventListener("mouseup",e),document.addEventListener("selectionchange",e),()=>{document.removeEventListener("mouseup",e),document.removeEventListener("selectionchange",e)}},[X]);let G=(0,r.useCallback)((e,t="comment",n="")=>{let s=`a-${Date.now()}-${Math.floor(1e6*Math.random())}`;d(r=>[...r,{id:s,excerpt:e,comment:n,kind:t}]),"comment"===t&&S(s),g(null),window.getSelection()?.removeAllRanges()},[]);(0,r.useEffect)(()=>{let e=e=>{let t=window.getSelection();if(!t||t.isCollapsed)return;let n=t.toString().trim();if(!n||!H.current?.contains(t.anchorNode))return;let s=document.activeElement;if(s&&/^(TEXTAREA|INPUT)$/.test(s.tagName)||!(1===e.key.length&&!e.metaKey&&!e.ctrlKey&&!e.altKey))return;e.preventDefault();let r=t.getRangeAt(0);K.current=r.cloneRange();let{x:a,y:o}=D(r);v({x:a,y:o,excerpt:n,seed:e.key}),g(null),window.getSelection()?.removeAllRanges()};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[]),(0,r.useEffect)(()=>{let e=R();if(!b||!e)return;let t=K.current;if(t)return e.set(E,M(t)),()=>{e.delete(E)}},[b]),(0,r.useEffect)(()=>{let e=R();if(!e||!H.current)return;let t=[],n=[];for(let e of i){let s=function(e,t){if(!t)return null;let n=document.createTreeWalker(e,NodeFilter.SHOW_TEXT,{acceptNode:e=>e.parentElement?.closest("pre, table")?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT}),s=[],r="";for(let e=n.nextNode();e;e=n.nextNode())s.push({node:e,start:r.length}),r+=e.nodeValue??"";let a=r.indexOf(t);if(a<0)return null;let o=e=>{for(let t=s.length-1;t>=0;t--)if(s[t].start<=e)return{node:s[t].node,offset:e-s[t].start};return null},l=o(a),i=o(a+t.length);if(!l||!i)return null;let d=document.createRange();return d.setStart(l.node,l.offset),d.setEnd(i.node,i.offset),d}(H.current,e.excerpt);s&&((e.kind??"comment")==="deletion"?n:t).push(s)}let s=(t,n)=>n.length?e.set(t,M(...n)):e.delete(t);return s($,t),s(P,n),()=>{e.delete($),e.delete(P)}},[i,e]),(0,r.useEffect)(()=>{if(!m)return;let e=e=>{let t=e.target;!t||U.current?.contains(t)||t.closest("[data-overall-toggle]")||x(!1)},t=e=>{"Escape"===e.key&&x(!1)};return document.addEventListener("mousedown",e),document.addEventListener("keydown",t),()=>{document.removeEventListener("mousedown",e),document.removeEventListener("keydown",t)}},[m]);let _=(e,t)=>d(n=>n.map(n=>n.id===e?{...n,comment:t}:n)),W=e=>d(t=>t.filter(t=>t.id!==e)),V=()=>{d([]),u(""),x(!1),fetch("/api/plan/annotations",{method:"DELETE",headers:(0,k.dh)((0,y.X0)())}).catch(()=>{})},J=async()=>{if(!T){F(!0);try{let e=o?.()??{},n=await fetch("/api/plan/annotations",{method:"POST",headers:{"content-type":"application/json",...(0,k.dh)((0,y.X0)())},body:JSON.stringify({annotations:i,globalComment:c,round:t,...e})});n.ok?B(!0):409===n.status&&window.location.reload()}finally{F(!1)}}},Q=(0,r.useMemo)(()=>i.filter(e=>"deletion"===e.kind||e.comment.trim()).length+ +!!c.trim(),[i,c]);return(0,r.useEffect)(()=>{n?.({liveCount:Q,submitting:T,submitted:q,submit:()=>void J(),clearAll:V,annotationCount:i.length,hasGlobalComment:!!c.trim(),globalOpen:m,toggleOverall:()=>x(e=>!e),annotations:i,updateComment:_,removeAnnotation:W,focusOnAnnotation:e=>S(e),addComment:e=>G(e,"comment")})},[Q,T,q,i,c,m]),(0,s.jsxs)("div",{className:"flex h-full min-h-0 flex-col",children:[(0,s.jsx)("div",{className:"relative shrink-0",children:(0,s.jsxs)("div",{className:"absolute right-3 top-2 z-30 flex items-center gap-1",children:[!a&&(0,s.jsxs)("button",{onClick:()=>void J(),disabled:T||0===Q,className:(0,C.cn)("flex items-center gap-1 rounded-md border px-2 py-1 text-[11px] font-semibold transition-colors",q?"border-emerald-500/40 bg-emerald-500/15 text-emerald-300":0===Q?"border-border text-muted-foreground opacity-50":"border-sky-500/40 bg-sky-500/15 text-sky-300 hover:bg-sky-500/25"),title:q?"Submitted — your terminal session is reading the feedback":"Submit all feedback so the agent can revise the plan",children:[q?(0,s.jsx)(l.A,{className:"size-3"}):(0,s.jsx)(p.A,{className:"size-3"}),q?"Submitted":"Submit feedback"]}),m&&(0,s.jsxs)("div",{ref:U,className:"absolute right-0 top-[calc(100%+6px)] z-50 w-[320px] rounded-md border border-border bg-card p-2 shadow-xl",children:[(0,s.jsxs)("div",{className:"mb-1 flex items-center justify-between",children:[(0,s.jsx)("span",{className:"text-[10px] font-semibold uppercase tracking-wide text-muted-foreground",children:"Overall feedback"}),(0,s.jsx)("button",{onClick:()=>x(!1),title:"Close (Esc)",className:"rounded p-0.5 text-muted-foreground hover:text-foreground",children:(0,s.jsx)(f.A,{className:"size-3"})})]}),(0,s.jsx)("textarea",{autoFocus:!0,value:c,onChange:e=>u(e.target.value),onKeyDown:e=>{e.stopPropagation(),"Enter"===e.key&&(e.metaKey||e.ctrlKey)?(e.preventDefault(),!T&&Q>0&&(J(),x(!1))):"Escape"===e.key&&(e.preventDefault(),x(!1))},placeholder:"Plan-level notes — e.g. 'split this into two phases' or 'wrong abstraction'…",rows:4,className:"w-full resize-y rounded border border-border bg-background px-2 py-1.5 text-[12px] leading-snug outline-none focus:border-sky-400/40"}),(0,s.jsx)("div",{className:"mt-1 text-right text-[9px] text-muted-foreground/70",children:"⌘/Ctrl+Enter to submit \xb7 Esc to close"})]})]})}),(0,s.jsx)("div",{ref:H,className:"min-h-0 flex-1 overflow-y-auto px-5 pb-5 pt-16 text-[15px] leading-[1.6] selection:bg-[var(--accent-2,#ff7a45)]/30",children:(0,s.jsx)(L,{markdown:e,annotations:b&&!z?[...i,{id:"__pending",excerpt:b.excerpt,comment:"",kind:"comment"}]:i,focusOnId:j,onClearFocus:()=>S(null),onUpdate:_,onRemove:W})}),h&&(0,s.jsxs)("div",{style:function(e,t){let{left:n,top:s}=A(e,t,76,34,window.innerWidth,window.innerHeight);return{position:"fixed",left:n,top:s,zIndex:60}}(h.x+4,h.y+6),className:"flex items-center gap-0.5 rounded-md border border-border bg-card/95 p-0.5 shadow-lg backdrop-blur",children:[(0,s.jsx)("button",{onClick:()=>{let e=window.getSelection();K.current=e&&e.rangeCount?e.getRangeAt(0).cloneRange():null,v({...h,seed:""}),g(null),e?.removeAllRanges()},title:"Comment on this text",className:"rounded p-1 text-sky-300 hover:bg-sky-500/15",children:(0,s.jsx)(N.A,{className:"size-3.5"})}),(0,s.jsx)("button",{onClick:()=>G(h.excerpt,"deletion"),title:"Mark this for deletion",className:"rounded p-1 text-red-300 hover:bg-red-500/15",children:(0,s.jsx)(w.A,{className:"size-3.5"})})]}),b&&(0,s.jsx)(I,{excerpt:b.excerpt,x:b.x,y:b.y,seed:b.seed,onConfirm:e=>{G(b.excerpt,"comment",e),v(null)},onCancel:()=>v(null)})]})}function I({excerpt:e,x:t,y:n,seed:a,onConfirm:o,onCancel:i}){let[d,c]=(0,r.useState)(a),u=(0,r.useRef)(null),[m,x]=(0,r.useState)(()=>A(t+4,n+6,256,130,window.innerWidth,window.innerHeight));(0,r.useLayoutEffect)(()=>{let e=u.current;if(!e)return;let{width:s,height:r}=e.getBoundingClientRect();x(A(t+4,n+6,s,r,window.innerWidth,window.innerHeight))},[t,n]);let h=()=>d.trim()?o(d.trim()):i();return(0,s.jsxs)("div",{ref:u,style:{position:"fixed",left:m.left,top:m.top,zIndex:60},className:"w-64 rounded-md border border-border bg-card/95 p-1.5 shadow-xl backdrop-blur",onBlur:e=>{u.current?.contains(e.relatedTarget)||h()},children:[(0,s.jsxs)("div",{className:"mb-1 line-clamp-1 text-[10px] text-muted-foreground",children:["“",e,"”"]}),(0,s.jsx)("textarea",{autoFocus:!0,value:d,onChange:e=>c(e.target.value),onFocus:e=>e.currentTarget.setSelectionRange(d.length,d.length),placeholder:"Comment… (Enter to add \xb7 Esc to discard)",onKeyDown:e=>{e.stopPropagation(),"Enter"!==e.key||e.shiftKey?"Escape"===e.key&&(e.preventDefault(),i()):(e.preventDefault(),h())},className:"h-16 w-full resize-none rounded bg-[var(--ink-hover)] px-1.5 py-1 text-xs outline-none placeholder:text-muted-foreground/50 focus:bg-[var(--ink-active)]"}),(0,s.jsxs)("div",{className:"mt-1 flex items-center justify-end gap-1",children:[(0,s.jsxs)("button",{type:"button",onClick:i,title:"Discard this comment (Esc)",className:"flex items-center gap-1 rounded px-1.5 py-0.5 text-[10px] font-medium text-muted-foreground transition-colors hover:bg-red-500/15 hover:text-red-300",children:[(0,s.jsx)(f.A,{className:"size-3"}),"Discard"]}),(0,s.jsxs)("button",{type:"button",onClick:h,disabled:!d.trim(),title:"Add this comment (Enter)",className:"flex items-center gap-1 rounded bg-sky-500/15 px-1.5 py-0.5 text-[10px] font-semibold text-sky-300 transition-colors hover:bg-sky-500/25 disabled:opacity-40",children:[(0,s.jsx)(l.A,{className:"size-3"}),"Add"]})]})]})}function T({annotations:e,updateComment:t,removeAnnotation:n,focusOnAnnotation:r,onClose:a}){return 0===e.length?(0,s.jsx)("div",{className:"rounded-lg border border-dashed border-border px-3 py-6 text-center text-[11px] text-muted-foreground",children:"Highlight any text in the plan to leave an inline comment."}):(0,s.jsx)("ul",{className:"space-y-1.5",children:e.map(e=>(0,s.jsx)("li",{className:(0,C.cn)("group rounded-md border bg-background/30 px-2 py-1.5 transition-colors hover:bg-background/50","deletion"===e.kind?"border-red-500/25":"border-sky-500/15"),children:(0,s.jsxs)("div",{className:"flex items-start justify-between gap-2",children:[(0,s.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,s.jsxs)("button",{type:"button",onClick:()=>{r(e.id),a?.()},title:"Jump to this excerpt in the plan",className:(0,C.cn)("block w-full truncate text-left text-[10.5px] font-mono","deletion"===e.kind?"text-red-300/90 line-through":"text-foreground/80 hover:text-foreground"),children:["“",e.excerpt,"”"]}),"deletion"!==e.kind&&(0,s.jsx)("textarea",{value:e.comment,onChange:n=>t(e.id,n.target.value),placeholder:"Write your comment…",rows:1,className:"field-sizing-content mt-1 w-full resize-none bg-transparent text-[11px] leading-snug text-foreground/90 outline-none placeholder:text-muted-foreground/60 focus:text-foreground"})]}),(0,s.jsx)("button",{onClick:()=>n(e.id),title:"Remove this annotation",className:"shrink-0 rounded p-1 text-muted-foreground/70 opacity-0 transition-opacity hover:bg-red-500/15 hover:text-red-300 group-hover:opacity-100",children:(0,s.jsx)(g.A,{className:"size-3"})})]})},e.id))})}function L({markdown:e,annotations:t,focusOnId:n,onClearFocus:a,onUpdate:o,onRemove:l}){let i=(0,r.useMemo)(()=>(0,S.n$)(e),[e]);return(0,s.jsx)("div",{className:"mx-auto w-full max-w-[66ch] space-y-4",children:i.map((e,r)=>(0,s.jsx)(F,{block:e,index:r,annotations:t,focusOnId:n,onClearFocus:a,onUpdate:o,onRemove:l},r))})}function F({block:e,index:t,annotations:n,focusOnId:r,onClearFocus:a,onUpdate:o,onRemove:l}){if("code"===e.kind)return(0,s.jsx)(S.NG,{text:e.text});if("table"===e.kind)return(0,s.jsx)(S.QH,{block:e});let i=(0,s.jsx)(q,{text:e.text,annotations:n,focusOnId:r,onClearFocus:a,onUpdate:o,onRemove:l}),d=(0,S.Vq)(e.kind)?(0,S.vB)(t):void 0;return(0,s.jsx)(s.Fragment,{children:(0,S.aM)(e,i,"reading",d)})}function q({text:e,annotations:t,focusOnId:n,onClearFocus:r,onUpdate:a,onRemove:o}){let l=(z?[]:t).map(t=>({a:t,idx:e.indexOf(t.excerpt)})).filter(e=>e.idx>=0).sort((e,t)=>e.idx-t.idx);if(!l.length)return(0,s.jsx)(H,{text:e});let i=[],d=0;for(let{a:t,idx:c}of l)c<d||(c>d&&i.push((0,s.jsx)(H,{text:e.slice(d,c)},`p-${d}`)),i.push((0,s.jsx)(B,{annotation:t,autoFocus:n===t.id,onClearFocus:r,onUpdate:a,onRemove:o},t.id)),d=c+t.excerpt.length);return d<e.length&&i.push((0,s.jsx)(H,{text:e.slice(d)},"p-tail")),(0,s.jsx)(s.Fragment,{children:i})}function B({annotation:e,autoFocus:t,onClearFocus:n,onUpdate:a,onRemove:o}){let l=(0,r.useRef)(null);return((0,r.useEffect)(()=>{if(t&&l.current){l.current.focus();let e=l.current.value;l.current.setSelectionRange(e.length,e.length),n()}},[t,n]),"deletion"===(e.kind??"comment"))?(0,s.jsxs)("span",{className:"relative inline",children:[(0,s.jsx)("span",{className:"rounded bg-red-500/15 px-0.5 text-red-200/90 line-through decoration-red-300/70 decoration-2",children:(0,s.jsx)(H,{text:e.excerpt})}),(0,s.jsx)("button",{type:"button",onClick:()=>o(e.id),title:"Unmark",className:"ml-0.5 inline-flex translate-y-[-1px] items-center text-red-300/70 hover:text-red-300",children:(0,s.jsx)(g.A,{className:"size-3"})})]}):(0,s.jsx)("span",{className:"rounded bg-[var(--accent-2,#ff7a45)]/15 px-0.5","data-annotation-id":e.id,children:(0,s.jsx)(H,{text:e.excerpt})})}function H({text:e}){return(0,s.jsx)(S.cV,{text:e})}var U=n(31966),K=n(69058),X=n(69272),G=n(52022),_=n(44853),W=n(5937),V=n(74350),J=n(89793),Q=n(96719);function Y({planId:e,className:t,title:n="Share a read-only link to this plan"}){let[a,o]=(0,r.useState)(!1),{status:l,url:i,error:d,copied:u,mint:m,copy:x,reset:h}=(0,J.b)();return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("button",{type:"button",title:n,onClick:function(){h(),o(!0),m({kind:"plan",...e?{planId:e}:{}})},className:t??"glass flex size-8 items-center justify-center rounded-lg text-muted-foreground transition-colors hover:text-foreground",children:(0,s.jsx)(W.A,{className:"size-3.5"})}),(0,s.jsx)(V.lG,{open:a,onOpenChange:o,children:(0,s.jsxs)(V.Cf,{children:[(0,s.jsxs)(V.c7,{children:[(0,s.jsx)(V.L3,{children:"Share this plan"}),(0,s.jsx)(V.rr,{children:"Anyone with the link can view this plan and its boards — no Beacon needed. Links expire after 7 days."})]}),"loading"===l&&(0,s.jsxs)("div",{className:"flex items-center gap-2 text-[12px] text-muted-foreground",children:[(0,s.jsx)(c.A,{className:"size-4 animate-spin"})," Creating link…"]}),"done"===l&&(0,s.jsx)(Q.F,{url:i,copied:u,onCopy:x}),"error"===l&&(0,s.jsx)("p",{className:"text-[12px] text-red-400",children:d})]})})]})}var Z=n(66616),ee=n(36849);let et="beacon:plan-history-sidebar";function en({pendingPlan:e=!1,workspaceId:t}){let n=(0,v.useRouter)(),[o,c]=(0,r.useState)([]),[u,m]=(0,r.useState)(null),[x,h]=(0,r.useState)(null),[p,g]=(0,r.useState)(null),[b,j]=(0,r.useState)("map"),[k,N]=(0,r.useState)(()=>{try{return"0"!==window.localStorage.getItem(et)}catch{return!0}}),w=(0,r.useCallback)(()=>{N(e=>{let t=!e;try{localStorage.setItem(et,t?"1":"0")}catch{}return t})},[]),A=(0,r.useCallback)(e=>{m(e);try{window.history.replaceState(window.history.state,"",(0,y.rc)({view:"history",plan:e}))}catch{}},[]);(0,r.useEffect)(()=>{(async()=>{try{let e=await fetch("/api/plan/history");if(!e.ok)return;let t=await e.json();if(c(t.items),g(t.activePlanId??null),t.items.length&&!u){let e=(0,y.d8)();m(e&&t.items.some(t=>t.id===e)?e:t.items[0].id)}}catch{}})()},[]),(0,r.useEffect)(()=>{u&&(async()=>{let e=await fetch(`/api/plan/history?id=${encodeURIComponent(u)}`);e.ok&&h(await e.json())})()},[u]);let z=(0,r.useMemo)(()=>(function(e){let t=new Map;for(let n of e){let e=new Date(n.archivedAt).toLocaleDateString(void 0,{weekday:"short",month:"short",day:"numeric"});t.has(e)||t.set(e,[]),t.get(e).push(n)}return Array.from(t.entries())})(o),[o]),E=(0,r.useMemo)(()=>(function(e){let t=e?.features??[];if(0===t.length)return{nodes:[],edges:[]};let n=new Map;t.forEach((e,t)=>{let s=e.title.trim();n.has(s)||n.set(s,`arch-${t}`)});let s=(e,t)=>n.get(e.title.trim())??`arch-${t}`,r=t.map((e,t)=>({id:s(e,t),parentId:null,cluster:e.cluster??null,status:"PENDING",priority:e.priority??2,title:e.title,role:e.role??null})),a=(0,ee.VI)(r,"cluster"),o=t.map((e,t)=>{let n=s(e,t),r=a.get(n)??{x:0,y:0};return{id:n,view:"ROADMAP",kind:e.kind??"FEATURE",cluster:e.cluster??null,layer:e.layer??null,title:e.title,role:e.role??null,plain:e.plain??null,status:"PENDING",priority:e.priority??2,x:r.x,y:r.y,source:"DRAFT",sourceRef:null,parentId:null,isCriterion:!1,files:[],bugFlags:[]}}),l=[];return t.forEach((e,t)=>{let r=s(e,t);for(let t of e.dependsOn??[]){let e=n.get(t.trim());e&&e!==r&&l.push({id:`arch-edge-${r}-${e}`,fromId:r,toId:e,kind:"DEPENDS",label:"depends on",sourceHandle:null,targetHandle:null})}}),{nodes:o,edges:l}})(x?.featureGraph),[x]),$=E.nodes.length>0,P=(x?.draftDoc?.tables.length??0)>0||(x?.draftDoc?.endpoints.length??0)>0,R=$||P,M="map"!==b||$?"db"!==b||P?b:"map":"db",D=!!x&&""===x.markdown.replace(/^#[^\n]*\n?/,"").trim(),O=e?(0,s.jsxs)("button",{onClick:()=>n.push((0,y.rc)()),className:"glass pointer-events-auto mb-1 ml-3 mt-1 flex h-8 w-fit shrink-0 items-center gap-1.5 rounded-full px-3 text-[11px] font-semibold text-sky-300 transition-colors hover:bg-sky-500/15",title:"Return to the plan that's still pending review",children:[(0,s.jsx)(U.A,{className:"size-3.5"})," Back to current plan"]}):null;return 0===o.length?(0,s.jsxs)("div",{className:"flex h-screen min-h-0 flex-col pt-14",children:[O,(0,s.jsx)("div",{className:"flex flex-1 items-center justify-center px-6 text-center",children:(0,s.jsxs)("div",{className:"max-w-md text-sm text-muted-foreground",children:[(0,s.jsx)(a.A,{className:"mx-auto mb-3 size-7 text-muted-foreground/40"}),(0,s.jsx)("div",{className:"mb-2 text-base font-semibold text-foreground",children:"No plans yet."}),"Ask the agent to propose a feature in your terminal session — it lands here via MCP and you can review + annotate on both sides. Past plans get archived to this page for browsing."]})})]}):(0,s.jsxs)("div",{className:"flex h-screen min-h-0 flex-col pt-14",children:[O,x&&(0,s.jsxs)("div",{className:"glass pointer-events-auto fixed right-3 top-3 z-30 flex h-9 items-center gap-2 rounded-full px-3",children:[(0,s.jsx)("span",{className:(0,C.cn)("rounded px-1.5 py-0.5 text-[9px] font-semibold uppercase tracking-wide","approved"===x.verdict?"bg-emerald-500/15 text-emerald-300":"bg-red-500/15 text-red-300"),children:x.verdict}),(0,s.jsx)("span",{className:"text-[10px] text-muted-foreground",children:new Date(x.archivedAt).toLocaleString()}),(0,s.jsx)("span",{"aria-hidden":!0,className:"h-4 w-px bg-border"}),(0,s.jsx)(Y,{planId:x.id,className:"flex size-6 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-[var(--ink-hover)] hover:text-foreground"})]}),(0,s.jsxs)("div",{className:"flex min-h-0 flex-1",children:[k?(0,s.jsxs)("aside",{className:"flex w-64 min-w-0 shrink-0 flex-col border-r border-border bg-card/30",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between border-b border-border px-3 py-2",children:[(0,s.jsxs)("span",{className:"text-[10.5px] font-semibold uppercase tracking-wide text-muted-foreground",children:["Plan history \xb7 ",o.length]}),(0,s.jsx)("button",{onClick:w,title:"Collapse history",className:"flex size-5 items-center justify-center rounded text-muted-foreground/70 transition-colors hover:bg-[var(--ink-hover)] hover:text-foreground",children:(0,s.jsx)(K.A,{className:"size-3.5"})})]}),(0,s.jsx)("ul",{className:"min-h-0 flex-1 overflow-y-auto",children:z.map(([e,t])=>(0,s.jsxs)("li",{children:[(0,s.jsx)("div",{className:"px-3 pb-1 pt-3 text-[9px] font-semibold uppercase tracking-widest text-muted-foreground/60",children:e}),(0,s.jsx)("ul",{children:t.map(e=>(0,s.jsx)("li",{children:(0,s.jsxs)("button",{onClick:()=>A(e.id),className:(0,C.cn)("flex w-full items-start gap-1.5 px-3 py-1.5 text-left text-[12px] transition-colors",u===e.id?"bg-[var(--ink-active)] text-foreground":"text-muted-foreground hover:bg-[var(--ink-hover)] hover:text-foreground"),children:[(0,s.jsx)("span",{className:(0,C.cn)("mt-0.5 inline-flex size-3.5 shrink-0 items-center justify-center rounded-full","approved"===e.verdict?"bg-emerald-500/15 text-emerald-300":"bg-red-500/15 text-red-300"),title:e.verdict,children:"approved"===e.verdict?(0,s.jsx)(l.A,{className:"size-2.5"}):(0,s.jsx)(f.A,{className:"size-2.5"})}),(0,s.jsx)("span",{className:"line-clamp-2 min-w-0 flex-1",children:e.description}),p===e.id&&(0,s.jsxs)("span",{title:"This plan is currently being executed",className:"mt-0.5 flex shrink-0 items-center gap-1 text-[9px] font-semibold uppercase tracking-wide text-[#ff7a45]",children:[(0,s.jsxs)("span",{className:"relative flex size-1.5",children:[(0,s.jsx)("span",{className:"absolute inline-flex size-full animate-ping rounded-full bg-[#ff7a45] opacity-75"}),(0,s.jsx)("span",{className:"relative inline-flex size-1.5 rounded-full bg-[#ff7a45]"})]}),"Live"]})]})},e.id))})]},e))})]}):(0,s.jsx)("aside",{className:"flex w-10 shrink-0 flex-col items-center border-r border-border bg-card/30 py-2",children:(0,s.jsx)("button",{onClick:w,title:`Show plan history \xb7 ${o.length}`,className:"flex size-7 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-[var(--ink-hover)] hover:text-foreground",children:(0,s.jsx)(X.A,{className:"size-4"})})}),x?(0,s.jsxs)("div",{className:"flex min-h-0 min-w-0 flex-1",children:[(0,s.jsx)("div",{className:(0,C.cn)("relative flex min-h-0 min-w-0 flex-col",!R&&"flex-1"),style:R?{width:"44%"}:void 0,children:(0,s.jsxs)("div",{className:"min-h-0 flex-1 overflow-y-auto px-5 py-4",children:[(0,s.jsx)(S.pO,{markdown:x.markdown}),D&&(0,s.jsx)("p",{className:"mt-2 text-[13px] text-muted-foreground",children:(x.featureGraph?.features?.length??0)===0&&(x.draftDoc?.tables?.length??0)===0&&(x.draftDoc?.endpoints?.length??0)===0?"This plan was approved without a detailed write-up — no features or schema were attached either.":"This plan has no written body. See the Features and Schema canvases for what it proposed."}),x.globalComment&&(0,s.jsxs)("div",{className:"mt-4 rounded-lg border border-border bg-card/40 p-3",children:[(0,s.jsx)("div",{className:"mb-1 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground",children:"Overall feedback"}),(0,s.jsx)("div",{className:"text-[12px] whitespace-pre-wrap",children:x.globalComment})]})]})}),R&&(0,s.jsxs)("div",{className:"relative flex min-h-0 min-w-0 flex-1 flex-col border-l border-border",children:[$&&P&&(0,s.jsx)("div",{className:"pointer-events-none absolute left-3 top-3 z-20",children:(0,s.jsxs)("div",{className:"glass pointer-events-auto flex items-center gap-1 rounded-full p-0.5",children:[(0,s.jsx)(Z.E,{active:"map"===M,onClick:()=>j("map"),icon:(0,s.jsx)(i.A,{className:"size-3"}),children:"Features"}),(0,s.jsx)(Z.E,{active:"db"===M,onClick:()=>j("db"),icon:(0,s.jsx)(d.A,{className:"size-3"}),children:"Schema"})]})}),(0,s.jsx)("div",{className:"min-h-0 flex-1 overflow-hidden bg-background",children:"map"===M?(0,s.jsx)(G.MapClient,{view:"ROADMAP",nodes:E.nodes,edges:E.edges,embedded:!0,readOnly:!0}):(0,s.jsx)(_.DbMapClient,{tables:[],relations:[],endpoints:[],draft:x.draftDoc??null,workspaceId:t,embedded:!0,readOnly:!0})})]})]}):(0,s.jsx)("section",{className:"flex min-h-0 min-w-0 flex-1 items-center justify-center text-sm text-muted-foreground",children:"Select a plan on the left to view it."})]})]})}var es=n(36483),er=n(1275),ea=n(94421),eo=n(36338),el=n(5497),ei=n(9083),ed=n(76721),ec=n(99314),eu=n(11012);function em(e){return"added"===e?"Added":"deleted"===e?"Deleted":"renamed"===e?"Renamed":"Edited"}let ex={Added:"text-emerald-300",Deleted:"text-rose-300",Renamed:"text-sky-300",Edited:"text-foreground/80"};function eh({file:e,view:t,unseen:n,transient:r,commentCount:a=0,quality:o,expanded:l=!1,rank:i,ago:d,onOpen:c,onToggleViewed:u,onFlag:m}){let x=em(e.status),h=e.additions+e.deletions,p=[];e.cues&&(e.cues.todos&&p.push({label:`TODO ${e.cues.todos}`,title:"TODO/FIXME/HACK markers added",prefill:`[quality scan] \`${e.path}\` adds ${e.cues.todos} TODO/FIXME marker(s). Resolve them now or explain why they're deferred.`}),e.cues.consoles&&p.push({label:`log ${e.cues.consoles}`,title:"console.* calls added",prefill:`[quality scan] \`${e.path}\` adds ${e.cues.consoles} console.* call(s). Remove debug logging before finishing.`}),e.cues.anys&&p.push({label:`any ${e.cues.anys}`,title:"`any` types added",prefill:`[quality scan] \`${e.path}\` adds ${e.cues.anys} \`any\` type(s). Replace them with real types.`}),e.cues.maxIndent>=5&&p.push({label:"deep",title:`Deep nesting added (${e.cues.maxIndent} levels)`,prefill:`[quality scan] \`${e.path}\` adds deeply nested code (${e.cues.maxIndent} indent levels). Flatten it — early returns or extracted helpers.`}));let f=o?.clones[0];return(0,s.jsxs)("div",{className:(0,C.cn)("group flex w-full items-center gap-2.5 px-4 py-2.5 text-left transition-colors hover:bg-[var(--ink-hover)]",r&&"animate-[card-arrive_1.6s_ease-out]",l&&"bg-[var(--ink-hover)]","viewed"===t&&!l&&"opacity-50"),children:[(0,s.jsx)("span",{className:(0,C.cn)("size-1.5 shrink-0 rounded-full",n?"bg-[#ff7a45]":"bg-transparent")}),void 0!==i&&(0,s.jsx)("span",{className:"w-5 shrink-0 text-right text-[10px] font-semibold tabular-nums text-muted-foreground/50",title:"Importance rank — size \xd7 how many files import it",children:i}),(0,s.jsxs)("button",{type:"button",onClick:()=>c(e.path),className:"flex min-w-0 flex-1 items-baseline gap-2.5",children:[(0,s.jsx)(ed.A,{className:(0,C.cn)("size-3 shrink-0 self-center text-muted-foreground/40 transition-transform",l&&"rotate-90")}),(0,s.jsx)("span",{className:(0,C.cn)("w-12 shrink-0 text-[9.5px] font-bold uppercase tracking-[0.08em]",ex[x]),children:x}),(0,s.jsx)("span",{className:"truncate font-mono text-[12.5px] text-foreground/90",title:e.path,children:e.oldPath?`${e.oldPath} → ${e.path}`:e.path}),e.symbols.length>0&&(0,s.jsxs)("span",{className:"hidden truncate text-[10.5px] text-muted-foreground/60 md:inline",children:["↳ ",e.symbols.slice(0,3).join(", "),e.symbols.length>3?"…":""]}),d&&(0,s.jsx)("span",{className:"shrink-0 text-[10px] tabular-nums text-muted-foreground/50",children:d})]}),e.formattingOnly&&(0,s.jsx)("span",{className:"shrink-0 rounded-full border border-border px-1.5 py-0.5 text-[9px] uppercase tracking-wide text-muted-foreground/70",children:"formatting"}),p.map(t=>(0,s.jsx)("button",{type:"button",title:`${t.title} — click to flag it to the agent`,onClick:()=>m?.(e,t.prefill),className:"hidden shrink-0 cursor-pointer rounded-full border border-border px-1.5 py-0.5 text-[9px] text-muted-foreground/80 transition-colors hover:border-border hover:text-foreground lg:inline",children:t.label},t.label)),o?.lint&&o.lint.errors+o.lint.warnings>0&&(0,s.jsxs)("button",{type:"button",title:`Repo linter on this file: ${o.lint.errors} error(s), ${o.lint.warnings} warning(s) — click to flag it to the agent`,onClick:()=>m?.(e,`[quality scan] \`${e.path}\` has ${o.lint.errors} lint error(s) and ${o.lint.warnings} warning(s) from the repo's own linter. Run it on this file and fix what it reports.`),className:(0,C.cn)("shrink-0 cursor-pointer rounded-full border px-1.5 py-0.5 text-[9px] font-medium transition-colors",o.lint.errors>0?"border-rose-400/30 bg-rose-400/10 text-rose-300 hover:bg-rose-400/20":"border-amber-400/25 bg-amber-400/10 text-amber-300/90 hover:bg-amber-400/20"),children:["lint ",o.lint.errors>0?`${o.lint.errors}✕`:`${o.lint.warnings}⚠`]}),f&&(0,s.jsxs)("button",{type:"button",title:`Added code resembles ${f.path} ~L${f.line} (${f.hits} matching fingerprints)${o.clones.length>1?` — and ${o.clones.length-1} more`:""} — click to flag it to the agent`,onClick:()=>m?.(e,`[quality scan] The code added to \`${e.path}\` looks duplicated from ${o.clones.map(e=>`\`${e.path}\` ~L${e.line} (${e.hits} matches)`).join(", ")}. Reuse or extract the shared logic instead of duplicating it.`),className:"flex shrink-0 cursor-pointer items-center gap-0.5 rounded-full border border-amber-400/30 bg-amber-400/10 px-1.5 py-0.5 text-[9px] font-medium text-amber-300 transition-colors hover:bg-amber-400/20",children:[(0,s.jsx)(ec.A,{className:"size-2.5"})," dup?"]}),a>0&&(0,s.jsxs)("span",{className:"flex shrink-0 items-center gap-0.5 text-[10px] text-[#ff7a45]",children:[(0,s.jsx)(N.A,{className:"size-3"}),a]}),(e.inDegree??0)>=8&&(0,s.jsxs)("span",{className:"flex shrink-0 items-center gap-0.5 text-[10px] text-amber-300/90",title:`${e.inDegree} files import this — check the blast radius`,children:[(0,s.jsx)(eu.A,{className:"size-3"}),e.inDegree]}),(0,s.jsxs)("span",{className:"w-24 shrink-0 text-right text-[11.5px] tabular-nums",title:`${h} changed lines`,children:[(0,s.jsxs)("span",{className:"text-emerald-400",children:["+",e.additions]})," ",(0,s.jsxs)("span",{className:"text-rose-400",children:["−",e.deletions]})]}),(0,s.jsx)(ep,{view:t,onToggle:t=>u(e,t)})]})}function ep({view:e,onToggle:t}){return(0,s.jsx)("button",{type:"button",onClick:()=>t("viewed"!==e),title:"viewed"===e?"Viewed — click to unmark":"invalidated"===e?"Changed since you viewed it — click to re-mark":"Mark as viewed",className:(0,C.cn)("flex size-5 shrink-0 items-center justify-center rounded border text-[10px] transition-colors","viewed"===e?"border-emerald-400/40 bg-emerald-500/15 text-emerald-300":"invalidated"===e?"border-amber-400/40 bg-amber-500/10 text-amber-300":"border-border text-transparent hover:text-muted-foreground"),children:"invalidated"===e?"!":(0,s.jsx)(l.A,{className:"size-3"})})}var ef=n(92476);n(68091);var eg=n(40006),eb=n(1185),ev=n(30707),ej=n(86272),ey=n(7542);function ek(e,t){let n=null;for(let s of e){let e=t[s.path]?.lastAt??(s.oldPath?t[s.oldPath]?.lastAt:void 0);void 0!==e&&(!n||e>n.lastAt)&&(n={path:s.path,lastAt:e})}return n}let eN={highlight:(e,t)=>eg.L.highlight(e,t).children},ew=`
|
|
2
2
|
.beacon-diff .token.comment,.beacon-diff .token.prolog,.beacon-diff .token.doctype,.beacon-diff .token.cdata{color:#6b7684;font-style:italic}
|
|
3
3
|
.beacon-diff .token.punctuation{color:#9aa4b2}
|
|
4
4
|
.beacon-diff .token.keyword,.beacon-diff .token.atrule,.beacon-diff .token.important,.beacon-diff .token.rule{color:#c792ea}
|
|
@@ -8,4 +8,4 @@
|
|
|
8
8
|
.beacon-diff .token.tag,.beacon-diff .token.property,.beacon-diff .token.selector,.beacon-diff .token.attr-name,.beacon-diff .token.builtin{color:#ffcb6b}
|
|
9
9
|
.beacon-diff .token.operator,.beacon-diff .token.entity,.beacon-diff .token.url{color:#89ddff}
|
|
10
10
|
.beacon-diff .token.variable{color:#f07178}
|
|
11
|
-
`;function eC(e){fetch(`/api/open?path=${encodeURIComponent(e)}`).catch(()=>{})}function eA({file:e,defaultMode:t="split",onFocus:n,maxBodyHeight:a,className:o}){let[l,i]=(0,r.useState)(t),[d,c]=(0,r.useState)(null),[u,m]=(0,r.useState)(!1),[x,p]=(0,r.useState)(0);(0,r.useEffect)(()=>{if(e.binary||e.tooLarge)return;let t=!1,n=(0,k.fk)();return fetch(`/api/changes?path=${encodeURIComponent(e.path)}&old=${encodeURIComponent(e.oldPath??"")}`,{cache:"no-store",headers:n?{"x-beacon-workspace":n}:void 0}).then(e=>e.json()).then(n=>{t||(c({path:e.path,diff:n.diff??""}),m(!1))}).catch(()=>{t||m(!0)}),()=>{t=!0}},[e.path,e.oldPath,e.binary,e.tooLarge,e.additions,e.deletions,x]);let f=(0,r.useMemo)(()=>{if(!d?.diff)return null;try{let e=(0,ef.FR)(d.diff);return e.find(e=>e.newPath===d.path)??e[0]??null}catch{return null}},[d]),g=(0,r.useMemo)(()=>{if(f)try{return(0,ef.qw)(f.hunks,{highlight:eg.L.registered(e.lang),refractor:eN,language:e.lang,enhancers:[(0,ef.Zc)(f.hunks,{type:"block"})]})}catch{return}},[f,e.lang]),v=d&&d.path===e.path,[j,y]=(0,r.useState)(new Set),[w,A]=(0,r.useState)([]),[S,z]=(0,r.useState)(null),[E,$]=(0,r.useState)(""),[P,R]=(0,r.useState)(!1),[M,D]=(0,r.useState)(!1),O=(0,r.useCallback)(async()=>{let t=(0,k.fk)(),n=await fetch(`/api/changes/comment?file=${encodeURIComponent(e.path)}`,{cache:"no-store",headers:t?{"x-beacon-workspace":t}:void 0}).then(e=>e.json()).catch(()=>null);A(n?.comments??[])},[e.path]);(0,r.useEffect)(()=>{let t=!1,n=(0,k.fk)();return fetch(`/api/changes/comment?file=${encodeURIComponent(e.path)}`,{cache:"no-store",headers:n?{"x-beacon-workspace":n}:void 0}).then(e=>e.json()).then(e=>{t||A(e?.comments??[])}).catch(()=>{}),()=>{t=!0}},[e.path]);let I=w.filter(e=>"question"===e.kind&&!e.answer).length;(0,r.useEffect)(()=>{if(0===I)return;let e=Date.now(),t=setInterval(()=>{Date.now()-e>9e5?clearInterval(t):O()},4e3);return()=>clearInterval(t)},[I,O]);let T=(0,r.useCallback)(async()=>{if(!S||!E.trim())return;let t=(0,k.fk)();await fetch("/api/changes/comment",{method:"POST",headers:{"content-type":"application/json",...t?{"x-beacon-workspace":t}:{}},body:JSON.stringify({file:e.path,line:S.line,side:S.side,body:E.trim(),text:S.text,held:P||void 0,kind:M?"question":void 0})}).catch(()=>{}),z(null),$(""),R(!1),O()},[S,E,P,M,e.path,O]),L=(0,r.useCallback)(async e=>{let t=(0,k.fk)();await fetch("/api/changes/comment",{method:"PATCH",headers:{"content-type":"application/json",...t?{"x-beacon-workspace":t}:{}},body:JSON.stringify(e)}).catch(()=>{}),O()},[O]),F=(0,r.useCallback)(async e=>{let t=(0,k.fk)();await fetch(`/api/changes/comment?id=${encodeURIComponent(e)}`,{method:"DELETE",headers:t?{"x-beacon-workspace":t}:void 0}).catch(()=>{}),O()},[O]),q=(0,r.useMemo)(()=>{let e=new Map,t={old:new Map,new:new Map};if(!f)return{byLine:e,byContent:t};let n=(e,n,s,r)=>{if(!n)return;let a=t[e].get(n);a?a.push({key:s,line:r}):t[e].set(n,[{key:s,line:r}])};for(let t of f.hunks)for(let s of t.changes){let t=(0,ef.k2)(s),r=s.content.trim(),a=(0,ef.zi)(s);a&&a>0&&(e.set(`new:${a}`,t),n("new",r,t,a));let o=(0,ef.Cg)(s);o&&o>0&&(e.set(`old:${o}`,t),n("old",r,t,o))}return{byLine:e,byContent:t}},[f]),B=(0,r.useCallback)((e,t)=>{let n="old"===t||void 0===t&&(0,ef.Ob)(e)?"old":"new",s="old"===n?(0,ef.Cg)(e):(0,ef.zi)(e);s&&!(s<=0)&&(z({key:(0,ef.k2)(e),line:s,side:n,text:e.content.trim()}),$(""))},[]),H=(0,r.useMemo)(()=>({onClick:e=>{let t=e.change;t&&B(t,e.side)}}),[B]),U=(0,r.useMemo)(()=>({onMouseUp:e=>{let t=window.getSelection();if(!t||t.isCollapsed||!t.toString().trim())return;let n=e.change;n&&B(n,e.side)}}),[B]),K=(0,r.useCallback)(({change:e,side:t,inHoverState:n,renderDefault:r})=>{let a=e&&(0,ef.Ob)(e)?"old":"new";return n&&e&&t===a?(0,s.jsx)("button",{type:"button",title:"Add a comment or question on this line (mode set in the toolbar)",className:"flex w-full items-center justify-center rounded-sm bg-[#ff7a45] text-[13px] font-bold leading-none text-white",onClick:n=>{n.stopPropagation(),B(e,t)},children:"+"}):r()},[B]),{widgets:X,orphans:G}=(0,r.useMemo)(()=>{let e=new Map,t=[],n=t=>{let n=e.get(t);return n||(n={comments:[],composer:!1},e.set(t,n)),n};for(let e of w){let s=e.text?q.byContent[e.side].get(e.text):void 0;if(s?.length)n(s.reduce((t,n)=>Math.abs(t.line-e.line)<=Math.abs(n.line-e.line)?t:n).key).comments.push(e);else{let s=q.byLine.get(`${e.side}:${e.line}`);!e.text&&s?n(s).comments.push(e):t.push(e)}}S&&(n(S.key).composer=!0);let r={};for(let[t,n]of e)r[t]=(0,s.jsxs)("div",{className:"border-y border-[#ff7a45]/20 bg-[#ff7a45]/[0.04] px-3 py-2",children:[n.comments.map(e=>(0,s.jsx)(eS,{c:e,onDelete:()=>void F(e.id),onToggleHeld:t=>void L({id:e.id,held:t})},e.id)),n.composer&&(0,s.jsx)(e$,{value:E,onChange:$,hold:P,onHold:R,isQuestion:M,onSubmit:()=>void T(),onCancel:()=>{z(null),$("")}})]});return{widgets:r,orphans:t}},[w,q,S,E,P,M,T,F,L]),_=w.filter(e=>e.held&&!e.deliveredAt).length;return(0,s.jsxs)("div",{className:(0,C.cn)("flex min-h-0 flex-col",o),children:[(0,s.jsx)("style",{children:ew}),(0,s.jsxs)("div",{className:"flex items-center gap-2 border-b border-border px-4 py-1.5",children:[w.length>0&&(0,s.jsxs)("span",{className:"flex shrink-0 items-center gap-1 rounded-full border border-[#ff7a45]/25 bg-[#ff7a45]/10 px-1.5 py-0.5 text-[10px] font-medium text-[#ff7a45]",title:"Line-comments on this file (sent to the agent on its next edit or reply)",children:[(0,s.jsx)(N.A,{className:"size-3"})," ",w.length]}),_>0&&(0,s.jsxs)("button",{type:"button",onClick:()=>void L({release:!0}),title:"Send the held comments to the agent as one batch (delivered on its next edit or reply)",className:"flex shrink-0 items-center gap-1 rounded-full border border-[#ff7a45]/40 bg-[#ff7a45]/15 px-2 py-0.5 text-[10px] font-semibold text-[#ff7a45] transition-colors hover:bg-[#ff7a45]/25",children:["Release ",_," held"]}),(0,s.jsxs)("div",{className:"flex shrink-0 items-center gap-0.5 rounded-full border border-border p-0.5",children:[(0,s.jsxs)("button",{type:"button",onClick:()=>D(!1),title:"Comment mode — leave one-way feedback the agent applies",className:(0,C.cn)("flex items-center gap-1 rounded-full px-2 py-0.5 text-[10px] font-medium transition-colors",M?"text-muted-foreground hover:text-foreground":"bg-[var(--ink-active)] text-foreground"),children:[(0,s.jsx)(N.A,{className:"size-3"})," Comment"]}),(0,s.jsxs)("button",{type:"button",onClick:()=>D(!0),title:"Ask mode — ask the agent a question about this code; it answers back into Beacon",className:(0,C.cn)("flex items-center gap-1 rounded-full px-2 py-0.5 text-[10px] font-medium transition-colors",M?"bg-[#ff7a45]/20 text-[#ff7a45]":"text-muted-foreground hover:text-foreground"),children:[(0,s.jsx)(h.A,{className:"size-3"})," Ask"]})]}),(0,s.jsx)("span",{className:"shrink-0 text-[10px] text-muted-foreground/45",children:M?"highlight or hover a line → ask":"highlight or hover a line → comment"}),(0,s.jsxs)("div",{className:"ml-auto flex shrink-0 items-center gap-0.5",children:[(0,s.jsxs)("div",{className:"flex items-center gap-0.5 rounded-full border border-border p-0.5",children:[(0,s.jsx)("button",{type:"button",onClick:()=>i("split"),title:"Split view",className:(0,C.cn)("flex size-5 items-center justify-center rounded-full transition-colors","split"===l?"bg-[var(--ink-active)] text-foreground":"text-muted-foreground hover:text-foreground"),children:(0,s.jsx)(eb.A,{className:"size-3"})}),(0,s.jsx)("button",{type:"button",onClick:()=>i("unified"),title:"Unified view",className:(0,C.cn)("flex size-5 items-center justify-center rounded-full transition-colors","unified"===l?"bg-[var(--ink-active)] text-foreground":"text-muted-foreground hover:text-foreground"),children:(0,s.jsx)(ev.A,{className:"size-3"})})]}),n&&(0,s.jsx)("button",{type:"button",onClick:n,title:"Focus — open this file full-page",className:"flex size-5 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-[var(--ink-hover)] hover:text-foreground",children:(0,s.jsx)(b.A,{className:"size-3"})}),(0,s.jsx)("button",{type:"button",onClick:()=>eC(e.path),title:"Open in editor",className:"flex size-5 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-[var(--ink-hover)] hover:text-foreground",children:(0,s.jsx)(er.A,{className:"size-3"})})]})]}),(0,s.jsxs)("div",{className:(0,C.cn)("min-h-0 flex-1 overflow-auto",M&&"cursor-help"),style:a?{maxHeight:a}:void 0,children:[G.length>0&&(0,s.jsxs)("div",{className:"border-b border-amber-400/20 bg-amber-400/[0.05] px-3 py-2",children:[(0,s.jsx)("div",{className:"mb-1 text-[10px] font-semibold uppercase tracking-wide text-amber-300/90",children:"The agent changed these lines since your comment"}),G.map(e=>(0,s.jsx)(eS,{c:e,orphaned:!0,onDelete:()=>void F(e.id),onToggleHeld:t=>void L({id:e.id,held:t})},e.id))]}),e.binary?(0,s.jsx)(eP,{icon:!0,children:"Binary file — no text diff."}):e.tooLarge?(0,s.jsx)(eP,{icon:!0,onOpen:()=>eC(e.path),children:"Diff too large to render here."}):v?f&&0!==f.hunks.length?(0,s.jsx)(ef.oO,{className:"beacon-diff",viewType:l,diffType:f.type,hunks:f.hunks,tokens:g,widgets:X,gutterEvents:H,codeEvents:U,renderGutter:K,children:e=>e.map(e=>{let t,n;return(t=e.changes.filter(e=>"delete"===e.type).map(e=>e.content),n=e.changes.filter(e=>"insert"===e.type).map(e=>e.content),(t.length>0||n.length>0)&&function(e,t){let n=e=>{let t=new Map;for(let n of e){let e=n.trim();e&&t.set(e,(t.get(e)??0)+1)}return t},s=n(e),r=n(t);if(s.size!==r.size)return!1;for(let[e,t]of s)if(r.get(e)!==t)return!1;return!0}(t,n)&&!j.has(e.content))?(0,s.jsx)(ef.NZ,{children:(0,s.jsxs)("div",{className:"flex items-center gap-2 bg-white/[0.02] px-4 py-1 text-[11px] text-muted-foreground",children:[(0,s.jsxs)("span",{children:["\xb7 formatting-only hunk (",e.changes.filter(e=>"normal"!==e.type).length," lines)"]}),(0,s.jsx)("button",{type:"button",onClick:()=>y(t=>new Set([...t,e.content])),className:"rounded-full border border-border px-2 py-0.5 text-[10px] hover:bg-[var(--ink-hover)]",children:"show"})]})},e.content):(0,s.jsx)(ef.D9,{hunk:e},e.content)})}):(0,s.jsx)(eP,{children:"No textual changes."}):u?(0,s.jsx)(eP,{icon:!0,onOpen:()=>p(e=>e+1),openLabel:"Retry",children:"Couldn't load the diff."}):(0,s.jsx)(eP,{children:"Loading diff…"})]})]})}function eS({c:e,orphaned:t=!1,onDelete:n,onToggleHeld:r}){let a="question"===e.kind,o=e.deliveredAt?"sent to agent":e.held?"held — release to send":a?"pending — sent on the agent's next turn":"pending — sent on the agent's next edit or reply";return(0,s.jsxs)("div",{className:"group mb-1 rounded-md border border-border bg-background/60 px-2.5 py-1.5",children:[(0,s.jsxs)("div",{className:"flex items-start gap-2",children:[a?(0,s.jsx)(h.A,{className:"mt-0.5 size-3.5 shrink-0 text-[#ff7a45]"}):(0,s.jsx)(N.A,{className:"mt-0.5 size-3.5 shrink-0 text-[#ff7a45]"}),(0,s.jsxs)("div",{className:"min-w-0 flex-1",children:[t&&e.text&&(0,s.jsxs)("div",{className:"mb-0.5 truncate font-mono text-[10px] text-muted-foreground/70",title:e.text,children:["was: ",(0,s.jsx)("span",{className:"line-through",children:e.text})]}),(0,s.jsx)("div",{className:"whitespace-pre-wrap text-[12px] leading-snug text-foreground/90",children:e.body}),(0,s.jsxs)("div",{className:"mt-0.5 flex flex-wrap items-center gap-1.5 text-[9px] uppercase tracking-wide text-muted-foreground/60",children:[(0,s.jsxs)("span",{children:[a?`question \xb7 line ${e.line}`:`line ${e.line}`," \xb7 ",o]}),a&&!e.answer&&e.deliveredAt&&(0,s.jsx)(eE,{delivered:!0}),!e.deliveredAt&&(0,s.jsx)("button",{type:"button",onClick:()=>r(!e.held),className:(0,C.cn)("rounded-full border px-1.5 py-px font-semibold transition-colors",e.held?"border-[#ff7a45]/40 text-[#ff7a45] hover:bg-[#ff7a45]/15":"border-border text-muted-foreground hover:text-foreground"),title:e.held?`Release this ${a?"question":"comment"} (sends on the agent's next edit or reply)`:`Hold this ${a?"question":"comment"} back to batch it`,children:e.held?"release":"hold"})]})]}),(0,s.jsx)("button",{type:"button",onClick:n,title:a?"Delete question":"Delete comment",className:"shrink-0 rounded p-0.5 text-muted-foreground/60 opacity-0 transition-opacity hover:text-red-300 group-hover:opacity-100",children:(0,s.jsx)(g.A,{className:"size-3"})})]}),a&&e.answer&&(0,s.jsx)(ez,{answer:e.answer,className:"ml-5 mt-1.5"})]})}function ez({answer:e,className:t}){return(0,s.jsxs)("div",{className:(0,C.cn)("rounded-md border border-sky-400/20 bg-sky-400/[0.06] px-2.5 py-1.5",t),children:[(0,s.jsxs)("div",{className:"mb-1 flex items-center gap-1 text-[9px] font-semibold uppercase tracking-wide text-sky-300/90",children:[(0,s.jsx)(ej.A,{className:"size-3"}),"Agent's answer"]}),(0,s.jsx)("div",{className:"whitespace-pre-wrap text-[12px] leading-relaxed text-foreground/90",children:e})]})}function eE({delivered:e,className:t}){return(0,s.jsxs)("span",{className:(0,C.cn)("flex items-center gap-1 text-sky-300/80",t),children:[(0,s.jsx)(c.A,{className:"size-2.5 animate-spin"}),e?"awaiting the agent's answer…":"queued — sent on the agent's next turn"]})}function e$({value:e,onChange:t,hold:n,onHold:r,isQuestion:a=!1,onSubmit:o,onCancel:l}){return(0,s.jsxs)("div",{className:"mt-1",children:[(0,s.jsx)("textarea",{autoFocus:!0,value:e,onChange:e=>t(e.target.value),onKeyDown:e=>{"Enter"===e.key&&(e.metaKey||e.ctrlKey)?(e.preventDefault(),o()):"Escape"===e.key&&(e.preventDefault(),l())},rows:2,placeholder:a?"Ask the agent about this line — it answers back into Beacon (⌘/Ctrl+Enter to send)":"Comment on this line — the agent gets it on its next edit or reply (⌘/Ctrl+Enter to send)",className:"w-full resize-y rounded border border-border bg-background px-2 py-1.5 text-[12px] leading-snug outline-none focus:border-[#ff7a45]/40"}),(0,s.jsxs)("div",{className:"mt-1 flex items-center gap-2",children:[(0,s.jsxs)("button",{type:"button",onClick:o,disabled:!e.trim(),className:(0,C.cn)("flex items-center gap-1 rounded-md px-2 py-1 text-[11px] font-semibold transition-colors",e.trim()?"bg-[#ff7a45]/20 text-[#ff7a45] hover:bg-[#ff7a45]/30":"text-muted-foreground opacity-50"),children:[a?(0,s.jsx)(h.A,{className:"size-3"}):(0,s.jsx)(N.A,{className:"size-3"}),a?"Ask":"Comment"]}),(0,s.jsx)("button",{type:"button",onClick:l,className:"rounded-md px-2 py-1 text-[11px] text-muted-foreground transition-colors hover:text-foreground",children:"Cancel"}),(0,s.jsxs)("label",{className:"ml-auto flex cursor-pointer items-center gap-1 text-[10px] text-muted-foreground",title:a?"Hold this question back — batch several, then Release to send them together":"Hold this comment back — batch several, then Release to send them together",children:[(0,s.jsx)("input",{type:"checkbox",checked:n,onChange:e=>r(e.target.checked),className:"size-3 accent-[#ff7a45]"}),"hold (batch)"]})]})]})}function eP({children:e,icon:t,onOpen:n,openLabel:r="Open in editor"}){return(0,s.jsxs)("div",{className:"flex items-center gap-2 px-4 py-6 text-[12px] text-muted-foreground",children:[t&&(0,s.jsx)(ey.A,{className:"size-4 shrink-0 text-amber-300/80"}),(0,s.jsx)("span",{children:e}),n&&(0,s.jsx)("button",{type:"button",onClick:n,className:"rounded-full border border-border px-2 py-0.5 text-[11px] text-foreground transition-colors hover:bg-[var(--ink-hover)]",children:r})]})}let eR=[/(^|\/)bun\.lock$/,/(^|\/)package-lock\.json$/,/(^|\/)yarn\.lock$/,/\.lock$/,/\.min\.\w+$/,/\.map$/,/(^|\/)(\.next|dist|build|node_modules|coverage)\//,/(^|\/)generated\//];function eM(e){return eR.some(t=>t.test(e))}function eD(e){return(e.additions+e.deletions)*(1+Math.log2(1+(e.inDegree??0)))}function eO(e){let t=e.split("/").pop()??"",n=/^(.+?)\.(test|spec)\.\w+$/.exec(t);return n?n[1]:null}function eI(e){let t=Math.max(1,Math.round(e/1e3));if(t<60)return`${t}s ago`;let n=Math.round(t/60);return n<60?`${n}m ago`:`${Math.round(n/60)}h ago`}function eT({files:e,touched:t,views:n,unseen:a,transients:l,commentCounts:i,questions:d,lens:u,onLens:m,onOpen:x,onSeen:p,onToggleViewed:g,quality:b,scanning:v,onScan:j,onCommentAdded:y,onFocus:N}){let[w,A]=(0,r.useState)(()=>Date.now()),S=(0,r.useSyncExternalStore)(()=>()=>{},()=>!0,()=>!1);(0,r.useEffect)(()=>{let e=setInterval(()=>A(Date.now()),3e4);return()=>clearInterval(e)},[]);let z=(0,r.useMemo)(()=>e.reduce((e,t)=>({add:e.add+t.additions,del:e.del+t.deletions}),{add:0,del:0}),[e]),E=Math.min(100,(z.add+z.del)/400*100),$=(0,r.useMemo)(()=>ek(e,t),[e,t]),P=S&&!!$&&w-$.lastAt<6e4,R=e.filter(e=>"viewed"===n[e.path]).length,M=(0,r.useMemo)(()=>new Map(e.map(e=>[e.path,e])),[e]),D=(0,r.useMemo)(()=>{let n,s,r;return n=e=>t[e.path]?.lastAt??(e.oldPath?t[e.oldPath]?.lastAt:void 0),s=(e,t)=>(n(t)??0)-(n(e)??0),r=e.filter(e=>(n(e)??0)>=w-3e5).sort(s),[{key:"now",label:"Now",files:r},{key:"session",label:"Earlier this session",files:e.filter(e=>void 0!==n(e)&&n(e)<w-3e5).sort(s)},{key:"before",label:"Before this session",files:e.filter(e=>void 0===n(e)).sort((e,t)=>e.path.localeCompare(t.path))}].filter(e=>e.files.length>0)},[e,t,w]),O=(0,r.useMemo)(()=>(function(e){let t=e.filter(e=>eM(e.path)),n=e.filter(e=>!eM(e.path)),s=n.filter(e=>null!==eO(e.path)),r=n.filter(e=>null===eO(e.path)).sort((e,t)=>eD(t)-eD(e)),a=[],o=new Set;for(let e of r){a.push(e);let t=(e.path.split("/").pop()??"").replace(/\.\w+$/,"");for(let e of s)o.has(e.path)||eO(e.path)!==t||(a.push(e),o.add(e.path))}for(let e of[...s].sort((e,t)=>eD(t)-eD(e)))o.has(e.path)||a.push(e);return{main:a,noise:[...t].sort((e,t)=>eD(t)-eD(e))}})(e),[e]),[I,T]=(0,r.useState)(new Set),L=e=>{p(e),T(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},F=(0,r.useMemo)(()=>"activity"===u?D.map(e=>({key:e.key,label:e.label,accent:"now"===e.key,paths:e.files.map(e=>e.path)})):[{key:"ranked",label:"Riskiest first — change size \xd7 importers",ranked:!0,paths:O.main.map(e=>e.path)},...O.noise.length?[{key:"noise",label:"Generated & lockfiles",dim:!0,paths:O.noise.map(e=>e.path)}]:[]],[u,D,O]),[q,B]=(0,r.useState)(null);I.size>0&&(null===q||q.lens!==u)?B({lens:u,sections:F}):0===I.size&&null!==q&&B(null);let H=(0,r.useMemo)(()=>{if(!q)return F;let e=new Set(q.sections.map(e=>e.key)),t=new Set(q.sections.flatMap(e=>e.paths)),n=q.sections.map(e=>{let n=F.find(t=>t.key===e.key),s=n?n.paths.filter(e=>!t.has(e)):[];return s.length?{...e,paths:[...e.paths,...s]}:e});for(let s of F){if(e.has(s.key))continue;let r=s.paths.filter(e=>!t.has(e));r.length&&n.push({...s,paths:r})}return n},[q,F]),[U,K]=(0,r.useState)(null),X=async()=>{if(!U||!U.text.trim()||U.sending)return;K({...U,sending:!0});let e=(0,k.fk)();await fetch("/api/changes/comment",{method:"POST",headers:{"content-type":"application/json",...e?{"x-beacon-workspace":e}:{}},body:JSON.stringify({file:U.file.path,line:1,side:"new",body:U.text.trim(),held:U.hold||void 0})}).catch(()=>{}),K(null),y()};return(0,s.jsxs)("div",{className:"mx-auto flex h-full w-full min-h-0 flex-col px-4",children:[(0,s.jsxs)("div",{className:"glass mt-3 shrink-0 space-y-2 rounded-2xl px-4 py-3",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2 text-[13px]",children:[(0,s.jsxs)("span",{className:(0,C.cn)("relative flex size-2 shrink-0",!P&&"opacity-30"),children:[P&&(0,s.jsx)("span",{className:"absolute inline-flex size-full animate-ping rounded-full bg-[#ff7a45] opacity-75"}),(0,s.jsx)("span",{className:"relative inline-flex size-2 rounded-full bg-[#ff7a45]"})]}),$?(0,s.jsxs)("button",{type:"button",onClick:N,disabled:!N,title:"Focus mode — follow the agent's edits live",className:"group/foc min-w-0 truncate rounded text-left transition-colors enabled:hover:text-foreground disabled:cursor-default",children:[(0,s.jsx)("span",{className:"text-muted-foreground",children:P?"Editing":"Last edited"})," ",(0,s.jsx)("span",{className:"font-mono text-[12px] text-foreground/90 underline-offset-2 group-hover/foc:underline",children:$.path}),S&&(0,s.jsxs)("span",{className:"text-muted-foreground",children:[" \xb7 ",eI(w-$.lastAt)]})]}):(0,s.jsx)("span",{className:"text-muted-foreground",children:"No agent edits this session"})]}),(0,s.jsxs)("div",{className:"flex flex-wrap items-center gap-3 text-[11px] text-muted-foreground",children:[(0,s.jsx)(o.A,{className:"size-3.5 shrink-0 text-[#ff7a45]"}),(0,s.jsxs)("span",{className:"tabular-nums",children:[e.length," files \xb7 ",(0,s.jsxs)("span",{className:"text-emerald-400",children:["+",z.add]})," ",(0,s.jsxs)("span",{className:"text-rose-400",children:["−",z.del]})]}),(0,s.jsx)("span",{"aria-hidden":!0,className:"h-1 w-24 overflow-hidden rounded-full bg-[var(--ink-active)]",title:"~400 changed lines is the review-attention budget",children:(0,s.jsx)("span",{className:(0,C.cn)("block h-full",E>=100?"bg-amber-400/80":"bg-white/35"),style:{width:`${E}%`}})}),(0,s.jsxs)("span",{className:"ml-auto tabular-nums",children:[a.size>0&&(0,s.jsxs)("span",{className:"text-[#ff7a45]",children:[a.size," unseen \xb7 "]}),R,"/",e.length," viewed"]}),(0,s.jsxs)("button",{type:"button",onClick:j,disabled:v||0===e.length,title:"Run the repo's linter on the changed files + scan added code for duplicated logic (deterministic, local)",className:(0,C.cn)("flex items-center gap-1 rounded-full border border-border px-2 py-0.5 text-[10px] font-medium transition-colors",v?"text-muted-foreground":"text-muted-foreground hover:bg-[var(--ink-hover)] hover:text-foreground"),children:[v?(0,s.jsx)(c.A,{className:"size-3 animate-spin"}):(0,s.jsx)(ea.A,{className:"size-3"}),v?"Scanning…":b?"Re-scan":"Quality scan"]}),(0,s.jsx)("div",{className:"flex items-center gap-0.5 rounded-full border border-border p-0.5",children:[{l:"activity",icon:(0,s.jsx)(eo.A,{className:"size-3"}),label:"Activity",title:"What the agent is doing, newest first"},{l:"review",icon:(0,s.jsx)(el.A,{className:"size-3"}),label:"Review",title:"Importance-first for a careful pass"},{l:"questions",icon:(0,s.jsx)(h.A,{className:"size-3"}),label:"Questions",title:"Questions you asked the agent + its answers"}].map(({l:e,icon:t,label:n,title:r})=>(0,s.jsxs)("button",{type:"button",onClick:()=>m(e),className:(0,C.cn)("flex items-center gap-1 rounded-full px-2 py-0.5 text-[10px] font-medium transition-colors",u===e?"bg-[var(--ink-active)] text-foreground":"text-muted-foreground hover:text-foreground"),title:r,children:[t,n,"questions"===e&&d.length>0&&(0,s.jsx)("span",{className:"ml-0.5 rounded-full bg-[#ff7a45]/20 px-1 text-[9px] font-semibold text-[#ff7a45]",children:d.length})]},e))})]})]}),U&&(0,s.jsxs)("div",{className:"fixed right-6 top-20 z-40 w-96 rounded-xl border border-border bg-card p-3 shadow-2xl",children:[(0,s.jsxs)("div",{className:"mb-2 flex items-center justify-between",children:[(0,s.jsxs)("span",{className:"flex items-center gap-1.5 text-[11px] font-semibold uppercase tracking-wide text-muted-foreground",children:[(0,s.jsx)(ei.A,{className:"size-3 text-[#ff7a45]"})," Flag to the agent"]}),(0,s.jsx)("button",{type:"button",onClick:()=>K(null),title:"Close",className:"rounded p-0.5 text-muted-foreground hover:text-foreground",children:(0,s.jsx)(f.A,{className:"size-3.5"})})]}),(0,s.jsx)("div",{className:"mb-1.5 truncate font-mono text-[11px] text-muted-foreground",title:U.file.path,children:U.file.path}),(0,s.jsx)("textarea",{autoFocus:!0,value:U.text,onChange:e=>K({...U,text:e.target.value}),onKeyDown:e=>{"Enter"===e.key&&(e.metaKey||e.ctrlKey)?(e.preventDefault(),X()):"Escape"===e.key&&(e.preventDefault(),K(null))},rows:4,className:"w-full resize-y rounded border border-border bg-background px-2 py-1.5 text-[12px] leading-snug outline-none focus:border-[#ff7a45]/40"}),(0,s.jsxs)("div",{className:"mt-2 flex items-center gap-2",children:[(0,s.jsx)("button",{type:"button",onClick:()=>void X(),disabled:!U.text.trim()||U.sending,className:(0,C.cn)("rounded-md px-2.5 py-1 text-[11px] font-semibold transition-colors",U.text.trim()&&!U.sending?"bg-[#ff7a45]/20 text-[#ff7a45] hover:bg-[#ff7a45]/30":"text-muted-foreground opacity-50"),children:U.sending?"Sending…":"Send to agent"}),(0,s.jsxs)("label",{className:"ml-auto flex cursor-pointer items-center gap-1 text-[10px] text-muted-foreground",title:"Hold this flag back — batch several, then Release to send them together",children:[(0,s.jsx)("input",{type:"checkbox",checked:U.hold,onChange:e=>K({...U,hold:e.target.checked}),className:"size-3 accent-[#ff7a45]"}),"hold (batch)"]})]}),(0,s.jsx)("p",{className:"mt-1.5 text-[10px] text-muted-foreground/70",children:"Delivered on the agent's next edit or reply."})]}),(0,s.jsx)("div",{className:"min-h-0 flex-1 space-y-3 overflow-y-auto py-3",children:"questions"===u?(0,s.jsx)(eL,{questions:d}):0===e.length?(0,s.jsx)("p",{className:"py-8 text-center text-[12px] text-muted-foreground",children:"No uncommitted changes yet — the agent's edits land here live."}):H.map(e=>{let r=e.paths.map(e=>M.get(e)).filter(e=>!!e);return 0===r.length?null:(0,s.jsx)(eF,{section:e,count:r.length,children:r.map((r,o)=>{var d;let c;return d={rank:e.ranked?o+1:void 0,ago:"activity"===u?(e=>{if(!S)return;let n=t[e.path]?.lastAt??(e.oldPath?t[e.oldPath]?.lastAt:void 0);return n?eI(w-n):void 0})(r):void 0},c=I.has(r.path),(0,s.jsxs)("div",{children:[(0,s.jsx)(eh,{file:r,view:n[r.path]??"unviewed",unseen:a.has(r.path),transient:l.has(r.path),commentCount:i[r.path]??0,quality:b?.[r.path],expanded:c,rank:d?.rank,ago:d?.ago,onOpen:L,onToggleViewed:g,onFlag:(e,t)=>K({file:e,text:t,hold:!1,sending:!1})}),c&&(0,s.jsx)("div",{className:"border-t border-border bg-black/25",children:(0,s.jsx)(eA,{file:r,defaultMode:"split",maxBodyHeight:520,onFocus:()=>x(r.path)},r.path)})]},r.path)})},e.key)})})]})}function eL({questions:e}){if(0===e.length)return(0,s.jsxs)("div",{className:"py-10 text-center text-[12px] text-muted-foreground",children:["No questions yet. Open a file, switch the diff to ",(0,s.jsx)("span",{className:"text-[#ff7a45]",children:"Ask"})," mode, and ask the agent about a line — its answer lands back here."]});let t=new Map;for(let n of[...e].sort((e,t)=>t.createdAt-e.createdAt)){let e=t.get(n.file);e?e.push(n):t.set(n.file,[n])}return(0,s.jsx)("div",{className:"space-y-3",children:[...t.entries()].map(([e,t])=>(0,s.jsxs)("div",{className:"glass overflow-hidden rounded-2xl",children:[(0,s.jsxs)("button",{type:"button",onClick:()=>eC(e),title:"Open in editor",className:"group flex w-full items-center gap-2 border-b border-border px-3 py-2 text-left",children:[(0,s.jsx)(h.A,{className:"size-3.5 shrink-0 text-[#ff7a45]"}),(0,s.jsx)("span",{className:"truncate font-mono text-[12px] text-foreground/90",children:e}),(0,s.jsx)("span",{className:"text-[10px] tabular-nums text-muted-foreground",children:t.length}),(0,s.jsx)(er.A,{className:"ml-auto size-3 shrink-0 text-transparent transition-colors group-hover:text-muted-foreground/70"})]}),(0,s.jsx)("div",{className:"space-y-2 p-3",children:t.map(e=>(0,s.jsxs)("div",{className:"rounded-lg border border-border bg-background/50 p-2.5",children:[(0,s.jsxs)("div",{className:"flex items-start gap-2",children:[(0,s.jsx)(h.A,{className:"mt-0.5 size-3.5 shrink-0 text-[#ff7a45]"}),(0,s.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,s.jsx)("div",{className:"whitespace-pre-wrap text-[12.5px] leading-snug text-foreground",children:e.body}),(0,s.jsxs)("div",{className:"mt-0.5 text-[9px] uppercase tracking-wide text-muted-foreground/60",children:["line ",e.line]})]})]}),e.answer?(0,s.jsx)(ez,{answer:e.answer,className:"ml-5 mt-2"}):(0,s.jsx)(eE,{delivered:!!e.deliveredAt,className:"ml-5 mt-1.5 text-[10px]"})]},e.id))})]},e))})}function eF({section:e,count:t,children:n}){let[a,o]=(0,r.useState)(!e.dim);return(0,s.jsxs)("section",{className:(0,C.cn)("overflow-hidden rounded-xl border border-border bg-white/[0.015]",e.accent&&"border-l-2 border-l-[#ff7a45]/40",e.dim&&"opacity-80"),children:[(0,s.jsxs)("button",{type:"button",onClick:()=>e.dim&&o(e=>!e),className:(0,C.cn)("flex w-full items-center gap-1.5 border-b border-border px-4 py-2 text-left text-[10px] font-semibold uppercase tracking-widest text-muted-foreground/80",e.dim&&"cursor-pointer hover:text-muted-foreground"),disabled:!e.dim,children:[e.dim&&(0,s.jsx)(ed.A,{className:(0,C.cn)("size-3 shrink-0 transition-transform",a&&"rotate-90")}),(0,s.jsx)("span",{className:"truncate",children:e.label}),(0,s.jsx)("span",{className:"ml-auto tabular-nums opacity-60",children:t})]}),a&&(0,s.jsx)("div",{className:"divide-y divide-white/[0.04]",children:n})]})}var eq=n(6923),eB=n(58309),eH=n(17494),eU=n(47409);let eK="beacon:changes-sidebar-open",eX="beacon:changes-sidebar-w";function eG(e){return e.map(e=>{var t;return{path:e.path,status:"added"===(t=e.status)?"added":"deleted"===t?"deleted":"modified",meta:`+${e.additions} −${e.deletions}`}})}function e_({repo:e,files:t,touched:n,contract:a,initialPath:l,livePath:i,onBack:d,views:c,onToggleViewed:u}){let m=(0,r.useMemo)(()=>new Set(n),[n]),x=e=>m.has(e.path)||!!e.oldPath&&m.has(e.oldPath),h=(0,r.useMemo)(()=>a?new Set([...a.declaredFiles,...a.authorizedExtras]):null,[a]),p=!!h&&h.size>0,f=e=>!!h&&(h.has(e.path)||!!e.oldPath&&h.has(e.oldPath)),[g,b]=(0,r.useState)(l),[v,j]=(0,r.useState)(()=>{try{return"0"!==window.localStorage.getItem(eK)}catch{return!0}}),[y,k]=(0,r.useState)(()=>{try{let e=Number(window.localStorage.getItem(eX));return e?Math.max(220,Math.min(620,e)):320}catch{return 320}}),N=(0,r.useCallback)(()=>{j(e=>{let t=!e;try{localStorage.setItem(eK,t?"1":"0")}catch{}return t})},[]),w=(0,r.useRef)(null),A=(0,r.useRef)(!1),S=(0,r.useCallback)(e=>{e.preventDefault(),A.current=!0,document.body.style.cursor="col-resize",document.body.style.userSelect="none"},[]);(0,r.useEffect)(()=>{let e=e=>{if(!A.current||!w.current)return;let t=w.current.getBoundingClientRect().left;k(Math.max(220,Math.min(620,e.clientX-t)))},t=()=>{if(A.current){A.current=!1,document.body.style.cursor="",document.body.style.userSelect="";try{localStorage.setItem(eX,String(y))}catch{}}};return window.addEventListener("pointermove",e),window.addEventListener("pointerup",t),()=>{window.removeEventListener("pointermove",e),window.removeEventListener("pointerup",t)}},[y]);let z=(0,r.useMemo)(()=>p?{onPlan:t.filter(f),strayed:t.filter(e=>!f(e)&&x(e)),other:t.filter(e=>!f(e)&&!x(e))}:null,[t,p,h,m]),E=t.some(x),[$,P]=(0,r.useState)("session"),R="session"!==$||E?$:"all",M=(0,r.useMemo)(()=>z?[...z.onPlan,...z.strayed,...z.other]:"all"===R?t:t.filter(x),[z,t,R,m]),D=(0,r.useMemo)(()=>new Map(t.map(e=>[e.path,e])),[t]),O=g&&M.some(e=>e.path===g)?g:M[0]?.path??null,I=O?D.get(O)??null:null,T=!!I&&!!z&&z.strayed.some(e=>e.path===I.path),L=y<300,F={session:{label:"This session",Icon:eq.A,title:"Files edited this session"},all:{label:"All",Icon:eB.A,title:"All uncommitted changes"}},q=(0,s.jsx)("div",{className:"ml-auto flex items-center gap-0.5 rounded-full border border-border p-0.5",children:["session","all"].map(e=>{let{label:t,Icon:n,title:r}=F[e],a="session"===e&&!E;return(0,s.jsx)("button",{type:"button",onClick:()=>P(e),disabled:a,className:(0,C.cn)("flex items-center justify-center rounded-full text-[10px] font-medium transition-colors",L?"size-5":"px-2 py-0.5",R===e?"bg-[var(--ink-active)] text-foreground":"text-muted-foreground hover:text-foreground",a&&"opacity-40"),title:r,children:L?(0,s.jsx)(n,{className:"size-3"}):t},e)})});return(0,s.jsxs)("div",{ref:w,className:"flex min-h-0 flex-1",children:[v?(0,s.jsxs)("aside",{style:{width:y},className:"flex min-w-0 shrink-0 flex-col border-r border-border bg-background",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2 px-3 pb-2 pt-3",children:[(0,s.jsx)("button",{type:"button",onClick:d,title:"Back to overview",className:"flex size-5 shrink-0 items-center justify-center rounded text-muted-foreground/70 transition-colors hover:bg-[var(--ink-hover)] hover:text-foreground",children:(0,s.jsx)(U.A,{className:"size-3.5"})}),(0,s.jsx)("button",{type:"button",onClick:N,title:"Hide the file list",className:"flex size-5 shrink-0 items-center justify-center rounded text-muted-foreground/70 transition-colors hover:bg-[var(--ink-hover)] hover:text-foreground",children:(0,s.jsx)(K.A,{className:"size-3.5"})}),(0,s.jsx)(o.A,{className:"size-4 shrink-0 text-[#ff7a45]"}),!L&&(0,s.jsx)("h1",{className:"text-sm font-semibold tracking-tight",children:"Changes"}),(0,s.jsx)("span",{className:"text-[11px] tabular-nums text-muted-foreground",children:M.length}),p?(0,s.jsx)("span",{className:(0,C.cn)("ml-auto flex items-center rounded-full border border-emerald-400/25 bg-emerald-400/10 font-medium text-emerald-300/90",L?"size-5 justify-center":"gap-1 px-2 py-0.5 text-[10px]"),title:`Scoped to this plan — ${h.size} file${1===h.size?"":"s"} in scope`,children:L?(0,s.jsx)(eH.A,{className:"size-3"}):"Plan-scoped"}):e&&t.length>0?q:null]}),(0,s.jsx)("div",{className:"min-h-0 flex-1 overflow-y-auto px-1.5 pb-4",children:e?0===t.length?(0,s.jsx)("p",{className:"px-2 py-4 text-[11px] leading-relaxed text-muted-foreground",children:"No uncommitted changes yet — edits the agent makes as it executes the plan show up here live."}):z?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(eV,{label:"On plan",tone:"plan",files:z.onPlan,onSelect:b,selectedPath:O,livePath:i,emptyNote:"No plan files changed yet."}),z.strayed.length>0?(0,s.jsx)(eV,{label:"Strayed",tone:"warn",files:z.strayed,onSelect:b,selectedPath:O,livePath:i}):z.onPlan.length>0?(0,s.jsx)("p",{className:"mb-1 px-2 py-1 text-[10px] text-emerald-400/70",children:"✓ No strays — all session edits are on-plan."}):null,z.other.length>0&&(0,s.jsx)(eV,{label:"Other uncommitted",tone:"muted",files:z.other,onSelect:b,selectedPath:O,livePath:i,defaultOpen:!1})]}):(0,s.jsx)(eU.h,{files:eG(M),onSelect:b,selectedPath:O,livePath:i}):(0,s.jsx)("p",{className:"px-2 py-4 text-[11px] text-muted-foreground",children:"Not a git repository."})})]}):null,v?(0,s.jsx)("div",{onPointerDown:S,className:"group relative w-px shrink-0 cursor-col-resize bg-border hover:bg-[var(--ink-active)]",title:"Drag to resize",children:(0,s.jsx)("div",{className:"absolute inset-y-0 -left-1.5 right-[-6px] z-10"})}):(0,s.jsxs)("aside",{className:"flex w-10 shrink-0 flex-col items-center gap-1 border-r border-border bg-background py-2",children:[(0,s.jsx)("button",{type:"button",onClick:d,title:"Back to overview",className:"flex size-7 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-[var(--ink-hover)] hover:text-foreground",children:(0,s.jsx)(U.A,{className:"size-4"})}),(0,s.jsx)("button",{type:"button",onClick:N,title:`Show the file list \xb7 ${M.length}`,className:"flex size-7 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-[var(--ink-hover)] hover:text-foreground",children:(0,s.jsx)(X.A,{className:"size-4"})})]}),(0,s.jsx)("main",{className:"flex min-w-0 flex-1 flex-col bg-background p-3",children:I?(0,s.jsxs)("div",{className:"flex min-h-0 flex-1 flex-col overflow-hidden rounded-xl border border-border bg-white/[0.015]",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2.5 border-b border-border px-4 py-2.5",children:[T&&(0,s.jsxs)("span",{className:"flex shrink-0 items-center gap-1 rounded-full border border-amber-400/30 bg-amber-400/10 px-1.5 py-0.5 text-[10px] font-medium text-amber-300",title:"This file is outside the plan's declared scope",children:[(0,s.jsx)(eu.A,{className:"size-3"})," Strayed"]}),(0,s.jsx)("span",{className:(0,C.cn)("shrink-0 text-[9.5px] font-bold uppercase tracking-[0.08em]",ex[em(I.status)]),children:em(I.status)}),(0,s.jsx)("span",{className:"truncate font-mono text-[12.5px] text-foreground/90",title:I.path,children:I.oldPath?`${I.oldPath} → ${I.path}`:I.path}),(0,s.jsxs)("span",{className:"ml-auto w-24 shrink-0 text-right text-[11.5px] tabular-nums",children:[(0,s.jsxs)("span",{className:"text-emerald-400",children:["+",I.additions]})," ",(0,s.jsxs)("span",{className:"text-rose-400",children:["−",I.deletions]})]}),c&&u&&(0,s.jsxs)("span",{className:"flex shrink-0 items-center gap-1.5 text-[10px] text-muted-foreground/70",children:["invalidated"===c[I.path]&&"changed since you viewed","viewed"===c[I.path]&&"viewed",(0,s.jsx)(ep,{view:c[I.path]??"unviewed",onToggle:e=>u(I,e)})]})]}),(0,s.jsx)(eA,{file:I,defaultMode:"split",className:"flex-1"},I.path)]}):(0,s.jsx)("div",{className:"flex flex-1 items-center justify-center px-6 text-center text-sm text-muted-foreground",children:e?0===t.length?"No uncommitted changes yet — edits the agent makes show up here live.":"Select a file to see its diff.":"Not a git repository."})})]})}let eW={plan:{text:"text-emerald-300/80"},warn:{text:"text-amber-300",icon:!0},muted:{text:"text-muted-foreground"}};function eV({label:e,tone:t,files:n,onSelect:a,selectedPath:o,livePath:l,defaultOpen:i=!0,emptyNote:d}){let[c,u]=(0,r.useState)(i),m=eW[t];return(0,s.jsxs)("div",{className:"mb-1",children:[(0,s.jsxs)("button",{type:"button",onClick:()=>u(e=>!e),className:(0,C.cn)("flex w-full items-center gap-1.5 rounded px-2 py-1 text-[10px] font-semibold uppercase tracking-wide transition-colors hover:bg-[var(--ink-hover)]",m.text),children:[(0,s.jsx)(ed.A,{className:(0,C.cn)("size-3 shrink-0 transition-transform",c&&"rotate-90")}),m.icon&&(0,s.jsx)(eu.A,{className:"size-3 shrink-0"}),(0,s.jsx)("span",{className:"truncate",children:e}),(0,s.jsx)("span",{className:"ml-auto tabular-nums opacity-70",children:n.length})]}),c&&(n.length>0?(0,s.jsx)(eU.h,{files:eG(n),onSelect:a,selectedPath:o,livePath:l}):d?(0,s.jsx)("p",{className:"px-2 py-1 pl-6 text-[10px] text-muted-foreground/70",children:d}):null)]})}var eJ=n(90467),eQ=n(79267),eY=n(15532);function eZ({repo:e,files:t,currentPath:n,onExit:a,views:o,onToggleViewed:l}){let[i,d]=(0,r.useState)(n??t[0]?.path??null),[c,u]=(0,r.useState)(!1),[m,x]=(0,r.useState)(n);m!==n&&(x(n),!c&&n&&d(n));let h=t.find(e=>e.path===i)??t.find(e=>e.path===n)??null,p=c&&!!n&&n!==i;return(0,s.jsxs)("div",{className:"flex min-h-0 flex-1 flex-col bg-background p-3",children:[(0,s.jsxs)("div",{className:"mb-2 flex shrink-0 items-center gap-2.5",children:[(0,s.jsx)("button",{type:"button",onClick:a,title:"Back to overview",className:"flex size-6 shrink-0 items-center justify-center rounded text-muted-foreground/70 transition-colors hover:bg-[var(--ink-hover)] hover:text-foreground",children:(0,s.jsx)(U.A,{className:"size-4"})}),p?(0,s.jsxs)("button",{type:"button",onClick:()=>{d(n),u(!1)},title:"Jump to the file the agent is editing now",className:"flex items-center gap-1.5 rounded-full border border-amber-400/30 bg-amber-400/10 px-2.5 py-1 text-[11px] font-medium text-amber-300 transition-colors hover:bg-amber-400/20",children:["agent moved to ",(0,s.jsx)("span",{className:"font-mono",children:n.split("/").pop()||n}),(0,s.jsx)(eJ.A,{className:"size-3"})," catch up"]}):c?(0,s.jsxs)("button",{type:"button",onClick:()=>u(!1),title:"Resume following the agent's edits",className:"flex items-center gap-1.5 rounded-full border border-border px-2.5 py-1 text-[11px] font-medium text-muted-foreground transition-colors hover:text-foreground",children:[(0,s.jsx)(eQ.A,{className:"size-3"})," Paused while you read \xb7 resume"]}):(0,s.jsxs)("span",{className:"flex items-center gap-1.5 rounded-full border border-[#ff7a45]/25 bg-[#ff7a45]/10 px-2.5 py-1 text-[11px] font-medium text-[#ff7a45]",children:[(0,s.jsx)(eY.A,{className:"size-3"})," Following the agent live"]})]}),h?(0,s.jsxs)("div",{onPointerDownCapture:()=>u(!0),onWheelCapture:()=>u(!0),onKeyDownCapture:()=>u(!0),className:"flex min-h-0 flex-1 flex-col overflow-hidden rounded-xl border border-border bg-white/[0.015]",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2.5 border-b border-border px-4 py-2.5",children:[(0,s.jsx)("span",{className:(0,C.cn)("shrink-0 text-[9.5px] font-bold uppercase tracking-[0.08em]",ex[em(h.status)]),children:em(h.status)}),(0,s.jsx)("span",{className:"truncate font-mono text-[12.5px] text-foreground/90",title:h.path,children:h.oldPath?`${h.oldPath} → ${h.path}`:h.path}),(0,s.jsxs)("span",{className:"ml-auto w-24 shrink-0 text-right text-[11.5px] tabular-nums",children:[(0,s.jsxs)("span",{className:"text-emerald-400",children:["+",h.additions]})," ",(0,s.jsxs)("span",{className:"text-rose-400",children:["−",h.deletions]})]}),o&&l&&(0,s.jsxs)("span",{className:"flex shrink-0 items-center gap-1.5 text-[10px] text-muted-foreground/70",children:["invalidated"===o[h.path]&&"changed since you viewed","viewed"===o[h.path]&&"viewed",(0,s.jsx)(ep,{view:o[h.path]??"unviewed",onToggle:e=>l(h,e)})]})]}),(0,s.jsx)(eA,{file:h,defaultMode:"split",className:"flex-1"},h.path)]}):(0,s.jsx)("div",{className:"flex flex-1 items-center justify-center px-6 text-center text-sm text-muted-foreground",children:e?"Waiting for the agent's next edit…":"Not a git repository."})]})}function e0(e){return`${e.status}:${e.additions}:${e.deletions}`}function e1({repo:e,files:t,touched:n,viewed:a,contract:o=null}){let[l,i]=(0,r.useState)("activity"),[d,c]=(0,r.useState)(null),[u,m]=(0,r.useState)(!1),x=(0,r.useMemo)(()=>ek(t,n),[t,n]),[h,p]=(0,r.useState)(a),[f,g]=(0,r.useState)(a);f!==a&&(g(a),p(a));let b=(0,r.useMemo)(()=>new Map(t.map(e=>[e.path,e0(e)])),[t]),[v,j]=(0,r.useState)(null),[y,N]=(0,r.useState)(new Set),[w,C]=(0,r.useState)(new Set);if(v!==b&&(j(b),v)){let e=[];for(let[t,n]of b)v.get(t)!==n&&e.push(t);N(t=>new Set([...[...t].filter(e=>b.has(e)),...e])),e.length&&C(new Set(e))}(0,r.useEffect)(()=>{if(0===w.size)return;let e=setTimeout(()=>C(new Set),1800);return()=>clearTimeout(e)},[w]);let A=(0,r.useMemo)(()=>(function(e,t){let n={};for(let s of e){let e=t[s.path];n[s.path]=e?e.sig===e0(s)?"viewed":"invalidated":"unviewed"}return n})(t,h),[t,h]),[S,z]=(0,r.useState)([]),[E,$]=(0,r.useState)(0);(0,r.useEffect)(()=>{let e=(0,k.fk)();fetch("/api/changes/comment",{cache:"no-store",headers:e?{"x-beacon-workspace":e}:void 0}).then(e=>e.json()).then(e=>z(e.comments??[])).catch(()=>{})},[t,E]);let P=(0,r.useMemo)(()=>{let e={};for(let t of S)"question"!==t.kind&&(e[t.file]=(e[t.file]??0)+1);return e},[S]),R=(0,r.useMemo)(()=>S.filter(e=>"question"===e.kind),[S]),M=R.filter(e=>!e.answer).length;(0,r.useEffect)(()=>{if(0===M)return;let e=Date.now(),t=setInterval(()=>{Date.now()-e>9e5?clearInterval(t):$(e=>e+1)},4e3);return()=>clearInterval(t)},[M]);let[D,O]=(0,r.useState)(null),[I,T]=(0,r.useState)(!1),L=async()=>{T(!0);let e=(0,k.fk)(),t=await fetch("/api/changes/quality",{method:"POST",cache:"no-store",headers:e?{"x-beacon-workspace":e}:void 0}).then(e=>e.json()).catch(()=>null);O(t?.files??null),T(!1)},F=e=>N(t=>{let n=new Set(t);return n.delete(e),n}),q=(e,t)=>{let n=t?e0(e):null;p(t=>{let s={...t};return n?s[e.path]={viewedAt:Date.now(),sig:n}:delete s[e.path],s}),F(e.path);let s=(0,k.fk)();fetch("/api/changes/viewed",{method:"POST",headers:{"content-type":"application/json",...s?{"x-beacon-workspace":s}:{}},body:JSON.stringify({path:e.path,sig:n})}).catch(()=>{})};return u?(0,s.jsx)(eZ,{repo:e,files:t,currentPath:x?.path??null,onExit:()=>m(!1),views:A,onToggleViewed:q}):null!==d?(0,s.jsx)(e_,{repo:e,files:t,touched:Object.keys(n),contract:o,initialPath:d,livePath:x?.path??null,onBack:()=>c(null),views:A,onToggleViewed:q}):(0,s.jsx)(eT,{files:t,touched:n,views:A,unseen:y,transients:w,commentCounts:P,questions:R,lens:l,onLens:i,onOpen:e=>{F(e),c(e)},onSeen:F,onToggleViewed:q,quality:D,scanning:I,onScan:()=>void L(),onCommentAdded:()=>$(e=>e+1),onFocus:()=>m(!0)})}function e5({files:e}){return(0,s.jsxs)("div",{className:"flex min-h-0 flex-1 flex-col bg-background",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2 border-b border-border px-4 py-3",children:[(0,s.jsx)(o.A,{className:"size-4 shrink-0 text-[#ff7a45]"}),(0,s.jsx)("h1",{className:"text-sm font-semibold tracking-tight",children:"Plan files"}),(0,s.jsx)("span",{className:"text-[11px] tabular-nums text-muted-foreground",children:e.length}),(0,s.jsx)("span",{className:"ml-auto truncate text-[11px] text-muted-foreground/80",children:"Files this plan declared \xb7 live diffs show only for the plan that's executing"})]}),(0,s.jsx)("div",{className:"min-h-0 flex-1 overflow-y-auto p-3",children:0===e.length?(0,s.jsx)("p",{className:"px-2 py-4 text-[11px] leading-relaxed text-muted-foreground",children:"No files were saved for this plan."}):(0,s.jsx)("ul",{className:"space-y-0.5",children:e.map(e=>(0,s.jsx)("li",{children:(0,s.jsxs)("button",{type:"button",onClick:()=>eC(e),title:"Open in editor",className:"group flex w-full items-center gap-2 rounded px-2 py-1 text-left font-mono text-[12px] text-foreground/90 transition-colors hover:bg-[var(--ink-hover)]",children:[(0,s.jsx)(es.A,{className:"size-3.5 shrink-0 text-muted-foreground/60"}),(0,s.jsx)("span",{className:"truncate",children:e}),(0,s.jsx)(er.A,{className:"ml-auto size-3 shrink-0 text-transparent transition-colors group-hover:text-muted-foreground/70"})]})},e))})})]})}function e3({markdown:e}){let t=(0,r.useMemo)(()=>(0,S.n$)(e).map((e,t)=>({b:e,i:t})).filter(({b:e})=>(0,S.Vq)(e.kind)).map(({b:e,i:t})=>({id:(0,S.vB)(t),level:(0,S.F8)(e.kind),label:(0,S.kz)(e.text)})).filter(e=>e.label.length>0),[e]),[n,a]=(0,r.useState)(null);return(0,r.useEffect)(()=>{if("u"<typeof IntersectionObserver||0===t.length)return;let e=t.map(e=>document.getElementById(e.id)).filter(e=>null!==e);if(0===e.length)return;let n=new IntersectionObserver(e=>{let t=e.filter(e=>e.isIntersecting).sort((e,t)=>e.boundingClientRect.top-t.boundingClientRect.top);t[0]&&a(t[0].target.id)},{rootMargin:"-12% 0px -70% 0px",threshold:0});return e.forEach(e=>n.observe(e)),()=>n.disconnect()},[t]),(0,s.jsxs)("aside",{className:"flex w-60 shrink-0 flex-col overflow-y-auto border-r border-border bg-background pt-16",children:[(0,s.jsx)("div",{className:"px-4 pb-2 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground",children:"Sections"}),0===t.length?(0,s.jsx)("p",{className:"px-4 text-[12px] text-muted-foreground/70",children:"No headings in this plan."}):(0,s.jsx)("nav",{className:"space-y-0.5 px-2 pb-6",children:t.map(e=>(0,s.jsx)("button",{onClick:()=>{var t;let n;return t=e.id,void((n=document.getElementById(t))&&(n.scrollIntoView({behavior:"smooth",block:"start"}),a(t)))},title:e.label,style:{paddingLeft:`${.5+.75*e.level}rem`},className:(0,C.cn)("block w-full truncate rounded py-1 pr-2 text-left text-[12px] leading-snug transition-colors",n===e.id?"bg-[var(--ink-active)] font-medium text-foreground":"text-muted-foreground hover:bg-[var(--ink-hover)] hover:text-foreground"),children:e.label},e.id))})]})}var e2=n(50981),e4=n(4474),e7=n(97358);function e9({open:e,onOpenChange:t,onConfirmed:n}){let[a,o]=(0,r.useState)("bypassPermissions"),[i,d]=(0,r.useState)(!1);async function c(){d(!0);try{await fetch("/api/preferences",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({planApprovalMode:a})}).catch(()=>{}),t(!1),n()}finally{d(!1)}}return(0,s.jsx)(V.lG,{open:e,onOpenChange:t,children:(0,s.jsxs)(V.Cf,{className:"max-w-lg",children:[(0,s.jsxs)(V.c7,{children:[(0,s.jsxs)(V.L3,{className:"flex items-center gap-2",children:[(0,s.jsx)(e2.A,{className:"size-4 text-emerald-400"}),"After approving, the agent should…"]}),(0,s.jsx)(V.rr,{children:"Pick the permission mode your terminal session enters when you approve a plan. We ask once and remember it for every project — change it anytime in Settings."})]}),(0,s.jsx)("div",{className:"space-y-2 py-1",children:e7.pC.map(e=>(0,s.jsxs)("button",{type:"button",onClick:()=>o(e.value),className:(0,C.cn)("flex w-full items-start gap-3 rounded-lg border p-3 text-left transition-colors",a===e.value?"border-emerald-500/50 bg-emerald-500/10":"border-border bg-white/[0.03] hover:bg-[var(--ink-hover)]"),children:[(0,s.jsx)("span",{className:(0,C.cn)("mt-0.5 flex size-4 shrink-0 items-center justify-center rounded-full border",a===e.value?"border-emerald-400 bg-emerald-400/20":"border-border"),children:a===e.value&&(0,s.jsx)(l.A,{className:"size-3 text-emerald-300"})}),(0,s.jsxs)("span",{className:"min-w-0",children:[(0,s.jsx)("span",{className:"block text-sm font-medium text-foreground",children:e.label}),(0,s.jsx)("span",{className:"block text-xs text-muted-foreground",children:e.description})]})]},e.value))}),(0,s.jsxs)(V.Es,{className:"items-center justify-between gap-2 sm:justify-between",children:[(0,s.jsx)("span",{className:"text-xs text-muted-foreground",children:"You can change this later in Settings."}),(0,s.jsx)(e4.$,{onClick:c,disabled:i,size:"sm",children:i?"Saving…":"Save & approve"})]})]})})}function e6({dbProps:e,mapProps:t,planMarkdown:n,repoFiles:N=[],forceHistory:w=!1,changesView:A=!1,changes:z=null,contract:E=null,planFiles:$=null}){let P=(0,v.useRouter)(),{status:R,discard:M}=(0,j.j)(),D=t.nodes.length>0,I=e.tables.length>0||e.endpoints.length>0||(e.draft?.tables.length??0)>0||(e.draft?.endpoints.length??0)>0,[L,F]=(0,r.useState)(D?"map":"db"),q="map"!==L||D?"db"!==L||I?L:"map":"db",[B,H]=(0,r.useState)(!1),U=(0,r.useRef)(!1),[K,X]=(0,r.useState)(!1),[W,V]=(0,r.useState)(null),J=(0,r.useRef)(!1),[Q,ee]=(0,r.useState)(null),et=(0,r.useCallback)(async()=>{ee(null);let e=(0,y.X0)();try{let t=await fetch("/api/plan/approve",{method:"POST",headers:(0,k.dh)(e)});if(!t.ok)throw Error(`approve ${t.status}`);let n=await fetch("/api/plan/verdict",{headers:(0,k.dh)(e),cache:"no-store"}).then(e=>e.json()).catch(()=>null);if(n?.kind!=="approved")throw Error("verdict not confirmed")}catch{ee("Approval didn't reach your terminal session — it wasn't confirmed. Please try Approve again.");return}V({features:R.features,tables:R.tables,endpoints:R.endpoints})},[R.features,R.tables,R.endpoints]);(0,r.useEffect)(()=>{if(!W)return;J.current=!1;let e=W.features>0?"/map?view=ROADMAP":W.tables>0||W.endpoints>0?"/map?view=DATABASE":"/map?view=ROADMAP",t=setTimeout(()=>{J.current||(J.current=!0,P.push(e))},3e3);return()=>clearTimeout(t)},[W,P]);let es=(0,r.useCallback)(async()=>{try{let e=await fetch("/api/preferences",{cache:"no-store"});if((await e.json()).planApprovalModeConfigured)return void et()}catch{et();return}X(!0)},[et]),[er,ea]=(0,r.useState)(null),eo=(0,r.useCallback)(e=>ea(e),[]),el=(0,r.useRef)(null),ei=(0,r.useRef)(null),ed=(0,r.useRef)(e.draft),[ec,eu]=(0,r.useState)(!1),em=(0,r.useCallback)(()=>eu(!0),[]),[ex,eh]=(0,r.useState)([]),[ep,ef]=(0,r.useState)(!1),[eg,eb]=(0,r.useState)(""),ev=(0,r.useCallback)(e=>{eb(e),ef(!0)},[]),ej=(0,r.useRef)(ex);(0,r.useEffect)(()=>{ej.current=ex},[ex]),(0,r.useEffect)(()=>{eh([]),ef(!1),eu(!1)},[R.proposedAt]),(0,r.useEffect)(()=>{let e=()=>void fetch("/api/plan/presence",{method:"POST",cache:"no-store",headers:(0,k.dh)((0,y.X0)())}).catch(()=>{});e();let t=setInterval(e,5e3);return()=>clearInterval(t)},[]);let ey=(0,r.useCallback)(()=>({draft:ed.current,questions:ej.current}),[]),ek=(0,r.useMemo)(()=>{let n=[];for(let e of t.nodes)n.push(`feature: ${e.title}`);for(let t of e.draft?.tables??[])n.push(`table: ${t.name}`);for(let t of e.tables)n.push(`table: ${t.name}`);for(let t of e.draft?.endpoints??[])n.push(`endpoint: ${t.method} ${t.path}`);for(let t of e.endpoints)n.push(`endpoint: ${t.method} ${t.path}`);return Array.from(new Set(n))},[t.nodes,e]),eN=er?(0,s.jsx)(T,{annotations:er.annotations,updateComment:er.updateComment,removeAnnotation:er.removeAnnotation,focusOnAnnotation:er.focusOnAnnotation,onClose:()=>"db"===q?ei.current?.close():el.current?.close()}):null,ew=(0,r.useCallback)(()=>{if(B){U.current=!0,H(!1);return}"db"===q?ei.current?.open():el.current?.open()},[q,B]);(0,r.useEffect)(()=>{!B&&U.current&&(U.current=!1,"db"===q?ei.current?.open():el.current?.open())},[B,q]);let eC=(0,r.useCallback)(e=>{er?.addComment(e)},[er]),eA=(0,r.useCallback)(e=>{er?.focusOnAnnotation(e),"db"===q?ei.current?.openComments():el.current?.openComments()},[er,q]),[eS,ez]=(0,r.useState)(()=>{try{let e=window.localStorage.getItem("beacon:plan-left-pct");return e?Math.max(20,Math.min(80,Number(e))):50}catch{return 50}}),eE=(0,r.useRef)(null),e$=(0,r.useRef)(!1),eP=(0,r.useCallback)(e=>{e.preventDefault(),e$.current=!0,document.body.style.cursor="col-resize",document.body.style.userSelect="none"},[]);(0,r.useEffect)(()=>{let e=e=>{if(!e$.current||!eE.current)return;let t=eE.current.getBoundingClientRect();ez(Math.max(20,Math.min(80,(e.clientX-t.left)/t.width*100)))},t=()=>{if(e$.current){e$.current=!1,document.body.style.cursor="",document.body.style.userSelect="";try{localStorage.setItem("beacon:plan-left-pct",String(eS))}catch{}}};return window.addEventListener("pointermove",e),window.addEventListener("pointerup",t),()=>{window.removeEventListener("pointermove",e),window.removeEventListener("pointerup",t)}},[eS]);let eR=async()=>{await fetch("/api/plan/annotations",{method:"DELETE",headers:(0,k.dh)((0,y.X0)())}).catch(()=>{}),await M(),P.refresh()};if((!R.pending||w||A)&&!W)return(0,s.jsxs)(S.Ue,{files:N,children:[(0,s.jsx)("div",{className:"pointer-events-none fixed left-1/2 top-3 z-30 -translate-x-1/2",children:(0,s.jsxs)("div",{className:"glass pointer-events-auto flex items-center gap-0.5 rounded-full p-0.5",children:[(0,s.jsx)(Z.E,{active:!A,onClick:()=>P.push((0,y.rc)({view:"history"})),icon:(0,s.jsx)(a.A,{className:"size-3"}),children:"Plan history"}),(0,s.jsx)(Z.E,{active:A,onClick:()=>P.push((0,y.rc)({view:"changes"})),icon:(0,s.jsx)(o.A,{className:"size-3"}),children:"Changes"})]})}),A&&$?(0,s.jsx)("div",{className:"flex h-screen min-h-0 flex-col pt-14",children:(0,s.jsx)(e5,{files:$})}):A&&z?(0,s.jsx)("div",{className:"flex h-screen min-h-0 flex-col pt-14",children:(0,s.jsx)(e1,{repo:z.repo,files:z.files,touched:z.touched,viewed:z.viewed,contract:E})}):(0,s.jsx)(en,{pendingPlan:R.pending,workspaceId:e.workspaceId})]});let eM=D||I,eD=eM&&!B,eO=!eM||B,eI=((er?.liveCount??0)>0||ec||ex.length>0)&&!er?.submitted;return(0,s.jsxs)("div",{className:"relative flex h-screen flex-col",children:[Q&&(0,s.jsx)("div",{className:"fixed bottom-4 left-1/2 z-[60] -translate-x-1/2 rounded-lg border border-red-500/40 bg-red-500/15 px-4 py-2 text-sm text-red-200 shadow-xl backdrop-blur",children:Q}),W&&(0,s.jsxs)("div",{className:"absolute inset-0 z-50 flex flex-col items-center justify-center gap-5 bg-background/97 px-6 text-center backdrop-blur-sm",children:[(0,s.jsx)("div",{className:"flex size-12 items-center justify-center rounded-full bg-emerald-500/15",children:(0,s.jsx)(l.A,{className:"size-6 text-emerald-300"})}),(0,s.jsxs)("div",{className:"space-y-1",children:[(0,s.jsx)("h2",{className:"text-lg font-semibold text-foreground",children:"Plan approved"}),(0,s.jsx)("p",{className:"max-w-sm text-sm text-muted-foreground",children:W.features>0||W.tables>0||W.endpoints>0?"It's committed. Here's where to find it:":"It's archived to your plan history."}),(0,s.jsx)("p",{className:"text-xs text-muted-foreground/70",children:"Taking you to the map in 3 seconds…"})]}),(0,s.jsxs)("div",{className:"flex flex-wrap items-center justify-center gap-2",children:[W.features>0&&(0,s.jsxs)("button",{onClick:()=>{J.current=!0,P.push("/map?view=ROADMAP")},className:"flex items-center gap-2 rounded-lg border border-border px-3 py-2 text-sm text-foreground transition-colors hover:bg-[var(--ink-hover)]",children:[(0,s.jsx)(i.A,{className:"size-4 text-sky-300"})," ",W.features," feature",1===W.features?"":"s"," → Map"]}),(W.tables>0||W.endpoints>0)&&(0,s.jsxs)("button",{onClick:()=>{J.current=!0,P.push("/map?view=DATABASE")},className:"flex items-center gap-2 rounded-lg border border-border px-3 py-2 text-sm text-foreground transition-colors hover:bg-[var(--ink-hover)]",children:[(0,s.jsx)(d.A,{className:"size-4 text-violet-300"})," ",W.tables," table",1===W.tables?"":"s"," \xb7 ",W.endpoints," endpoint",1===W.endpoints?"":"s"," → Database"]}),(0,s.jsxs)("button",{onClick:()=>{J.current=!0,V(null),P.push((0,y.rc)({view:"changes"}))},className:"flex items-center gap-2 rounded-lg border border-border px-3 py-2 text-sm text-foreground transition-colors hover:bg-[var(--ink-hover)]",children:[(0,s.jsx)(o.A,{className:"size-4 text-[#ff7a45]"})," Watch changes"]})]}),(0,s.jsx)("button",{onClick:()=>{J.current=!0,V(null),P.push((0,y.rc)({view:"history"}))},className:"rounded-full border border-border px-3 py-1.5 text-xs font-medium text-muted-foreground transition-colors hover:bg-[var(--ink-hover)] hover:text-foreground",children:"Done — browse plan history"})]}),er?.submitted&&(0,s.jsxs)("div",{className:"absolute inset-0 z-40 flex flex-col items-center justify-center gap-4 bg-background/95 px-6 text-center backdrop-blur-sm",children:[(0,s.jsx)("div",{className:"flex size-12 items-center justify-center rounded-full bg-sky-500/15",children:(0,s.jsx)(c.A,{className:"size-6 animate-spin text-sky-300"})}),(0,s.jsxs)("div",{className:"space-y-1",children:[(0,s.jsx)("h2",{className:"text-lg font-semibold text-foreground",children:"Feedback sent"}),(0,s.jsx)("p",{className:"max-w-sm text-sm text-muted-foreground",children:"Your terminal session is revising the plan based on your comments. The updated plan will appear here automatically — no need to refresh."})]}),(0,s.jsx)("button",{onClick:()=>P.push((0,y.rc)({view:"history"})),className:"rounded-full border border-border px-3 py-1.5 text-xs font-medium text-muted-foreground transition-colors hover:bg-[var(--ink-hover)] hover:text-foreground",children:"Browse past plans"})]}),(0,s.jsxs)("div",{className:"pointer-events-none fixed right-3 top-3 z-30 flex items-center gap-2",children:[eM&&B&&(0,s.jsx)("button",{onClick:()=>H(!1),title:"Collapse — show the board again",className:"glass pointer-events-auto flex size-8 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-[var(--ink-hover)] hover:text-foreground",children:(0,s.jsx)(u.A,{className:"size-3.5"})}),(0,s.jsxs)("div",{className:"glass pointer-events-auto flex h-10 items-center gap-0.5 rounded-full px-1",children:[(0,s.jsx)("button",{onClick:()=>P.push((0,y.rc)({view:"history"})),title:"Browse past plans (you can come back to this one)",className:"flex size-8 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-[var(--ink-hover)] hover:text-foreground",children:(0,s.jsx)(a.A,{className:"size-3.5"})}),(0,s.jsx)(Y,{className:"flex size-8 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-[var(--ink-hover)] hover:text-foreground"}),(0,s.jsx)("span",{"aria-hidden":!0,className:"mx-1 h-5 w-px bg-border"}),eM&&(0,s.jsxs)("button",{onClick:ew,disabled:!er,title:er?.annotationCount?`Open the side panel \xb7 ${er.annotationCount} comment${1===er.annotationCount?"":"s"} so far`:"Open the side panel (details + comments)",className:"relative flex size-8 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-[var(--ink-hover)] hover:text-foreground",children:[(0,s.jsx)(m.A,{className:"size-3.5"}),er&&(er.annotationCount??0)>0&&(0,s.jsx)("span",{className:"absolute -right-0.5 -top-0.5 flex h-3.5 min-w-3.5 items-center justify-center rounded-full bg-sky-500 px-1 text-[9px] font-semibold text-white",children:er.annotationCount})]}),(0,s.jsxs)("button",{"data-overall-toggle":!0,onClick:()=>er?.toggleOverall?.(),disabled:!er?.toggleOverall,title:er?.hasGlobalComment?"Edit your overall feedback":"Add overall plan-level feedback",className:(0,C.cn)("relative flex size-8 shrink-0 items-center justify-center rounded-full transition-colors",er?.globalOpen?"bg-[var(--ink-active)] text-foreground":er?.hasGlobalComment?"text-sky-300 hover:bg-sky-500/15":"text-muted-foreground hover:bg-[var(--ink-hover)] hover:text-foreground"),children:[(0,s.jsx)(x.A,{className:"size-3.5"}),er?.hasGlobalComment&&(0,s.jsx)("span",{className:"absolute -right-0.5 -top-0.5 size-2 rounded-full bg-sky-400"})]}),(0,s.jsxs)("button",{onClick:()=>ef(e=>!e),title:"Ask the agent a question about a node (answered in its next round)",className:(0,C.cn)("relative flex size-8 shrink-0 items-center justify-center rounded-full transition-colors",ep?"bg-[var(--ink-active)] text-foreground":ex.length?"text-sky-300 hover:bg-sky-500/15":"text-muted-foreground hover:bg-[var(--ink-hover)] hover:text-foreground"),children:[(0,s.jsx)(h.A,{className:"size-3.5"}),ex.length>0&&(0,s.jsx)("span",{className:"absolute -right-0.5 -top-0.5 flex h-3.5 min-w-3.5 items-center justify-center rounded-full bg-sky-500 px-1 text-[9px] font-semibold text-white",children:ex.length})]}),(0,s.jsx)("span",{"aria-hidden":!0,className:"mx-1 h-5 w-px bg-border"}),(0,s.jsxs)("button",{onClick:()=>er?.submit(),disabled:!er||er.submitting||0===er.liveCount&&!ec&&0===ex.length,title:er&&(0!==er.liveCount||ec||0!==ex.length)?er.submitted?"Submitted — your terminal session is reading the feedback":"Submit feedback (comments + canvas edits) so the agent can revise the plan":"Highlight text or edit the canvas, then submit",className:(0,C.cn)("flex shrink-0 items-center gap-1 rounded-full px-2.5 py-1 text-[11px] font-semibold transition-colors",er?.submitted?"text-sky-300":er&&(0!==er.liveCount||ec||0!==ex.length)?"text-sky-300 hover:bg-sky-500/15":"text-muted-foreground opacity-50"),children:[er?.submitted?(0,s.jsx)(l.A,{className:"size-3"}):(0,s.jsx)(p.A,{className:"size-3"}),er?.submitted?"Submitted":"Feedback"]}),eI&&(0,s.jsxs)("button",{onClick:()=>{er?.clearAll?.(),eu(!1),eh([])},title:"Discard your unsubmitted comments / canvas edits so you can approve the plan as-is",className:"flex shrink-0 items-center gap-1 rounded-full px-2 py-1 text-[11px] font-medium text-amber-300/90 transition-colors hover:bg-amber-500/15",children:[(0,s.jsx)(f.A,{className:"size-3"})," Clear to approve"]}),(0,s.jsxs)("button",{onClick:()=>void es(),disabled:eI,title:eI?"You have unsubmitted feedback — submit it, or click ‘Clear to approve’ to drop it":"Approve the plan",className:(0,C.cn)("flex shrink-0 items-center gap-1 rounded-full border border-emerald-500/40 bg-emerald-500/15 px-2.5 py-1 text-[11px] font-semibold text-emerald-300 transition-colors hover:bg-emerald-500/25",eI&&"opacity-40 hover:bg-emerald-500/15"),children:[(0,s.jsx)(l.A,{className:"size-3"})," Approve"]}),(0,s.jsxs)("button",{onClick:eR,className:"flex shrink-0 items-center gap-1 rounded-full px-2.5 py-1 text-[11px] font-medium text-muted-foreground transition-colors hover:bg-red-500/15 hover:text-red-300",title:"Discard the plan",children:[(0,s.jsx)(g.A,{className:"size-3"})," Discard"]}),(0,s.jsx)(e9,{open:K,onOpenChange:X,onConfirmed:()=>void et()})]})]}),ep&&(0,s.jsxs)("div",{className:"fixed right-3 top-16 z-30 w-80 rounded-xl border border-border bg-card p-3 shadow-xl",children:[(0,s.jsxs)("div",{className:"mb-2 flex items-center justify-between",children:[(0,s.jsx)("span",{className:"text-[11px] font-semibold uppercase tracking-wide text-muted-foreground",children:"Ask the agent"}),(0,s.jsx)("button",{onClick:()=>ef(!1),title:"Close",className:"rounded p-0.5 text-muted-foreground hover:text-foreground",children:(0,s.jsx)(f.A,{className:"size-3.5"})})]}),(0,s.jsx)(e8,{targets:ek,initialTarget:eg,onAdd:e=>eh(t=>[...t,e])}),ex.length>0&&(0,s.jsx)("ul",{className:"mt-2 space-y-1",children:ex.map((e,t)=>(0,s.jsxs)("li",{className:"group flex items-start justify-between gap-2 rounded-md border border-border bg-background/40 px-2 py-1",children:[(0,s.jsxs)("div",{className:"min-w-0",children:[(0,s.jsx)("div",{className:"truncate font-mono text-[10px] text-sky-300/90",children:e.target}),(0,s.jsx)("div",{className:"text-[11px] text-foreground/90",children:e.question})]}),(0,s.jsx)("button",{onClick:()=>eh(e=>e.filter((e,n)=>n!==t)),title:"Remove",className:"shrink-0 rounded p-0.5 text-muted-foreground/70 opacity-0 transition-opacity hover:text-red-300 group-hover:opacity-100",children:(0,s.jsx)(f.A,{className:"size-3"})})]},t))}),(0,s.jsx)("p",{className:"mt-2 text-[10px] text-muted-foreground",children:"Questions are sent with your feedback on Submit — the agent answers them in its next round."})]}),(0,s.jsxs)("div",{ref:eE,className:"flex min-h-0 flex-1",children:[eO&&(0,s.jsx)(e3,{markdown:n}),(0,s.jsxs)("div",{className:(0,C.cn)("relative flex min-w-0 flex-col",!eD&&"flex-1"),style:eD?{width:`${eS}%`}:void 0,children:[eD&&(0,s.jsx)("div",{className:"pointer-events-none absolute right-3 top-3 z-20",children:(0,s.jsx)("button",{onClick:()=>H(!0),title:"Expand the plan to full width",className:"glass pointer-events-auto flex size-8 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-[var(--ink-hover)] hover:text-foreground",children:(0,s.jsx)(b.A,{className:"size-3.5"})})}),(0,s.jsx)("div",{className:"min-h-0 flex-1 overflow-hidden bg-background",children:(0,s.jsx)(S.Ue,{files:N,children:(0,s.jsx)(O,{markdown:n,round:R.proposedAt,onApi:eo,hideSubmit:!0,getExtraSubmitPayload:ey})})})]}),eD&&(0,s.jsx)("div",{onPointerDown:eP,className:"group relative w-px shrink-0 cursor-col-resize bg-border hover:bg-[var(--ink-active)]",title:"Drag to resize",children:(0,s.jsx)("div",{className:"absolute inset-y-0 -left-1.5 right-[-6px] z-10"})}),eD&&(0,s.jsxs)("div",{className:"relative flex min-w-0 flex-col",style:{width:`${100-eS}%`},children:[D&&I&&(0,s.jsx)("div",{className:"pointer-events-none absolute left-3 top-3 z-20",children:(0,s.jsxs)("div",{className:"glass pointer-events-auto flex items-center gap-1 rounded-full p-0.5",children:[(0,s.jsx)(Z.E,{active:"map"===q,onClick:()=>F("map"),icon:(0,s.jsx)(i.A,{className:"size-3"}),children:"Map"}),(0,s.jsx)(Z.E,{active:"db"===q,onClick:()=>F("db"),icon:(0,s.jsx)(d.A,{className:"size-3"}),children:"Database"})]})}),(0,s.jsx)("div",{className:"min-h-0 flex-1 overflow-hidden bg-background",children:"map"===q?(0,s.jsx)(G.MapClient,{view:t.view,nodes:t.nodes,edges:t.edges,hasFrontend:t.hasFrontend,embedded:!0,commentsContent:eN,commentsCount:er?.annotationCount??0,controlRef:el,onAskAgent:ev,onAddComment:eC,annotations:er?.annotations,onPinClick:eA,onUpdateComment:er?.updateComment,onRemoveComment:er?.removeAnnotation}):(0,s.jsx)(_.DbMapClient,{tables:e.tables,relations:e.relations,endpoints:e.endpoints,draft:e.draft,workspaceId:e.workspaceId,diffBase:e.diffBase,embedded:!0,draftRef:ed,onEdit:em,controlRef:ei,commentsContent:eN,commentsCount:er?.annotationCount??0,onAddComment:eC,annotations:er?.annotations,onPinClick:eA,onUpdateComment:er?.updateComment,onRemoveComment:er?.removeAnnotation})})]})]})]})}function e8({targets:e,onAdd:t,initialTarget:n}){let[a,o]=(0,r.useState)(n||e[0]||""),[l,i]=(0,r.useState)("");(0,r.useEffect)(()=>{n&&o(n)},[n]),(0,r.useEffect)(()=>{!a&&e[0]&&o(e[0])},[e,a]);let d=()=>{let e=l.trim();e&&(t({target:a||"(plan)",question:e}),i(""))};return(0,s.jsxs)("div",{className:"space-y-1.5",children:[e.length>0&&(0,s.jsx)("select",{value:a,onChange:e=>o(e.target.value),className:"w-full rounded border border-border bg-background px-2 py-1 text-[11px] outline-none focus:border-sky-400/40",children:e.map(e=>(0,s.jsx)("option",{value:e,className:"bg-card",children:e},e))}),(0,s.jsx)("textarea",{value:l,onChange:e=>i(e.target.value),onKeyDown:e=>{"Enter"===e.key&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),d())},rows:2,placeholder:"e.g. why a new table instead of reusing users? (⌘/Ctrl+Enter to add)",className:"w-full resize-y rounded border border-border bg-background px-2 py-1.5 text-[12px] leading-snug outline-none focus:border-sky-400/40"}),(0,s.jsx)("button",{onClick:d,disabled:!l.trim(),className:(0,C.cn)("w-full rounded-md px-2 py-1 text-[11px] font-semibold transition-colors",l.trim()?"bg-sky-500/15 text-sky-300 hover:bg-sky-500/25":"text-muted-foreground opacity-50"),children:"Add question"})]})}},48484:(e,t,n)=>{"use strict";n.d(t,{PlanProvider:()=>c,j:()=>u});var s=n(95155),r=n(12115),a=n(73321),o=n(60292),l=n(99979);let i={pending:!1,proposedAt:0,tables:0,endpoints:0,features:0},d=(0,r.createContext)(null);function c({children:e}){let t=(0,a.useRouter)(),[n,u]=(0,r.useState)(i),m=(0,r.useCallback)(async()=>{try{let e=await fetch("/api/plan",{method:"GET",cache:"no-store",headers:(0,o.dh)((0,l.X0)())});if(!e.ok)return;let t=await e.json();u(t)}catch{}},[]);(0,r.useEffect)(()=>{m();let e=setInterval(()=>void m(),4e3);return()=>clearInterval(e)},[m]);let x=(0,r.useCallback)(async()=>{await fetch("/api/plan",{method:"DELETE",headers:(0,o.dh)((0,l.X0)())}).catch(()=>{}),u(i),t.refresh()},[t]),h=(0,r.useCallback)(async()=>{await fetch("/api/plan/approve",{method:"POST",headers:(0,o.dh)((0,l.X0)())}).catch(()=>{}),u(i),t.refresh()},[t]);return(0,s.jsx)(d.Provider,{value:{status:n,discard:x,approvePlan:h,refresh:m},children:e})}function u(){let e=(0,r.useContext)(d);if(!e)throw Error("usePlan must be used inside PlanProvider");return e}},97358:(e,t,n)=>{"use strict";n.d(t,{pC:()=>s});let s=[{value:"default",label:"Manual approval",description:"Approve each tool call yourself — Claude Code's default."},{value:"acceptEdits",label:"Auto-accept edits",description:"Auto-approve file edits; still ask before running other tools."},{value:"bypassPermissions",label:"Bypass permissions",description:"Auto-approve every tool call (like --dangerously-skip-permissions)."},{value:"auto",label:"Auto",description:"Autonomous, gated by a safety classifier (needs a recent Claude Code + Sonnet 4.6+)."}]},99979:(e,t,n)=>{"use strict";function s(){return new URLSearchParams(window.location.search).get("ws")}function r(){return new URLSearchParams(window.location.search).get("plan")}function a(e){let t=new URLSearchParams,n=s();n&&t.set("ws",n);let a=r();for(let[n,s]of(a&&t.set("plan",a),Object.entries(e??{})))""===s?t.delete(n):t.set(n,s);let o=t.toString();return o?`/plan?${o}`:"/plan"}n.d(t,{X0:()=>s,d8:()=>r,rc:()=>a})}},e=>{e.O(0,[2574,1770,3862,5004,277,8500,4888,7424,9887,5957,5697,4674,6639,3908,9784,4853,1909,8441,3794,7358],()=>e(e.s=22137)),_N_E=e.O()}]);
|
|
11
|
+
`;function eC(e){fetch(`/api/open?path=${encodeURIComponent(e)}`).catch(()=>{})}function eA({file:e,defaultMode:t="split",onFocus:n,maxBodyHeight:a,className:o}){let[l,i]=(0,r.useState)(t),[d,c]=(0,r.useState)(null),[u,m]=(0,r.useState)(!1),[x,p]=(0,r.useState)(0);(0,r.useEffect)(()=>{if(e.binary||e.tooLarge)return;let t=!1,n=(0,k.fk)();return fetch(`/api/changes?path=${encodeURIComponent(e.path)}&old=${encodeURIComponent(e.oldPath??"")}`,{cache:"no-store",headers:n?{"x-beacon-workspace":n}:void 0}).then(e=>e.json()).then(n=>{t||(c({path:e.path,diff:n.diff??""}),m(!1))}).catch(()=>{t||m(!0)}),()=>{t=!0}},[e.path,e.oldPath,e.binary,e.tooLarge,e.additions,e.deletions,x]);let f=(0,r.useMemo)(()=>{if(!d?.diff)return null;try{let e=(0,ef.FR)(d.diff);return e.find(e=>e.newPath===d.path)??e[0]??null}catch{return null}},[d]),g=(0,r.useMemo)(()=>{if(f)try{return(0,ef.qw)(f.hunks,{highlight:eg.L.registered(e.lang),refractor:eN,language:e.lang,enhancers:[(0,ef.Zc)(f.hunks,{type:"block"})]})}catch{return}},[f,e.lang]),v=d&&d.path===e.path,[j,y]=(0,r.useState)(new Set),[w,A]=(0,r.useState)([]),[S,z]=(0,r.useState)(null),[E,$]=(0,r.useState)(""),[P,R]=(0,r.useState)(!1),[M,D]=(0,r.useState)(!1),O=(0,r.useCallback)(async()=>{let t=(0,k.fk)(),n=await fetch(`/api/changes/comment?file=${encodeURIComponent(e.path)}`,{cache:"no-store",headers:t?{"x-beacon-workspace":t}:void 0}).then(e=>e.json()).catch(()=>null);A(n?.comments??[])},[e.path]);(0,r.useEffect)(()=>{let t=!1,n=(0,k.fk)();return fetch(`/api/changes/comment?file=${encodeURIComponent(e.path)}`,{cache:"no-store",headers:n?{"x-beacon-workspace":n}:void 0}).then(e=>e.json()).then(e=>{t||A(e?.comments??[])}).catch(()=>{}),()=>{t=!0}},[e.path]);let I=w.filter(e=>"question"===e.kind&&!e.answer).length;(0,r.useEffect)(()=>{if(0===I)return;let e=Date.now(),t=setInterval(()=>{Date.now()-e>9e5?clearInterval(t):O()},4e3);return()=>clearInterval(t)},[I,O]);let T=(0,r.useCallback)(async()=>{if(!S||!E.trim())return;let t=(0,k.fk)();await fetch("/api/changes/comment",{method:"POST",headers:{"content-type":"application/json",...t?{"x-beacon-workspace":t}:{}},body:JSON.stringify({file:e.path,line:S.line,side:S.side,body:E.trim(),text:S.text,held:P||void 0,kind:M?"question":void 0})}).catch(()=>{}),z(null),$(""),R(!1),O()},[S,E,P,M,e.path,O]),L=(0,r.useCallback)(async e=>{let t=(0,k.fk)();await fetch("/api/changes/comment",{method:"PATCH",headers:{"content-type":"application/json",...t?{"x-beacon-workspace":t}:{}},body:JSON.stringify(e)}).catch(()=>{}),O()},[O]),F=(0,r.useCallback)(async e=>{let t=(0,k.fk)();await fetch(`/api/changes/comment?id=${encodeURIComponent(e)}`,{method:"DELETE",headers:t?{"x-beacon-workspace":t}:void 0}).catch(()=>{}),O()},[O]),q=(0,r.useMemo)(()=>{let e=new Map,t={old:new Map,new:new Map};if(!f)return{byLine:e,byContent:t};let n=(e,n,s,r)=>{if(!n)return;let a=t[e].get(n);a?a.push({key:s,line:r}):t[e].set(n,[{key:s,line:r}])};for(let t of f.hunks)for(let s of t.changes){let t=(0,ef.k2)(s),r=s.content.trim(),a=(0,ef.zi)(s);a&&a>0&&(e.set(`new:${a}`,t),n("new",r,t,a));let o=(0,ef.Cg)(s);o&&o>0&&(e.set(`old:${o}`,t),n("old",r,t,o))}return{byLine:e,byContent:t}},[f]),B=(0,r.useCallback)((e,t)=>{let n="old"===t||void 0===t&&(0,ef.Ob)(e)?"old":"new",s="old"===n?(0,ef.Cg)(e):(0,ef.zi)(e);s&&!(s<=0)&&(z({key:(0,ef.k2)(e),line:s,side:n,text:e.content.trim()}),$(""))},[]),H=(0,r.useMemo)(()=>({onClick:e=>{let t=e.change;t&&B(t,e.side)}}),[B]),U=(0,r.useMemo)(()=>({onMouseUp:e=>{let t=window.getSelection();if(!t||t.isCollapsed||!t.toString().trim())return;let n=e.change;n&&B(n,e.side)}}),[B]),K=(0,r.useCallback)(({change:e,side:t,inHoverState:n,renderDefault:r})=>{let a=e&&(0,ef.Ob)(e)?"old":"new";return n&&e&&t===a?(0,s.jsx)("button",{type:"button",title:"Add a comment or question on this line (mode set in the toolbar)",className:"flex w-full items-center justify-center rounded-sm bg-[#ff7a45] text-[13px] font-bold leading-none text-white",onClick:n=>{n.stopPropagation(),B(e,t)},children:"+"}):r()},[B]),{widgets:X,orphans:G}=(0,r.useMemo)(()=>{let e=new Map,t=[],n=t=>{let n=e.get(t);return n||(n={comments:[],composer:!1},e.set(t,n)),n};for(let e of w){let s=e.text?q.byContent[e.side].get(e.text):void 0;if(s?.length)n(s.reduce((t,n)=>Math.abs(t.line-e.line)<=Math.abs(n.line-e.line)?t:n).key).comments.push(e);else{let s=q.byLine.get(`${e.side}:${e.line}`);!e.text&&s?n(s).comments.push(e):t.push(e)}}S&&(n(S.key).composer=!0);let r={};for(let[t,n]of e)r[t]=(0,s.jsxs)("div",{className:"border-y border-[#ff7a45]/20 bg-[#ff7a45]/[0.04] px-3 py-2",children:[n.comments.map(e=>(0,s.jsx)(eS,{c:e,onDelete:()=>void F(e.id),onToggleHeld:t=>void L({id:e.id,held:t})},e.id)),n.composer&&(0,s.jsx)(e$,{value:E,onChange:$,hold:P,onHold:R,isQuestion:M,onSubmit:()=>void T(),onCancel:()=>{z(null),$("")}})]});return{widgets:r,orphans:t}},[w,q,S,E,P,M,T,F,L]),_=w.filter(e=>e.held&&!e.deliveredAt).length;return(0,s.jsxs)("div",{className:(0,C.cn)("flex min-h-0 flex-col",o),children:[(0,s.jsx)("style",{children:ew}),(0,s.jsxs)("div",{className:"flex items-center gap-2 border-b border-border px-4 py-1.5",children:[w.length>0&&(0,s.jsxs)("span",{className:"flex shrink-0 items-center gap-1 rounded-full border border-[#ff7a45]/25 bg-[#ff7a45]/10 px-1.5 py-0.5 text-[10px] font-medium text-[#ff7a45]",title:"Line-comments on this file (sent to the agent on its next edit or reply)",children:[(0,s.jsx)(N.A,{className:"size-3"})," ",w.length]}),_>0&&(0,s.jsxs)("button",{type:"button",onClick:()=>void L({release:!0}),title:"Send the held comments to the agent as one batch (delivered on its next edit or reply)",className:"flex shrink-0 items-center gap-1 rounded-full border border-[#ff7a45]/40 bg-[#ff7a45]/15 px-2 py-0.5 text-[10px] font-semibold text-[#ff7a45] transition-colors hover:bg-[#ff7a45]/25",children:["Release ",_," held"]}),(0,s.jsxs)("div",{className:"flex shrink-0 items-center gap-0.5 rounded-full border border-border p-0.5",children:[(0,s.jsxs)("button",{type:"button",onClick:()=>D(!1),title:"Comment mode — leave one-way feedback the agent applies",className:(0,C.cn)("flex items-center gap-1 rounded-full px-2 py-0.5 text-[10px] font-medium transition-colors",M?"text-muted-foreground hover:text-foreground":"bg-[var(--ink-active)] text-foreground"),children:[(0,s.jsx)(N.A,{className:"size-3"})," Comment"]}),(0,s.jsxs)("button",{type:"button",onClick:()=>D(!0),title:"Ask mode — ask the agent a question about this code; it answers back into Beacon",className:(0,C.cn)("flex items-center gap-1 rounded-full px-2 py-0.5 text-[10px] font-medium transition-colors",M?"bg-[#ff7a45]/20 text-[#ff7a45]":"text-muted-foreground hover:text-foreground"),children:[(0,s.jsx)(h.A,{className:"size-3"})," Ask"]})]}),(0,s.jsx)("span",{className:"shrink-0 text-[10px] text-muted-foreground/45",children:M?"highlight or hover a line → ask":"highlight or hover a line → comment"}),(0,s.jsxs)("div",{className:"ml-auto flex shrink-0 items-center gap-0.5",children:[(0,s.jsxs)("div",{className:"flex items-center gap-0.5 rounded-full border border-border p-0.5",children:[(0,s.jsx)("button",{type:"button",onClick:()=>i("split"),title:"Split view",className:(0,C.cn)("flex size-5 items-center justify-center rounded-full transition-colors","split"===l?"bg-[var(--ink-active)] text-foreground":"text-muted-foreground hover:text-foreground"),children:(0,s.jsx)(eb.A,{className:"size-3"})}),(0,s.jsx)("button",{type:"button",onClick:()=>i("unified"),title:"Unified view",className:(0,C.cn)("flex size-5 items-center justify-center rounded-full transition-colors","unified"===l?"bg-[var(--ink-active)] text-foreground":"text-muted-foreground hover:text-foreground"),children:(0,s.jsx)(ev.A,{className:"size-3"})})]}),n&&(0,s.jsx)("button",{type:"button",onClick:n,title:"Focus — open this file full-page",className:"flex size-5 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-[var(--ink-hover)] hover:text-foreground",children:(0,s.jsx)(b.A,{className:"size-3"})}),(0,s.jsx)("button",{type:"button",onClick:()=>eC(e.path),title:"Open in editor",className:"flex size-5 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-[var(--ink-hover)] hover:text-foreground",children:(0,s.jsx)(er.A,{className:"size-3"})})]})]}),(0,s.jsxs)("div",{className:(0,C.cn)("min-h-0 flex-1 overflow-auto",M&&"cursor-help"),style:a?{maxHeight:a}:void 0,children:[G.length>0&&(0,s.jsxs)("div",{className:"border-b border-amber-400/20 bg-amber-400/[0.05] px-3 py-2",children:[(0,s.jsx)("div",{className:"mb-1 text-[10px] font-semibold uppercase tracking-wide text-amber-300/90",children:"The agent changed these lines since your comment"}),G.map(e=>(0,s.jsx)(eS,{c:e,orphaned:!0,onDelete:()=>void F(e.id),onToggleHeld:t=>void L({id:e.id,held:t})},e.id))]}),e.binary?(0,s.jsx)(eP,{icon:!0,children:"Binary file — no text diff."}):e.tooLarge?(0,s.jsx)(eP,{icon:!0,onOpen:()=>eC(e.path),children:"Diff too large to render here."}):v?f&&0!==f.hunks.length?(0,s.jsx)(ef.oO,{className:"beacon-diff",viewType:l,diffType:f.type,hunks:f.hunks,tokens:g,widgets:X,gutterEvents:H,codeEvents:U,renderGutter:K,children:e=>e.map(e=>{let t,n;return(t=e.changes.filter(e=>"delete"===e.type).map(e=>e.content),n=e.changes.filter(e=>"insert"===e.type).map(e=>e.content),(t.length>0||n.length>0)&&function(e,t){let n=e=>{let t=new Map;for(let n of e){let e=n.trim();e&&t.set(e,(t.get(e)??0)+1)}return t},s=n(e),r=n(t);if(s.size!==r.size)return!1;for(let[e,t]of s)if(r.get(e)!==t)return!1;return!0}(t,n)&&!j.has(e.content))?(0,s.jsx)(ef.NZ,{children:(0,s.jsxs)("div",{className:"flex items-center gap-2 bg-white/[0.02] px-4 py-1 text-[11px] text-muted-foreground",children:[(0,s.jsxs)("span",{children:["\xb7 formatting-only hunk (",e.changes.filter(e=>"normal"!==e.type).length," lines)"]}),(0,s.jsx)("button",{type:"button",onClick:()=>y(t=>new Set([...t,e.content])),className:"rounded-full border border-border px-2 py-0.5 text-[10px] hover:bg-[var(--ink-hover)]",children:"show"})]})},e.content):(0,s.jsx)(ef.D9,{hunk:e},e.content)})}):(0,s.jsx)(eP,{children:"No textual changes."}):u?(0,s.jsx)(eP,{icon:!0,onOpen:()=>p(e=>e+1),openLabel:"Retry",children:"Couldn't load the diff."}):(0,s.jsx)(eP,{children:"Loading diff…"})]})]})}function eS({c:e,orphaned:t=!1,onDelete:n,onToggleHeld:r}){let a="question"===e.kind,o=e.deliveredAt?"sent to agent":e.held?"held — release to send":a?"pending — sent on the agent's next turn":"pending — sent on the agent's next edit or reply";return(0,s.jsxs)("div",{className:"group mb-1 rounded-md border border-border bg-background/60 px-2.5 py-1.5",children:[(0,s.jsxs)("div",{className:"flex items-start gap-2",children:[a?(0,s.jsx)(h.A,{className:"mt-0.5 size-3.5 shrink-0 text-[#ff7a45]"}):(0,s.jsx)(N.A,{className:"mt-0.5 size-3.5 shrink-0 text-[#ff7a45]"}),(0,s.jsxs)("div",{className:"min-w-0 flex-1",children:[t&&e.text&&(0,s.jsxs)("div",{className:"mb-0.5 truncate font-mono text-[10px] text-muted-foreground/70",title:e.text,children:["was: ",(0,s.jsx)("span",{className:"line-through",children:e.text})]}),(0,s.jsx)("div",{className:"whitespace-pre-wrap text-[12px] leading-snug text-foreground/90",children:e.body}),(0,s.jsxs)("div",{className:"mt-0.5 flex flex-wrap items-center gap-1.5 text-[9px] uppercase tracking-wide text-muted-foreground/60",children:[(0,s.jsxs)("span",{children:[a?`question \xb7 line ${e.line}`:`line ${e.line}`," \xb7 ",o]}),a&&!e.answer&&e.deliveredAt&&(0,s.jsx)(eE,{delivered:!0}),!e.deliveredAt&&(0,s.jsx)("button",{type:"button",onClick:()=>r(!e.held),className:(0,C.cn)("rounded-full border px-1.5 py-px font-semibold transition-colors",e.held?"border-[#ff7a45]/40 text-[#ff7a45] hover:bg-[#ff7a45]/15":"border-border text-muted-foreground hover:text-foreground"),title:e.held?`Release this ${a?"question":"comment"} (sends on the agent's next edit or reply)`:`Hold this ${a?"question":"comment"} back to batch it`,children:e.held?"release":"hold"})]})]}),(0,s.jsx)("button",{type:"button",onClick:n,title:a?"Delete question":"Delete comment",className:"shrink-0 rounded p-0.5 text-muted-foreground/60 opacity-0 transition-opacity hover:text-red-300 group-hover:opacity-100",children:(0,s.jsx)(g.A,{className:"size-3"})})]}),a&&e.answer&&(0,s.jsx)(ez,{answer:e.answer,className:"ml-5 mt-1.5"})]})}function ez({answer:e,className:t}){return(0,s.jsxs)("div",{className:(0,C.cn)("rounded-md border border-sky-400/20 bg-sky-400/[0.06] px-2.5 py-1.5",t),children:[(0,s.jsxs)("div",{className:"mb-1 flex items-center gap-1 text-[9px] font-semibold uppercase tracking-wide text-sky-300/90",children:[(0,s.jsx)(ej.A,{className:"size-3"}),"Agent's answer"]}),(0,s.jsx)("div",{className:"whitespace-pre-wrap text-[12px] leading-relaxed text-foreground/90",children:e})]})}function eE({delivered:e,className:t}){return(0,s.jsxs)("span",{className:(0,C.cn)("flex items-center gap-1 text-sky-300/80",t),children:[(0,s.jsx)(c.A,{className:"size-2.5 animate-spin"}),e?"awaiting the agent's answer…":"queued — sent on the agent's next turn"]})}function e$({value:e,onChange:t,hold:n,onHold:r,isQuestion:a=!1,onSubmit:o,onCancel:l}){return(0,s.jsxs)("div",{className:"mt-1",children:[(0,s.jsx)("textarea",{autoFocus:!0,value:e,onChange:e=>t(e.target.value),onKeyDown:e=>{"Enter"===e.key&&(e.metaKey||e.ctrlKey)?(e.preventDefault(),o()):"Escape"===e.key&&(e.preventDefault(),l())},rows:2,placeholder:a?"Ask the agent about this line — it answers back into Beacon (⌘/Ctrl+Enter to send)":"Comment on this line — the agent gets it on its next edit or reply (⌘/Ctrl+Enter to send)",className:"w-full resize-y rounded border border-border bg-background px-2 py-1.5 text-[12px] leading-snug outline-none focus:border-[#ff7a45]/40"}),(0,s.jsxs)("div",{className:"mt-1 flex items-center gap-2",children:[(0,s.jsxs)("button",{type:"button",onClick:o,disabled:!e.trim(),className:(0,C.cn)("flex items-center gap-1 rounded-md px-2 py-1 text-[11px] font-semibold transition-colors",e.trim()?"bg-[#ff7a45]/20 text-[#ff7a45] hover:bg-[#ff7a45]/30":"text-muted-foreground opacity-50"),children:[a?(0,s.jsx)(h.A,{className:"size-3"}):(0,s.jsx)(N.A,{className:"size-3"}),a?"Ask":"Comment"]}),(0,s.jsx)("button",{type:"button",onClick:l,className:"rounded-md px-2 py-1 text-[11px] text-muted-foreground transition-colors hover:text-foreground",children:"Cancel"}),(0,s.jsxs)("label",{className:"ml-auto flex cursor-pointer items-center gap-1 text-[10px] text-muted-foreground",title:a?"Hold this question back — batch several, then Release to send them together":"Hold this comment back — batch several, then Release to send them together",children:[(0,s.jsx)("input",{type:"checkbox",checked:n,onChange:e=>r(e.target.checked),className:"size-3 accent-[#ff7a45]"}),"hold (batch)"]})]})]})}function eP({children:e,icon:t,onOpen:n,openLabel:r="Open in editor"}){return(0,s.jsxs)("div",{className:"flex items-center gap-2 px-4 py-6 text-[12px] text-muted-foreground",children:[t&&(0,s.jsx)(ey.A,{className:"size-4 shrink-0 text-amber-300/80"}),(0,s.jsx)("span",{children:e}),n&&(0,s.jsx)("button",{type:"button",onClick:n,className:"rounded-full border border-border px-2 py-0.5 text-[11px] text-foreground transition-colors hover:bg-[var(--ink-hover)]",children:r})]})}let eR=[/(^|\/)bun\.lock$/,/(^|\/)package-lock\.json$/,/(^|\/)yarn\.lock$/,/\.lock$/,/\.min\.\w+$/,/\.map$/,/(^|\/)(\.next|dist|build|node_modules|coverage)\//,/(^|\/)generated\//];function eM(e){return eR.some(t=>t.test(e))}function eD(e){return(e.additions+e.deletions)*(1+Math.log2(1+(e.inDegree??0)))}function eO(e){let t=e.split("/").pop()??"",n=/^(.+?)\.(test|spec)\.\w+$/.exec(t);return n?n[1]:null}function eI(e){let t=Math.max(1,Math.round(e/1e3));if(t<60)return`${t}s ago`;let n=Math.round(t/60);return n<60?`${n}m ago`:`${Math.round(n/60)}h ago`}function eT({files:e,touched:t,views:n,unseen:a,transients:l,commentCounts:i,questions:d,lens:u,onLens:m,onOpen:x,onSeen:p,onToggleViewed:g,quality:b,scanning:v,onScan:j,onCommentAdded:y,onFocus:N}){let[w,A]=(0,r.useState)(()=>Date.now()),S=(0,r.useSyncExternalStore)(()=>()=>{},()=>!0,()=>!1);(0,r.useEffect)(()=>{let e=setInterval(()=>A(Date.now()),3e4);return()=>clearInterval(e)},[]);let z=(0,r.useMemo)(()=>e.reduce((e,t)=>({add:e.add+t.additions,del:e.del+t.deletions}),{add:0,del:0}),[e]),E=Math.min(100,(z.add+z.del)/400*100),$=(0,r.useMemo)(()=>ek(e,t),[e,t]),P=S&&!!$&&w-$.lastAt<6e4,R=e.filter(e=>"viewed"===n[e.path]).length,M=(0,r.useMemo)(()=>new Map(e.map(e=>[e.path,e])),[e]),D=(0,r.useMemo)(()=>{let n,s,r;return n=e=>t[e.path]?.lastAt??(e.oldPath?t[e.oldPath]?.lastAt:void 0),s=(e,t)=>(n(t)??0)-(n(e)??0),r=e.filter(e=>(n(e)??0)>=w-3e5).sort(s),[{key:"now",label:"Now",files:r},{key:"session",label:"Earlier this session",files:e.filter(e=>void 0!==n(e)&&n(e)<w-3e5).sort(s)},{key:"before",label:"Before this session",files:e.filter(e=>void 0===n(e)).sort((e,t)=>e.path.localeCompare(t.path))}].filter(e=>e.files.length>0)},[e,t,w]),O=(0,r.useMemo)(()=>(function(e){let t=e.filter(e=>eM(e.path)),n=e.filter(e=>!eM(e.path)),s=n.filter(e=>null!==eO(e.path)),r=n.filter(e=>null===eO(e.path)).sort((e,t)=>eD(t)-eD(e)),a=[],o=new Set;for(let e of r){a.push(e);let t=(e.path.split("/").pop()??"").replace(/\.\w+$/,"");for(let e of s)o.has(e.path)||eO(e.path)!==t||(a.push(e),o.add(e.path))}for(let e of[...s].sort((e,t)=>eD(t)-eD(e)))o.has(e.path)||a.push(e);return{main:a,noise:[...t].sort((e,t)=>eD(t)-eD(e))}})(e),[e]),[I,T]=(0,r.useState)(new Set),L=e=>{p(e),T(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},F=(0,r.useMemo)(()=>"activity"===u?D.map(e=>({key:e.key,label:e.label,accent:"now"===e.key,paths:e.files.map(e=>e.path)})):[{key:"ranked",label:"Riskiest first — change size \xd7 importers",ranked:!0,paths:O.main.map(e=>e.path)},...O.noise.length?[{key:"noise",label:"Generated & lockfiles",dim:!0,paths:O.noise.map(e=>e.path)}]:[]],[u,D,O]),[q,B]=(0,r.useState)(null);I.size>0&&(null===q||q.lens!==u)?B({lens:u,sections:F}):0===I.size&&null!==q&&B(null);let H=(0,r.useMemo)(()=>{if(!q)return F;let e=new Set(q.sections.map(e=>e.key)),t=new Set(q.sections.flatMap(e=>e.paths)),n=q.sections.map(e=>{let n=F.find(t=>t.key===e.key),s=n?n.paths.filter(e=>!t.has(e)):[];return s.length?{...e,paths:[...e.paths,...s]}:e});for(let s of F){if(e.has(s.key))continue;let r=s.paths.filter(e=>!t.has(e));r.length&&n.push({...s,paths:r})}return n},[q,F]),[U,K]=(0,r.useState)(null),X=async()=>{if(!U||!U.text.trim()||U.sending)return;K({...U,sending:!0});let e=(0,k.fk)();await fetch("/api/changes/comment",{method:"POST",headers:{"content-type":"application/json",...e?{"x-beacon-workspace":e}:{}},body:JSON.stringify({file:U.file.path,line:1,side:"new",body:U.text.trim(),held:U.hold||void 0})}).catch(()=>{}),K(null),y()};return(0,s.jsxs)("div",{className:"mx-auto flex h-full w-full min-h-0 flex-col px-4",children:[(0,s.jsxs)("div",{className:"glass mt-3 shrink-0 space-y-2 rounded-2xl px-4 py-3",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2 text-[13px]",children:[(0,s.jsxs)("span",{className:(0,C.cn)("relative flex size-2 shrink-0",!P&&"opacity-30"),children:[P&&(0,s.jsx)("span",{className:"absolute inline-flex size-full animate-ping rounded-full bg-[#ff7a45] opacity-75"}),(0,s.jsx)("span",{className:"relative inline-flex size-2 rounded-full bg-[#ff7a45]"})]}),$?(0,s.jsxs)("button",{type:"button",onClick:N,disabled:!N,title:"Focus mode — follow the agent's edits live",className:"group/foc min-w-0 truncate rounded text-left transition-colors enabled:hover:text-foreground disabled:cursor-default",children:[(0,s.jsx)("span",{className:"text-muted-foreground",children:P?"Editing":"Last edited"})," ",(0,s.jsx)("span",{className:"font-mono text-[12px] text-foreground/90 underline-offset-2 group-hover/foc:underline",children:$.path}),S&&(0,s.jsxs)("span",{className:"text-muted-foreground",children:[" \xb7 ",eI(w-$.lastAt)]})]}):(0,s.jsx)("span",{className:"text-muted-foreground",children:"No agent edits this session"})]}),(0,s.jsxs)("div",{className:"flex flex-wrap items-center gap-3 text-[11px] text-muted-foreground",children:[(0,s.jsx)(o.A,{className:"size-3.5 shrink-0 text-[#ff7a45]"}),(0,s.jsxs)("span",{className:"tabular-nums",children:[e.length," files \xb7 ",(0,s.jsxs)("span",{className:"text-emerald-400",children:["+",z.add]})," ",(0,s.jsxs)("span",{className:"text-rose-400",children:["−",z.del]})]}),(0,s.jsx)("span",{"aria-hidden":!0,className:"h-1 w-24 overflow-hidden rounded-full bg-[var(--ink-active)]",title:"~400 changed lines is the review-attention budget",children:(0,s.jsx)("span",{className:(0,C.cn)("block h-full",E>=100?"bg-amber-400/80":"bg-white/35"),style:{width:`${E}%`}})}),(0,s.jsxs)("span",{className:"ml-auto tabular-nums",children:[a.size>0&&(0,s.jsxs)("span",{className:"text-[#ff7a45]",children:[a.size," unseen \xb7 "]}),R,"/",e.length," viewed"]}),(0,s.jsxs)("button",{type:"button",onClick:j,disabled:v||0===e.length,title:"Run the repo's linter on the changed files + scan added code for duplicated logic (deterministic, local)",className:(0,C.cn)("flex items-center gap-1 rounded-full border border-border px-2 py-0.5 text-[10px] font-medium transition-colors",v?"text-muted-foreground":"text-muted-foreground hover:bg-[var(--ink-hover)] hover:text-foreground"),children:[v?(0,s.jsx)(c.A,{className:"size-3 animate-spin"}):(0,s.jsx)(ea.A,{className:"size-3"}),v?"Scanning…":b?"Re-scan":"Quality scan"]}),(0,s.jsx)("div",{className:"flex items-center gap-0.5 rounded-full border border-border p-0.5",children:[{l:"activity",icon:(0,s.jsx)(eo.A,{className:"size-3"}),label:"Activity",title:"What the agent is doing, newest first"},{l:"review",icon:(0,s.jsx)(el.A,{className:"size-3"}),label:"Review",title:"Importance-first for a careful pass"},{l:"questions",icon:(0,s.jsx)(h.A,{className:"size-3"}),label:"Questions",title:"Questions you asked the agent + its answers"}].map(({l:e,icon:t,label:n,title:r})=>(0,s.jsxs)("button",{type:"button",onClick:()=>m(e),className:(0,C.cn)("flex items-center gap-1 rounded-full px-2 py-0.5 text-[10px] font-medium transition-colors",u===e?"bg-[var(--ink-active)] text-foreground":"text-muted-foreground hover:text-foreground"),title:r,children:[t,n,"questions"===e&&d.length>0&&(0,s.jsx)("span",{className:"ml-0.5 rounded-full bg-[#ff7a45]/20 px-1 text-[9px] font-semibold text-[#ff7a45]",children:d.length})]},e))})]})]}),U&&(0,s.jsxs)("div",{className:"fixed right-6 top-20 z-40 w-96 rounded-xl border border-border bg-card p-3 shadow-2xl",children:[(0,s.jsxs)("div",{className:"mb-2 flex items-center justify-between",children:[(0,s.jsxs)("span",{className:"flex items-center gap-1.5 text-[11px] font-semibold uppercase tracking-wide text-muted-foreground",children:[(0,s.jsx)(ei.A,{className:"size-3 text-[#ff7a45]"})," Flag to the agent"]}),(0,s.jsx)("button",{type:"button",onClick:()=>K(null),title:"Close",className:"rounded p-0.5 text-muted-foreground hover:text-foreground",children:(0,s.jsx)(f.A,{className:"size-3.5"})})]}),(0,s.jsx)("div",{className:"mb-1.5 truncate font-mono text-[11px] text-muted-foreground",title:U.file.path,children:U.file.path}),(0,s.jsx)("textarea",{autoFocus:!0,value:U.text,onChange:e=>K({...U,text:e.target.value}),onKeyDown:e=>{"Enter"===e.key&&(e.metaKey||e.ctrlKey)?(e.preventDefault(),X()):"Escape"===e.key&&(e.preventDefault(),K(null))},rows:4,className:"w-full resize-y rounded border border-border bg-background px-2 py-1.5 text-[12px] leading-snug outline-none focus:border-[#ff7a45]/40"}),(0,s.jsxs)("div",{className:"mt-2 flex items-center gap-2",children:[(0,s.jsx)("button",{type:"button",onClick:()=>void X(),disabled:!U.text.trim()||U.sending,className:(0,C.cn)("rounded-md px-2.5 py-1 text-[11px] font-semibold transition-colors",U.text.trim()&&!U.sending?"bg-[#ff7a45]/20 text-[#ff7a45] hover:bg-[#ff7a45]/30":"text-muted-foreground opacity-50"),children:U.sending?"Sending…":"Send to agent"}),(0,s.jsxs)("label",{className:"ml-auto flex cursor-pointer items-center gap-1 text-[10px] text-muted-foreground",title:"Hold this flag back — batch several, then Release to send them together",children:[(0,s.jsx)("input",{type:"checkbox",checked:U.hold,onChange:e=>K({...U,hold:e.target.checked}),className:"size-3 accent-[#ff7a45]"}),"hold (batch)"]})]}),(0,s.jsx)("p",{className:"mt-1.5 text-[10px] text-muted-foreground/70",children:"Delivered on the agent's next edit or reply."})]}),(0,s.jsx)("div",{className:"min-h-0 flex-1 space-y-3 overflow-y-auto py-3",children:"questions"===u?(0,s.jsx)(eL,{questions:d}):0===e.length?(0,s.jsx)("p",{className:"py-8 text-center text-[12px] text-muted-foreground",children:"No uncommitted changes yet — the agent's edits land here live."}):H.map(e=>{let r=e.paths.map(e=>M.get(e)).filter(e=>!!e);return 0===r.length?null:(0,s.jsx)(eF,{section:e,count:r.length,children:r.map((r,o)=>{var d;let c;return d={rank:e.ranked?o+1:void 0,ago:"activity"===u?(e=>{if(!S)return;let n=t[e.path]?.lastAt??(e.oldPath?t[e.oldPath]?.lastAt:void 0);return n?eI(w-n):void 0})(r):void 0},c=I.has(r.path),(0,s.jsxs)("div",{children:[(0,s.jsx)(eh,{file:r,view:n[r.path]??"unviewed",unseen:a.has(r.path),transient:l.has(r.path),commentCount:i[r.path]??0,quality:b?.[r.path],expanded:c,rank:d?.rank,ago:d?.ago,onOpen:L,onToggleViewed:g,onFlag:(e,t)=>K({file:e,text:t,hold:!1,sending:!1})}),c&&(0,s.jsx)("div",{className:"border-t border-border bg-black/25",children:(0,s.jsx)(eA,{file:r,defaultMode:"split",maxBodyHeight:520,onFocus:()=>x(r.path)},r.path)})]},r.path)})},e.key)})})]})}function eL({questions:e}){if(0===e.length)return(0,s.jsxs)("div",{className:"py-10 text-center text-[12px] text-muted-foreground",children:["No questions yet. Open a file, switch the diff to ",(0,s.jsx)("span",{className:"text-[#ff7a45]",children:"Ask"})," mode, and ask the agent about a line — its answer lands back here."]});let t=new Map;for(let n of[...e].sort((e,t)=>t.createdAt-e.createdAt)){let e=t.get(n.file);e?e.push(n):t.set(n.file,[n])}return(0,s.jsx)("div",{className:"space-y-3",children:[...t.entries()].map(([e,t])=>(0,s.jsxs)("div",{className:"glass overflow-hidden rounded-2xl",children:[(0,s.jsxs)("button",{type:"button",onClick:()=>eC(e),title:"Open in editor",className:"group flex w-full items-center gap-2 border-b border-border px-3 py-2 text-left",children:[(0,s.jsx)(h.A,{className:"size-3.5 shrink-0 text-[#ff7a45]"}),(0,s.jsx)("span",{className:"truncate font-mono text-[12px] text-foreground/90",children:e}),(0,s.jsx)("span",{className:"text-[10px] tabular-nums text-muted-foreground",children:t.length}),(0,s.jsx)(er.A,{className:"ml-auto size-3 shrink-0 text-transparent transition-colors group-hover:text-muted-foreground/70"})]}),(0,s.jsx)("div",{className:"space-y-2 p-3",children:t.map(e=>(0,s.jsxs)("div",{className:"rounded-lg border border-border bg-background/50 p-2.5",children:[(0,s.jsxs)("div",{className:"flex items-start gap-2",children:[(0,s.jsx)(h.A,{className:"mt-0.5 size-3.5 shrink-0 text-[#ff7a45]"}),(0,s.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,s.jsx)("div",{className:"whitespace-pre-wrap text-[12.5px] leading-snug text-foreground",children:e.body}),(0,s.jsxs)("div",{className:"mt-0.5 text-[9px] uppercase tracking-wide text-muted-foreground/60",children:["line ",e.line]})]})]}),e.answer?(0,s.jsx)(ez,{answer:e.answer,className:"ml-5 mt-2"}):(0,s.jsx)(eE,{delivered:!!e.deliveredAt,className:"ml-5 mt-1.5 text-[10px]"})]},e.id))})]},e))})}function eF({section:e,count:t,children:n}){let[a,o]=(0,r.useState)(!e.dim);return(0,s.jsxs)("section",{className:(0,C.cn)("overflow-hidden rounded-xl border border-border bg-white/[0.015]",e.accent&&"border-l-2 border-l-[#ff7a45]/40",e.dim&&"opacity-80"),children:[(0,s.jsxs)("button",{type:"button",onClick:()=>e.dim&&o(e=>!e),className:(0,C.cn)("flex w-full items-center gap-1.5 border-b border-border px-4 py-2 text-left text-[10px] font-semibold uppercase tracking-widest text-muted-foreground/80",e.dim&&"cursor-pointer hover:text-muted-foreground"),disabled:!e.dim,children:[e.dim&&(0,s.jsx)(ed.A,{className:(0,C.cn)("size-3 shrink-0 transition-transform",a&&"rotate-90")}),(0,s.jsx)("span",{className:"truncate",children:e.label}),(0,s.jsx)("span",{className:"ml-auto tabular-nums opacity-60",children:t})]}),a&&(0,s.jsx)("div",{className:"divide-y divide-white/[0.04]",children:n})]})}var eq=n(6923),eB=n(58309),eH=n(17494),eU=n(47409);let eK="beacon:changes-sidebar-open",eX="beacon:changes-sidebar-w";function eG(e){return e.map(e=>{var t;return{path:e.path,status:"added"===(t=e.status)?"added":"deleted"===t?"deleted":"modified",meta:`+${e.additions} −${e.deletions}`}})}function e_({repo:e,files:t,touched:n,contract:a,initialPath:l,livePath:i,onBack:d,views:c,onToggleViewed:u}){let m=(0,r.useMemo)(()=>new Set(n),[n]),x=e=>m.has(e.path)||!!e.oldPath&&m.has(e.oldPath),h=(0,r.useMemo)(()=>a?new Set([...a.declaredFiles,...a.authorizedExtras]):null,[a]),p=!!h&&h.size>0,f=e=>!!h&&(h.has(e.path)||!!e.oldPath&&h.has(e.oldPath)),[g,b]=(0,r.useState)(l),[v,j]=(0,r.useState)(()=>{try{return"0"!==window.localStorage.getItem(eK)}catch{return!0}}),[y,k]=(0,r.useState)(()=>{try{let e=Number(window.localStorage.getItem(eX));return e?Math.max(220,Math.min(620,e)):320}catch{return 320}}),N=(0,r.useCallback)(()=>{j(e=>{let t=!e;try{localStorage.setItem(eK,t?"1":"0")}catch{}return t})},[]),w=(0,r.useRef)(null),A=(0,r.useRef)(!1),S=(0,r.useCallback)(e=>{e.preventDefault(),A.current=!0,document.body.style.cursor="col-resize",document.body.style.userSelect="none"},[]);(0,r.useEffect)(()=>{let e=e=>{if(!A.current||!w.current)return;let t=w.current.getBoundingClientRect().left;k(Math.max(220,Math.min(620,e.clientX-t)))},t=()=>{if(A.current){A.current=!1,document.body.style.cursor="",document.body.style.userSelect="";try{localStorage.setItem(eX,String(y))}catch{}}};return window.addEventListener("pointermove",e),window.addEventListener("pointerup",t),()=>{window.removeEventListener("pointermove",e),window.removeEventListener("pointerup",t)}},[y]);let z=(0,r.useMemo)(()=>p?{onPlan:t.filter(f),strayed:t.filter(e=>!f(e)&&x(e)),other:t.filter(e=>!f(e)&&!x(e))}:null,[t,p,h,m]),E=t.some(x),[$,P]=(0,r.useState)("session"),R="session"!==$||E?$:"all",M=(0,r.useMemo)(()=>z?[...z.onPlan,...z.strayed,...z.other]:"all"===R?t:t.filter(x),[z,t,R,m]),D=(0,r.useMemo)(()=>new Map(t.map(e=>[e.path,e])),[t]),O=g&&M.some(e=>e.path===g)?g:M[0]?.path??null,I=O?D.get(O)??null:null,T=!!I&&!!z&&z.strayed.some(e=>e.path===I.path),L=y<300,F={session:{label:"This session",Icon:eq.A,title:"Files edited this session"},all:{label:"All",Icon:eB.A,title:"All uncommitted changes"}},q=(0,s.jsx)("div",{className:"ml-auto flex items-center gap-0.5 rounded-full border border-border p-0.5",children:["session","all"].map(e=>{let{label:t,Icon:n,title:r}=F[e],a="session"===e&&!E;return(0,s.jsx)("button",{type:"button",onClick:()=>P(e),disabled:a,className:(0,C.cn)("flex items-center justify-center rounded-full text-[10px] font-medium transition-colors",L?"size-5":"px-2 py-0.5",R===e?"bg-[var(--ink-active)] text-foreground":"text-muted-foreground hover:text-foreground",a&&"opacity-40"),title:r,children:L?(0,s.jsx)(n,{className:"size-3"}):t},e)})});return(0,s.jsxs)("div",{ref:w,className:"flex min-h-0 flex-1",children:[v?(0,s.jsxs)("aside",{style:{width:y},className:"flex min-w-0 shrink-0 flex-col border-r border-border bg-background",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2 px-3 pb-2 pt-3",children:[(0,s.jsx)("button",{type:"button",onClick:d,title:"Back to overview",className:"flex size-5 shrink-0 items-center justify-center rounded text-muted-foreground/70 transition-colors hover:bg-[var(--ink-hover)] hover:text-foreground",children:(0,s.jsx)(U.A,{className:"size-3.5"})}),(0,s.jsx)("button",{type:"button",onClick:N,title:"Hide the file list",className:"flex size-5 shrink-0 items-center justify-center rounded text-muted-foreground/70 transition-colors hover:bg-[var(--ink-hover)] hover:text-foreground",children:(0,s.jsx)(K.A,{className:"size-3.5"})}),(0,s.jsx)(o.A,{className:"size-4 shrink-0 text-[#ff7a45]"}),!L&&(0,s.jsx)("h1",{className:"text-sm font-semibold tracking-tight",children:"Changes"}),(0,s.jsx)("span",{className:"text-[11px] tabular-nums text-muted-foreground",children:M.length}),p?(0,s.jsx)("span",{className:(0,C.cn)("ml-auto flex items-center rounded-full border border-emerald-400/25 bg-emerald-400/10 font-medium text-emerald-300/90",L?"size-5 justify-center":"gap-1 px-2 py-0.5 text-[10px]"),title:`Scoped to this plan — ${h.size} file${1===h.size?"":"s"} in scope`,children:L?(0,s.jsx)(eH.A,{className:"size-3"}):"Plan-scoped"}):e&&t.length>0?q:null]}),(0,s.jsx)("div",{className:"min-h-0 flex-1 overflow-y-auto px-1.5 pb-4",children:e?0===t.length?(0,s.jsx)("p",{className:"px-2 py-4 text-[11px] leading-relaxed text-muted-foreground",children:"No uncommitted changes yet — edits the agent makes as it executes the plan show up here live."}):z?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(eV,{label:"On plan",tone:"plan",files:z.onPlan,onSelect:b,selectedPath:O,livePath:i,emptyNote:"No plan files changed yet."}),z.strayed.length>0?(0,s.jsx)(eV,{label:"Strayed",tone:"warn",files:z.strayed,onSelect:b,selectedPath:O,livePath:i}):z.onPlan.length>0?(0,s.jsx)("p",{className:"mb-1 px-2 py-1 text-[10px] text-emerald-400/70",children:"✓ No strays — all session edits are on-plan."}):null,z.other.length>0&&(0,s.jsx)(eV,{label:"Other uncommitted",tone:"muted",files:z.other,onSelect:b,selectedPath:O,livePath:i,defaultOpen:!1})]}):(0,s.jsx)(eU.h,{files:eG(M),onSelect:b,selectedPath:O,livePath:i}):(0,s.jsx)("p",{className:"px-2 py-4 text-[11px] text-muted-foreground",children:"Not a git repository."})})]}):null,v?(0,s.jsx)("div",{onPointerDown:S,className:"group relative w-px shrink-0 cursor-col-resize bg-border hover:bg-[var(--ink-active)]",title:"Drag to resize",children:(0,s.jsx)("div",{className:"absolute inset-y-0 -left-1.5 right-[-6px] z-10"})}):(0,s.jsxs)("aside",{className:"flex w-10 shrink-0 flex-col items-center gap-1 border-r border-border bg-background py-2",children:[(0,s.jsx)("button",{type:"button",onClick:d,title:"Back to overview",className:"flex size-7 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-[var(--ink-hover)] hover:text-foreground",children:(0,s.jsx)(U.A,{className:"size-4"})}),(0,s.jsx)("button",{type:"button",onClick:N,title:`Show the file list \xb7 ${M.length}`,className:"flex size-7 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-[var(--ink-hover)] hover:text-foreground",children:(0,s.jsx)(X.A,{className:"size-4"})})]}),(0,s.jsx)("main",{className:"flex min-w-0 flex-1 flex-col bg-background p-3",children:I?(0,s.jsxs)("div",{className:"flex min-h-0 flex-1 flex-col overflow-hidden rounded-xl border border-border bg-white/[0.015]",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2.5 border-b border-border px-4 py-2.5",children:[T&&(0,s.jsxs)("span",{className:"flex shrink-0 items-center gap-1 rounded-full border border-amber-400/30 bg-amber-400/10 px-1.5 py-0.5 text-[10px] font-medium text-amber-300",title:"This file is outside the plan's declared scope",children:[(0,s.jsx)(eu.A,{className:"size-3"})," Strayed"]}),(0,s.jsx)("span",{className:(0,C.cn)("shrink-0 text-[9.5px] font-bold uppercase tracking-[0.08em]",ex[em(I.status)]),children:em(I.status)}),(0,s.jsx)("span",{className:"truncate font-mono text-[12.5px] text-foreground/90",title:I.path,children:I.oldPath?`${I.oldPath} → ${I.path}`:I.path}),(0,s.jsxs)("span",{className:"ml-auto w-24 shrink-0 text-right text-[11.5px] tabular-nums",children:[(0,s.jsxs)("span",{className:"text-emerald-400",children:["+",I.additions]})," ",(0,s.jsxs)("span",{className:"text-rose-400",children:["−",I.deletions]})]}),c&&u&&(0,s.jsxs)("span",{className:"flex shrink-0 items-center gap-1.5 text-[10px] text-muted-foreground/70",children:["invalidated"===c[I.path]&&"changed since you viewed","viewed"===c[I.path]&&"viewed",(0,s.jsx)(ep,{view:c[I.path]??"unviewed",onToggle:e=>u(I,e)})]})]}),(0,s.jsx)(eA,{file:I,defaultMode:"split",className:"flex-1"},I.path)]}):(0,s.jsx)("div",{className:"flex flex-1 items-center justify-center px-6 text-center text-sm text-muted-foreground",children:e?0===t.length?"No uncommitted changes yet — edits the agent makes show up here live.":"Select a file to see its diff.":"Not a git repository."})})]})}let eW={plan:{text:"text-emerald-300/80"},warn:{text:"text-amber-300",icon:!0},muted:{text:"text-muted-foreground"}};function eV({label:e,tone:t,files:n,onSelect:a,selectedPath:o,livePath:l,defaultOpen:i=!0,emptyNote:d}){let[c,u]=(0,r.useState)(i),m=eW[t];return(0,s.jsxs)("div",{className:"mb-1",children:[(0,s.jsxs)("button",{type:"button",onClick:()=>u(e=>!e),className:(0,C.cn)("flex w-full items-center gap-1.5 rounded px-2 py-1 text-[10px] font-semibold uppercase tracking-wide transition-colors hover:bg-[var(--ink-hover)]",m.text),children:[(0,s.jsx)(ed.A,{className:(0,C.cn)("size-3 shrink-0 transition-transform",c&&"rotate-90")}),m.icon&&(0,s.jsx)(eu.A,{className:"size-3 shrink-0"}),(0,s.jsx)("span",{className:"truncate",children:e}),(0,s.jsx)("span",{className:"ml-auto tabular-nums opacity-70",children:n.length})]}),c&&(n.length>0?(0,s.jsx)(eU.h,{files:eG(n),onSelect:a,selectedPath:o,livePath:l}):d?(0,s.jsx)("p",{className:"px-2 py-1 pl-6 text-[10px] text-muted-foreground/70",children:d}):null)]})}var eJ=n(90467),eQ=n(79267),eY=n(15532);function eZ({repo:e,files:t,currentPath:n,onExit:a,views:o,onToggleViewed:l}){let[i,d]=(0,r.useState)(n??t[0]?.path??null),[c,u]=(0,r.useState)(!1),[m,x]=(0,r.useState)(n);m!==n&&(x(n),!c&&n&&d(n));let h=t.find(e=>e.path===i)??t.find(e=>e.path===n)??null,p=c&&!!n&&n!==i;return(0,s.jsxs)("div",{className:"flex min-h-0 flex-1 flex-col bg-background p-3",children:[(0,s.jsxs)("div",{className:"mb-2 flex shrink-0 items-center gap-2.5",children:[(0,s.jsx)("button",{type:"button",onClick:a,title:"Back to overview",className:"flex size-6 shrink-0 items-center justify-center rounded text-muted-foreground/70 transition-colors hover:bg-[var(--ink-hover)] hover:text-foreground",children:(0,s.jsx)(U.A,{className:"size-4"})}),p?(0,s.jsxs)("button",{type:"button",onClick:()=>{d(n),u(!1)},title:"Jump to the file the agent is editing now",className:"flex items-center gap-1.5 rounded-full border border-amber-400/30 bg-amber-400/10 px-2.5 py-1 text-[11px] font-medium text-amber-300 transition-colors hover:bg-amber-400/20",children:["agent moved to ",(0,s.jsx)("span",{className:"font-mono",children:n.split("/").pop()||n}),(0,s.jsx)(eJ.A,{className:"size-3"})," catch up"]}):c?(0,s.jsxs)("button",{type:"button",onClick:()=>u(!1),title:"Resume following the agent's edits",className:"flex items-center gap-1.5 rounded-full border border-border px-2.5 py-1 text-[11px] font-medium text-muted-foreground transition-colors hover:text-foreground",children:[(0,s.jsx)(eQ.A,{className:"size-3"})," Paused while you read \xb7 resume"]}):(0,s.jsxs)("span",{className:"flex items-center gap-1.5 rounded-full border border-[#ff7a45]/25 bg-[#ff7a45]/10 px-2.5 py-1 text-[11px] font-medium text-[#ff7a45]",children:[(0,s.jsx)(eY.A,{className:"size-3"})," Following the agent live"]})]}),h?(0,s.jsxs)("div",{onPointerDownCapture:()=>u(!0),onWheelCapture:()=>u(!0),onKeyDownCapture:()=>u(!0),className:"flex min-h-0 flex-1 flex-col overflow-hidden rounded-xl border border-border bg-white/[0.015]",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2.5 border-b border-border px-4 py-2.5",children:[(0,s.jsx)("span",{className:(0,C.cn)("shrink-0 text-[9.5px] font-bold uppercase tracking-[0.08em]",ex[em(h.status)]),children:em(h.status)}),(0,s.jsx)("span",{className:"truncate font-mono text-[12.5px] text-foreground/90",title:h.path,children:h.oldPath?`${h.oldPath} → ${h.path}`:h.path}),(0,s.jsxs)("span",{className:"ml-auto w-24 shrink-0 text-right text-[11.5px] tabular-nums",children:[(0,s.jsxs)("span",{className:"text-emerald-400",children:["+",h.additions]})," ",(0,s.jsxs)("span",{className:"text-rose-400",children:["−",h.deletions]})]}),o&&l&&(0,s.jsxs)("span",{className:"flex shrink-0 items-center gap-1.5 text-[10px] text-muted-foreground/70",children:["invalidated"===o[h.path]&&"changed since you viewed","viewed"===o[h.path]&&"viewed",(0,s.jsx)(ep,{view:o[h.path]??"unviewed",onToggle:e=>l(h,e)})]})]}),(0,s.jsx)(eA,{file:h,defaultMode:"split",className:"flex-1"},h.path)]}):(0,s.jsx)("div",{className:"flex flex-1 items-center justify-center px-6 text-center text-sm text-muted-foreground",children:e?"Waiting for the agent's next edit…":"Not a git repository."})]})}function e0(e){return`${e.status}:${e.additions}:${e.deletions}`}function e1({repo:e,files:t,touched:n,viewed:a,contract:o=null}){let[l,i]=(0,r.useState)("activity"),[d,c]=(0,r.useState)(null),[u,m]=(0,r.useState)(!1),x=(0,r.useMemo)(()=>ek(t,n),[t,n]),[h,p]=(0,r.useState)(a),[f,g]=(0,r.useState)(a);f!==a&&(g(a),p(a));let b=(0,r.useMemo)(()=>new Map(t.map(e=>[e.path,e0(e)])),[t]),[v,j]=(0,r.useState)(null),[y,N]=(0,r.useState)(new Set),[w,C]=(0,r.useState)(new Set);if(v!==b&&(j(b),v)){let e=[];for(let[t,n]of b)v.get(t)!==n&&e.push(t);N(t=>new Set([...[...t].filter(e=>b.has(e)),...e])),e.length&&C(new Set(e))}(0,r.useEffect)(()=>{if(0===w.size)return;let e=setTimeout(()=>C(new Set),1800);return()=>clearTimeout(e)},[w]);let A=(0,r.useMemo)(()=>(function(e,t){let n={};for(let s of e){let e=t[s.path];n[s.path]=e?e.sig===e0(s)?"viewed":"invalidated":"unviewed"}return n})(t,h),[t,h]),[S,z]=(0,r.useState)([]),[E,$]=(0,r.useState)(0);(0,r.useEffect)(()=>{let e=(0,k.fk)();fetch("/api/changes/comment",{cache:"no-store",headers:e?{"x-beacon-workspace":e}:void 0}).then(e=>e.json()).then(e=>z(e.comments??[])).catch(()=>{})},[t,E]);let P=(0,r.useMemo)(()=>{let e={};for(let t of S)"question"!==t.kind&&(e[t.file]=(e[t.file]??0)+1);return e},[S]),R=(0,r.useMemo)(()=>S.filter(e=>"question"===e.kind),[S]),M=R.filter(e=>!e.answer).length;(0,r.useEffect)(()=>{if(0===M)return;let e=Date.now(),t=setInterval(()=>{Date.now()-e>9e5?clearInterval(t):$(e=>e+1)},4e3);return()=>clearInterval(t)},[M]);let[D,O]=(0,r.useState)(null),[I,T]=(0,r.useState)(!1),L=async()=>{T(!0);let e=(0,k.fk)(),t=await fetch("/api/changes/quality",{method:"POST",cache:"no-store",headers:e?{"x-beacon-workspace":e}:void 0}).then(e=>e.json()).catch(()=>null);O(t?.files??null),T(!1)},F=e=>N(t=>{let n=new Set(t);return n.delete(e),n}),q=(e,t)=>{let n=t?e0(e):null;p(t=>{let s={...t};return n?s[e.path]={viewedAt:Date.now(),sig:n}:delete s[e.path],s}),F(e.path);let s=(0,k.fk)();fetch("/api/changes/viewed",{method:"POST",headers:{"content-type":"application/json",...s?{"x-beacon-workspace":s}:{}},body:JSON.stringify({path:e.path,sig:n})}).catch(()=>{})};return u?(0,s.jsx)(eZ,{repo:e,files:t,currentPath:x?.path??null,onExit:()=>m(!1),views:A,onToggleViewed:q}):null!==d?(0,s.jsx)(e_,{repo:e,files:t,touched:Object.keys(n),contract:o,initialPath:d,livePath:x?.path??null,onBack:()=>c(null),views:A,onToggleViewed:q}):(0,s.jsx)(eT,{files:t,touched:n,views:A,unseen:y,transients:w,commentCounts:P,questions:R,lens:l,onLens:i,onOpen:e=>{F(e),c(e)},onSeen:F,onToggleViewed:q,quality:D,scanning:I,onScan:()=>void L(),onCommentAdded:()=>$(e=>e+1),onFocus:()=>m(!0)})}function e5({files:e}){return(0,s.jsxs)("div",{className:"flex min-h-0 flex-1 flex-col bg-background",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2 border-b border-border px-4 py-3",children:[(0,s.jsx)(o.A,{className:"size-4 shrink-0 text-[#ff7a45]"}),(0,s.jsx)("h1",{className:"text-sm font-semibold tracking-tight",children:"Plan files"}),(0,s.jsx)("span",{className:"text-[11px] tabular-nums text-muted-foreground",children:e.length}),(0,s.jsx)("span",{className:"ml-auto truncate text-[11px] text-muted-foreground/80",children:"Files this plan declared \xb7 live diffs show only for the plan that's executing"})]}),(0,s.jsx)("div",{className:"min-h-0 flex-1 overflow-y-auto p-3",children:0===e.length?(0,s.jsx)("p",{className:"px-2 py-4 text-[11px] leading-relaxed text-muted-foreground",children:"No files were saved for this plan."}):(0,s.jsx)("ul",{className:"space-y-0.5",children:e.map(e=>(0,s.jsx)("li",{children:(0,s.jsxs)("button",{type:"button",onClick:()=>eC(e),title:"Open in editor",className:"group flex w-full items-center gap-2 rounded px-2 py-1 text-left font-mono text-[12px] text-foreground/90 transition-colors hover:bg-[var(--ink-hover)]",children:[(0,s.jsx)(es.A,{className:"size-3.5 shrink-0 text-muted-foreground/60"}),(0,s.jsx)("span",{className:"truncate",children:e}),(0,s.jsx)(er.A,{className:"ml-auto size-3 shrink-0 text-transparent transition-colors group-hover:text-muted-foreground/70"})]})},e))})})]})}function e3({markdown:e}){let t=(0,r.useMemo)(()=>(0,S.n$)(e).map((e,t)=>({b:e,i:t})).filter(({b:e})=>(0,S.Vq)(e.kind)).map(({b:e,i:t})=>({id:(0,S.vB)(t),level:(0,S.F8)(e.kind),label:(0,S.kz)(e.text)})).filter(e=>e.label.length>0),[e]),[n,a]=(0,r.useState)(null);return(0,r.useEffect)(()=>{if("u"<typeof IntersectionObserver||0===t.length)return;let e=t.map(e=>document.getElementById(e.id)).filter(e=>null!==e);if(0===e.length)return;let n=new IntersectionObserver(e=>{let t=e.filter(e=>e.isIntersecting).sort((e,t)=>e.boundingClientRect.top-t.boundingClientRect.top);t[0]&&a(t[0].target.id)},{rootMargin:"-12% 0px -70% 0px",threshold:0});return e.forEach(e=>n.observe(e)),()=>n.disconnect()},[t]),(0,s.jsxs)("aside",{className:"flex w-60 shrink-0 flex-col overflow-y-auto border-r border-border bg-background pt-16",children:[(0,s.jsx)("div",{className:"px-4 pb-2 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground",children:"Sections"}),0===t.length?(0,s.jsx)("p",{className:"px-4 text-[12px] text-muted-foreground/70",children:"No headings in this plan."}):(0,s.jsx)("nav",{className:"space-y-0.5 px-2 pb-6",children:t.map(e=>(0,s.jsx)("button",{onClick:()=>{var t;let n;return t=e.id,void((n=document.getElementById(t))&&(n.scrollIntoView({behavior:"smooth",block:"start"}),a(t)))},title:e.label,style:{paddingLeft:`${.5+.75*e.level}rem`},className:(0,C.cn)("block w-full truncate rounded py-1 pr-2 text-left text-[12px] leading-snug transition-colors",n===e.id?"bg-[var(--ink-active)] font-medium text-foreground":"text-muted-foreground hover:bg-[var(--ink-hover)] hover:text-foreground"),children:e.label},e.id))})]})}var e2=n(50981),e4=n(4474),e7=n(97358);function e9({open:e,onOpenChange:t,onConfirmed:n}){let[a,o]=(0,r.useState)("bypassPermissions"),[i,d]=(0,r.useState)(!1);async function c(){d(!0);try{await fetch("/api/preferences",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({planApprovalMode:a})}).catch(()=>{}),t(!1),n()}finally{d(!1)}}return(0,s.jsx)(V.lG,{open:e,onOpenChange:t,children:(0,s.jsxs)(V.Cf,{className:"max-w-lg",children:[(0,s.jsxs)(V.c7,{children:[(0,s.jsxs)(V.L3,{className:"flex items-center gap-2",children:[(0,s.jsx)(e2.A,{className:"size-4 text-emerald-400"}),"After approving, the agent should…"]}),(0,s.jsx)(V.rr,{children:"Pick the permission mode your terminal session enters when you approve a plan. We ask once and remember it for every project — change it anytime in Settings."})]}),(0,s.jsx)("div",{className:"space-y-2 py-1",children:e7.pC.map(e=>(0,s.jsxs)("button",{type:"button",onClick:()=>o(e.value),className:(0,C.cn)("flex w-full items-start gap-3 rounded-lg border p-3 text-left transition-colors",a===e.value?"border-emerald-500/50 bg-emerald-500/10":"border-border bg-white/[0.03] hover:bg-[var(--ink-hover)]"),children:[(0,s.jsx)("span",{className:(0,C.cn)("mt-0.5 flex size-4 shrink-0 items-center justify-center rounded-full border",a===e.value?"border-emerald-400 bg-emerald-400/20":"border-border"),children:a===e.value&&(0,s.jsx)(l.A,{className:"size-3 text-emerald-300"})}),(0,s.jsxs)("span",{className:"min-w-0",children:[(0,s.jsx)("span",{className:"block text-sm font-medium text-foreground",children:e.label}),(0,s.jsx)("span",{className:"block text-xs text-muted-foreground",children:e.description})]})]},e.value))}),(0,s.jsxs)(V.Es,{className:"items-center justify-between gap-2 sm:justify-between",children:[(0,s.jsx)("span",{className:"text-xs text-muted-foreground",children:"You can change this later in Settings."}),(0,s.jsx)(e4.$,{onClick:c,disabled:i,size:"sm",children:i?"Saving…":"Save & approve"})]})]})})}function e6({dbProps:e,mapProps:t,planMarkdown:n,repoFiles:N=[],forceHistory:w=!1,changesView:A=!1,changes:z=null,contract:E=null,planFiles:$=null}){let P=(0,v.useRouter)(),{status:R,discard:M}=(0,j.j)(),D=t.nodes.length>0,I=e.tables.length>0||e.endpoints.length>0||(e.draft?.tables.length??0)>0||(e.draft?.endpoints.length??0)>0,[L,F]=(0,r.useState)(D?"map":"db"),q="map"!==L||D?"db"!==L||I?L:"map":"db",[B,H]=(0,r.useState)(!1),U=(0,r.useRef)(!1),[K,X]=(0,r.useState)(!1),[W,V]=(0,r.useState)(null),J=(0,r.useRef)(!1),[Q,ee]=(0,r.useState)(null),et=(0,r.useCallback)(async()=>{ee(null);let e=(0,y.X0)();try{let t=await fetch("/api/plan/approve",{method:"POST",headers:(0,k.dh)(e)});if(!t.ok)throw Error(`approve ${t.status}`);let n=await fetch("/api/plan/verdict",{headers:(0,k.dh)(e),cache:"no-store"}).then(e=>e.json()).catch(()=>null);if(n?.kind!=="approved")throw Error("verdict not confirmed")}catch{ee("Approval didn't reach your terminal session — it wasn't confirmed. Please try Approve again.");return}V({features:R.features,tables:R.tables,endpoints:R.endpoints})},[R.features,R.tables,R.endpoints]);(0,r.useEffect)(()=>{if(!W)return;J.current=!1;let e=W.features>0?"/map?view=ROADMAP":W.tables>0||W.endpoints>0?"/map?view=DATABASE":"/map?view=ROADMAP",t=setTimeout(()=>{J.current||(J.current=!0,P.push(e))},3e3);return()=>clearTimeout(t)},[W,P]);let es=(0,r.useCallback)(async()=>{try{let e=await fetch("/api/preferences",{cache:"no-store"});if((await e.json()).planApprovalModeConfigured)return void et()}catch{et();return}X(!0)},[et]),[er,ea]=(0,r.useState)(null),eo=(0,r.useCallback)(e=>ea(e),[]),el=(0,r.useRef)(null),ei=(0,r.useRef)(null),ed=(0,r.useRef)(e.draft),[ec,eu]=(0,r.useState)(!1),em=(0,r.useCallback)(()=>eu(!0),[]),[ex,eh]=(0,r.useState)([]),[ep,ef]=(0,r.useState)(!1),[eg,eb]=(0,r.useState)(""),ev=(0,r.useCallback)(e=>{eb(e),ef(!0)},[]),ej=(0,r.useRef)(ex);(0,r.useEffect)(()=>{ej.current=ex},[ex]),(0,r.useEffect)(()=>{eh([]),ef(!1),eu(!1)},[R.proposedAt]),(0,r.useEffect)(()=>{let e=()=>void fetch("/api/plan/presence",{method:"POST",cache:"no-store",headers:(0,k.dh)((0,y.X0)())}).catch(()=>{});e();let t=setInterval(e,5e3);return()=>clearInterval(t)},[]);let ey=(0,r.useCallback)(()=>({draft:ed.current,questions:ej.current}),[]),ek=(0,r.useMemo)(()=>{let n=[];for(let e of t.nodes)n.push(`feature: ${e.title}`);for(let t of e.draft?.tables??[])n.push(`table: ${t.name}`);for(let t of e.tables)n.push(`table: ${t.name}`);for(let t of e.draft?.endpoints??[])n.push(`endpoint: ${t.method} ${t.path}`);for(let t of e.endpoints)n.push(`endpoint: ${t.method} ${t.path}`);return Array.from(new Set(n))},[t.nodes,e]),eN=er?(0,s.jsx)(T,{annotations:er.annotations,updateComment:er.updateComment,removeAnnotation:er.removeAnnotation,focusOnAnnotation:er.focusOnAnnotation,onClose:()=>"db"===q?ei.current?.close():el.current?.close()}):null,ew=(0,r.useCallback)(()=>{if(B){U.current=!0,H(!1);return}"db"===q?ei.current?.open():el.current?.open()},[q,B]);(0,r.useEffect)(()=>{!B&&U.current&&(U.current=!1,"db"===q?ei.current?.open():el.current?.open())},[B,q]);let eC=(0,r.useCallback)(e=>{er?.addComment(e)},[er]),eA=(0,r.useCallback)(e=>{er?.focusOnAnnotation(e),"db"===q?ei.current?.openComments():el.current?.openComments()},[er,q]),[eS,ez]=(0,r.useState)(()=>{try{let e=window.localStorage.getItem("beacon:plan-left-pct");return e?Math.max(20,Math.min(80,Number(e))):50}catch{return 50}}),eE=(0,r.useRef)(null),e$=(0,r.useRef)(!1),eP=(0,r.useCallback)(e=>{e.preventDefault(),e$.current=!0,document.body.style.cursor="col-resize",document.body.style.userSelect="none"},[]);(0,r.useEffect)(()=>{let e=e=>{if(!e$.current||!eE.current)return;let t=eE.current.getBoundingClientRect();ez(Math.max(20,Math.min(80,(e.clientX-t.left)/t.width*100)))},t=()=>{if(e$.current){e$.current=!1,document.body.style.cursor="",document.body.style.userSelect="";try{localStorage.setItem("beacon:plan-left-pct",String(eS))}catch{}}};return window.addEventListener("pointermove",e),window.addEventListener("pointerup",t),()=>{window.removeEventListener("pointermove",e),window.removeEventListener("pointerup",t)}},[eS]);let eR=async()=>{await fetch("/api/plan/annotations",{method:"DELETE",headers:(0,k.dh)((0,y.X0)())}).catch(()=>{}),await M(),P.refresh()};if((!R.pending||w||A)&&!W)return(0,s.jsxs)(S.Ue,{files:N,children:[(0,s.jsx)("div",{className:"pointer-events-none fixed left-1/2 top-3 z-30 -translate-x-1/2",children:(0,s.jsxs)("div",{className:"glass pointer-events-auto flex items-center gap-0.5 rounded-full p-0.5",children:[(0,s.jsx)(Z.E,{active:!A,onClick:()=>P.push((0,y.rc)({view:"history"})),icon:(0,s.jsx)(a.A,{className:"size-3"}),children:"Plan history"}),(0,s.jsx)(Z.E,{active:A,onClick:()=>P.push((0,y.rc)({view:"changes"})),icon:(0,s.jsx)(o.A,{className:"size-3"}),children:"Changes"})]})}),A&&$?(0,s.jsx)("div",{className:"flex h-screen min-h-0 flex-col pt-14",children:(0,s.jsx)(e5,{files:$})}):A&&z?(0,s.jsx)("div",{className:"flex h-screen min-h-0 flex-col pt-14",children:(0,s.jsx)(e1,{repo:z.repo,files:z.files,touched:z.touched,viewed:z.viewed,contract:E})}):(0,s.jsx)(en,{pendingPlan:R.pending,workspaceId:e.workspaceId})]});let eM=D||I,eD=eM&&!B,eO=!eM||B,eI=((er?.liveCount??0)>0||ec||ex.length>0)&&!er?.submitted;return(0,s.jsxs)("div",{className:"relative flex h-screen flex-col",children:[Q&&(0,s.jsx)("div",{className:"fixed bottom-4 left-1/2 z-[60] -translate-x-1/2 rounded-lg border border-red-500/40 bg-red-500/15 px-4 py-2 text-sm text-red-200 shadow-xl backdrop-blur",children:Q}),W&&(0,s.jsxs)("div",{className:"absolute inset-0 z-50 flex flex-col items-center justify-center gap-5 bg-background/97 px-6 text-center backdrop-blur-sm",children:[(0,s.jsx)("div",{className:"flex size-12 items-center justify-center rounded-full bg-emerald-500/15",children:(0,s.jsx)(l.A,{className:"size-6 text-emerald-300"})}),(0,s.jsxs)("div",{className:"space-y-1",children:[(0,s.jsx)("h2",{className:"text-lg font-semibold text-foreground",children:"Plan approved"}),(0,s.jsx)("p",{className:"max-w-sm text-sm text-muted-foreground",children:W.features>0||W.tables>0||W.endpoints>0?"It's committed. Here's where to find it:":"It's archived to your plan history."}),(0,s.jsx)("p",{className:"text-xs text-muted-foreground/70",children:"Taking you to the map in 3 seconds…"})]}),(0,s.jsxs)("div",{className:"flex flex-wrap items-center justify-center gap-2",children:[W.features>0&&(0,s.jsxs)("button",{onClick:()=>{J.current=!0,P.push("/map?view=ROADMAP")},className:"flex items-center gap-2 rounded-lg border border-border px-3 py-2 text-sm text-foreground transition-colors hover:bg-[var(--ink-hover)]",children:[(0,s.jsx)(i.A,{className:"size-4 text-sky-300"})," ",W.features," feature",1===W.features?"":"s"," → Map"]}),(W.tables>0||W.endpoints>0)&&(0,s.jsxs)("button",{onClick:()=>{J.current=!0,P.push("/map?view=DATABASE")},className:"flex items-center gap-2 rounded-lg border border-border px-3 py-2 text-sm text-foreground transition-colors hover:bg-[var(--ink-hover)]",children:[(0,s.jsx)(d.A,{className:"size-4 text-violet-300"})," ",W.tables," table",1===W.tables?"":"s"," \xb7 ",W.endpoints," endpoint",1===W.endpoints?"":"s"," → Database"]}),(0,s.jsxs)("button",{onClick:()=>{J.current=!0,V(null),P.push((0,y.rc)({view:"changes"}))},className:"flex items-center gap-2 rounded-lg border border-border px-3 py-2 text-sm text-foreground transition-colors hover:bg-[var(--ink-hover)]",children:[(0,s.jsx)(o.A,{className:"size-4 text-[#ff7a45]"})," Watch changes"]})]}),(0,s.jsx)("button",{onClick:()=>{J.current=!0,V(null),P.push((0,y.rc)({view:"history"}))},className:"rounded-full border border-border px-3 py-1.5 text-xs font-medium text-muted-foreground transition-colors hover:bg-[var(--ink-hover)] hover:text-foreground",children:"Done — browse plan history"})]}),er?.submitted&&(0,s.jsxs)("div",{className:"absolute inset-0 z-40 flex flex-col items-center justify-center gap-4 bg-background/95 px-6 text-center backdrop-blur-sm",children:[(0,s.jsx)("div",{className:"flex size-12 items-center justify-center rounded-full bg-sky-500/15",children:(0,s.jsx)(c.A,{className:"size-6 animate-spin text-sky-300"})}),(0,s.jsxs)("div",{className:"space-y-1",children:[(0,s.jsx)("h2",{className:"text-lg font-semibold text-foreground",children:"Feedback sent"}),(0,s.jsx)("p",{className:"max-w-sm text-sm text-muted-foreground",children:"Your terminal session is revising the plan based on your comments. The updated plan will appear here automatically — no need to refresh."})]}),(0,s.jsx)("button",{onClick:()=>P.push((0,y.rc)({view:"history"})),className:"rounded-full border border-border px-3 py-1.5 text-xs font-medium text-muted-foreground transition-colors hover:bg-[var(--ink-hover)] hover:text-foreground",children:"Browse past plans"})]}),(0,s.jsxs)("div",{className:"pointer-events-none fixed right-3 top-3 z-30 flex items-center gap-2",children:[eM&&B&&(0,s.jsx)("button",{onClick:()=>H(!1),title:"Collapse — show the board again",className:"glass pointer-events-auto flex size-8 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-[var(--ink-hover)] hover:text-foreground",children:(0,s.jsx)(u.A,{className:"size-3.5"})}),(0,s.jsxs)("div",{className:"glass pointer-events-auto flex h-10 items-center gap-0.5 rounded-full px-1",children:[(0,s.jsx)("button",{onClick:()=>P.push((0,y.rc)({view:"history"})),title:"Browse past plans (you can come back to this one)",className:"flex size-8 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-[var(--ink-hover)] hover:text-foreground",children:(0,s.jsx)(a.A,{className:"size-3.5"})}),(0,s.jsx)(Y,{className:"flex size-8 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-[var(--ink-hover)] hover:text-foreground"}),(0,s.jsx)("span",{"aria-hidden":!0,className:"mx-1 h-5 w-px bg-border"}),eM&&(0,s.jsxs)("button",{onClick:ew,disabled:!er,title:er?.annotationCount?`Open the side panel \xb7 ${er.annotationCount} comment${1===er.annotationCount?"":"s"} so far`:"Open the side panel (details + comments)",className:"relative flex size-8 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-[var(--ink-hover)] hover:text-foreground",children:[(0,s.jsx)(m.A,{className:"size-3.5"}),er&&(er.annotationCount??0)>0&&(0,s.jsx)("span",{className:"absolute -right-0.5 -top-0.5 flex h-3.5 min-w-3.5 items-center justify-center rounded-full bg-sky-500 px-1 text-[9px] font-semibold text-white",children:er.annotationCount})]}),(0,s.jsxs)("button",{"data-overall-toggle":!0,onClick:()=>er?.toggleOverall?.(),disabled:!er?.toggleOverall,title:er?.hasGlobalComment?"Edit your overall feedback":"Add overall plan-level feedback",className:(0,C.cn)("relative flex size-8 shrink-0 items-center justify-center rounded-full transition-colors",er?.globalOpen?"bg-[var(--ink-active)] text-foreground":er?.hasGlobalComment?"text-sky-300 hover:bg-sky-500/15":"text-muted-foreground hover:bg-[var(--ink-hover)] hover:text-foreground"),children:[(0,s.jsx)(x.A,{className:"size-3.5"}),er?.hasGlobalComment&&(0,s.jsx)("span",{className:"absolute -right-0.5 -top-0.5 size-2 rounded-full bg-sky-400"})]}),(0,s.jsxs)("button",{onClick:()=>ef(e=>!e),title:"Ask the agent a question about a node (answered in its next round)",className:(0,C.cn)("relative flex size-8 shrink-0 items-center justify-center rounded-full transition-colors",ep?"bg-[var(--ink-active)] text-foreground":ex.length?"text-sky-300 hover:bg-sky-500/15":"text-muted-foreground hover:bg-[var(--ink-hover)] hover:text-foreground"),children:[(0,s.jsx)(h.A,{className:"size-3.5"}),ex.length>0&&(0,s.jsx)("span",{className:"absolute -right-0.5 -top-0.5 flex h-3.5 min-w-3.5 items-center justify-center rounded-full bg-sky-500 px-1 text-[9px] font-semibold text-white",children:ex.length})]}),(0,s.jsx)("span",{"aria-hidden":!0,className:"mx-1 h-5 w-px bg-border"}),(0,s.jsxs)("button",{onClick:()=>er?.submit(),disabled:!er||er.submitting||0===er.liveCount&&!ec&&0===ex.length,title:er&&(0!==er.liveCount||ec||0!==ex.length)?er.submitted?"Submitted — your terminal session is reading the feedback":"Submit feedback (comments + canvas edits) so the agent can revise the plan":"Highlight text or edit the canvas, then submit",className:(0,C.cn)("flex shrink-0 items-center gap-1 rounded-full px-2.5 py-1 text-[11px] font-semibold transition-colors",er?.submitted?"text-sky-300":er&&(0!==er.liveCount||ec||0!==ex.length)?"text-sky-300 hover:bg-sky-500/15":"text-muted-foreground opacity-50"),children:[er?.submitted?(0,s.jsx)(l.A,{className:"size-3"}):(0,s.jsx)(p.A,{className:"size-3"}),er?.submitted?"Submitted":"Feedback"]}),eI&&(0,s.jsxs)("button",{onClick:()=>{er?.clearAll?.(),eu(!1),eh([])},title:"Discard your unsubmitted comments / canvas edits so you can approve the plan as-is",className:"flex shrink-0 items-center gap-1 rounded-full px-2 py-1 text-[11px] font-medium text-amber-300/90 transition-colors hover:bg-amber-500/15",children:[(0,s.jsx)(f.A,{className:"size-3"})," Clear to approve"]}),(0,s.jsxs)("button",{onClick:()=>void es(),disabled:eI,title:eI?"You have unsubmitted feedback — submit it, or click ‘Clear to approve’ to drop it":"Approve the plan",className:(0,C.cn)("flex shrink-0 items-center gap-1 rounded-full border border-emerald-500/40 bg-emerald-500/15 px-2.5 py-1 text-[11px] font-semibold text-emerald-300 transition-colors hover:bg-emerald-500/25",eI&&"opacity-40 hover:bg-emerald-500/15"),children:[(0,s.jsx)(l.A,{className:"size-3"})," Approve"]}),(0,s.jsxs)("button",{onClick:eR,className:"flex shrink-0 items-center gap-1 rounded-full px-2.5 py-1 text-[11px] font-medium text-muted-foreground transition-colors hover:bg-red-500/15 hover:text-red-300",title:"Discard the plan",children:[(0,s.jsx)(g.A,{className:"size-3"})," Discard"]}),(0,s.jsx)(e9,{open:K,onOpenChange:X,onConfirmed:()=>void et()})]})]}),ep&&(0,s.jsxs)("div",{className:"fixed right-3 top-16 z-30 w-80 rounded-xl border border-border bg-card p-3 shadow-xl",children:[(0,s.jsxs)("div",{className:"mb-2 flex items-center justify-between",children:[(0,s.jsx)("span",{className:"text-[11px] font-semibold uppercase tracking-wide text-muted-foreground",children:"Ask the agent"}),(0,s.jsx)("button",{onClick:()=>ef(!1),title:"Close",className:"rounded p-0.5 text-muted-foreground hover:text-foreground",children:(0,s.jsx)(f.A,{className:"size-3.5"})})]}),(0,s.jsx)(e8,{targets:ek,initialTarget:eg,onAdd:e=>eh(t=>[...t,e])}),ex.length>0&&(0,s.jsx)("ul",{className:"mt-2 space-y-1",children:ex.map((e,t)=>(0,s.jsxs)("li",{className:"group flex items-start justify-between gap-2 rounded-md border border-border bg-background/40 px-2 py-1",children:[(0,s.jsxs)("div",{className:"min-w-0",children:[(0,s.jsx)("div",{className:"truncate font-mono text-[10px] text-sky-300/90",children:e.target}),(0,s.jsx)("div",{className:"text-[11px] text-foreground/90",children:e.question})]}),(0,s.jsx)("button",{onClick:()=>eh(e=>e.filter((e,n)=>n!==t)),title:"Remove",className:"shrink-0 rounded p-0.5 text-muted-foreground/70 opacity-0 transition-opacity hover:text-red-300 group-hover:opacity-100",children:(0,s.jsx)(f.A,{className:"size-3"})})]},t))}),(0,s.jsx)("p",{className:"mt-2 text-[10px] text-muted-foreground",children:"Questions are sent with your feedback on Submit — the agent answers them in its next round."})]}),(0,s.jsxs)("div",{ref:eE,className:"flex min-h-0 flex-1",children:[eO&&(0,s.jsx)(e3,{markdown:n}),(0,s.jsxs)("div",{className:(0,C.cn)("relative flex min-w-0 flex-col",!eD&&"flex-1"),style:eD?{width:`${eS}%`}:void 0,children:[eD&&(0,s.jsx)("div",{className:"pointer-events-none absolute right-3 top-3 z-20",children:(0,s.jsx)("button",{onClick:()=>H(!0),title:"Expand the plan to full width",className:"glass pointer-events-auto flex size-8 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-[var(--ink-hover)] hover:text-foreground",children:(0,s.jsx)(b.A,{className:"size-3.5"})})}),(0,s.jsx)("div",{className:"min-h-0 flex-1 overflow-hidden bg-background",children:(0,s.jsx)(S.Ue,{files:N,children:(0,s.jsx)(O,{markdown:n,round:R.proposedAt,onApi:eo,hideSubmit:!0,getExtraSubmitPayload:ey})})})]}),eD&&(0,s.jsx)("div",{onPointerDown:eP,className:"group relative w-px shrink-0 cursor-col-resize bg-border hover:bg-[var(--ink-active)]",title:"Drag to resize",children:(0,s.jsx)("div",{className:"absolute inset-y-0 -left-1.5 right-[-6px] z-10"})}),eD&&(0,s.jsxs)("div",{className:"relative flex min-w-0 flex-col",style:{width:`${100-eS}%`},children:[D&&I&&(0,s.jsx)("div",{className:"pointer-events-none absolute left-3 top-3 z-20",children:(0,s.jsxs)("div",{className:"glass pointer-events-auto flex items-center gap-1 rounded-full p-0.5",children:[(0,s.jsx)(Z.E,{active:"map"===q,onClick:()=>F("map"),icon:(0,s.jsx)(i.A,{className:"size-3"}),children:"Map"}),(0,s.jsx)(Z.E,{active:"db"===q,onClick:()=>F("db"),icon:(0,s.jsx)(d.A,{className:"size-3"}),children:"Database"})]})}),(0,s.jsx)("div",{className:"min-h-0 flex-1 overflow-hidden bg-background",children:"map"===q?(0,s.jsx)(G.MapClient,{view:t.view,nodes:t.nodes,edges:t.edges,hasFrontend:t.hasFrontend,embedded:!0,commentsContent:eN,commentsCount:er?.annotationCount??0,controlRef:el,onAskAgent:ev,onAddComment:eC,annotations:er?.annotations,onPinClick:eA,onUpdateComment:er?.updateComment,onRemoveComment:er?.removeAnnotation}):(0,s.jsx)(_.DbMapClient,{tables:e.tables,relations:e.relations,endpoints:e.endpoints,draft:e.draft,workspaceId:e.workspaceId,diffBase:e.diffBase,embedded:!0,draftRef:ed,onEdit:em,controlRef:ei,commentsContent:eN,commentsCount:er?.annotationCount??0,onAddComment:eC,annotations:er?.annotations,onPinClick:eA,onUpdateComment:er?.updateComment,onRemoveComment:er?.removeAnnotation})})]})]})]})}function e8({targets:e,onAdd:t,initialTarget:n}){let[a,o]=(0,r.useState)(n||e[0]||""),[l,i]=(0,r.useState)("");(0,r.useEffect)(()=>{n&&o(n)},[n]),(0,r.useEffect)(()=>{!a&&e[0]&&o(e[0])},[e,a]);let d=()=>{let e=l.trim();e&&(t({target:a||"(plan)",question:e}),i(""))};return(0,s.jsxs)("div",{className:"space-y-1.5",children:[e.length>0&&(0,s.jsx)("select",{value:a,onChange:e=>o(e.target.value),className:"w-full rounded border border-border bg-background px-2 py-1 text-[11px] outline-none focus:border-sky-400/40",children:e.map(e=>(0,s.jsx)("option",{value:e,className:"bg-card",children:e},e))}),(0,s.jsx)("textarea",{value:l,onChange:e=>i(e.target.value),onKeyDown:e=>{"Enter"===e.key&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),d())},rows:2,placeholder:"e.g. why a new table instead of reusing users? (⌘/Ctrl+Enter to add)",className:"w-full resize-y rounded border border-border bg-background px-2 py-1.5 text-[12px] leading-snug outline-none focus:border-sky-400/40"}),(0,s.jsx)("button",{onClick:d,disabled:!l.trim(),className:(0,C.cn)("w-full rounded-md px-2 py-1 text-[11px] font-semibold transition-colors",l.trim()?"bg-sky-500/15 text-sky-300 hover:bg-sky-500/25":"text-muted-foreground opacity-50"),children:"Add question"})]})}},48484:(e,t,n)=>{"use strict";n.d(t,{PlanProvider:()=>c,j:()=>u});var s=n(95155),r=n(12115),a=n(73321),o=n(60292),l=n(99979);let i={pending:!1,proposedAt:0,tables:0,endpoints:0,features:0},d=(0,r.createContext)(null);function c({children:e}){let t=(0,a.useRouter)(),[n,u]=(0,r.useState)(i),m=(0,r.useCallback)(async()=>{try{let e=await fetch("/api/plan",{method:"GET",cache:"no-store",headers:(0,o.dh)((0,l.X0)())});if(!e.ok)return;let t=await e.json();u(t)}catch{}},[]);(0,r.useEffect)(()=>{m();let e=setInterval(()=>void m(),4e3);return()=>clearInterval(e)},[m]);let x=(0,r.useCallback)(async()=>{await fetch("/api/plan",{method:"DELETE",headers:(0,o.dh)((0,l.X0)())}).catch(()=>{}),u(i),t.refresh()},[t]),h=(0,r.useCallback)(async()=>{await fetch("/api/plan/approve",{method:"POST",headers:(0,o.dh)((0,l.X0)())}).catch(()=>{}),u(i),t.refresh()},[t]);return(0,s.jsx)(d.Provider,{value:{status:n,discard:x,approvePlan:h,refresh:m},children:e})}function u(){let e=(0,r.useContext)(d);if(!e)throw Error("usePlan must be used inside PlanProvider");return e}},97358:(e,t,n)=>{"use strict";n.d(t,{pC:()=>s});let s=[{value:"default",label:"Manual approval",description:"Approve each tool call yourself — Claude Code's default."},{value:"acceptEdits",label:"Auto-accept edits",description:"Auto-approve file edits; still ask before running other tools."},{value:"bypassPermissions",label:"Bypass permissions",description:"Auto-approve every tool call (like --dangerously-skip-permissions)."},{value:"auto",label:"Auto",description:"Autonomous, gated by a safety classifier (needs a recent Claude Code + Sonnet 4.6+)."}]},99979:(e,t,n)=>{"use strict";function s(){return new URLSearchParams(window.location.search).get("ws")}function r(){return new URLSearchParams(window.location.search).get("plan")}function a(e){let t=new URLSearchParams,n=s();n&&t.set("ws",n);let a=r();for(let[n,s]of(a&&t.set("plan",a),Object.entries(e??{})))""===s?t.delete(n):t.set(n,s);let o=t.toString();return o?`/plan?${o}`:"/plan"}n.d(t,{X0:()=>s,d8:()=>r,rc:()=>a})}},e=>{e.O(0,[2574,1770,3862,5004,277,8500,4888,2114,1569,5547,8710,6283,6639,7347,2022,4853,1909,8441,3794,7358],()=>e(e.s=22137)),_N_E=e.O()}]);
|