@leanspec/ui 0.2.28 → 0.3.0
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/dist/{_baseUniq-BtJuknnJ.js → _baseUniq-Cfpafgc0.js} +1 -1
- package/dist/{arc-O-rE7YCB.js → arc-Ch9WDeqx.js} +1 -1
- package/dist/{architecture-U656AL7Q-BeYqAAo7.js → architecture-U656AL7Q-BMkAcamw.js} +1 -1
- package/dist/{architectureDiagram-VXUJARFQ-DlDB9-tN.js → architectureDiagram-VXUJARFQ-B2kiuB6l.js} +3 -3
- package/dist/assets/ChatSettingsPage-BNkUWXD7.js +1 -0
- package/dist/assets/ContextPage-BXFBa390.js +14 -0
- package/dist/assets/{DashboardPage-DQH28Es5.js → DashboardPage-DG3o4y5K.js} +1 -1
- package/dist/assets/DependenciesPage-CAJX6zmQ.js +2 -0
- package/dist/assets/{FilesPage-BBVU37eW.js → FilesPage-E9VTXi3O.js} +3 -3
- package/dist/assets/SessionDetailPage-DsFv3UaN.js +4 -0
- package/dist/assets/SessionsPage-BJQkApgV.js +1 -0
- package/dist/assets/SpecDetailPage-NxlrFJ3X.js +3 -0
- package/dist/assets/SpecsPage-D7dH4bxd.js +1 -0
- package/dist/assets/StatsPage-DcDN3p4C.js +36 -0
- package/dist/assets/{_baseUniq-Dacov6Rp.js → _baseUniq-BLwGRN9T.js} +1 -1
- package/dist/assets/{arc-C1vHYpyW.js → arc-D46jVWXL.js} +1 -1
- package/dist/assets/architectureDiagram-VXUJARFQ-GKb1fnPC.js +36 -0
- package/dist/assets/blockDiagram-VD42YOAC-BAeW8TcZ.js +122 -0
- package/dist/assets/c4Diagram-YG6GDRKO-DsCDxNEY.js +10 -0
- package/dist/assets/channel-BCohFlQD.js +1 -0
- package/dist/assets/chunk-4BX2VUAB--jRtR2Gx.js +1 -0
- package/dist/assets/{chunk-55IACEB6-CEO6q7uK.js → chunk-55IACEB6-CK4VujpY.js} +1 -1
- package/dist/assets/{chunk-B4BG7PRW-DeXdKUh1.js → chunk-B4BG7PRW-CpmnmzRV.js} +6 -6
- package/dist/assets/chunk-DI55MBZ5-g0bpnDBm.js +220 -0
- package/dist/assets/{chunk-FMBD7UC4-D6UFHN61.js → chunk-FMBD7UC4-DrlucdFf.js} +1 -1
- package/dist/assets/chunk-QN33PNHL-Di9WxIWk.js +1 -0
- package/dist/assets/{chunk-QZHKN3VN-XfElTSSy.js → chunk-QZHKN3VN-DQ-Hq4Ek.js} +1 -1
- package/dist/assets/{chunk-TZMSLE5B-DAIUJ9YL.js → chunk-TZMSLE5B-Cdg6dOwb.js} +1 -1
- package/dist/assets/classDiagram-2ON5EDUG-BB3bs3WS.js +1 -0
- package/dist/assets/classDiagram-v2-WZHVMYZB-BB3bs3WS.js +1 -0
- package/dist/assets/clone-BFGeeEUV.js +1 -0
- package/dist/assets/{code-block-37QAKDTI-B3a0lz6t.js → code-block-37QAKDTI-B_yBCn5T.js} +1 -1
- package/dist/assets/cose-bilkent-S5V4N54A-BMhRWD7P.js +1 -0
- package/dist/assets/cytoscape.esm-Boq4YasU.js +321 -0
- package/dist/assets/dagre-6UL2VRFP-BI8xXpYB.js +4 -0
- package/dist/assets/diagram-PSM6KHXK-DqSGGlhJ.js +24 -0
- package/dist/assets/diagram-QEK2KX5R-CIjtZbdl.js +43 -0
- package/dist/assets/diagram-S2PKOQOG-CKt9XoCU.js +24 -0
- package/dist/assets/{erDiagram-Q2GNP2WA-BqqB9yVU.js → erDiagram-Q2GNP2WA-BRSo0yH7.js} +4 -4
- package/dist/assets/flowDiagram-NV44I4VS-BthSoz_o.js +162 -0
- package/dist/assets/{funnel-x-DD5BpUpW.js → funnel-x-B9PkB_Ch.js} +1 -1
- package/dist/assets/{ganttDiagram-JELNMOA3-DXHyY80Y.js → ganttDiagram-JELNMOA3-CNwbRK5k.js} +1 -1
- package/dist/assets/gitGraphDiagram-NY62KEGX-BNGeVHTR.js +65 -0
- package/dist/assets/{graph-0GUv5NSb.js → graph-DadEESFe.js} +1 -1
- package/dist/assets/index-CENAb10b.js +2187 -0
- package/dist/assets/index-Dw2Hz3j4.css +1 -0
- package/dist/assets/{info-BoE52mzX.js → info-DW259gfi.js} +1 -1
- package/dist/assets/{infoDiagram-WHAUD3N6-C_TEtQdE.js → infoDiagram-WHAUD3N6-CeJF3upx.js} +1 -1
- package/dist/assets/{journeyDiagram-XKPGCS4Q-JFcsNaoS.js → journeyDiagram-XKPGCS4Q-Dr67Preg.js} +1 -1
- package/dist/assets/kanban-definition-3W4ZIXB7-DpwQotp4.js +89 -0
- package/dist/assets/{layout-DlGkdPxn.js → layout-4MguctiF.js} +1 -1
- package/dist/assets/{linear-DMzKEHWt.js → linear-IgIsApJd.js} +1 -1
- package/dist/assets/{min-D9GrKucE.js → min-s8C1gLFb.js} +1 -1
- package/dist/assets/mindmap-definition-VGOIOE7T-DFKUH7eJ.js +68 -0
- package/dist/assets/{page-transition-BMYHE1EG.js → page-transition-2ToPXqzU.js} +1 -1
- package/dist/assets/pieDiagram-ADFJNKIX-BpyrOtAX.js +30 -0
- package/dist/assets/quadrantDiagram-AYHSOK5B-CAuPRVrk.js +7 -0
- package/dist/assets/{refresh-ccw-CqpLwlfM.js → refresh-ccw-A4xr5yc-.js} +1 -1
- package/dist/assets/{requirementDiagram-UZGBJVZJ-DQ1RBDeF.js → requirementDiagram-UZGBJVZJ-eokL0bzi.js} +7 -7
- package/dist/assets/sankeyDiagram-TZEHDZUN-B2hHsE_f.js +10 -0
- package/dist/assets/{sequenceDiagram-WL72ISMW-ClnYRNdC.js → sequenceDiagram-WL72ISMW-Clj8c0qS.js} +16 -16
- package/dist/assets/{session-mode-badge-auIgZbxq.js → session-mode-badge-C89NgahF.js} +1 -1
- package/dist/assets/{stat-card-BdyKZs20.js → stat-card-DV-CrlHv.js} +1 -1
- package/dist/assets/{stateDiagram-FKZM4ZOC-xdSWJeM-.js → stateDiagram-FKZM4ZOC-B4OFkmnx.js} +1 -1
- package/dist/assets/stateDiagram-v2-4FDKWEC3-XElvWSPn.js +1 -0
- package/dist/assets/{table-of-contents-B56zI3O0.js → table-of-contents-DXTiOsyr.js} +1 -1
- package/dist/assets/{time-BvMRJTpu.js → time-D3zosL_G.js} +1 -1
- package/dist/assets/timeline-definition-IT6M3QCI-Y7w9Ot5X.js +61 -0
- package/dist/assets/treemap-KMMF4GRG-DS1ewDz-.js +128 -0
- package/dist/assets/{trending-up-qrMVjIzR.js → trending-up-D4zFB2hx.js} +1 -1
- package/dist/assets/{validation-badge-DKLDRlSe.js → validation-badge-BPbTJ9B4.js} +1 -1
- package/dist/assets/{xychartDiagram-PRI3JC2R-LmjJ6LwN.js → xychartDiagram-PRI3JC2R-DTRIkv2x.js} +1 -1
- package/dist/{blockDiagram-VD42YOAC-Cvqa8noV.js → blockDiagram-VD42YOAC-BJR0FCnk.js} +5 -5
- package/dist/{c4Diagram-YG6GDRKO-D4hwame5.js → c4Diagram-YG6GDRKO-Bt0Epxwp.js} +2 -2
- package/dist/{channel-C59vLj3i.js → channel-Dk7mWM0A.js} +1 -1
- package/dist/{chunk-4BX2VUAB-BwnJRlDR.js → chunk-4BX2VUAB-ByHqqe_a.js} +1 -1
- package/dist/{chunk-55IACEB6-CUvZDifa.js → chunk-55IACEB6-C6Rm-yNH.js} +1 -1
- package/dist/{chunk-B4BG7PRW-0lyBGfGe.js → chunk-B4BG7PRW-B7fIUqxs.js} +4 -4
- package/dist/{chunk-DI55MBZ5-DzuHPqVn.js → chunk-DI55MBZ5-qLuPk8Gl.js} +3 -3
- package/dist/{chunk-FMBD7UC4-CXI1mAvv.js → chunk-FMBD7UC4-Bgxdan8l.js} +1 -1
- package/dist/{chunk-QN33PNHL-BX4buhkI.js → chunk-QN33PNHL-BkO_Xn3V.js} +1 -1
- package/dist/{chunk-QZHKN3VN-p7skz8XQ.js → chunk-QZHKN3VN-m08GnZpm.js} +1 -1
- package/dist/{chunk-TZMSLE5B-BaJuPr6J.js → chunk-TZMSLE5B-DvK9Nkqp.js} +1 -1
- package/dist/{classDiagram-v2-WZHVMYZB-Be0dkyy-.js → classDiagram-2ON5EDUG-DCzOVBP6.js} +2 -2
- package/dist/{classDiagram-2ON5EDUG-Be0dkyy-.js → classDiagram-v2-WZHVMYZB-DCzOVBP6.js} +2 -2
- package/dist/{clone-DDo6Ol2x.js → clone-BpfNWUZj.js} +1 -1
- package/dist/{cose-bilkent-S5V4N54A-Bt2GyPMu.js → cose-bilkent-S5V4N54A-BpjQClp_.js} +1 -1
- package/dist/{dagre-6UL2VRFP-B4GNvmUo.js → dagre-6UL2VRFP-Br_w0Y4b.js} +5 -5
- package/dist/{diagram-PSM6KHXK-CXpX_sN2.js → diagram-PSM6KHXK-reYm7V8l.js} +4 -4
- package/dist/{diagram-QEK2KX5R-BTpahbEj.js → diagram-QEK2KX5R-DrEPfuxO.js} +3 -3
- package/dist/{diagram-S2PKOQOG-BAp1IJGB.js → diagram-S2PKOQOG-vRL82AgB.js} +3 -3
- package/dist/{erDiagram-Q2GNP2WA-RpXtWNOz.js → erDiagram-Q2GNP2WA-DrANUeXv.js} +4 -4
- package/dist/{flowDiagram-NV44I4VS-DVAeihFU.js → flowDiagram-NV44I4VS-lzqrgi2-.js} +5 -5
- package/dist/{ganttDiagram-JELNMOA3-NnFNN967.js → ganttDiagram-JELNMOA3-Box6Sn7f.js} +2 -2
- package/dist/{gitGraph-F6HP7TQM-BA0p69BL.js → gitGraph-F6HP7TQM-ww-U1ysL.js} +1 -1
- package/dist/{gitGraphDiagram-NY62KEGX-STAanBwe.js → gitGraphDiagram-NY62KEGX-CtgGW6L9.js} +4 -4
- package/dist/{graph-Cl7g8mJo.js → graph-Csrlu3OG.js} +2 -2
- package/dist/{index-OMQgmcXQ.js → index-DSZdQoC5.js} +34 -34
- package/dist/index.html +13 -3
- package/dist/info-NVLQJR56-DdSoNNwK.js +5 -0
- package/dist/{infoDiagram-WHAUD3N6-Ch5c_x3A.js → infoDiagram-WHAUD3N6-B4cHYKqw.js} +2 -2
- package/dist/{journeyDiagram-XKPGCS4Q-BT3WQmRa.js → journeyDiagram-XKPGCS4Q-CNZRK4ng.js} +4 -4
- package/dist/{kanban-definition-3W4ZIXB7-CiJoVHr_.js → kanban-definition-3W4ZIXB7-DVYPrMkR.js} +2 -2
- package/dist/{layout-BsDPuqRL.js → layout-qhjDJGCt.js} +4 -4
- package/dist/lib/components/projects/create-project-dialog.d.ts +2 -1
- package/dist/lib/components/projects/git-import-dialog.d.ts +6 -0
- package/dist/lib/components/projects/git-import-form.d.ts +6 -0
- package/dist/lib/components/root-redirect.d.ts +1 -1
- package/dist/lib/hooks/useCapabilities.d.ts +180 -0
- package/dist/lib/index.js +1 -1
- package/dist/lib/lib/api.d.ts +4 -6
- package/dist/lib/lib/backend-adapter/core.d.ts +6 -8
- package/dist/lib/lib/backend-adapter/http.d.ts +5 -7
- package/dist/lib/lib/backend-adapter/tauri.d.ts +5 -7
- package/dist/lib/locales/en/common.json.d.ts +2 -2
- package/dist/lib/locales/zh-CN/common.json.d.ts +2 -2
- package/dist/lib/types/api.d.ts +7 -15
- package/dist/lib/types/generated/AdapterCapabilities.d.ts +18 -0
- package/dist/lib/types/generated/CompletableItem.d.ts +15 -0
- package/dist/lib/types/generated/EnumOption.d.ts +16 -0
- package/dist/lib/types/generated/FieldDef.d.ts +28 -0
- package/dist/lib/types/generated/FieldDisplay.d.ts +4 -0
- package/dist/lib/types/generated/FieldKind.d.ts +46 -0
- package/dist/lib/types/generated/FieldValue.d.ts +32 -0
- package/dist/lib/types/generated/ItemLink.d.ts +17 -0
- package/dist/lib/types/generated/LinkTypeDef.d.ts +11 -0
- package/dist/lib/types/generated/MetadataFieldSpec.d.ts +28 -0
- package/dist/lib/types/generated/MetadataKind.d.ts +17 -0
- package/dist/lib/types/generated/MetadataValue.d.ts +26 -0
- package/dist/lib/types/generated/Reference.d.ts +8 -0
- package/dist/lib/types/generated/SearchHit.d.ts +8 -0
- package/dist/lib/types/generated/SemanticHint.d.ts +4 -0
- package/dist/lib/types/generated/SpecDoc.d.ts +30 -0
- package/dist/lib/types/generated/SpecItem.d.ts +48 -0
- package/dist/lib/types/generated/SpecSchema.d.ts +25 -0
- package/dist/{linear-mOFrDt-p.js → linear-BEsG2XDl.js} +1 -1
- package/dist/{mermaid-parser.core-BKozsbnK.js → mermaid-parser.core-DI0P4xje.js} +10 -10
- package/dist/{min-BiKl7Djw.js → min-BrWJCoG9.js} +2 -2
- package/dist/{mindmap-definition-VGOIOE7T-BD-DdVQV.js → mindmap-definition-VGOIOE7T-BG1ZbSXN.js} +3 -3
- package/dist/{packet-BFZMPI3H-BCwLzQdp.js → packet-BFZMPI3H-0R4cyXFa.js} +1 -1
- package/dist/pie-7BOR55EZ-CBC6Vnp9.js +5 -0
- package/dist/{pieDiagram-ADFJNKIX-Bu8RN200.js → pieDiagram-ADFJNKIX-Bq3pEiUt.js} +4 -4
- package/dist/{quadrantDiagram-AYHSOK5B-DI1Je7Nn.js → quadrantDiagram-AYHSOK5B-CJCCPwac.js} +2 -2
- package/dist/radar-NHE76QYJ-R7FbU2R0.js +5 -0
- package/dist/{requirementDiagram-UZGBJVZJ-Ddx_vMRb.js → requirementDiagram-UZGBJVZJ-CEFnCGpg.js} +3 -3
- package/dist/{sankeyDiagram-TZEHDZUN-iAFyjtkY.js → sankeyDiagram-TZEHDZUN-vRgejrr7.js} +1 -1
- package/dist/{sequenceDiagram-WL72ISMW-NRQcqxnw.js → sequenceDiagram-WL72ISMW-Bn_-xqGS.js} +3 -3
- package/dist/{stateDiagram-FKZM4ZOC-3S1hbbmf.js → stateDiagram-FKZM4ZOC-D1wpTHL-.js} +4 -4
- package/dist/{stateDiagram-v2-4FDKWEC3-E5a40kZz.js → stateDiagram-v2-4FDKWEC3-DZ6_hPx3.js} +2 -2
- package/dist/{timeline-definition-IT6M3QCI-BCFa3ZrF.js → timeline-definition-IT6M3QCI-sxhKRCeY.js} +2 -2
- package/dist/{treemap-KMMF4GRG-BGlzeb2l.js → treemap-KMMF4GRG-BAGKypyB.js} +1 -1
- package/dist/ui.css +1 -1
- package/dist/{xychartDiagram-PRI3JC2R-CopvajdE.js → xychartDiagram-PRI3JC2R-BvZs2fIv.js} +2 -2
- package/package.json +2 -2
- package/dist/assets/ChatSettingsPage-DftRMMtU.js +0 -1
- package/dist/assets/ContextPage-CbK7ew6E.js +0 -14
- package/dist/assets/DependenciesPage-E93gHx4A.js +0 -2
- package/dist/assets/SessionDetailPage-7Nyk2Vvu.js +0 -4
- package/dist/assets/SessionsPage-aHydkWMy.js +0 -1
- package/dist/assets/SpecDetailPage-C2P-OlXI.js +0 -3
- package/dist/assets/SpecsPage-CYIBmjhJ.js +0 -1
- package/dist/assets/StatsPage-BE2SnGB_.js +0 -36
- package/dist/assets/architectureDiagram-VXUJARFQ-CJuppwvY.js +0 -36
- package/dist/assets/blockDiagram-VD42YOAC-JKuFC2tB.js +0 -122
- package/dist/assets/c4Diagram-YG6GDRKO-BGNHTjgV.js +0 -10
- package/dist/assets/channel-BBhsr-rR.js +0 -1
- package/dist/assets/chunk-4BX2VUAB-Dn9K_Ir6.js +0 -1
- package/dist/assets/chunk-DI55MBZ5-CoaAvDwo.js +0 -220
- package/dist/assets/chunk-QN33PNHL-BhFNOvzX.js +0 -1
- package/dist/assets/classDiagram-2ON5EDUG-DWsZgeAJ.js +0 -1
- package/dist/assets/classDiagram-v2-WZHVMYZB-DWsZgeAJ.js +0 -1
- package/dist/assets/clone-C2afIJUs.js +0 -1
- package/dist/assets/cose-bilkent-S5V4N54A-BMI_fEV7.js +0 -1
- package/dist/assets/cytoscape.esm-5J0xJHOV.js +0 -321
- package/dist/assets/dagre-6UL2VRFP-Llr-yTYV.js +0 -4
- package/dist/assets/diagram-PSM6KHXK-DwgNF44T.js +0 -24
- package/dist/assets/diagram-QEK2KX5R-ITZ8Vmt3.js +0 -43
- package/dist/assets/diagram-S2PKOQOG-BIRpYLio.js +0 -24
- package/dist/assets/flowDiagram-NV44I4VS-BNAcE_z4.js +0 -162
- package/dist/assets/gitGraphDiagram-NY62KEGX-BgdesX0s.js +0 -65
- package/dist/assets/index-C5tD8lpO.css +0 -1
- package/dist/assets/index-DSWQaVP_.js +0 -2187
- package/dist/assets/kanban-definition-3W4ZIXB7-D74EewjL.js +0 -89
- package/dist/assets/mindmap-definition-VGOIOE7T-bEmI6QdX.js +0 -68
- package/dist/assets/pieDiagram-ADFJNKIX-LrgsuoFm.js +0 -30
- package/dist/assets/quadrantDiagram-AYHSOK5B-XAEnrTcF.js +0 -7
- package/dist/assets/sankeyDiagram-TZEHDZUN-4LprtsUC.js +0 -10
- package/dist/assets/stateDiagram-v2-4FDKWEC3-DyupCcgD.js +0 -1
- package/dist/assets/timeline-definition-IT6M3QCI-BMCplyxv.js +0 -61
- package/dist/assets/treemap-KMMF4GRG-DXswoz8b.js +0 -128
- package/dist/info-NVLQJR56-iVvUDnHs.js +0 -5
- package/dist/lib/components/projects/github-import-dialog.d.ts +0 -6
- package/dist/pie-7BOR55EZ-0JoXf6-u.js +0 -5
- package/dist/radar-NHE76QYJ-FdQK6UPP.js +0 -5
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { _ as a, s as gi, g as xi, q as Xt, p as di, a as fi, b as pi, l as Nt, H as mi, e as yi, y as bi, E as St, D as Yt, F as Ai, K as wi, i as Ci, aA as Si, R as Wt } from "./index-
|
|
1
|
+
import { _ as a, s as gi, g as xi, q as Xt, p as di, a as fi, b as pi, l as Nt, H as mi, e as yi, y as bi, E as St, D as Yt, F as Ai, K as wi, i as Ci, aA as Si, R as Wt } from "./index-DSZdQoC5.js";
|
|
2
2
|
import { i as _i } from "./init-DjUOC4st.js";
|
|
3
3
|
import { o as ki } from "./ordinal-B6-f3MAq.js";
|
|
4
|
-
import { l as zt } from "./linear-
|
|
4
|
+
import { l as zt } from "./linear-BEsG2XDl.js";
|
|
5
5
|
function Ri(e, t, i) {
|
|
6
6
|
e = +e, t = +t, i = (n = arguments.length) < 2 ? (t = e, e = 0, 1) : n < 3 ? 1 : +i;
|
|
7
7
|
for (var s = -1, n = Math.max(0, Math.ceil((t - e) / i)) | 0, o = new Array(n); ++s < n; )
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@leanspec/ui",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "LeanSpec web UI launcher for visual spec management (Vite SPA)",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"@ai-sdk/react": "^3.0.41",
|
|
35
35
|
"@dagrejs/dagre": "^1.1.8",
|
|
36
36
|
"@exuanbo/file-icons-js": "^3.3.0",
|
|
37
|
-
"@leanspec/http-server": "0.
|
|
37
|
+
"@leanspec/http-server": "0.3.0",
|
|
38
38
|
"@radix-ui/react-accordion": "^1.2.12",
|
|
39
39
|
"@radix-ui/react-avatar": "^1.1.11",
|
|
40
40
|
"@radix-ui/react-collapsible": "^1.1.12",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{h as de,u as U,aP as re,aQ as ce,aR as oe,r as x,j as e,aS as H,C as F,l as z,aT as Z,a as r,aU as he,i as O,k as q,aV as B,aW as G,aX as V,aY as $,aZ as _,a_ as Q,a$ as W,b0 as p,D as S,b as T,c as P,d as M,b1 as L,b2 as R,B as A,b3 as xe,b4 as X}from"./index-DSWQaVP_.js";const me=[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}]],Y=de("pen",me);function m({htmlFor:t,children:u,className:l=""}){return e.jsx("label",{htmlFor:t,className:`text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70 ${l}`,children:u})}function ve(){const{t}=U("common"),u=re(),{data:l,isLoading:j,error:a,refetch:i}=ce(),{updateProvider:o,deleteProvider:d,updateModel:c,deleteModel:h,updateDefaults:f}=oe(),v=a?.message??null,[n,y]=x.useState(!1),[J,C]=x.useState(null),[ee,b]=x.useState(!1),[N,k]=x.useState(null),[K,D]=x.useState(null),[I,w]=x.useState(null),se=s=>{D(s)},te=async()=>{!l||!K||(await d({config:l,providerId:K}),D(null))},ae=async s=>{l&&(await o({config:l,provider:s}),y(!1),C(null))},ie=async(s,g)=>{l&&(await c({config:l,providerId:s,model:g}),b(!1),k(null))},ne=(s,g)=>{w({providerId:s,modelId:g})},le=async()=>{!l||!I||(await h({config:l,providerId:I.providerId,modelId:I.modelId}),w(null))},E=async(s,g)=>{l&&await f({config:l,field:s,value:g})};return j?e.jsx("div",{className:"flex items-center justify-center h-full",children:e.jsx("div",{className:"animate-pulse text-muted-foreground",children:t("actions.loading")})}):v||!l?e.jsx(H,{children:e.jsx(F,{children:e.jsxs(z,{className:"p-6",children:[e.jsxs("div",{className:"flex items-center gap-2 text-destructive",children:[e.jsx(Z,{className:"h-5 w-5"}),e.jsx("p",{children:v||t("chat.settings.errors.loadConfiguration")})]}),e.jsx(r,{onClick:()=>i(),className:"mt-4",children:t("actions.retry")})]})})}):e.jsxs("div",{className:"h-full overflow-auto",children:[e.jsxs(H,{contentClassName:"space-y-6",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(r,{variant:"ghost",size:"icon",onClick:()=>u(-1),children:e.jsx(he,{className:"h-4 w-4"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold",children:t("chat.settings.title")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:t("chat.settings.description")})]})]}),e.jsxs(F,{children:[e.jsx(O,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(q,{children:t("chat.settings.providers")}),e.jsx(B,{children:t("chat.settings.providersDescription")})]}),e.jsxs(r,{onClick:()=>{C(null),y(!0)},size:"sm",children:[e.jsx(G,{className:"h-4 w-4 mr-2"}),t("chat.settings.addProvider")]})]})}),e.jsx(z,{className:"space-y-4",children:l.providers.map(s=>e.jsx(ue,{provider:s,isDefault:l.settings.defaultProviderId===s.id,onEdit:()=>{C(s),y(!0)},onDelete:()=>se(s.id),onAddModel:()=>{k({providerId:s.id,model:null}),b(!0)},onEditModel:g=>{k({providerId:s.id,model:g}),b(!0)},onDeleteModel:g=>ne(s.id,g)},s.id))})]}),e.jsxs(F,{children:[e.jsxs(O,{children:[e.jsx(q,{children:t("chat.settings.defaults")}),e.jsx(B,{children:t("chat.settings.defaultsDescription")})]}),e.jsx(z,{className:"space-y-4",children:e.jsxs("div",{className:"grid gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(m,{htmlFor:"default-provider",children:t("chat.settings.defaultProvider")}),e.jsxs(V,{value:l.settings.defaultProviderId,onValueChange:s=>E("defaultProviderId",s),children:[e.jsx($,{id:"default-provider",children:e.jsx(_,{})}),e.jsx(Q,{children:l.providers.map(s=>e.jsx(W,{value:s.id,disabled:!s.hasApiKey,children:s.name},s.id))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(m,{htmlFor:"default-model",children:t("chat.settings.defaultModel")}),e.jsxs(V,{value:l.settings.defaultModelId,onValueChange:s=>E("defaultModelId",s),children:[e.jsx($,{id:"default-model",children:e.jsx(_,{})}),e.jsx(Q,{children:l.providers.find(s=>s.id===l.settings.defaultProviderId)?.models.map(s=>e.jsx(W,{value:s.id,children:s.name},s.id))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(m,{htmlFor:"max-steps",children:t("chat.settings.maxSteps")}),e.jsx(p,{id:"max-steps",type:"number",min:1,max:50,value:l.settings.maxSteps,onChange:s=>E("maxSteps",Number(s.target.value))}),e.jsx("p",{className:"text-xs text-muted-foreground",children:t("chat.settings.maxStepsHelp")})]})]})})]})]}),n&&e.jsx(je,{provider:J,existingIds:l.providers.map(s=>s.id),onSave:ae,onCancel:()=>{y(!1),C(null)}}),ee&&N&&e.jsx(ge,{model:N.model,providerId:N.providerId,existingIds:l.providers.find(s=>s.id===N.providerId)?.models.map(s=>s.id)??[],onSave:s=>ie(N.providerId,s),onCancel:()=>{b(!1),k(null)}}),e.jsx(S,{open:!!K,onOpenChange:s=>!s&&D(null),children:e.jsxs(T,{children:[e.jsxs(P,{children:[e.jsx(M,{children:t("chat.settings.deleteProviderTitle")}),e.jsx(L,{children:t("chat.settings.confirmDeleteProvider")})]}),e.jsxs(R,{children:[e.jsx(r,{variant:"outline",onClick:()=>D(null),children:t("actions.cancel")}),e.jsx(r,{variant:"destructive",onClick:te,children:t("actions.delete")})]})]})}),e.jsx(S,{open:!!I,onOpenChange:s=>!s&&w(null),children:e.jsxs(T,{children:[e.jsxs(P,{children:[e.jsx(M,{children:t("chat.settings.deleteModelTitle")}),e.jsx(L,{children:t("chat.settings.confirmDeleteModel")})]}),e.jsxs(R,{children:[e.jsx(r,{variant:"outline",onClick:()=>w(null),children:t("actions.cancel")}),e.jsx(r,{variant:"destructive",onClick:le,children:t("actions.delete")})]})]})})]})}function ue({provider:t,isDefault:u,onEdit:l,onDelete:j,onAddModel:a,onEditModel:i,onDeleteModel:o}){const{t:d}=U("common");return e.jsxs("div",{className:"border rounded-lg p-4 space-y-3",children:[e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h3",{className:"font-semibold",children:t.name}),u&&e.jsx(A,{variant:"secondary",className:"text-xs",children:d("chat.settings.default")}),t.hasApiKey?e.jsxs(A,{variant:"outline",className:"text-xs gap-1",children:[e.jsx(xe,{className:"h-3 w-3"}),d("chat.settings.keyConfigured")]}):e.jsxs(A,{variant:"destructive",className:"text-xs gap-1",children:[e.jsx(Z,{className:"h-3 w-3"}),d("chat.settings.noKey")]})]}),e.jsxs("p",{className:"text-sm text-muted-foreground mt-1",children:[t.id," ",t.baseURL&&`• ${t.baseURL}`]})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(r,{variant:"ghost",size:"icon",onClick:l,children:e.jsx(Y,{className:"h-4 w-4"})}),e.jsx(r,{variant:"ghost",size:"icon",onClick:j,children:e.jsx(X,{className:"h-4 w-4"})})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-sm font-medium",children:d("chat.settings.models")}),e.jsxs(r,{variant:"ghost",size:"sm",onClick:a,children:[e.jsx(G,{className:"h-3 w-3 mr-1"}),d("chat.settings.addModel")]})]}),e.jsx("div",{className:"space-y-1",children:t.models.map(c=>e.jsxs("div",{className:"flex items-center justify-between text-sm py-1 px-2 rounded hover:bg-muted",children:[e.jsxs("div",{children:[e.jsx("span",{className:"font-mono text-xs",children:c.id}),e.jsx("span",{className:"mx-2 text-muted-foreground",children:"•"}),e.jsx("span",{children:c.name}),c.maxTokens&&e.jsxs("span",{className:"ml-2 text-xs text-muted-foreground",children:["(",c.maxTokens.toLocaleString()," tokens)"]})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(r,{variant:"ghost",size:"icon",className:"h-6 w-6",onClick:()=>i(c),children:e.jsx(Y,{className:"h-3 w-3"})}),e.jsx(r,{variant:"ghost",size:"icon",className:"h-6 w-6",onClick:()=>o(c.id),children:e.jsx(X,{className:"h-3 w-3"})})]})]},c.id))})]})]})}function je({provider:t,existingIds:u,onSave:l,onCancel:j}){const{t:a}=U("common"),[i,o]=x.useState({id:t?.id??"",name:t?.name??"",baseURL:t?.baseURL??"",apiKey:"",hasApiKey:t?.hasApiKey??!1}),[d,c]=x.useState({}),h=!!t,f=()=>{const n={};return i.id.trim()?!h&&u.includes(i.id)?n.id=a("chat.settings.errors.idExists"):/^[a-z0-9-]+$/.test(i.id)||(n.id=a("chat.settings.errors.idInvalid")):n.id=a("chat.settings.errors.idRequired"),i.name.trim()||(n.name=a("chat.settings.errors.nameRequired")),i.baseURL&&!i.baseURL.match(/^https?:\/\//)&&(n.baseURL=a("chat.settings.errors.urlInvalid")),c(n),Object.keys(n).length===0},v=()=>{if(!f())return;const n=i.apiKey.trim();l({id:i.id,name:i.name,baseURL:i.baseURL||void 0,models:t?.models??[],hasApiKey:n?!0:i.hasApiKey,apiKey:n||void 0})};return e.jsx(S,{open:!0,onOpenChange:j,children:e.jsxs(T,{children:[e.jsxs(P,{children:[e.jsx(M,{children:a(h?"chat.settings.editProvider":"chat.settings.addProvider")}),e.jsx(L,{children:a("chat.settings.providerDialogDescription")})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs(m,{htmlFor:"provider-id",children:[a("chat.settings.providerId")," ",e.jsx("span",{className:"text-destructive",children:"*"})]}),e.jsx(p,{id:"provider-id",value:i.id,onChange:n=>o({...i,id:n.target.value}),placeholder:a("chat.settings.placeholders.providerId"),disabled:h}),d.id&&e.jsx("p",{className:"text-xs text-destructive",children:d.id}),e.jsx("p",{className:"text-xs text-muted-foreground",children:a("chat.settings.providerIdHelp")})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(m,{htmlFor:"provider-name",children:[a("chat.settings.providerName")," ",e.jsx("span",{className:"text-destructive",children:"*"})]}),e.jsx(p,{id:"provider-name",value:i.name,onChange:n=>o({...i,name:n.target.value}),placeholder:a("chat.settings.placeholders.providerName")}),d.name&&e.jsx("p",{className:"text-xs text-destructive",children:d.name})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(m,{htmlFor:"provider-baseurl",children:a("chat.settings.baseURL")}),e.jsx(p,{id:"provider-baseurl",value:i.baseURL,onChange:n=>o({...i,baseURL:n.target.value}),placeholder:a("chat.settings.placeholders.baseUrl")}),d.baseURL&&e.jsx("p",{className:"text-xs text-destructive",children:d.baseURL}),e.jsx("p",{className:"text-xs text-muted-foreground",children:a("chat.settings.baseURLHelp")})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(m,{htmlFor:"provider-apikey",children:a("chat.settings.apiKey")}),e.jsx(p,{id:"provider-apikey",type:"password",value:i.apiKey,onChange:n=>o({...i,apiKey:n.target.value}),placeholder:a(h?"chat.settings.placeholders.apiKeyMasked":"chat.settings.placeholders.apiKeyEnv")}),e.jsx("p",{className:"text-xs text-muted-foreground",children:a("chat.settings.apiKeyHelp")})]})]}),e.jsxs(R,{children:[e.jsx(r,{variant:"outline",onClick:j,children:a("actions.cancel")}),e.jsx(r,{onClick:v,children:a("actions.save")})]})]})})}function ge({model:t,existingIds:u,onSave:l,onCancel:j}){const{t:a}=U("common"),[i,o]=x.useState({id:t?.id??"",name:t?.name??"",maxTokens:t?.maxTokens?.toString()??""}),[d,c]=x.useState({}),h=!!t,f=()=>{const n={};return i.id.trim()?!h&&u.includes(i.id)&&(n.id=a("chat.settings.errors.modelIdExists")):n.id=a("chat.settings.errors.modelIdRequired"),i.name.trim()||(n.name=a("chat.settings.errors.modelNameRequired")),i.maxTokens&&Number.isNaN(Number(i.maxTokens))&&(n.maxTokens=a("chat.settings.errors.maxTokensInvalid")),c(n),Object.keys(n).length===0},v=()=>{f()&&l({id:i.id,name:i.name,maxTokens:i.maxTokens?Number(i.maxTokens):void 0})};return e.jsx(S,{open:!0,onOpenChange:j,children:e.jsxs(T,{children:[e.jsxs(P,{children:[e.jsx(M,{children:a(h?"chat.settings.editModel":"chat.settings.addModel")}),e.jsx(L,{children:a("chat.settings.modelDialogDescription")})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs(m,{htmlFor:"model-id",children:[a("chat.settings.modelId")," ",e.jsx("span",{className:"text-destructive",children:"*"})]}),e.jsx(p,{id:"model-id",value:i.id,onChange:n=>o({...i,id:n.target.value}),placeholder:a("chat.settings.placeholders.modelId"),disabled:h}),d.id&&e.jsx("p",{className:"text-xs text-destructive",children:d.id})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(m,{htmlFor:"model-name",children:[a("chat.settings.modelName")," ",e.jsx("span",{className:"text-destructive",children:"*"})]}),e.jsx(p,{id:"model-name",value:i.name,onChange:n=>o({...i,name:n.target.value}),placeholder:a("chat.settings.placeholders.modelName")}),d.name&&e.jsx("p",{className:"text-xs text-destructive",children:d.name})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(m,{htmlFor:"model-maxtokens",children:a("chat.settings.maxTokens")}),e.jsx(p,{id:"model-maxtokens",type:"number",value:i.maxTokens,onChange:n=>o({...i,maxTokens:n.target.value}),placeholder:a("chat.settings.placeholders.maxTokens")}),d.maxTokens&&e.jsx("p",{className:"text-xs text-destructive",children:d.maxTokens}),e.jsx("p",{className:"text-xs text-muted-foreground",children:a("chat.settings.maxTokensHelp")})]})]}),e.jsxs(R,{children:[e.jsx(r,{variant:"outline",onClick:j,children:a("actions.cancel")}),e.jsx(r,{onClick:v,children:a("actions.save")})]})]})})}export{ve as ChatSettingsPage};
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import{h as z,r as m,u as P,j as e,aS as v,a as k,aU as _,bU as M,bA as H,bV as $,B as f,bW as V,bX as J,bY as W,bZ as U,b_ as q,b$ as R,c0 as X,c1 as G,c2 as Y,bm as Z,bf as K,bn as Q,b0 as ee,br as te,C as N,l as y,c3 as A,f as I,c4 as E,c5 as se,i as ne,k as ae,aV as oe,aT as S,bh as ce,c6 as re,c7 as le}from"./index-DSWQaVP_.js";import{T as ie,a as de}from"./table-of-contents-B56zI3O0.js";import{I as xe}from"./info-BoE52mzX.js";const me=[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]],ge=z("external-link",me);const he=[["path",{d:"M12 4v16",key:"1654pz"}],["path",{d:"M4 7V5a1 1 0 0 1 1-1h14a1 1 0 0 1 1 1v2",key:"e0r10z"}],["path",{d:"M9 20h6",key:"s66wpe"}]],pe=z("type",he);function ue(t){return e.jsx("input",{type:"checkbox",...t,className:"appearance-none h-4 w-4 shrink-0 rounded-sm border border-input bg-background disabled:cursor-default checked:bg-primary checked:border-primary relative mr-2 top-[3px] align-middle after:content-[''] after:hidden checked:after:block after:absolute after:left-[5px] after:top-[1px] after:w-[4px] after:h-[8px] after:border-r-[2px] after:border-b-[2px] after:border-primary-foreground after:rotate-45"})}function fe(t,o){return`vscode://file${o.startsWith("/")?o:`${t}/${o}`}`}function je({file:t,projectRoot:o,onBack:i}){const[s,x]=m.useState(!1),r=t.name.toLowerCase().endsWith(".md"),c=t.name.toLowerCase().endsWith(".json"),{t:n,i18n:l}=P("common"),h=m.useMemo(()=>t.content,[t.content]),g=async()=>{try{await navigator.clipboard.writeText(t.content),x(!0),setTimeout(()=>x(!1),1500)}catch(a){console.error("Failed to copy context content",a)}},p=()=>{o&&window.open(fe(o,t.path),"_blank")};return e.jsxs(v,{contentClassName:"space-y-6",children:[e.jsxs("header",{className:"flex flex-col gap-3 sticky top-14 bg-background py-2 z-10",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[i&&e.jsxs(k,{variant:"ghost",size:"sm",onClick:i,className:"h-8 px-2",children:[e.jsx(_,{className:"h-4 w-4 mr-1"}),n("contextPage.detail.back")]}),e.jsx(M,{className:"h-5 w-5 text-primary"}),e.jsxs("div",{className:"flex flex-col",children:[e.jsx("h2",{className:"text-lg sm:text-xl font-semibold leading-tight break-words",children:t.name}),e.jsx("span",{className:"text-xs text-muted-foreground break-all",children:t.path})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[o&&e.jsxs(k,{variant:"ghost",size:"sm",onClick:p,className:"h-8 px-3 text-xs",children:[e.jsx(ge,{className:"h-3.5 w-3.5 mr-1"}),n("contextPage.detail.openInEditor")]}),e.jsxs(k,{variant:"ghost",size:"sm",onClick:g,className:"h-8 px-3 text-xs",children:[s?e.jsx(H,{className:"h-3.5 w-3.5 mr-1 text-green-600"}):e.jsx($,{className:"h-3.5 w-3.5 mr-1"}),n(s?"contextPage.detail.copySuccess":"contextPage.detail.copy")]})]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-xs text-muted-foreground",children:[e.jsxs(f,{variant:"outline",className:"text-xs flex items-center gap-1",children:[e.jsx(pe,{className:"h-3 w-3"}),t.fileType||n("contextPage.detail.defaultFileType")]}),e.jsxs(f,{variant:"outline",className:"text-xs flex items-center gap-1",children:[e.jsx(V,{className:"h-3 w-3"}),n("contextPage.badges.tokens",{formattedCount:t.tokenCount.toLocaleString()})]}),e.jsxs(f,{variant:"outline",className:"text-xs flex items-center gap-1",children:[e.jsx(M,{className:"h-3 w-3"}),n("contextPage.detail.lines",{count:t.lineCount})]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(J,{className:"h-3.5 w-3.5"}),n("contextPage.detail.modified",{date:W(t.modified??t.modifiedAt,l.language)})]}),e.jsx("span",{className:"text-muted-foreground",children:"•"}),e.jsx("span",{children:n("contextPage.detail.size",{size:(t.size/1024).toFixed(1)})})]})]}),e.jsxs("div",{className:"grid gap-6 xl:grid-cols-[minmax(0,1fr)_320px]",children:[e.jsx("div",{className:"overflow-hidden p-4 sm:p-6",children:c?e.jsx("pre",{className:"p-3 text-sm overflow-x-auto bg-muted/40 rounded-md border whitespace-pre-wrap",children:(()=>{try{return JSON.stringify(JSON.parse(t.content),null,2)}catch(a){return console.error("Failed to parse JSON context file",a),t.content}})()}):r?e.jsx("article",{className:"prose prose-slate dark:prose-invert max-w-none prose-sm sm:prose-base",children:e.jsx(U,{remarkPlugins:[X,G],rehypePlugins:[q,R],components:{input:a=>a.type==="checkbox"?e.jsx(ue,{...a}):e.jsx("input",{...a}),pre:({children:a,...d})=>{const j=(Array.isArray(a)?a:[a])[0];if(j&&typeof j=="object"&&"props"in j&&typeof j.props?.className=="string"&&j.props?.className?.includes("language-mermaid")){const C=j.props?.children,F=typeof C=="string"?C:"";return e.jsx(Y,{chart:F})}return e.jsx("pre",{...d,children:a})}},children:t.content})}):e.jsx("pre",{className:"p-3 text-sm overflow-x-auto bg-muted/40 rounded-md border whitespace-pre-wrap",children:t.content})}),r&&e.jsx("aside",{className:"hidden xl:block sticky top-28 h-[calc(100vh-8rem)] overflow-y-auto",children:e.jsx(ie,{content:h})})]}),r&&e.jsx("div",{className:"xl:hidden",children:e.jsx(de,{content:h})})]})}function L(t){return t<5e3?"text-green-600 dark:text-green-400":t<1e4?"text-blue-600 dark:text-blue-400":t<2e4?"text-yellow-600 dark:text-yellow-400":"text-red-600 dark:text-red-400"}function b(t,o){if(!o||o.length<2)return 0;const i=new RegExp(o.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),"gi"),s=t.match(i);return s?s.length:0}function O({icon:t,title:o,description:i,suggestion:s}){return e.jsxs("div",{className:"flex flex-col items-center justify-center py-8 text-center",children:[e.jsx(t,{className:"h-12 w-12 text-muted-foreground/50 mb-4"}),e.jsx("h3",{className:"text-sm font-medium text-muted-foreground",children:o}),e.jsx("p",{className:"text-xs text-muted-foreground/70 mt-1 max-w-xs",children:i}),s&&e.jsx("p",{className:"text-xs text-primary mt-2",children:s})]})}function Ne({file:t,searchQuery:o,onClick:i}){const{t:s}=P("common"),x=o?b(t.content,o):0;if(!(!o||x>0||t.name.toLowerCase().includes(o.toLowerCase())))return null;const c=x===1?s("contextPage.badges.matchesSingular",{count:x}):s("contextPage.badges.matchesPlural",{count:x}),n=s("contextPage.badges.tokens",{formattedCount:t.tokenCount.toLocaleString()});return e.jsx("button",{onClick:i,className:"w-full text-left p-4 rounded-lg border border-border bg-card hover:bg-accent transition-colors",children:e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx(M,{className:"h-4 w-4 text-primary shrink-0"}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-sm font-medium truncate",children:t.name}),e.jsx("div",{className:"text-xs text-muted-foreground truncate",children:t.path})]})]}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[o&&x>0&&e.jsx(f,{variant:"secondary",className:"text-xs bg-yellow-100 dark:bg-yellow-900",children:c}),e.jsxs(f,{variant:"outline",className:"text-xs",children:[e.jsx(A,{className:"h-3 w-3 mr-1"}),n]})]})]})})}function T({title:t,description:o,icon:i,files:s,emptyMessage:x,emptySuggestion:r,searchQuery:c,onFileSelect:n}){const{t:l}=P("common"),h=s.reduce((u,w)=>u+w.tokenCount,0),g=m.useMemo(()=>!c||c.length<2?s:s.filter(u=>{const w=b(u.content,c),B=u.name.toLowerCase().includes(c.toLowerCase());return w>0||B}),[s,c]),p=m.useMemo(()=>!c||c.length<2?0:g.reduce((u,w)=>u+b(w.content,c),0),[g,c]),a=g.length,d=m.useMemo(()=>p===1?l("contextPage.badges.matchesSingular",{count:p}):l("contextPage.badges.matchesPlural",{count:p}),[l,p]),D=m.useMemo(()=>a===s.length?a===1?l("contextPage.badges.filesSingular",{count:a}):l("contextPage.badges.filesPlural",{count:a}):l("contextPage.badges.filesFiltered",{count:a,total:s.length}),[s.length,a,l]),j=m.useMemo(()=>l("contextPage.badges.tokens",{formattedCount:h.toLocaleString()}),[l,h]),C=c?l("contextPage.search.noMatchesTitle"):x,F=l(c?"contextPage.search.noMatchesDescription":"contextPage.search.noFilesDescription");return e.jsxs(N,{children:[e.jsx(ne,{className:"pb-3",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-2 rounded-lg bg-primary/10",children:e.jsx(i,{className:"h-5 w-5 text-primary"})}),e.jsxs("div",{children:[e.jsx(ae,{className:"text-lg",children:t}),e.jsx(oe,{children:o})]})]}),s.length>0&&e.jsxs("div",{className:"flex items-center gap-2",children:[c&&p>0&&e.jsx(f,{variant:"secondary",className:"text-xs bg-yellow-100 dark:bg-yellow-900 text-yellow-800 dark:text-yellow-200",children:d}),e.jsx(f,{variant:"secondary",className:"text-xs",children:D}),e.jsxs(f,{variant:"outline",className:I("text-xs",L(h)),children:[e.jsx(A,{className:"h-3 w-3 mr-1"}),j]})]})]})}),e.jsx(y,{children:g.length===0?e.jsx(O,{icon:S,title:C,description:F,suggestion:c?void 0:r}):e.jsx("div",{className:"space-y-3",children:g.map(u=>e.jsx(Ne,{file:u,searchQuery:c,onClick:()=>n?.(u)},u.path))})})]})}function ye({context:t}){const[o,i]=m.useState(!1),[s,x]=m.useState(""),[r,c]=m.useState(null),{t:n}=P("common"),l=async()=>{const a=[];for(const d of t.agentInstructions)a.push(`# ${d.path}
|
|
2
|
-
|
|
3
|
-
${d.content}
|
|
4
|
-
`);t.config.file&&a.push(`# ${t.config.file.path}
|
|
5
|
-
|
|
6
|
-
${t.config.file.content}
|
|
7
|
-
`);for(const d of t.projectDocs)a.push(`# ${d.path}
|
|
8
|
-
|
|
9
|
-
${d.content}
|
|
10
|
-
`);try{await navigator.clipboard.writeText(a.join(`
|
|
11
|
-
---
|
|
12
|
-
|
|
13
|
-
`)),i(!0),setTimeout(()=>i(!1),2e3)}catch(d){console.error("Failed to copy all content:",d)}},h=t.agentInstructions.length>0||t.config.file!==null||t.projectDocs.length>0,g=m.useMemo(()=>{if(!s||s.length<2)return 0;let a=0;for(const d of t.agentInstructions)a+=b(d.content,s);t.config.file&&(a+=b(t.config.file.content,s));for(const d of t.projectDocs)a+=b(d.content,s);return a},[t,s]),p=r?{name:r.name,path:r.path,content:r.content,size:new Blob([r.content]).size,tokenCount:r.tokenCount,lineCount:r.content.split(`
|
|
14
|
-
`).length,modified:r.lastModified instanceof Date?r.lastModified.toISOString():r.lastModified}:null;return r&&p?e.jsx("div",{className:"min-h-screen bg-background",children:e.jsx(je,{file:p,projectRoot:t.projectRoot,onBack:()=>c(null)})}):e.jsxs(v,{contentClassName:"space-y-6",children:[e.jsx(Z,{title:n("contextPage.title"),description:n("contextPage.description"),actions:h?e.jsx(k,{variant:"outline",size:"sm",onClick:l,className:"shrink-0",children:o?e.jsxs(e.Fragment,{children:[e.jsx(K,{className:"h-4 w-4 mr-2 text-green-600"}),n("contextPage.copyAllSuccess")]}):e.jsxs(e.Fragment,{children:[e.jsx($,{className:"h-4 w-4 mr-2"}),n("contextPage.copyAll")]})}):void 0}),h&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"relative",children:[e.jsx(Q,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(ee,{type:"text",placeholder:n("contextPage.searchPlaceholder"),value:s,onChange:a=>x(a.target.value),className:"pl-10 pr-10"}),s&&e.jsx(k,{variant:"ghost",size:"sm",className:"absolute right-1 top-1/2 -translate-y-1/2 h-7 w-7 p-0",onClick:()=>x(""),children:e.jsx(te,{className:"h-4 w-4"})})]}),s&&s.length>=2&&e.jsx("div",{className:"flex items-center gap-2 text-sm",children:g>0?e.jsx(f,{variant:"secondary",className:"bg-yellow-100 dark:bg-yellow-900 text-yellow-800 dark:text-yellow-200",children:g===1?n("contextPage.badges.matchesFoundSingular",{count:g}):n("contextPage.badges.matchesFoundPlural",{count:g})}):e.jsx("span",{className:"text-muted-foreground",children:n("contextPage.searchNoMatches",{query:s})})}),e.jsx(N,{className:"bg-muted/30",children:e.jsx(y,{className:"py-4",children:e.jsxs("div",{className:"flex flex-wrap items-center gap-4 sm:gap-8",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(A,{className:I("h-5 w-5",L(t.totalTokens))}),e.jsx("span",{className:"text-sm",children:e.jsx("strong",{className:L(t.totalTokens),children:n("contextPage.summary.totalTokens",{formattedCount:t.totalTokens.toLocaleString()})})})]}),e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(xe,{className:"h-4 w-4"}),n("contextPage.summary.contextBudget")]})]})})})]}),e.jsxs("div",{className:"space-y-6",children:[e.jsx(T,{title:n("contextPage.sections.agents.title"),description:n("contextPage.sections.agents.description"),icon:E,files:t.agentInstructions,emptyMessage:n("contextPage.sections.agents.empty"),emptySuggestion:n("contextPage.sections.agents.suggestion"),searchQuery:s,onFileSelect:c}),e.jsx(T,{title:n("contextPage.sections.config.title"),description:n("contextPage.sections.config.description"),icon:se,files:t.config.file?[t.config.file]:[],emptyMessage:n("contextPage.sections.config.empty"),emptySuggestion:n("contextPage.sections.config.suggestion"),searchQuery:s,onFileSelect:c}),e.jsx(T,{title:n("contextPage.sections.docs.title"),description:n("contextPage.sections.docs.description"),icon:M,files:t.projectDocs,emptyMessage:n("contextPage.sections.docs.empty"),emptySuggestion:n("contextPage.sections.docs.suggestion"),searchQuery:s,onFileSelect:c})]}),!h&&e.jsx(N,{className:"mt-8",children:e.jsx(y,{className:"py-12",children:e.jsx(O,{icon:E,title:n("contextPage.emptyState.title"),description:n("contextPage.emptyState.description"),suggestion:n("contextPage.emptyState.suggestion")})})})]})}function ke(){const{currentProject:t,loading:o,error:i}=ce(),{t:s}=P(["common","errors"]),[x,r]=m.useState(null),[c,n]=m.useState(!0),[l,h]=m.useState(null),g=i instanceof Error?i.message:i;return m.useEffect(()=>{async function p(){if(!o){if(!t?.id){r(null),n(!1);return}n(!0),h(null);try{const a=await le.getProjectContext();r(a)}catch(a){const d=a instanceof Error?a.message:s("contextPage.errors.list",{ns:"common"});h(d)}finally{n(!1)}}}p()},[t?.id,o,s]),o||c?e.jsx(re,{}):l&&t?e.jsx(v,{children:e.jsx(N,{children:e.jsxs(y,{className:"py-10 text-center space-y-3",children:[e.jsx("div",{className:"flex justify-center",children:e.jsx(S,{className:"h-6 w-6 text-destructive"})}),e.jsx("div",{className:"text-lg font-semibold",children:s("contextPage.errors.loadFailed",{ns:"common"})}),e.jsx("p",{className:"text-sm text-muted-foreground",children:g||l||s("errors.loadingError",{ns:"errors"})})]})})}):t?x?e.jsx(ye,{context:x}):e.jsx(v,{children:e.jsx(N,{children:e.jsxs(y,{className:"py-10 text-center space-y-3",children:[e.jsx("div",{className:"flex justify-center",children:e.jsx(S,{className:"h-6 w-6 text-muted-foreground"})}),e.jsx("div",{className:"text-lg font-semibold",children:s("contextPage.emptyState.title")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s("contextPage.emptyState.description")})]})})}):e.jsx(v,{children:e.jsx(N,{children:e.jsxs(y,{className:"py-10 text-center space-y-3",children:[e.jsx("div",{className:"flex justify-center",children:e.jsx(S,{className:"h-6 w-6 text-muted-foreground"})}),e.jsx("div",{className:"text-lg font-semibold",children:s("contextPage.errors.noProject",{ns:"common"})}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s("contextPage.errors.noProjectDescription",{ns:"common"})})]})})})}export{ke as ContextPage};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{r as f,d5 as _e,d6 as me,x as Je,d7 as et,d8 as y,d9 as Le,da as ge,db as tt,dc as nt,dd as st,de as ve,df as rt,dg as ot,dh as at,u as Ne,j as e,cI as Oe,cc as Re,cb as Te,bX as he,cM as Fe,cN as pe,cO as Ae,aT as Be,f as C,di as ye,b5 as it,b6 as ct,a as lt,b7 as dt,b8 as ut,b9 as mt,ba as gt,bb as ht,bc as pt,bd as xt,be as De,br as ft,bf as bt,dj as Ie,dk as we,dl as yt,bg as wt,aP as vt,bl as Nt,bh as jt,c7 as kt,dm as $e,dn as St,aS as Ee,bm as Et}from"./index-DSWQaVP_.js";const Ve=({id:t,x:n,y:c,width:l,height:r,style:a,color:g,strokeColor:x,strokeWidth:d,className:i,borderRadius:m,shapeRendering:h,onClick:N,selected:s})=>{const{background:v,backgroundColor:k}=a||{},P=g||v||k;return y.createElement("rect",{className:ge(["react-flow__minimap-node",{selected:s},i]),x:n,y:c,rx:m,ry:m,width:l,height:r,fill:P,stroke:x,strokeWidth:d,shapeRendering:h,onClick:N?M=>N(M,t):void 0})};Ve.displayName="MiniMapNode";var Ct=f.memo(Ve);const Mt=t=>t.nodeOrigin,Pt=t=>t.getNodes().filter(n=>!n.hidden&&n.width&&n.height),Ce=t=>t instanceof Function?t:()=>t;function Dt({nodeStrokeColor:t="transparent",nodeColor:n="#e2e2e2",nodeClassName:c="",nodeBorderRadius:l=5,nodeStrokeWidth:r=2,nodeComponent:a=Ct,onClick:g}){const x=me(Pt,ve),d=me(Mt),i=Ce(n),m=Ce(t),h=Ce(c),N=typeof window>"u"||window.chrome?"crispEdges":"geometricPrecision";return y.createElement(y.Fragment,null,x.map(s=>{const{x:v,y:k}=st(s,d).positionAbsolute;return y.createElement(a,{key:s.id,x:v,y:k,width:s.width,height:s.height,style:s.style,selected:s.selected,className:h(s),color:i(s),borderRadius:l,strokeColor:m(s),strokeWidth:r,shapeRendering:N,onClick:g,id:s.id})}))}var It=f.memo(Dt);const $t=200,zt=150,Ht=t=>{const n=t.getNodes(),c={x:-t.transform[0]/t.transform[2],y:-t.transform[1]/t.transform[2],width:t.width/t.transform[2],height:t.height/t.transform[2]};return{viewBB:c,boundingRect:n.length>0?rt(ot(n,t.nodeOrigin),c):c,rfId:t.rfId}},_t="react-flow__minimap-desc";function We({style:t,className:n,nodeStrokeColor:c="transparent",nodeColor:l="#e2e2e2",nodeClassName:r="",nodeBorderRadius:a=5,nodeStrokeWidth:g=2,nodeComponent:x,maskColor:d="rgb(240, 240, 240, 0.6)",maskStrokeColor:i="none",maskStrokeWidth:m=1,position:h="bottom-right",onClick:N,onNodeClick:s,pannable:v=!1,zoomable:k=!1,ariaLabel:P="React Flow mini map",inversePan:M=!1,zoomStep:E=10,offsetScale:S=5}){const T=_e(),I=f.useRef(null),{boundingRect:O,viewBB:$,rfId:Q}=me(Ht,ve),b=t?.width??$t,L=t?.height??zt,G=O.width/b,xe=O.height/L,B=Math.max(G,xe),ce=B*b,oe=B*L,z=S*B,R=O.x-(ce-O.width)/2-z,q=O.y-(oe-O.height)/2-z,X=ce+z*2,ae=oe+z*2,fe=`${_t}-${Q}`,Y=f.useRef(0);Y.current=B,f.useEffect(()=>{if(I.current){const K=Je(I.current),J=U=>{const{transform:o,d3Selection:p,d3Zoom:w}=T.getState();if(U.sourceEvent.type!=="wheel"||!p||!w)return;const D=-U.sourceEvent.deltaY*(U.sourceEvent.deltaMode===1?.05:U.sourceEvent.deltaMode?1:.002)*E,H=o[2]*Math.pow(2,D);w.scaleTo(p,H)},le=U=>{const{transform:o,d3Selection:p,d3Zoom:w,translateExtent:D,width:H,height:F}=T.getState();if(U.sourceEvent.type!=="mousemove"||!p||!w)return;const A=Y.current*Math.max(1,o[2])*(M?-1:1),V={x:o[0]-U.sourceEvent.movementX*A,y:o[1]-U.sourceEvent.movementY*A},ee=[[0,0],[H,F]],ie=tt.translate(V.x,V.y).scale(o[2]),re=w.constrain()(ie,ee,D);w.transform(p,re)},ke=et().on("zoom",v?le:null).on("zoom.wheel",k?J:null);return K.call(ke),()=>{K.on("zoom",null)}}},[v,k,M,E]);const se=N?K=>{const J=nt(K);N(K,{x:J[0],y:J[1]})}:void 0,je=s?(K,J)=>{const le=T.getState().nodeInternals.get(J);s(K,le)}:void 0;return y.createElement(Le,{position:h,style:t,className:ge(["react-flow__minimap",n]),"data-testid":"rf__minimap"},y.createElement("svg",{width:b,height:L,viewBox:`${R} ${q} ${X} ${ae}`,role:"img","aria-labelledby":fe,ref:I,onClick:se},P&&y.createElement("title",{id:fe},P),y.createElement(It,{onClick:je,nodeColor:l,nodeStrokeColor:c,nodeBorderRadius:a,nodeClassName:r,nodeStrokeWidth:g,nodeComponent:x}),y.createElement("path",{className:"react-flow__minimap-mask",d:`M${R-z},${q-z}h${X+z*2}v${ae+z*2}h${-X-z*2}z
|
|
2
|
-
M${$.x},${$.y}h${$.width}v${$.height}h${-$.width}z`,fill:d,fillRule:"evenodd",stroke:i,strokeWidth:m,pointerEvents:"none"})))}We.displayName="MiniMap";var Lt=f.memo(We);function Ot(){return y.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32"},y.createElement("path",{d:"M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z"}))}function Rt(){return y.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 5"},y.createElement("path",{d:"M0 0h32v4.2H0z"}))}function Tt(){return y.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 30"},y.createElement("path",{d:"M3.692 4.63c0-.53.4-.938.939-.938h5.215V0H4.708C2.13 0 0 2.054 0 4.63v5.216h3.692V4.631zM27.354 0h-5.2v3.692h5.17c.53 0 .984.4.984.939v5.215H32V4.631A4.624 4.624 0 0027.354 0zm.954 24.83c0 .532-.4.94-.939.94h-5.215v3.768h5.215c2.577 0 4.631-2.13 4.631-4.707v-5.139h-3.692v5.139zm-23.677.94c-.531 0-.939-.4-.939-.94v-5.138H0v5.139c0 2.577 2.13 4.707 4.708 4.707h5.138V25.77H4.631z"}))}function Ft(){return y.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32"},y.createElement("path",{d:"M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0 8 0 4.571 3.429 4.571 7.619v3.048H3.048A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047zm4.724-13.866H7.467V7.619c0-2.59 2.133-4.724 4.723-4.724 2.591 0 4.724 2.133 4.724 4.724v3.048z"}))}function At(){return y.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32"},y.createElement("path",{d:"M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0c-4.114 1.828-1.37 2.133.305 2.438 1.676.305 4.42 2.59 4.42 5.181v3.048H3.047A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047z"}))}const ue=({children:t,className:n,...c})=>y.createElement("button",{type:"button",className:ge(["react-flow__controls-button",n]),...c},t);ue.displayName="ControlButton";const Bt=t=>({isInteractive:t.nodesDraggable||t.nodesConnectable||t.elementsSelectable,minZoomReached:t.transform[2]<=t.minZoom,maxZoomReached:t.transform[2]>=t.maxZoom}),Ze=({style:t,showZoom:n=!0,showFitView:c=!0,showInteractive:l=!0,fitViewOptions:r,onZoomIn:a,onZoomOut:g,onFitView:x,onInteractiveChange:d,className:i,children:m,position:h="bottom-left"})=>{const N=_e(),[s,v]=f.useState(!1),{isInteractive:k,minZoomReached:P,maxZoomReached:M}=me(Bt,ve),{zoomIn:E,zoomOut:S,fitView:T}=at();if(f.useEffect(()=>{v(!0)},[]),!s)return null;const I=()=>{E(),a?.()},O=()=>{S(),g?.()},$=()=>{T(r),x?.()},Q=()=>{N.setState({nodesDraggable:!k,nodesConnectable:!k,elementsSelectable:!k}),d?.(!k)};return y.createElement(Le,{className:ge(["react-flow__controls",i]),position:h,style:t,"data-testid":"rf__controls"},n&&y.createElement(y.Fragment,null,y.createElement(ue,{onClick:I,className:"react-flow__controls-zoomin",title:"zoom in","aria-label":"zoom in",disabled:M},y.createElement(Ot,null)),y.createElement(ue,{onClick:O,className:"react-flow__controls-zoomout",title:"zoom out","aria-label":"zoom out",disabled:P},y.createElement(Rt,null))),c&&y.createElement(ue,{className:"react-flow__controls-fitview",onClick:$,title:"fit view","aria-label":"fit view"},y.createElement(Tt,null)),l&&y.createElement(ue,{className:"react-flow__controls-interactive",onClick:Q,title:"toggle interactivity","aria-label":"toggle interactivity"},k?y.createElement(At,null):y.createElement(Ft,null)),m)};Ze.displayName="Controls";var Vt=f.memo(Ze),Z;(function(t){t.Lines="lines",t.Dots="dots",t.Cross="cross"})(Z||(Z={}));function Wt({color:t,dimensions:n,lineWidth:c}){return y.createElement("path",{stroke:t,strokeWidth:c,d:`M${n[0]/2} 0 V${n[1]} M0 ${n[1]/2} H${n[0]}`})}function Zt({color:t,radius:n}){return y.createElement("circle",{cx:n,cy:n,r:n,fill:t})}const Ut={[Z.Dots]:"#91919a",[Z.Lines]:"#eee",[Z.Cross]:"#e2e2e2"},Gt={[Z.Dots]:1,[Z.Lines]:1,[Z.Cross]:6},qt=t=>({transform:t.transform,patternId:`pattern-${t.rfId}`});function Ue({id:t,variant:n=Z.Dots,gap:c=20,size:l,lineWidth:r=1,offset:a=2,color:g,style:x,className:d}){const i=f.useRef(null),{transform:m,patternId:h}=me(qt,ve),N=g||Ut[n],s=l||Gt[n],v=n===Z.Dots,k=n===Z.Cross,P=Array.isArray(c)?c:[c,c],M=[P[0]*m[2]||1,P[1]*m[2]||1],E=s*m[2],S=k?[E,E]:M,T=v?[E/a,E/a]:[S[0]/a,S[1]/a];return y.createElement("svg",{className:ge(["react-flow__background",d]),style:{...x,position:"absolute",width:"100%",height:"100%",top:0,left:0},ref:i,"data-testid":"rf__background"},y.createElement("pattern",{id:h+t,x:m[0]%M[0],y:m[1]%M[1],width:M[0],height:M[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${T[0]},-${T[1]})`},v?y.createElement(Zt,{color:N,radius:E/a}):y.createElement(Wt,{dimensions:S,color:N,lineWidth:r})),y.createElement("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${h+t})`}))}Ue.displayName="Background";var Xt=f.memo(Ue);const Ge={planned:he,"in-progress":Te,complete:Re,archived:Oe},qe={critical:Be,high:Ae,medium:pe,low:Fe};function ze({spec:t,type:n,depth:c,onClick:l}){const{t:r}=Ne(),a={upstream:"border-l-amber-500",downstream:"border-l-emerald-500"},g=c===1?r("dependenciesPage.sidebar.depth.direct"):r("dependenciesPage.sidebar.depth.level",{depth:c}),x=Ge[t.status]||he,d=qe[t.priority]||pe;return e.jsxs("button",{onClick:l,className:C("w-full text-left px-2 py-1.5 rounded border-l-2 bg-muted/30 hover:bg-muted/50 transition-colors",a[n]),children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsxs("span",{className:"text-[10px] font-bold text-muted-foreground",children:["#",t.number]}),e.jsx("div",{className:C("rounded p-0.5 flex items-center justify-center",t.status==="planned"&&"bg-blue-500/20",t.status==="in-progress"&&"bg-orange-500/20",t.status==="complete"&&"bg-green-500/20",t.status==="archived"&&"bg-gray-500/20"),title:r(`status.${t.status}`),children:e.jsx(x,{className:C("h-2.5 w-2.5",t.status==="planned"&&"text-blue-600 dark:text-blue-400",t.status==="in-progress"&&"text-orange-600 dark:text-orange-400",t.status==="complete"&&"text-green-600 dark:text-green-400",t.status==="archived"&&"text-gray-500 dark:text-gray-400")})}),e.jsx("div",{className:C("rounded p-0.5 flex items-center justify-center",t.priority==="critical"&&"bg-red-500/20",t.priority==="high"&&"bg-orange-500/20",t.priority==="medium"&&"bg-blue-500/20",t.priority==="low"&&"bg-gray-500/20"),title:t.priority?r(`priority.${t.priority}`):void 0,children:e.jsx(d,{className:C("h-2.5 w-2.5",t.priority==="critical"&&"text-red-600 dark:text-red-400",t.priority==="high"&&"text-orange-600 dark:text-orange-400",t.priority==="medium"&&"text-blue-600 dark:text-blue-400",t.priority==="low"&&"text-gray-500 dark:text-gray-400")})}),e.jsx("span",{className:"text-[8px] px-1 py-0.5 rounded bg-muted text-muted-foreground font-medium ml-auto",children:g})]}),e.jsx("p",{className:"text-[11px] text-foreground truncate leading-tight mt-0.5",children:t.name})]})}function Yt({focusedDetails:t,onSelectSpec:n,onOpenSpec:c}){const{t:l}=Ne();if(!t)return e.jsx("div",{className:"w-64 shrink-0 rounded-lg border border-border bg-background/95 overflow-hidden flex flex-col",children:e.jsx("div",{className:"flex-1 flex items-center justify-center p-4",children:e.jsxs("div",{className:"text-center text-muted-foreground",children:[e.jsx("div",{className:"w-12 h-12 mx-auto mb-3 rounded-full bg-muted/50 flex items-center justify-center",children:e.jsx("svg",{className:"w-6 h-6",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M15 15l-2 5L9 9l11 4-5 2zm0 0l5 5M7.188 2.239l.777 2.897M5.136 7.965l-2.898-.777M13.95 4.05l-2.122 2.122m-5.657 5.656l-2.12 2.122"})})}),e.jsx("p",{className:"text-sm font-medium",children:l("dependenciesPage.sidebar.emptyTitle")}),e.jsx("p",{className:"text-xs mt-1",children:l("dependenciesPage.sidebar.emptyDescription")})]})})});const{node:r,upstream:a,downstream:g}=t,x=Ge[r.status]||he,d=qe[r.priority]||pe;return e.jsxs("div",{className:"w-64 shrink-0 rounded-lg border border-border bg-background/95 overflow-hidden flex flex-col",children:[e.jsxs("div",{className:"p-3 border-b border-border bg-muted/30",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsxs("span",{className:"font-bold text-sm",children:["#",r.number]}),e.jsx("div",{className:C("rounded p-1 flex items-center justify-center",r.status==="planned"&&"bg-blue-500/20",r.status==="in-progress"&&"bg-orange-500/20",r.status==="complete"&&"bg-green-500/20",r.status==="archived"&&"bg-gray-500/20"),title:r.status,children:e.jsx(x,{className:C("h-3 w-3",r.status==="planned"&&"text-blue-600 dark:text-blue-300",r.status==="in-progress"&&"text-orange-600 dark:text-orange-300",r.status==="complete"&&"text-green-600 dark:text-green-300",r.status==="archived"&&"text-gray-500 dark:text-gray-300")})}),e.jsx("div",{className:C("rounded p-1 flex items-center justify-center",r.priority==="critical"&&"bg-red-500/20",r.priority==="high"&&"bg-orange-500/20",r.priority==="medium"&&"bg-blue-500/20",r.priority==="low"&&"bg-gray-500/20"),title:r.priority,children:e.jsx(d,{className:C("h-3 w-3",r.priority==="critical"&&"text-red-600 dark:text-red-300",r.priority==="high"&&"text-orange-600 dark:text-orange-300",r.priority==="medium"&&"text-blue-600 dark:text-blue-300",r.priority==="low"&&"text-gray-500 dark:text-gray-300")})})]}),e.jsx("p",{className:"text-sm font-medium text-foreground leading-snug",children:r.name}),e.jsx("button",{onClick:()=>c(r.number),className:"mt-2 w-full rounded bg-primary/20 border border-primary/40 px-2 py-1.5 text-xs text-primary hover:bg-primary/30 font-medium",children:l("dependenciesPage.sidebar.openSpec")})]}),e.jsxs("div",{className:"flex-1 overflow-auto p-3 space-y-4",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx("span",{className:"inline-block w-2 h-2 rounded-full bg-amber-500"}),e.jsx("span",{className:"text-xs font-semibold text-muted-foreground uppercase tracking-wide",children:l("dependenciesPage.sidebar.dependsOnHeading",{count:a.reduce((i,m)=>i+m.specs.length,0)})})]}),a.length>0?e.jsx("div",{className:"space-y-1.5",children:a.flatMap(i=>i.specs.map(m=>e.jsx(ze,{spec:m,type:"upstream",depth:i.depth,onClick:()=>n(m.id)},m.id)))}):e.jsx("p",{className:"text-xs text-muted-foreground/60 italic",children:l("dependenciesPage.sidebar.emptyUpstream")})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx("span",{className:"inline-block w-2 h-2 rounded-full bg-emerald-500"}),e.jsx("span",{className:"text-xs font-semibold text-muted-foreground uppercase tracking-wide",children:l("dependenciesPage.sidebar.requiredByHeading",{count:g.reduce((i,m)=>i+m.specs.length,0)})})]}),g.length>0?e.jsx("div",{className:"space-y-1.5",children:g.flatMap(i=>i.specs.map(m=>e.jsx(ze,{spec:m,type:"downstream",depth:i.depth,onClick:()=>n(m.id)},m.id)))}):e.jsx("p",{className:"text-xs text-muted-foreground/60 italic",children:l("dependenciesPage.sidebar.emptyDownstream")})]})]})]})}const Me=180,Xe=60,Pe=120,Ye=40,be="#f59e0b",Kt={planned:"border-blue-500 bg-blue-100 text-blue-800 dark:bg-blue-950/60 dark:text-blue-200","in-progress":"border-orange-500 bg-orange-100 text-orange-800 dark:bg-orange-950/60 dark:text-orange-200",complete:"border-green-500 bg-green-100 text-green-800 dark:bg-green-950/60 dark:text-green-200",archived:"border-gray-400 bg-gray-100 text-gray-600 dark:border-gray-500/80 dark:bg-gray-900/60 dark:text-gray-400"},Qt={planned:"#3b82f6","in-progress":"#f97316",complete:"#22c55e",archived:"#6b7280"};function Jt(t,n,c=2){const l=new Map;l.set(t,0);const r=new Map,a=new Map;n.forEach(d=>{r.has(d.source)||r.set(d.source,new Set),r.get(d.source).add(d.target),a.has(d.target)||a.set(d.target,new Set),a.get(d.target).add(d.source)});let g=new Set([t]),x=1;for(;g.size>0&&x<=c;){const d=new Set;g.forEach(i=>{const m=r.get(i);m&&m.forEach(h=>{l.has(h)||(l.set(h,x),d.add(h))})}),g=d,x++}for(g=new Set([t]),x=1;g.size>0&&x<=c;){const d=new Set;g.forEach(i=>{const m=a.get(i);m&&m.forEach(h=>{l.has(h)||(l.set(h,x),d.add(h))})}),g=d,x++}return l}function He(t,n,c,l,r={}){if(t.length===0)return{nodes:[],edges:[]};if((r.mode??"graph")==="focus"&&r.focusedNodeId)return en(t,n,c);const g=c?Pe:Me,x=c?Ye:Xe,d=c?30:50,i=new Set;n.forEach(s=>{i.add(s.source),i.add(s.target)});const m=t.filter(s=>i.has(s.id)),h=l?t.filter(s=>!i.has(s.id)):[],N=[];if(m.length>0){const s=new ye.graphlib.Graph;s.setGraph({rankdir:"LR",align:"UL",nodesep:c?30:50,ranksep:c?80:120,marginx:40,marginy:40}),s.setDefaultEdgeLabel(()=>({})),m.forEach(E=>{s.setNode(E.id,{width:g,height:x})}),n.forEach(E=>{i.has(E.source)&&i.has(E.target)&&s.setEdge(E.source,E.target)}),ye.layout(s);let v=1/0,k=1/0,P=0,M=0;if(m.forEach(E=>{const S=s.node(E.id);v=Math.min(v,S.x-g/2),k=Math.min(k,S.y-x/2),P=Math.max(P,S.x+g/2),M=Math.max(M,S.y+x/2)}),m.forEach(E=>{const S=s.node(E.id);N.push({...E,position:{x:S.x-v,y:S.y-k}})}),h.length>0){const E=M-k,S=P-v,T=E+d*2,I=Math.ceil(Math.sqrt(h.length*1.5)),O=I*(g+d),$=S>O?Math.floor((S-O)/2):0;h.forEach((Q,b)=>{const L=b%I,G=Math.floor(b/I);N.push({...Q,position:{x:$+L*(g+d),y:T+G*(x+d)}})})}}else{const s=Math.ceil(Math.sqrt(h.length*1.5));h.forEach((v,k)=>{const P=k%s,M=Math.floor(k/s);N.push({...v,position:{x:P*(g+d),y:M*(x+d)}})})}return{nodes:N,edges:n}}function en(t,n,c){const l=c?Pe:Me,r=c?Ye:Xe,a=new ye.graphlib.Graph;a.setGraph({rankdir:"LR",align:"UL",nodesep:c?30:50,ranksep:c?80:120,marginx:40,marginy:40}),a.setDefaultEdgeLabel(()=>({})),t.forEach(i=>{a.setNode(i.id,{width:l,height:r})}),n.forEach(i=>{a.setEdge(i.source,i.target)}),ye.layout(a);let g=1/0,x=1/0;return t.forEach(i=>{const m=a.node(i.id);g=Math.min(g,m.x-l/2),x=Math.min(x,m.y-r/2)}),{nodes:t.map(i=>{const m=a.node(i.id);return{...i,position:{x:m.x-g,y:m.y-x}}}),edges:n}}function tn({statusFilter:t,statusCounts:n,showStandalone:c,isCompact:l,viewMode:r,focusedNodeId:a,connectionStats:g,onToggleStatus:x,onToggleStandalone:d,onToggleCompact:i,onToggleViewMode:m,onClear:h,t:N}){const s=t.length>0||a;return e.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 text-xs",children:[["draft","planned","in-progress","complete","archived"].map(v=>{const k=t.length===0||t.includes(v),P=N(`status.${v}`),M=n[v]||0;return e.jsxs("button",{onClick:()=>x(v),className:C("rounded border px-2 py-1 font-medium transition-colors",k&&v==="draft"&&"border-slate-500/60 bg-slate-500/20 text-slate-700 dark:text-slate-200",k&&v==="planned"&&"border-blue-500/60 bg-blue-500/20 text-blue-700 dark:text-blue-300",k&&v==="in-progress"&&"border-orange-500/60 bg-orange-500/20 text-orange-700 dark:text-orange-300",k&&v==="complete"&&"border-green-500/60 bg-green-500/20 text-green-700 dark:text-green-300",k&&v==="archived"&&"border-gray-500/60 bg-gray-500/20 text-gray-600 dark:text-gray-300",!k&&"border-border bg-background text-muted-foreground/40"),children:[P,e.jsx("span",{className:"ml-1 opacity-60",children:N("dependenciesPage.filters.count",{count:M})})]},v)}),e.jsx("span",{className:"h-3 w-px bg-border"}),e.jsx("button",{onClick:d,className:C("rounded border px-2 py-1 font-medium transition-colors",c?"border-violet-500/60 bg-violet-500/20 text-violet-700 dark:text-violet-300":"border-border bg-background hover:bg-accent text-muted-foreground"),children:N("dependenciesPage.filters.showStandalone",{count:g.standalone})}),e.jsx("span",{className:"h-3 w-px bg-border"}),e.jsx("button",{onClick:i,className:C("rounded border px-2 py-1 font-medium transition-colors",l?"border-primary/60 bg-primary/20 text-primary":"border-border bg-background hover:bg-accent text-muted-foreground"),children:N("dependenciesPage.filters.compact")}),a&&e.jsx("button",{onClick:m,className:C("rounded border px-2 py-1 font-medium transition-colors",r==="focus"?"border-primary/60 bg-primary/20 text-primary":"border-border bg-background hover:bg-accent text-muted-foreground"),children:N("dependenciesPage.filters.focusMode")}),s&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"h-3 w-px bg-border"}),e.jsx("button",{onClick:h,className:"rounded border border-red-500/40 bg-red-500/10 px-2 py-1 font-medium text-red-400 hover:bg-red-500/20",children:N("dependenciesPage.filters.clear")})]})]})}function nn({data:t,focusedNodeId:n,onSelectSpec:c,onClearSelection:l,t:r}){const[a,g]=f.useState(!1),[x,d]=f.useState(""),i=f.useMemo(()=>n?t.nodes.find(h=>h.id===n):null,[n,t]),m=f.useMemo(()=>{const h=[...t.nodes].sort((s,v)=>v.number-s.number);if(!x.trim())return h.slice(0,15);const N=x.toLowerCase();return h.filter(s=>s.name.toLowerCase().includes(N)||s.number.toString().includes(N)||s.tags.some(v=>v.toLowerCase().includes(N))).slice(0,15)},[t,x]);return e.jsxs(it,{open:a,onOpenChange:g,children:[e.jsx(ct,{asChild:!0,children:e.jsxs(lt,{variant:"outline",role:"combobox","aria-expanded":a,className:C("w-[240px] h-9 justify-between px-3 text-xs",n&&"border-primary/60 bg-primary/10 text-foreground"),children:[i?e.jsxs("span",{className:"truncate flex items-center",children:[e.jsxs("span",{className:"text-muted-foreground mr-2 font-mono",children:["#",i.number]}),e.jsx("span",{className:"truncate",children:i.name})]}):e.jsx("span",{className:"text-muted-foreground font-normal",children:r("dependenciesPage.selector.placeholder")}),e.jsx(dt,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx(ut,{className:"w-[300px] p-0",align:"end",children:e.jsxs(mt,{shouldFilter:!1,children:[e.jsx(gt,{placeholder:r("dependenciesPage.selector.filterPlaceholder"),value:x,onValueChange:d,className:"text-xs"}),e.jsxs(ht,{children:[e.jsx(pt,{className:"py-2 text-center text-xs text-muted-foreground",children:r("dependenciesPage.selector.empty")}),e.jsxs(xt,{children:[n&&e.jsxs(De,{onSelect:()=>{l(),g(!1),d("")},className:"text-muted-foreground",children:[e.jsx(ft,{className:"mr-2 h-3.5 w-3.5"}),r("dependenciesPage.selector.clearSelection")]}),m.map(h=>e.jsxs(De,{value:h.id,onSelect:()=>{c(h.id),g(!1),d("")},children:[e.jsxs("span",{className:"text-muted-foreground font-mono mr-2",children:["#",h.number]}),e.jsx("span",{className:"truncate flex-1",children:h.name}),e.jsx("span",{className:C("text-[9px] px-1 py-0.5 rounded uppercase font-medium ml-2 shrink-0",h.status==="draft"&&"bg-slate-500/20 text-slate-600 dark:text-slate-300",h.status==="planned"&&"bg-blue-500/20 text-blue-600 dark:text-blue-400",h.status==="in-progress"&&"bg-orange-500/20 text-orange-600 dark:text-orange-400",h.status==="complete"&&"bg-green-500/20 text-green-600 dark:text-green-400",h.status==="archived"&&"bg-gray-500/20 text-gray-500 dark:text-gray-400"),children:h.status==="in-progress"?"WIP":h.status.slice(0,3)}),e.jsx("div",{className:C("mr-2 flex h-4 w-4 items-center justify-center",n===h.id?"opacity-100":"opacity-0"),children:e.jsx(bt,{className:"h-4 w-4"})})]},h.id))]})]})]})})]})}const sn={planned:he,"in-progress":Te,complete:Re,archived:Oe},rn={critical:Be,high:Ae,medium:pe,low:Fe},Ke=f.memo(function({data:n}){const{t:c}=Ne(),l=n.isCompact,r=n.isSecondary,a=n.connectionDepth===0?1:n.connectionDepth===1?.95:n.connectionDepth===2?.7:n.isDimmed?.15:1,g=r?.65:1,x=sn[n.tone]||he,d=rn[n.priority]||pe;return e.jsxs("div",{className:C("flex flex-col rounded-lg shadow-lg transition-all duration-200",Kt[n.tone],n.interactive&&"cursor-pointer hover:scale-105 hover:shadow-xl hover:border-gray-400 dark:hover:border-white/50",n.isFocused&&"ring-2 ring-gray-800 dark:ring-white ring-offset-2 ring-offset-background scale-110 z-50",n.connectionDepth===1&&"ring-1 ring-gray-400 dark:ring-white/40",l?"px-2 py-1 gap-0.5":"px-2.5 py-1.5 gap-0.5",r?"border border-dashed":"border-2"),style:{width:l?Pe:Me,opacity:a*g,transform:n.isDimmed?"scale(0.9)":void 0},children:[e.jsx(Ie,{type:"target",position:we.Left,className:"opacity-0"}),e.jsxs("div",{className:"flex items-center justify-between gap-1",children:[e.jsxs("span",{className:C("font-bold",l?"text-[9px]":"text-[10px]"),children:["#",n.number.toString().padStart(3,"0")]}),e.jsxs("div",{className:"flex items-center gap-0.5",children:[e.jsx("div",{className:C("rounded flex items-center justify-center",l?"p-0.5":"p-1",n.tone==="planned"&&"bg-blue-500/30",n.tone==="in-progress"&&"bg-orange-500/30",n.tone==="complete"&&"bg-green-500/30",n.tone==="archived"&&"bg-gray-500/30"),title:c(`status.${n.tone}`),children:e.jsx(x,{className:C(l?"h-2 w-2":"h-2.5 w-2.5")})}),e.jsx("div",{className:C("rounded flex items-center justify-center",l?"p-0.5":"p-1",n.priority==="critical"&&"bg-red-500/30",n.priority==="high"&&"bg-orange-500/30",n.priority==="medium"&&"bg-blue-500/30",n.priority==="low"&&"bg-gray-500/30"),title:n.priority?c(`priority.${n.priority}`):void 0,children:e.jsx(d,{className:C(l?"h-2 w-2":"h-2.5 w-2.5")})}),n.connectionDepth!==void 0&&n.connectionDepth>0&&e.jsx("span",{className:C("font-medium rounded bg-muted/50 text-muted-foreground",l?"text-[7px] px-0.5 py-0.5":"text-[8px] px-1 py-0.5"),title:c("dependenciesPage.graph.levelTitle",{depth:n.connectionDepth}),children:c("dependenciesPage.graph.levelBadge",{depth:n.connectionDepth})})]})]}),e.jsx("span",{className:C("font-medium leading-tight truncate",l?"text-[8px]":"text-[10px]"),title:n.label,children:l?n.shortLabel:n.label}),e.jsx(Ie,{type:"source",position:we.Right,className:"opacity-0"})]})});Ke.displayName="SpecNode";const on={specNode:Ke};function an({nodes:t,edges:n,showStandalone:c,onNodeClick:l,onPaneClick:r,onInstance:a,t:g}){const x=f.useCallback(d=>{a(d),requestAnimationFrame(()=>{d.fitView({padding:.15,duration:300})})},[a]);return t.length===0?e.jsx("div",{className:"flex h-full items-center justify-center text-muted-foreground",children:e.jsxs("div",{className:"text-center",children:[e.jsx("p",{className:"text-sm font-medium",children:g("dependenciesPage.empty.title")}),e.jsx("p",{className:"text-xs mt-1",children:g(c?"dependenciesPage.empty.filters":"dependenciesPage.empty.standaloneHint")})]})}):e.jsxs(yt,{nodes:t,edges:n,nodeTypes:on,onInit:x,className:"h-full w-full",fitView:!0,proOptions:{hideAttribution:!0},nodesDraggable:!0,nodesConnectable:!1,elementsSelectable:!0,panOnScroll:!0,panOnDrag:!0,zoomOnScroll:!0,zoomOnPinch:!0,minZoom:.05,maxZoom:2,onNodeClick:l,onPaneClick:r,children:[e.jsx(Xt,{gap:20,size:1,color:"rgba(100, 116, 139, 0.06)"}),e.jsx(Vt,{showInteractive:!1,className:"!bg-background/90 !border-border !rounded-md"}),e.jsx(Lt,{nodeColor:d=>{const i=d.data;return Qt[i.tone]||"#6b7280"},maskColor:"rgba(128, 128, 128, 0.6)",className:"!bg-white/95 dark:!bg-background/95 !border-border !rounded-md",style:{width:120,height:80},pannable:!0,zoomable:!0})]})}function ln(){const{specName:t,projectId:n}=wt(),c=vt(),[l,r]=Nt(),{t:a}=Ne(),{currentProject:g,loading:x}=jt(),d=!n||g?.id===n,i=l.get("spec"),m=n??g?.id,h=m?`/projects/${m}`:"/projects",N=f.useCallback(o=>`${h}/specs/${o}`,[h]),[s,v]=f.useState(null),[k,P]=f.useState(!0),[M,E]=f.useState(null),[S,T]=f.useState(null),[I,O]=f.useState(!1),[$,Q]=f.useState([]),[b,L]=f.useState(null),[G,xe]=f.useState("graph"),[B,ce]=f.useState(!1),oe=f.useRef(!1),z=f.useRef(null);f.useEffect(()=>{!d||x||(P(!0),kt.getDependencies(t).then(o=>{v(o),ce(o.nodes.length>30)}).catch(o=>E(o instanceof Error?o.message:a("errors:loadingError"))).finally(()=>P(!1)))},[x,d,t,a]),f.useEffect(()=>{if(s&&!oe.current){if(i){const o=s.nodes.find(p=>p.number.toString()===i);o&&(z.current=o.id,L(o.id))}oe.current=!0}},[i,s]),f.useEffect(()=>{if(!s||!oe.current)return;if(z.current!==null){if(b===z.current){z.current=null;return}z.current=null}const o=b?s.nodes.find(w=>w.id===b):null,p=o?o.number.toString():null;if(p!==i){const w=new URLSearchParams(l);p?w.set("spec",p):w.delete("spec"),r(w,{replace:!0})}},[b,s,i,l,r]);const R=f.useMemo(()=>(s?.edges||[]).filter(o=>o.type==="dependsOn"),[s?.edges]),q=f.useMemo(()=>{const o=new Map,p=new Map;return R.forEach(w=>{o.has(w.source)||o.set(w.source,new Set),o.get(w.source).add(w.target),p.has(w.target)||p.set(w.target,new Set),p.get(w.target).add(w.source)}),{upstream:o,downstream:p}},[R]),X=f.useMemo(()=>b?Jt(b,R,1/0):null,[b,R]);f.useEffect(()=>{!b&&G==="focus"&&xe("graph")},[b,G]);const ae=f.useCallback((o,p)=>{const w=new Set,D=[o];for(;D.length>0;){const H=D.shift(),F=p.get(H);F&&F.forEach(A=>{w.has(A)||(w.add(A),D.push(A))})}return w},[]),fe=f.useMemo(()=>{if(!b||!s)return null;const o=s.nodes.find(D=>D.id===b);if(!o)return null;const p=new Map(s.nodes.map(D=>[D.id,D])),w=(D,H)=>{const F=new Set([D]),A=[];let V=new Set([D]),ee=1;for(;V.size>0;){const ie=new Set,re=[];V.forEach(Se=>{const u=H.get(Se);u&&u.forEach(j=>{if(!F.has(j)){F.add(j),ie.add(j);const W=p.get(j);W&&re.push(W)}})}),re.length>0&&A.push({depth:ee,specs:re}),V=ie,ee++}return A};return{node:o,upstream:w(b,q.upstream),downstream:w(b,q.downstream)}},[b,s,q]),Y=f.useMemo(()=>{if(!s)return{nodes:[],edges:[]};const o=G==="focus"&&!!b,p=(u,j)=>({id:u.id,type:"specNode",data:{label:u.name,shortLabel:u.name.length>14?u.name.slice(0,12)+"…":u.name,badge:u.status==="in-progress"?"WIP":u.status.slice(0,3).toUpperCase(),number:u.number,tone:u.status,priority:u.priority,href:N(u.number),interactive:!0,isFocused:j.isFocused,connectionDepth:j.connectionDepth,isDimmed:j.isDimmed,isCompact:B,isSecondary:j.isSecondary},position:{x:0,y:0},draggable:!0,selectable:!0,sourcePosition:we.Right,targetPosition:we.Left});if(o&&b){const u=ae(b,q.upstream),j=ae(b,q.downstream),W=new Set([b,...u,...j]),ne=s.nodes.filter(_=>W.has(_.id)).map(_=>{const de=b===_.id;return p(_,{isFocused:de,connectionDepth:de?0:X?.get(_.id),isDimmed:!1,isSecondary:!1})}),Qe=R.filter(_=>W.has(_.source)&&W.has(_.target)).map(_=>{const de=_.source===b||_.target===b;return{id:`${_.source}-${_.target}-dependsOn`,source:_.source,target:_.target,type:"smoothstep",animated:de,markerEnd:{type:$e.ArrowClosed,color:be,width:18,height:18},style:{stroke:be,strokeWidth:de?2.75:2,opacity:1}}});return He(ne,Qe,B,!1,{mode:"focus",focusedNodeId:b})}const w=s.nodes.filter(u=>$.length===0||$.includes(u.status)),D=new Set(w.map(u=>u.id)),H=new Set(D),F=[...D];for(;F.length>0;){const u=F.shift();R.forEach(j=>{j.source===u&&!H.has(j.target)&&(H.add(j.target),F.push(j.target)),j.target===u&&!H.has(j.source)&&(H.add(j.source),F.push(j.source))})}const A=R.filter(u=>H.has(u.source)&&H.has(u.target));let V=s.nodes.filter(u=>H.has(u.id));if(!I){const u=new Set;A.forEach(j=>{u.add(j.source),u.add(j.target)}),V=V.filter(j=>u.has(j.id))}const ee=new Set(V.map(u=>u.id)),ie=new Set([...ee].filter(u=>!D.has(u))),re=V.map(u=>{const j=b===u.id,W=ie.has(u.id);let te,ne=!1;return b&&(te=X?.get(u.id),ne=te===void 0),p(u,{isFocused:j,connectionDepth:te,isDimmed:ne,isSecondary:W})}),Se=A.filter(u=>ee.has(u.source)&&ee.has(u.target)).map(u=>{let j=!0,W=.7;if(b){const te=X?.get(u.source),ne=X?.get(u.target);j=te!==void 0&&ne!==void 0&&(te===0||ne===0),W=j?1:te!==void 0&&ne!==void 0?.4:.1}return{id:`${u.source}-${u.target}-dependsOn`,source:u.source,target:u.target,type:"smoothstep",animated:j&&b!==null,markerEnd:{type:$e.ArrowClosed,color:be,width:18,height:18},style:{stroke:be,strokeWidth:j?2.5:1.5,opacity:W}}});return He(re,Se,B,I,{mode:"graph"})},[s,R,$,b,X,B,I,q,G,N,ae]),se=f.useMemo(()=>{if(!s)return{connected:0,standalone:0};const o=new Set;return R.forEach(p=>{o.add(p.source),o.add(p.target)}),{connected:o.size,standalone:s.nodes.length-o.size}},[R,s]),je=f.useMemo(()=>{if(!s)return{};const o={};return s.nodes.forEach(p=>{o[p.status]=(o[p.status]||0)+1}),o},[s]);f.useEffect(()=>{if(!S)return;const o=setTimeout(()=>{S.fitView({padding:.15,duration:300})},50);return()=>clearTimeout(o)},[S,Y,$,I]),f.useEffect(()=>{if(!S||!b||!i)return;const o=Y.nodes.find(p=>p.id===b);if(o){const p=setTimeout(()=>{S.setCenter(o.position.x+80,o.position.y+30,{duration:400,zoom:1})},400);return()=>clearTimeout(p)}},[S,b,i,Y.nodes]);const K=f.useCallback((o,p)=>{if(p?.data){if(o.detail===2&&p.data.href){c(p.data.href);return}L(w=>w===p.id?null:p.id)}},[c]),J=f.useCallback(()=>{L(null)},[]),le=o=>{Q(p=>p.includes(o)?p.filter(w=>w!==o):[...p,o]),L(null)},ke=()=>{Q([]),L(null)},U=o=>{if(L(o),S){const p=Y.nodes.find(w=>w.id===o);p&&S.setCenter(p.position.x+80,p.position.y+30,{duration:400,zoom:1})}};return k?e.jsx(St,{}):M||!s?e.jsx(Ee,{children:e.jsx("div",{className:"flex items-center justify-center h-[calc(100vh-10rem)]",children:e.jsxs("div",{className:"text-center",children:[e.jsx("p",{className:"text-lg font-semibold text-destructive mb-2",children:a("dependenciesPage.state.errorTitle")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:M||a("dependenciesPage.state.errorDescription")})]})})}):s.nodes.length===0?e.jsx(Ee,{children:e.jsxs("div",{className:"rounded-lg border border-border bg-muted/30 p-8 text-center",children:[e.jsx("h2",{className:"text-xl font-semibold mb-2",children:a("dependenciesPage.empty.noDependencies")}),e.jsx("p",{className:"text-muted-foreground",children:a("dependenciesPage.empty.noDependenciesDescription")})]})}):e.jsx(Ee,{className:"h-[calc(100vh-7rem)]",contentClassName:"flex h-full flex-col gap-4",children:e.jsxs("div",{className:"flex h-full flex-col gap-4",children:[e.jsx(Et,{title:a("dependenciesPage.title"),description:a("dependenciesPage.description"),actions:e.jsx(nn,{data:s,focusedNodeId:b,onSelectSpec:U,onClearSelection:()=>L(null),t:a})}),e.jsx("div",{className:"text-sm text-muted-foreground",children:se.connected>0?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-emerald-600 dark:text-emerald-400",children:a("dependenciesPage.header.summary.connected",{count:se.connected})}),se.standalone>0&&e.jsxs(e.Fragment,{children:[" • ",e.jsx("span",{className:"text-muted-foreground",children:a("dependenciesPage.header.summary.standalone",{count:se.standalone})})]})]}):e.jsx("span",{children:a("dependenciesPage.header.summary.none")})}),e.jsx(tn,{statusFilter:$,statusCounts:je,showStandalone:I,isCompact:B,viewMode:G,focusedNodeId:b,connectionStats:se,onToggleStatus:le,onToggleStandalone:()=>O(!I),onToggleCompact:()=>ce(!B),onToggleViewMode:()=>xe(o=>o==="graph"?"focus":"graph"),onClear:ke,t:a}),e.jsxs("div",{className:"flex flex-1 gap-3 min-h-0",children:[e.jsx("div",{className:"flex-1 overflow-hidden rounded-lg border border-border bg-gray-50 dark:bg-[#080c14]",children:e.jsx(an,{nodes:Y.nodes,edges:Y.edges,showStandalone:I,onNodeClick:K,onPaneClick:J,onInstance:T,t:a})}),e.jsx(Yt,{focusedDetails:fe,onSelectSpec:L,onOpenSpec:o=>c(N(o))})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-4 text-[10px] text-muted-foreground",children:[e.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[e.jsx("span",{className:"inline-block h-0.5 w-6 bg-amber-400 rounded"}),a("dependenciesPage.legend.dependsOn")]}),e.jsx("span",{className:"text-muted-foreground/50 ml-auto",children:a("dependenciesPage.legend.instructions")})]})]})})}export{ln as DependenciesPage};
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import{h as P,cf as ke,u as Ce,bg as Le,bh as De,r,c7 as f,cg as te,ch as Ee,ci as Pe,cj as Te,ck as $e,bv as Me,cl as ze,cm as Ie,j as e,bs as Ae,cn as ae,c8 as ne,a as l,bq as Re,B as v,f as x,bu as re,co as _e,cp as Oe,cq as Fe,bF as Ue,bG as ie,bH as qe,bn as oe,cr as le,bV as ce,cs as de,ct as Je,cu as Ve,cv as me,cw as Be,cx as ue,cy as He}from"./index-DSWQaVP_.js";import{P as We}from"./page-transition-BMYHE1EG.js";import{S as Qe}from"./session-mode-badge-auIgZbxq.js";const Ze=[["path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2",key:"169zse"}]],Ge=P("activity",Ze);const Xe=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 12.5 8 15l2 2.5",key:"1tg20x"}],["path",{d:"m14 12.5 2 2.5-2 2.5",key:"yinavb"}]],xe=P("file-code",Xe);const Ye=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}]],Ke=P("panel-left",Ye);function es(){return ke()}const E=new Set(["pending","running","paused"]);function rs(){const{t:n}=Ce("common"),{sessionId:d,projectId:N}=Le(),{currentProject:T,loading:b}=De(),$=N??T?.id,M=$?`/projects/${$}`:"/projects",w=!N||T?.id===N,[a,z]=r.useState(null),[S,I]=r.useState([]),[A,R]=r.useState([]),[pe,_]=r.useState(!0),[k,O]=r.useState(!0),[F,U]=r.useState(null),[q,he]=r.useState(null),[fe,J]=r.useState(new Set),[p,V]=r.useState(""),[j,ge]=r.useState("messages"),[B,H]=r.useState(!1),[ve,be]=r.useState(()=>Date.now()),C=r.useRef(null),{setMobileOpen:we}=es(),c=r.useCallback(async(s=!1)=>{if(!(!d||!w||b)){s||_(!0);try{const t=await f.getSession(d);z(t),U(null)}catch(t){U(t instanceof Error?t.message:n("sessions.errors.load"))}finally{s||_(!1)}}},[b,w,d,n]),h=r.useCallback(async(s=!1)=>{if(!(!d||!w||b)){s||O(!0);try{const t=await f.getSessionLogs(d);I(t);const i=t.reduce((o,L)=>te(o,Ee(L)),[]);R(Pe(i))}finally{s||O(!1)}}},[b,w,d]);r.useEffect(()=>{c(),h()},[c,h]),r.useEffect(()=>{if(!a||!E.has(a.status))return;const t=window.location.origin.replace(/^http/,"ws")+`/api/sessions/${a.id}/stream`,i=new WebSocket(t);return i.onmessage=o=>{try{const L=JSON.parse(o.data),u=Te(L);u&&(R(D=>te(D,u)),u.type==="log"&&I(D=>[...D,{id:Date.now(),timestamp:u.timestamp,level:u.level,message:u.message}]),u.type==="complete"&&(c(!0),h(!0)))}catch{}},()=>i.close()},[a,c,h]),r.useEffect(()=>{if(!a||!E.has(a.status))return;const s=window.setInterval(()=>{c(!0),h(!0)},2e3);return()=>window.clearInterval(s)},[h,c,a]),r.useEffect(()=>{if(!a||!E.has(a.status))return;const s=window.setInterval(()=>{be(Date.now())},1e3);return()=>window.clearInterval(s)},[a]),r.useEffect(()=>{const s=C.current;if(!s)return;const t=s.querySelector("[data-radix-scroll-area-viewport]");t?t.scrollTop=t.scrollHeight:s.scrollTop=s.scrollHeight},[S]);const m=$e(a),y=j==="verbose",g=r.useMemo(()=>{const s=p.trim().toLowerCase();return S.filter(t=>!(!y&&t.message.includes("Session still running")||s&&!`${t.level} ${t.message}`.toLowerCase().includes(s)))},[S,p,y]),W=r.useMemo(()=>{if(!m)return[];const s=p.trim().toLowerCase();return A.filter(t=>j==="messages"&&t.type==="log"||t.type==="log"&&!y&&t.message.includes("Session still running")?!1:s?t.type==="acp_message"||t.type==="acp_thought"?t.content.toLowerCase().includes(s):t.type==="acp_tool_call"?`${t.tool} ${JSON.stringify(t.args)} ${JSON.stringify(t.result??"")}`.toLowerCase().includes(s):t.type==="acp_plan"?t.entries.some(i=>i.title.toLowerCase().includes(s)):!1:!0)},[m,p,A,y,j]),Q=a?Me(a,ve):null,Z=a?ze(a.tokenCount):null,G=a?Ie(a.tokenCount):null,je=s=>s.length>12?s.slice(0,8):s,X=async()=>{a&&(await f.stopSession(a.id),await c())},ye=async()=>{a&&(await f.pauseSession(a.id),await c())},Ne=async()=>{a&&(await f.resumeSession(a.id),await c())},Y=()=>m?JSON.stringify(W,null,2):g.map(s=>`[${s.timestamp}] ${s.level.toUpperCase()} ${s.message}`).join(`
|
|
2
|
-
`),K=()=>{const s=Y(),t=new Blob([s],{type:m?"application/json;charset=utf-8":"text/plain;charset=utf-8"}),i=URL.createObjectURL(t),o=document.createElement("a");o.href=i,o.download=`session-${d??n("sessions.export.fallbackName")}.${m?"json":"txt"}`,document.body.appendChild(o),o.click(),o.remove(),URL.revokeObjectURL(i)},ee=5e5,se=async()=>{const s=Y(),t=s.length>ee?s.slice(0,ee)+`
|
|
3
|
-
|
|
4
|
-
… (truncated)`:s;await navigator.clipboard.writeText(t),H(!0),setTimeout(()=>H(!1),2e3)},Se=async(s,t)=>{if(a){J(i=>{const o=new Set(i);return o.add(s),o});try{const i=await f.respondToSessionPermission(a.id,s,t);z(i)}catch(i){he(i instanceof Error?i.message:n("sessions.errors.load"))}finally{J(i=>{const o=new Set(i);return o.delete(s),o})}}};return pe?e.jsx("div",{className:"flex-1 min-w-0 py-10 text-center text-sm text-muted-foreground",children:n("actions.loading")}):F||!a?e.jsx("div",{className:"flex-1 min-w-0 flex items-center justify-center",children:e.jsx(Ae,{icon:ae,title:n("sessionDetail.state.notFoundTitle"),description:F||n("sessionDetail.state.notFoundDescription"),tone:"error",actions:e.jsx(ne,{to:`${M}/sessions`,className:"inline-flex",children:e.jsx(l,{variant:"outline",size:"sm",className:"gap-2",children:n("sessions.actions.back")})})})}):e.jsx(We,{className:"flex-1 min-w-0",children:e.jsxs("div",{className:"h-[calc(100vh-3.5rem)] flex flex-col",children:[e.jsx("header",{className:"shrink-0 border-b bg-card",children:e.jsxs("div",{className:"px-4 sm:px-6 py-2 sm:py-3",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1.5 sm:mb-2",children:[e.jsx(l,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0 lg:hidden shrink-0",onClick:()=>we(!0),children:e.jsx(Ke,{className:"h-4 w-4"})}),e.jsx(Re,{runnerId:a.runner,size:24}),e.jsx("h1",{className:"text-lg sm:text-xl font-bold tracking-tight",children:n("sessionDetail.title",{id:je(a.id)})})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-xs",children:[e.jsxs(v,{variant:"outline",className:x("flex items-center gap-1.5 w-fit border-transparent h-5 px-2 py-0.5 text-xs font-medium",re[a.status].className),children:[(()=>{const s=re[a.status].icon;return e.jsx(s,{className:"h-3.5 w-3.5"})})(),n(`sessions.status.${a.status}`)]}),e.jsx(Qe,{mode:a.mode}),e.jsxs(v,{variant:"outline",className:"flex items-center gap-1.5 w-fit border-transparent h-5 px-2 py-0.5 text-xs font-medium bg-secondary text-secondary-foreground",children:[e.jsx(Ge,{className:"h-3.5 w-3.5"}),n(m?"sessions.labels.protocolAcp":"sessions.labels.protocolCli")]}),Q&&e.jsxs(v,{variant:"outline",className:"flex items-center gap-1.5 w-fit border-transparent h-5 px-2 py-0.5 text-xs font-medium bg-secondary text-secondary-foreground",children:[e.jsx(_e,{className:"h-3.5 w-3.5"}),Q]}),Z&&e.jsxs(v,{variant:"outline",className:"flex items-center gap-1.5 w-fit border-transparent h-5 px-2 py-0.5 text-xs font-medium bg-secondary text-secondary-foreground",children:[e.jsx(Oe,{className:"h-3.5 w-3.5"}),Z]}),G!=null&&e.jsxs(v,{variant:"outline",className:"flex items-center gap-1.5 w-fit border-transparent h-5 px-2 py-0.5 text-xs font-medium bg-secondary text-secondary-foreground",children:[e.jsx(Fe,{className:"h-3.5 w-3.5"}),n("sessions.labels.costApprox",{value:G.toFixed(2)})]})]}),a.specIds&&a.specIds.length>0&&e.jsxs("div",{className:"flex flex-wrap gap-2 text-xs text-muted-foreground mt-1.5",children:[e.jsxs("span",{children:[n("sessions.labels.specs"),":"]}),a.specIds.map(s=>e.jsx(ne,{to:`${M}/specs/${s}`,className:"hover:text-primary hover:underline font-medium",children:s},s))]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2 mt-2",children:[a.status==="running"&&e.jsxs(e.Fragment,{children:[e.jsxs(l,{type:"button",variant:"outline",size:"sm",onClick:()=>{ye()},className:"h-8 rounded-full border px-3 text-xs font-medium text-muted-foreground transition-colors hover:text-foreground",children:[e.jsx(Ue,{className:"mr-1.5 h-3.5 w-3.5"}),n("sessions.actions.pause")]}),e.jsxs(l,{type:"button",variant:"outline",size:"sm",onClick:()=>{X()},className:"h-8 rounded-full border px-3 text-xs font-medium text-destructive transition-colors hover:bg-destructive/10",children:[e.jsx(ie,{className:"mr-1.5 h-3.5 w-3.5"}),n("sessions.actions.stop")]})]}),a.status==="paused"&&e.jsxs(e.Fragment,{children:[e.jsxs(l,{type:"button",variant:"outline",size:"sm",onClick:()=>{Ne()},className:"h-8 rounded-full border px-3 text-xs font-medium text-muted-foreground transition-colors hover:text-foreground",children:[e.jsx(qe,{className:"mr-1.5 h-3.5 w-3.5"}),n("sessions.actions.resume")]}),e.jsxs(l,{type:"button",variant:"outline",size:"sm",onClick:()=>{X()},className:"h-8 rounded-full border px-3 text-xs font-medium text-destructive transition-colors hover:bg-destructive/10",children:[e.jsx(ie,{className:"mr-1.5 h-3.5 w-3.5"}),n("sessions.actions.stop")]})]}),!1]})]})}),q&&e.jsxs("div",{className:"rounded-md border border-destructive/30 bg-destructive/10 px-4 py-3 text-sm text-destructive font-medium flex items-center gap-2",children:[e.jsx(ae,{className:"h-4 w-4"}),q]}),e.jsx("div",{className:"flex-1 min-h-0 flex flex-col overflow-hidden w-full",children:m?e.jsxs(Je,{value:j,onValueChange:s=>ge(s),className:"flex-1 flex flex-col min-h-0",children:[e.jsxs("div",{className:"border-b px-4 py-2 flex items-center justify-between bg-muted/20 gap-4",children:[e.jsx("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:e.jsxs("div",{className:"relative flex-1 max-w-sm",children:[e.jsx(oe,{className:"absolute left-2.5 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-muted-foreground"}),e.jsx("input",{value:p,onChange:s=>V(s.target.value),placeholder:n("sessionDetail.filters.search"),className:"h-8 w-full rounded-md border border-border bg-background pl-8 pr-3 text-xs focus:outline-none focus:ring-1 focus:ring-ring"})]})}),e.jsxs("div",{className:"flex items-center gap-2 justify-end",children:[e.jsxs(Ve,{className:"h-8 bg-muted/50 p-0.5",children:[e.jsx(me,{value:"messages",className:"text-xs h-7 px-3 data-[state=active]:bg-background data-[state=active]:shadow-sm",children:e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(Be,{className:"h-3.5 w-3.5"}),e.jsx("span",{children:n("sessionDetail.displayMode.messages")})]})}),e.jsx(me,{value:"verbose",className:"text-xs h-7 px-3 data-[state=active]:bg-background data-[state=active]:shadow-sm",children:e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(xe,{className:"h-3.5 w-3.5"}),e.jsx("span",{children:n("sessionDetail.displayMode.verbose")})]})})]}),e.jsx("div",{className:"h-4 w-px bg-border mx-1"}),e.jsx(l,{size:"sm",variant:"ghost",className:"h-8 w-8 p-0",onClick:K,title:n("sessionDetail.actions.download"),children:e.jsx(le,{className:"h-4 w-4"})}),e.jsx(l,{size:"sm",variant:"ghost",className:x("h-8 w-8 p-0",B&&"text-emerald-500"),onClick:()=>{se()},title:n("sessionDetail.actions.copyLogs"),children:e.jsx(ce,{className:"h-4 w-4"})})]})]}),e.jsx(ue,{value:"messages",className:"flex-1 min-h-0 mt-0 data-[state=inactive]:hidden relative",children:e.jsx("div",{className:"absolute inset-0",children:e.jsx(He,{className:"h-full border-0 rounded-none bg-transparent",events:W,loading:k,emptyTitle:n("sessions.emptyLogs"),emptyDescription:n("sessionDetail.logsDescription"),onPermissionResponse:(s,t)=>{Se(s,t)},isPermissionResponding:s=>fe.has(s)})})}),e.jsx(ue,{value:"verbose",className:"flex-1 min-h-0 mt-0 data-[state=inactive]:hidden relative h-full",children:e.jsx(de,{className:"h-full bg-background",ref:C,children:e.jsx("div",{className:"p-4 font-mono text-xs",children:k?e.jsx("div",{className:"text-muted-foreground",children:n("actions.loading")}):g.length===0?e.jsx("div",{className:"text-muted-foreground text-center italic opacity-60 py-8",children:n("sessions.emptyLogs")}):g.map(s=>{const t=s.message.trim().startsWith("{")||s.message.trim().startsWith("[");return e.jsxs("div",{className:"mb-0.5 group hover:bg-muted/30 -mx-4 px-4 py-1 flex gap-3 items-start border-l-2 border-transparent",children:[e.jsxs("span",{className:"text-muted-foreground/40 whitespace-nowrap select-none w-24 shrink-0 text-[10px] pt-0.5 text-right font-light tabular-nums",children:[new Date(s.timestamp).toLocaleTimeString([],{hour12:!1,hour:"2-digit",minute:"2-digit",second:"2-digit"}),".",e.jsx("span",{className:"opacity-50",children:new Date(s.timestamp).getMilliseconds().toString().padStart(3,"0")})]}),e.jsx("span",{className:x("uppercase text-[10px] font-bold w-14 shrink-0 pt-0.5 select-none text-center rounded-sm bg-muted/30",s.level==="error"?"text-rose-600 bg-rose-500/10 dark:text-rose-400":s.level==="warn"?"text-amber-600 bg-amber-500/10 dark:text-amber-400":s.level==="info"?"text-sky-600 bg-sky-500/10 dark:text-sky-400":s.level==="debug"?"text-violet-600 bg-violet-500/10 dark:text-violet-400":"text-muted-foreground"),children:s.level}),e.jsx("div",{className:x("flex-1 min-w-0 break-all whitespace-pre-wrap leading-relaxed",t&&"text-emerald-600 dark:text-emerald-400"),children:s.message})]},`${s.id}-${s.timestamp}`)})})})})]}):e.jsxs("div",{className:"flex-1 flex flex-col min-h-0",children:[e.jsxs("div",{className:"border-b px-4 py-2 flex items-center justify-between bg-muted/20 gap-4",children:[e.jsx("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:e.jsxs("div",{className:"relative flex-1 max-w-sm",children:[e.jsx(oe,{className:"absolute left-2.5 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-muted-foreground"}),e.jsx("input",{value:p,onChange:s=>V(s.target.value),placeholder:n("sessionDetail.filters.search"),className:"h-8 w-full rounded-md border border-border bg-background pl-8 pr-3 text-xs focus:outline-none focus:ring-1 focus:ring-ring"})]})}),e.jsxs("div",{className:"flex items-center gap-2 justify-end",children:[e.jsxs("div",{className:"flex items-center gap-2 font-medium text-sm text-muted-foreground mr-2",children:[e.jsx(xe,{className:"h-4 w-4"}),e.jsx("span",{children:"Verbose Logs"})]}),e.jsx("div",{className:"h-4 w-px bg-border mx-1"}),e.jsx(l,{size:"sm",variant:"ghost",className:"h-8 w-8 p-0",onClick:K,title:n("sessionDetail.actions.download"),children:e.jsx(le,{className:"h-4 w-4"})}),e.jsx(l,{size:"sm",variant:"ghost",className:x("h-8 w-8 p-0",B&&"text-emerald-500"),onClick:()=>{se()},title:n("sessionDetail.actions.copyLogs"),children:e.jsx(ce,{className:"h-4 w-4"})})]})]}),e.jsx(de,{className:"flex-1 h-full bg-background",ref:C,children:e.jsx("div",{className:"p-4 font-mono text-xs",children:k?e.jsx("div",{className:"text-muted-foreground",children:n("actions.loading")}):g.length===0?e.jsx("div",{className:"text-muted-foreground text-center italic opacity-60 py-8",children:n("sessions.emptyLogs")}):g.map(s=>{const t=s.message.trim().startsWith("{")||s.message.trim().startsWith("[");return e.jsxs("div",{className:"mb-0.5 group hover:bg-muted/30 -mx-4 px-4 py-1 flex gap-3 items-start border-l-2 border-transparent",children:[e.jsxs("span",{className:"text-muted-foreground/40 whitespace-nowrap select-none w-24 shrink-0 text-[10px] pt-0.5 text-right font-light tabular-nums",children:[new Date(s.timestamp).toLocaleTimeString([],{hour12:!1,hour:"2-digit",minute:"2-digit",second:"2-digit"}),".",e.jsx("span",{className:"opacity-50",children:new Date(s.timestamp).getMilliseconds().toString().padStart(3,"0")})]}),e.jsx("span",{className:x("uppercase text-[10px] font-bold w-14 shrink-0 pt-0.5 select-none text-center rounded-sm bg-muted/30",s.level==="error"?"text-rose-600 bg-rose-500/10 dark:text-rose-400":s.level==="warn"?"text-amber-600 bg-amber-500/10 dark:text-amber-400":s.level==="info"?"text-sky-600 bg-sky-500/10 dark:text-sky-400":s.level==="debug"?"text-violet-600 bg-violet-500/10 dark:text-violet-400":"text-muted-foreground"),children:s.level}),e.jsx("div",{className:x("flex-1 min-w-0 break-all whitespace-pre-wrap leading-relaxed",t&&"text-emerald-600 dark:text-emerald-400"),children:s.message})]},`${s.id}-${s.timestamp}`)})})})]})})]})})}export{rs as SessionDetailPage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{u as Z,r,j as s,b5 as Ns,b6 as vs,a as m,b7 as ys,b8 as Cs,b9 as ws,ba as Ss,bb as Ps,bc as ks,bd as Ds,be as Fs,bf as Ts,f as _,bg as Rs,bh as Is,bi as Ls,bj as zs,bk as Ms,bl as Bs,aS as X,C as Y,l as K,bm as As,aW as $s,bn as Os,b0 as Es,bo as Vs,aX as I,aY as L,aZ as z,a_ as M,a$ as p,bp as rs,bq as ns,br as qs,bs as ss,bt as Qs,aP as Gs,bu as Hs,bv as Xs,bw as Zs,bx as _s,by as Js,bz as Us,B as es,bA as Ws,bB as Ys,bC as Ks,bD as se,bE as ee,bF as ae,bG as as,bH as te,bI as re,bJ as ts}from"./index-DSWQaVP_.js";import{P as ne}from"./page-transition-BMYHE1EG.js";import{S as le}from"./session-mode-badge-auIgZbxq.js";import{F as ie,a as oe}from"./funnel-x-DD5BpUpW.js";import{R as ce}from"./refresh-ccw-CqpLwlfM.js";function de({value:a,onValueChange:t,options:x,placeholder:g,searchPlaceholder:h,emptyText:f}){const{t:i}=Z("common"),[j,b]=r.useState(!1);return s.jsxs(Ns,{open:j,onOpenChange:b,children:[s.jsx(vs,{asChild:!0,children:s.jsxs(m,{variant:"outline",role:"combobox","aria-expanded":j,className:"w-full justify-between font-normal",children:[a?x.find(d=>d.value===a)?.label??a:g??i("sessions.select.placeholder"),s.jsx(ys,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),s.jsx(Cs,{className:"w-[--radix-popover-trigger-width] p-0",align:"start",children:s.jsxs(ws,{children:[s.jsx(Ss,{placeholder:h??i("sessions.select.search")}),s.jsxs(Ps,{children:[s.jsx(ks,{children:f??i("sessions.select.empty")}),s.jsx(Ds,{children:x.map(d=>s.jsxs(Fs,{value:d.label,className:"cursor-pointer",onSelect:()=>{t(d.value),b(!1)},children:[s.jsx(Ts,{className:_("mr-2 h-4 w-4",a===d.value?"opacity-100":"opacity-0")}),d.label]},d.value))})]})]})})]})}const N=20;function ue(a){if(a.status==="running"||a.status==="pending")return"active";const t=ts(a.startedAt),g=ts().startOf("day"),h=g.subtract(1,"day"),f=t.startOf("day");return f.isSame(g)?"today":f.isSame(h)?"yesterday":"older"}function me(a){const t={active:[],today:[],yesterday:[],older:[]};return a.forEach(x=>{t[ue(x)].push(x)}),t}function be(){const{t:a}=Z("common"),{projectId:t}=Rs(),{currentProject:x,loading:g}=Is(),h=t??x?.id,f=h?`/projects/${h}`:"/projects",i=Ls(h??null),j=zs(h??null),{stopSession:b,pauseSession:d,resumeSession:D}=Ms(h??null),u=r.useMemo(()=>i.data??[],[i.data]),w=r.useMemo(()=>j.data??[],[j.data]),F=g||i.isLoading,T=i.error?a("sessions.errors.load"):null,[B]=Bs(),[v,A]=r.useState(""),[n,S]=r.useState("all"),[P,ls]=r.useState("all"),[k,is]=r.useState("all"),[C,os]=r.useState(()=>B.get("spec")??"all"),[$,cs]=r.useState("started-desc"),[ds,y]=r.useState(N),[us,O]=r.useState(!1),E=r.useCallback(e=>{A(e),y(N)},[]),V=r.useCallback(e=>{S(e),y(N)},[]),q=r.useCallback(e=>{ls(e),y(N)},[]),Q=r.useCallback(e=>{is(e),y(N)},[]),G=r.useCallback(e=>{os(e),y(N)},[]),ms=r.useCallback(e=>{cs(e),y(N)},[]),H=r.useCallback(async()=>{await i.refetch(),await j.refetch()},[i,j]),xs=r.useMemo(()=>{const e=u.map(o=>o.status).filter(Boolean);return Array.from(new Set(e))},[u]),hs=r.useMemo(()=>{const e=u.map(o=>o.runner).filter(Boolean);return Array.from(new Set(e))},[u]),ps=r.useMemo(()=>{const e=u.map(o=>o.mode).filter(Boolean);return Array.from(new Set(e))},[u]),gs=r.useMemo(()=>w.map(e=>({id:e.specName,label:e.specNumber?`#${e.specNumber} ${e.title??e.specName}`:e.title??e.specName})).sort((e,o)=>e.label.localeCompare(o.label)),[w]),R=r.useMemo(()=>{const o=[...u.filter(l=>{if(v){const c=v.toLowerCase();if(!(l.id.toLowerCase().includes(c)||(l.specIds?.some(W=>W.toLowerCase().includes(c))??!1)||l.runner.toLowerCase().includes(c)||(l.prompt?.toLowerCase().includes(c)??!1)))return!1}return!(n!=="all"&&l.status!==n||P!=="all"&&l.runner!==P||k!=="all"&&l.mode!==k||C!=="all"&&(!l.specIds?.length||!l.specIds.some(c=>c===C||c.includes(C))))})];switch($){case"started-asc":o.sort((l,c)=>new Date(l.startedAt).getTime()-new Date(c.startedAt).getTime());break;case"duration-desc":o.sort((l,c)=>{const U=l.durationMs??0;return(c.durationMs??0)-U});break;case"status":o.sort((l,c)=>l.status.localeCompare(c.status));break;default:o.sort((l,c)=>new Date(c.startedAt).getTime()-new Date(l.startedAt).getTime());break}return o},[k,v,u,$,C,n,P]),J=R.slice(0,ds),js=r.useCallback(async e=>{await b(e)},[b]),fs=r.useCallback(async e=>{await d(e)},[d]),bs=r.useCallback(async e=>{await D(e)},[D]);return F?s.jsx(X,{children:s.jsx(Y,{children:s.jsx(K,{className:"py-10 text-center text-sm text-muted-foreground",children:a("actions.loading")})})}):T?s.jsx(X,{children:s.jsx(Y,{children:s.jsxs(K,{className:"py-10 text-center space-y-3",children:[s.jsx("div",{className:"text-lg font-semibold",children:a("sessionsPage.state.errorTitle")}),s.jsx("p",{className:"text-sm text-muted-foreground",children:T}),s.jsx(m,{variant:"secondary",size:"sm",onClick:H,className:"mt-2",children:a("actions.retry")})]})})}):s.jsxs(ne,{className:_("flex-1 min-w-0"),children:[s.jsxs(X,{className:"h-[calc(100vh-3.5rem)]",contentClassName:"flex h-full flex-col gap-4",children:[s.jsxs("div",{className:"flex flex-col gap-4 sticky top-0 bg-background mt-0 py-2 z-10",children:[s.jsx(As,{title:a("sessionsPage.title"),description:a("sessionsPage.description"),actions:s.jsxs(m,{size:"sm",variant:"outline",className:"gap-2",onClick:()=>O(!0),children:[s.jsx($s,{className:"h-4 w-4"}),a("sessions.actions.new")]})}),s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"relative",children:[s.jsx(Os,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 w-4 h-4 text-muted-foreground"}),s.jsx(Es,{value:v,onChange:e=>E(e.target.value),placeholder:a("sessionsPage.filters.search"),className:"w-full pl-10 pr-4 py-2"})]}),s.jsxs("div",{className:"flex flex-wrap gap-3 items-center",children:[s.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[s.jsx(Vs,{className:"w-4 h-4"}),s.jsx("span",{className:"text-sm font-medium",children:a("specsNavSidebar.filtersLabel")})]}),s.jsxs(I,{value:n,onValueChange:V,children:[s.jsx(L,{className:"w-[140px] h-9",children:s.jsx(z,{placeholder:a("sessionsPage.filters.status")})}),s.jsxs(M,{children:[s.jsx(p,{value:"all",className:"cursor-pointer",children:a("sessionsPage.filters.status")}),xs.map(e=>s.jsx(p,{value:e,className:"cursor-pointer",children:a(`sessions.status.${e}`)},e))]})]}),s.jsxs(I,{value:P,onValueChange:q,children:[s.jsx(L,{className:"w-[140px] h-9",children:s.jsx(z,{placeholder:a("sessionsPage.filters.runner")})}),s.jsxs(M,{children:[s.jsx(p,{value:"all",className:"cursor-pointer",children:a("sessionsPage.filters.runner")}),hs.map(e=>s.jsx(p,{value:e,className:"cursor-pointer",children:s.jsxs("span",{className:"flex items-center gap-2",children:[s.jsx(ns,{runnerId:e,size:16}),rs(e,a)]})},e))]})]}),s.jsxs(I,{value:k,onValueChange:Q,children:[s.jsx(L,{className:"w-[140px] h-9",children:s.jsx(z,{placeholder:a("sessionsPage.filters.mode")})}),s.jsxs(M,{children:[s.jsx(p,{value:"all",className:"cursor-pointer",children:a("sessionsPage.filters.mode")}),ps.map(e=>s.jsx(p,{value:e,className:"cursor-pointer",children:a(`sessions.modes.${e}`)},e))]})]}),s.jsx("div",{className:"w-[180px]",children:s.jsx(de,{value:C,onValueChange:G,options:[{value:"all",label:a("sessionsPage.filters.spec")},...gs.map(e=>({value:e.id,label:e.label}))],placeholder:a("sessionsPage.filters.spec"),searchPlaceholder:a("sessions.select.search"),emptyText:a("sessions.select.empty")})}),s.jsxs(I,{value:$,onValueChange:e=>ms(e),children:[s.jsx(L,{className:"w-[160px] h-9",children:s.jsx(z,{placeholder:a("sessionsPage.sort.startedDesc")})}),s.jsxs(M,{children:[s.jsx(p,{value:"started-desc",className:"cursor-pointer",children:a("sessionsPage.sort.startedDesc")}),s.jsx(p,{value:"started-asc",className:"cursor-pointer",children:a("sessionsPage.sort.startedAsc")}),s.jsx(p,{value:"duration-desc",className:"cursor-pointer",children:a("sessionsPage.sort.durationDesc")}),s.jsx(p,{value:"status",className:"cursor-pointer",children:a("sessionsPage.sort.status")})]})]}),(v||n!=="all"||P!=="all"||k!=="all"||C!=="all")&&s.jsxs(m,{onClick:()=>{E(""),V("all"),q("all"),Q("all"),G("all")},variant:"ghost",size:"sm",className:"h-9 gap-1",children:[s.jsx(qs,{className:"w-4 h-4"}),a("specsNavSidebar.clearFilters")]}),s.jsx("span",{className:"text-sm text-muted-foreground",children:a("specsPage.filters.filteredCount",{filtered:R.length,total:u.length})})]})]})]}),s.jsx("div",{className:"flex-1 min-h-0",children:u.length===0?s.jsx(ss,{icon:ie,title:a("sessionsPage.state.emptyTitle"),description:a("sessionsPage.state.emptyDescription"),actions:s.jsx(m,{variant:"secondary",size:"sm",onClick:()=>O(!0),children:a("sessions.actions.new")})}):R.length===0?s.jsx(ss,{icon:oe,title:a("sessionsPage.state.noResultsTitle"),description:a("sessionsPage.state.noResultsDescription"),actions:s.jsxs("div",{className:"flex gap-2 flex-wrap justify-center",children:[s.jsx(m,{variant:"outline",size:"sm",onClick:()=>{E(""),V("all"),q("all"),Q("all"),G("all")},children:a("specsNavSidebar.clearFilters")}),s.jsxs(m,{variant:"secondary",size:"sm",onClick:H,children:[s.jsx(ce,{className:"h-4 w-4 mr-2"}),a("sessionsPage.buttons.refresh")]})]})}):s.jsxs("div",{className:"space-y-6",children:[["active","today","yesterday","older"].map(e=>{const o=me(J)[e];return o.length===0?null:s.jsxs("section",{className:"space-y-2",children:[s.jsxs("h3",{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:[a(`sessionsPage.groups.${e}`)," (",o.length,")"]}),s.jsx("div",{className:"space-y-2",children:o.map(l=>s.jsx(xe,{session:l,basePath:f,onStop:js,onPause:fs,onResume:bs},l.id))})]},e)}),J.length<R.length&&s.jsx("div",{className:"flex justify-center",children:s.jsx(m,{variant:"outline",size:"sm",onClick:()=>y(e=>e+N),children:a("sessionsPage.buttons.loadMore")})})]})})]}),s.jsx(Qs,{open:us,onOpenChange:O,projectPath:x?.path,onCreated:()=>{H()}})]})}const xe=r.memo(function({session:t,basePath:x,onStop:g,onPause:h,onResume:f}){const{t:i,i18n:j}=Z("common"),b=Gs(),d=Hs[t.status],D=d.icon,u=Xs(t),[w,F]=r.useState(!1),T=t.prompt||t.id.slice(0,8),B=t.status==="running"||t.status==="paused",v=n=>{n.target.closest("button, a")||b(`${x}/sessions/${t.id}`)},A=n=>{n.stopPropagation(),F(S=>!S)};return s.jsx("div",{className:"block border rounded-lg hover:bg-secondary/50 transition-colors bg-background cursor-pointer",onClick:v,children:s.jsxs("div",{className:"flex items-start",children:[s.jsx("div",{className:"w-8 h-full invisible flex items-center text-muted-foreground"}),s.jsxs("div",{className:"flex-1 p-4 pl-0",children:[s.jsxs("div",{className:"flex items-start justify-between gap-4 mb-2",children:[s.jsxs("div",{className:"flex items-start gap-2 min-w-0 pr-4",children:[s.jsx(Zs,{children:s.jsxs(_s,{children:[s.jsx(Js,{asChild:!0,children:s.jsx("span",{className:"flex-shrink-0 mt-0.5",children:s.jsx(ns,{runnerId:t.runner,size:24})})}),s.jsx(Us,{children:rs(t.runner,i)})]})}),s.jsx("div",{children:s.jsx("h3",{className:"font-medium line-clamp-2 leading-relaxed",children:T})})]}),s.jsxs("div",{className:"flex gap-2 items-center flex-shrink-0 flex-wrap justify-end",children:[s.jsxs(es,{variant:"outline",className:_("flex items-center gap-1.5 w-fit border-transparent h-6 px-2 py-0.5 text-xs font-medium",d.className),children:[s.jsx(D,{className:"h-3.5 w-3.5"}),i(`sessions.status.${t.status}`)]}),s.jsx(le,{mode:t.mode})]})]}),s.jsx("div",{className:"mb-3 flex items-center gap-2 flex-wrap",children:!t.specIds||t.specIds.length===0?s.jsx("span",{className:"text-xs text-muted-foreground italic",children:i("sessionsPage.labels.noSpecs","No specs")}):t.specIds.map(n=>s.jsxs(es,{variant:"secondary",className:"flex items-center gap-1 text-xs hover:bg-secondary/80 cursor-pointer",onClick:S=>{S.stopPropagation(),b(`${x}/specs/${n}`)},children:[s.jsx(Ws,{className:"h-3 w-3"}),n]},n))}),s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsxs("div",{className:"flex items-center gap-4 text-sm text-muted-foreground min-w-0",children:[t.startedAt&&s.jsx("span",{className:"shrink-0 text-xs",children:Ys(t.startedAt,j.language)}),u?s.jsx(Ks,{duration:u}):null,s.jsxs(m,{variant:"ghost",size:"sm",className:"h-6 px-2 text-xs",onClick:A,children:[w?s.jsx(se,{className:"h-3 w-3 mr-1"}):s.jsx(ee,{className:"h-3 w-3 mr-1"}),"Logs"]})]}),B&&s.jsxs("div",{className:"flex gap-2 items-center flex-shrink-0",children:[t.status==="running"&&s.jsxs(s.Fragment,{children:[s.jsxs(m,{size:"sm",variant:"secondary",className:"gap-1 h-6 text-xs px-2",onClick:n=>{n.stopPropagation(),h(t.id)},children:[s.jsx(ae,{className:"h-3 w-3"}),i("sessions.actions.pause")]}),s.jsxs(m,{size:"sm",variant:"destructive",className:"gap-1 h-6 text-xs px-2",onClick:n=>{n.stopPropagation(),g(t.id)},children:[s.jsx(as,{className:"h-3 w-3"}),i("sessions.actions.stop")]})]}),t.status==="paused"&&s.jsxs(s.Fragment,{children:[s.jsxs(m,{size:"sm",variant:"secondary",className:"gap-1 h-6 text-xs px-2",onClick:n=>{n.stopPropagation(),f(t.id)},children:[s.jsx(te,{className:"h-3 w-3"}),i("sessions.actions.resume")]}),s.jsxs(m,{size:"sm",variant:"destructive",className:"gap-1 h-6 text-xs px-2",onClick:n=>{n.stopPropagation(),g(t.id)},children:[s.jsx(as,{className:"h-3 w-3"}),i("sessions.actions.stop")]})]})]})]}),w&&s.jsx("div",{className:"mt-4 border-t pt-4",onClick:n=>n.stopPropagation(),children:s.jsx("div",{className:"h-[300px] overflow-hidden rounded-md border",children:s.jsx(re,{sessionId:t.id,onBack:()=>F(!1)})})})]})]})})});export{be as SessionsPage};
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import{h as F,j as e,f as M,dZ as is,bB as Ae,bX as _e,cb as os,d_ as ke,cc as cs,cI as ls,cf as ds,d$ as ms,e0 as us,e1 as Re,e2 as ps,e3 as oe,c4 as hs,bU as xs,u as V,r as i,b5 as ce,b6 as le,a as O,aW as ee,b8 as de,b9 as Pe,bn as fs,ba as ze,bb as Fe,bc as Ie,be as se,bf as gs,B as me,br as $e,aP as Be,c7 as L,D as ue,b as pe,c as he,d as xe,b1 as fe,e4 as ge,aX as Ve,aY as qe,cE as Ne,aZ as Ue,a_ as He,a$ as Ke,e5 as Ns,e6 as js,bd as Ce,aS as je,e7 as ys,e8 as vs,e9 as Te,c8 as Qe,bE as bs,L as ws,bY as De,ea as Ss,eb as ks,ec as Cs,bZ as Ts,b$ as Ds,b_ as Es,ed as Os,c0 as Ms,c1 as Ls,ee as As,ef as _s,bg as Rs,bl as Ps,bh as zs,cU as Fs,eg as Is,bi as $s,eh as Bs,cT as Vs,ei as qs,bs as Us,cn as Hs}from"./index-DSWQaVP_.js";import{P as Ks}from"./page-transition-BMYHE1EG.js";import{c as Qs,T as Ee,V as Oe,C as Ws,a as Gs,b as Xs}from"./validation-badge-DKLDRlSe.js";import{T as Ys}from"./trending-up-qrMVjIzR.js";import{T as Zs,a as Js}from"./table-of-contents-B56zI3O0.js";import{R as et}from"./refresh-ccw-CqpLwlfM.js";import"./token-utils-x_d_uTQu.js";import"./info-BoE52mzX.js";const st=[["ellipse",{cx:"12",cy:"5",rx:"9",ry:"3",key:"msslwz"}],["path",{d:"M3 5V19A9 3 0 0 0 21 19V5",key:"1wlel7"}],["path",{d:"M3 12A9 3 0 0 0 21 12",key:"mv7ke4"}]],tt=F("database",st);const at=[["path",{d:"M15 14c.2-1 .7-1.7 1.5-2.5 1-.9 1.5-2.2 1.5-3.5A6 6 0 0 0 6 8c0 1 .2 2.2 1.5 3.5.7.7 1.3 1.5 1.5 2.5",key:"1gvzjb"}],["path",{d:"M9 18h6",key:"x1upvd"}],["path",{d:"M10 22h4",key:"ceow96"}]],nt=F("lightbulb",at);const rt=[["path",{d:"M9 17H7A5 5 0 0 1 7 7h2",key:"8i5ue5"}],["path",{d:"M15 7h2a5 5 0 1 1 0 10h-2",key:"1b9ql8"}],["line",{x1:"8",x2:"16",y1:"12",y2:"12",key:"1jonct"}]],We=F("link-2",rt);const it=[["path",{d:"M14.106 5.553a2 2 0 0 0 1.788 0l3.659-1.83A1 1 0 0 1 21 4.619v12.764a1 1 0 0 1-.553.894l-4.553 2.277a2 2 0 0 1-1.788 0l-4.212-2.106a2 2 0 0 0-1.788 0l-3.659 1.83A1 1 0 0 1 3 19.381V6.618a1 1 0 0 1 .553-.894l4.553-2.277a2 2 0 0 1 1.788 0z",key:"169xi5"}],["path",{d:"M15 5.764v15",key:"1pn4in"}],["path",{d:"M9 3.236v15",key:"1uimfh"}]],ot=F("map",it);const ct=[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"m21 3-7 7",key:"1l2asr"}],["path",{d:"m3 21 7-7",key:"tjx5ai"}],["path",{d:"M9 21H3v-6",key:"wtvkvv"}]],lt=F("maximize-2",ct);const dt=[["path",{d:"m14 10 7-7",key:"oa77jy"}],["path",{d:"M20 10h-6V4",key:"mjg0md"}],["path",{d:"m3 21 7-7",key:"tjx5ai"}],["path",{d:"M4 14h6v6",key:"rmj7iw"}]],mt=F("minimize-2",dt);const ut=[["path",{d:"M4.5 16.5c-1.5 1.26-2 5-2 5s3.74-.5 5-2c.71-.84.7-2.13-.09-2.91a2.18 2.18 0 0 0-2.91-.09z",key:"m3kijz"}],["path",{d:"m12 15-3-3a22 22 0 0 1 2-3.95A12.88 12.88 0 0 1 22 2c0 2.72-.78 7.5-6 11a22.35 22.35 0 0 1-4 2z",key:"1fmvmk"}],["path",{d:"M9 12H4s.55-3.03 2-4c1.62-1.08 5 0 5 0",key:"1f8sc4"}],["path",{d:"M12 15v5s3.03-.55 4-2c1.08-1.62 0-5 0-5",key:"qeys4"}]],pt=F("rocket",ut);const ht=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}]],xt=F("shield",ht);const ft=[["path",{d:"M21 10.656V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h12.344",key:"2acyp4"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]],gt=F("square-check-big",ft);const Nt=[["path",{d:"M14.5 2v17.5c0 1.4-1.1 2.5-2.5 2.5c-1.4 0-2.5-1.1-2.5-2.5V2",key:"125lnx"}],["path",{d:"M8.5 2h7",key:"csnxdl"}],["path",{d:"M14.5 16h-5",key:"1ox875"}]],jt=F("test-tube",Nt);const yt=[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["path",{d:"M16 3.128a4 4 0 0 1 0 7.744",key:"16gr8j"}],["path",{d:"M22 21v-2a4 4 0 0 0-3-3.87",key:"kshegd"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}]],vt=F("users",yt),Me={created:"Created",inProgress:"In Progress",complete:"Complete",archived:"Archived",awaiting:"Awaiting",queued:"Queued",pending:"Pending"};function bt({createdAt:s,updatedAt:o,completedAt:x,status:p,className:d,labels:m=Me,language:c="en"}){const t={...Me,...m},u=[];return s&&u.push({label:t.created,date:s,isActive:!0,isFuture:!1,icon:_e,color:"text-blue-600"}),p==="in-progress"||p==="complete"||p==="archived"?u.push({label:t.inProgress,date:o||s,isActive:!0,isFuture:!1,icon:os,color:"text-orange-600"}):u.push({label:t.inProgress,date:null,isActive:!1,isFuture:!0,icon:ke,color:"text-muted-foreground"}),p==="complete"||p==="archived"?u.push({label:t.complete,date:x||o,isActive:!0,isFuture:!1,icon:cs,color:"text-green-600"}):u.push({label:t.complete,date:null,isActive:!1,isFuture:!0,icon:ke,color:"text-muted-foreground"}),p==="archived"&&u.push({label:t.archived,date:o,isActive:!0,isFuture:!1,icon:ls,color:"text-gray-600"}),u.length===0?null:e.jsx("div",{className:M("flex items-start gap-2",d),children:u.map((a,j)=>{const n=a.icon,S=j===u.length-1,w=S?null:u[j+1],b=a.date&&w?.date&&!w.isFuture?is(a.date,w.date,c):"";return e.jsxs("div",{className:"flex items-center gap-2 flex-1",children:[e.jsxs("div",{className:"flex flex-col items-center gap-1 min-w-0",children:[e.jsx("div",{className:M("w-8 h-8 rounded-full border-2 bg-background flex items-center justify-center shrink-0",a.isActive&&!a.isFuture?"border-primary":"border-muted-foreground/40"),children:n&&e.jsx(n,{className:M("h-4 w-4",a.isActive&&!a.isFuture?"text-primary":"text-muted-foreground/60")})}),e.jsx("div",{className:M("text-xs font-medium text-center whitespace-nowrap",a.isActive&&!a.isFuture?"text-foreground":"text-muted-foreground"),children:a.label}),e.jsxs("div",{className:"text-[10px] text-center min-h-[14px]",children:[a.date&&!a.isFuture&&e.jsx("span",{className:"text-muted-foreground",children:Ae(a.date,c)}),!a.date&&a.isFuture&&e.jsx("span",{className:"text-muted-foreground/70",children:t.awaiting}),a.date&&a.isFuture&&e.jsx("span",{className:"text-muted-foreground/70",children:t.queued}),!a.date&&!a.isFuture&&e.jsx("span",{className:"text-muted-foreground/60",children:t.pending})]})]}),!S&&e.jsxs("div",{className:"flex flex-col items-center flex-1 min-w-4 gap-0.5",children:[e.jsx("div",{className:M("h-0.5 w-full",a.isActive&&!a.isFuture?"bg-primary":"bg-muted-foreground/40")}),b&&e.jsx("div",{className:"text-[10px] text-muted-foreground font-medium whitespace-nowrap",children:b})]})]},j)})})}function wt(){return ds()}const St={NOT_FOUND:"apiCodes.notFound",PROJECT_NOT_FOUND:"apiCodes.projectNotFound",SPEC_NOT_FOUND:"apiCodes.specNotFound",NO_PROJECT:"apiCodes.noProject",INVALID_REQUEST:"apiCodes.invalidRequest",UNAUTHORIZED:"apiCodes.unauthorized",VALIDATION_FAILED:"apiCodes.validationFailed",DATABASE_ERROR:"apiCodes.databaseError",CONFIG_ERROR:"apiCodes.configError",TOOL_NOT_FOUND:"apiCodes.toolNotFound",TOOL_ERROR:"apiCodes.toolError",INTERNAL_ERROR:"apiCodes.internalError"};function kt(s,o){if(s instanceof ms){if(s.code){const x=St[s.code];if(x)return o(x,{ns:"errors",defaultValue:s.message})}switch(s.status){case 404:return o("specNotFound",{ns:"errors"});case 400:return o("invalidInput",{ns:"errors"});case 500:return o("unknownError",{ns:"errors"});default:return o("loadingError",{ns:"errors"})}}return s instanceof Error&&s.message.includes("Failed to fetch")?o("networkError",{ns:"errors"}):s instanceof Error?s.message:o("unknownError",{ns:"errors"})}const Ct=[{keywords:["architecture","system","structure","diagram"],icon:ot,color:"text-indigo-600"},{keywords:["ui","ux","mockup","wireframe","prototype","design"],icon:us,color:"text-purple-600"},{keywords:["implementation","code","develop","build"],icon:Qs,color:"text-green-600"},{keywords:["api","endpoint","integration","interface"],icon:Re,color:"text-blue-600"},{keywords:["test","qa","quality","validation"],icon:jt,color:"text-orange-600"},{keywords:["task","todo","checklist","milestone"],icon:gt,color:"text-slate-600"},{keywords:["config","setup","settings","environment"],icon:ps,color:"text-amber-600"},{keywords:["deploy","devops","ci","cd","pipeline","release"],icon:pt,color:"text-rose-600"},{keywords:["migration","upgrade","refactor","transition"],icon:oe,color:"text-cyan-600"},{keywords:["security","auth","permission","access","encryption"],icon:xt,color:"text-red-600"},{keywords:["performance","optimization","speed","cache","benchmark"],icon:Ys,color:"text-emerald-600"},{keywords:["database","data","schema","model","query"],icon:tt,color:"text-sky-600"},{keywords:["notes","research","findings","considerations","exploration"],icon:nt,color:"text-yellow-600"},{keywords:["doc","guide","manual","reference","readme"],icon:hs,color:"text-gray-500"},{keywords:["github","git","vcs","version"],icon:oe,color:"text-pink-600"}],Tt={icon:xs,color:"text-gray-600"};function Dt(s){const o=s.toLowerCase();for(const x of Ct)if(x.keywords.some(p=>o.includes(p)))return{icon:x.icon,color:x.color};return Tt}function Et(s){return s.replace(/\.md$/i,"").split(/[-_]/).map(o=>o.charAt(0).toUpperCase()+o.slice(1).toLowerCase()).join(" ")}const Ot=s=>s!=null?s.toString().padStart(3,"0"):null;function Z({specs:s,onSelect:o,disabled:x,excludeSpecNames:p=[],placeholder:d,emptyLabel:m}){const{t:c}=V("common"),[t,u]=i.useState(!1),[a,j]=i.useState(""),n=d??c("search.placeholder"),S=m??c("relationships.empty.noSpecs"),w=i.useMemo(()=>new Set(p),[p]),b=i.useMemo(()=>{const h=a.trim().toLowerCase();return s.filter(N=>!w.has(N.specName)).filter(N=>h?[N.title,N.specName,N.specNumber?.toString()].filter(Boolean).join(" ").toLowerCase().includes(h):!0).slice(0,20)},[w,a,s]);return e.jsxs(ce,{open:t,onOpenChange:u,children:[e.jsx(le,{asChild:!0,children:e.jsxs(O,{type:"button",variant:"outline",size:"sm",disabled:x,className:"h-7 px-2 text-xs gap-1",children:[e.jsx(ee,{className:"h-3.5 w-3.5"}),n]})}),e.jsx(de,{className:"w-72 p-0",align:"start",children:e.jsxs(Pe,{children:[e.jsxs("div",{className:"flex items-center px-3 border-b",children:[e.jsx(fs,{className:"h-4 w-4 text-muted-foreground"}),e.jsx(ze,{placeholder:n,value:a,onValueChange:j,className:"border-0 focus:ring-0"})]}),e.jsxs(Fe,{children:[e.jsx(Ie,{children:S}),b.map(h=>{const N=Ot(h.specNumber??null),l=h.title||h.specName;return e.jsx(se,{value:`${N?`#${N}`:""} ${l}`.trim(),onSelect:()=>{o(h),u(!1),j("")},children:e.jsxs("div",{className:"flex items-start gap-2 w-full",children:[e.jsx(gs,{className:M("mt-0.5 h-4 w-4 text-muted-foreground","opacity-0")}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[N&&e.jsxs("span",{className:"text-xs font-mono text-muted-foreground",children:["#",N]}),e.jsx("span",{className:"truncate text-sm font-medium",children:l})]}),e.jsx("div",{className:"text-xs text-muted-foreground truncate",children:h.specName})]})]})},h.specName)})]})]})})]})}const Mt=s=>s!=null?s.toString().padStart(3,"0"):null;function J({title:s,items:o,emptyLabel:x,canEdit:p,onNavigate:d,onRemove:m,actions:c}){return e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("h4",{className:"text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:s}),c]}),o.length===0?e.jsx("div",{className:"text-xs text-muted-foreground italic",children:x}):e.jsx("div",{className:"flex flex-wrap gap-2",children:o.map(t=>{const u=Mt(t.specNumber??null),a=t.title||t.specName;return e.jsxs(me,{variant:"secondary",className:M("flex items-center gap-2 px-2 py-1 text-xs"),children:[e.jsxs("button",{type:"button",onClick:()=>d(t.specName),className:"flex items-center gap-1 text-left hover:text-primary",children:[u&&e.jsxs("span",{className:"font-mono text-[10px] text-muted-foreground",children:["#",u]}),e.jsx("span",{className:"max-w-[160px] truncate",children:a})]}),p&&m&&e.jsx(O,{type:"button",variant:"ghost",size:"icon",className:"h-4 w-4 p-0",onClick:()=>m(t.specName),children:e.jsx($e,{className:"h-3 w-3"})})]},t.specName)})})]})}function Lt({spec:s,open:o,onOpenChange:x,basePath:p,disabled:d,onUpdated:m}){const{t:c}=V("common"),t=Be(),[u,a]=i.useState([]),[j,n]=i.useState(!1),S=i.useMemo(()=>new Map(u.map(r=>[r.specName,r])),[u]),w=i.useCallback(async()=>{try{n(!0);const r=await L.getSpecs();a(r)}catch{a([])}finally{n(!1)}},[]);i.useEffect(()=>{o&&w()},[w,o]);const b=i.useCallback(r=>window.confirm(c("relationships.confirmRemove",{label:r})),[c]),h=i.useCallback(r=>{t(`${p}/specs/${r}`),x(!1)},[p,t,x]),N=i.useCallback(async r=>{await r(),m()},[m]),l=i.useCallback(r=>{const T=S.get(r);return T?{specName:T.specName,title:T.title,specNumber:T.specNumber}:{specName:r}},[S]),C=s.parent?l(s.parent):null,D=(s.children||[]).map(l),f=(s.dependsOn||[]).map(l),z=(s.requiredBy||[]).map(l);return e.jsx(ue,{open:o,onOpenChange:x,children:e.jsxs(pe,{className:"w-[min(720px,95vw)] max-w-3xl max-h-[85vh] overflow-y-auto",children:[e.jsxs(he,{children:[e.jsx(xe,{children:c("relationships.title")}),e.jsx(fe,{children:c("relationships.description")})]}),e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm font-semibold",children:[e.jsx(Re,{className:"h-4 w-4"}),c("relationships.sections.hierarchy")]}),e.jsx(J,{title:c("relationships.parent"),items:C?[C]:[],emptyLabel:c("relationships.empty.parent"),canEdit:!d,onNavigate:h,onRemove:C&&!d?()=>{b(C.title||C.specName)&&N(()=>L.updateSpec(s.specName,{parent:null}))}:void 0,actions:d?void 0:e.jsx(Z,{specs:u,onSelect:r=>{N(()=>L.updateSpec(s.specName,{parent:r.specName}))},disabled:j||d,excludeSpecNames:[s.specName],placeholder:c("relationships.actions.setParent"),emptyLabel:c("relationships.empty.noSpecs")})}),e.jsx(J,{title:c("relationships.children"),items:D,emptyLabel:c("relationships.empty.children"),canEdit:!d,onNavigate:h,onRemove:d?void 0:r=>{const T=l(r);b(T.title||T.specName)&&N(()=>L.updateSpec(r,{parent:null}))},actions:d?void 0:e.jsx(Z,{specs:u,onSelect:r=>{r.specName!==s.specName&&N(()=>L.updateSpec(r.specName,{parent:s.specName}))},disabled:j||d,excludeSpecNames:[s.specName,...s.children||[]],placeholder:c("relationships.actions.addChild"),emptyLabel:c("relationships.empty.noSpecs")})})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm font-semibold",children:[e.jsx(oe,{className:"h-4 w-4"}),c("relationships.sections.dependencies")]}),e.jsx(J,{title:c("relationships.dependsOn"),items:f,emptyLabel:c("relationships.empty.dependsOn"),canEdit:!d,onNavigate:h,onRemove:d?void 0:r=>{const T=l(r);b(T.title||T.specName)&&N(()=>L.updateSpec(s.specName,{removeDependsOn:[r]}))},actions:d?void 0:e.jsx(Z,{specs:u,onSelect:r=>{r.specName!==s.specName&&N(()=>L.updateSpec(s.specName,{addDependsOn:[r.specName]}))},disabled:j||d,excludeSpecNames:[s.specName,...s.dependsOn||[]],placeholder:c("relationships.actions.addDependsOn"),emptyLabel:c("relationships.empty.noSpecs")})}),e.jsx(J,{title:c("relationships.requiredBy"),items:z,emptyLabel:c("relationships.empty.requiredBy"),canEdit:!d,onNavigate:h,onRemove:d?void 0:r=>{const T=l(r);b(T.title||T.specName)&&N(()=>L.updateSpec(r,{removeDependsOn:[s.specName]}))},actions:d?void 0:e.jsx(Z,{specs:u,onSelect:r=>{r.specName!==s.specName&&N(()=>L.updateSpec(r.specName,{addDependsOn:[s.specName]}))},disabled:j||d,excludeSpecNames:[s.specName,...s.requiredBy||[]],placeholder:c("relationships.actions.addRequiredBy"),emptyLabel:c("relationships.empty.noSpecs")})})]}),e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 border-t pt-4",children:[e.jsxs(O,{variant:"outline",size:"sm",type:"button",onClick:()=>t(`${p}/specs?view=board&groupByParent=1`),className:"gap-2",children:[e.jsx(vt,{className:"h-4 w-4"}),c("relationships.actions.viewHierarchy")]}),e.jsxs(O,{variant:"outline",size:"sm",type:"button",onClick:()=>t(`${p}/dependencies?spec=${s.specNumber||s.id}`),className:"gap-2",children:[e.jsx(We,{className:"h-4 w-4"}),c("relationships.actions.viewDependencies")]})]})]})]})})}const re=Object.entries(Ns).map(([s,o])=>({value:s,labelKey:o.labelKey,className:o.className,Icon:o.icon}));function At({specName:s,value:o,onChange:x,expectedContentHash:p,disabled:d=!1,className:m}){const c=o||"planned",[t,u]=i.useState(c),[a,j]=i.useState(!1),[n,S]=i.useState(null),[w,b]=i.useState(null),{t:h}=V("common"),N=ge();i.useEffect(()=>{u(o||"planned"),j(!1),S(null)},[o,s]);const l=re.find(f=>f.value===t)||re[0],C=async(f,z=!1)=>{if(f===t)return;const r=t;u(f),j(!0),S(null);try{await L.updateSpec(s,{status:f,expectedContentHash:p,force:z}),x?.(f),N()}catch(T){u(r);const I=T instanceof Error?T.message:h("editors.statusError");S(I)}finally{j(!1)}},D=f=>{if(f!==t){if(t==="draft"&&(f==="in-progress"||f==="complete")){b(f);return}C(f)}};return e.jsxs("div",{className:"space-y-1",children:[e.jsxs(Ve,{value:t,onValueChange:f=>D(f),disabled:d||a,children:[e.jsx(qe,{className:M("h-7 w-fit min-w-0 sm:min-w-[120px] border-0 px-2 text-xs font-medium justify-center sm:justify-start",l.className,m,a&&"opacity-70"),"aria-label":h("editors.changeStatus"),children:e.jsxs("div",{className:"flex items-center gap-1.5",children:[a?e.jsx(Ne,{className:"h-3.5 w-3.5 animate-spin"}):e.jsx(l.Icon,{className:"h-3.5 w-3.5"}),e.jsx(Ue,{placeholder:h("specsPage.filters.status"),children:e.jsx("span",{className:"hidden sm:inline",children:h(l.labelKey)})})]})}),e.jsx(He,{children:re.map(f=>e.jsx(Ke,{value:f.value,className:"flex items-center gap-2",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(f.Icon,{className:"h-4 w-4"}),e.jsx("span",{children:h(f.labelKey)})]})},f.value))})]}),n&&e.jsx("p",{className:"text-xs text-destructive",children:n}),e.jsx(ue,{open:w!==null,onOpenChange:f=>!f&&b(null),children:e.jsxs(pe,{children:[e.jsxs(he,{children:[e.jsx(xe,{children:h("editors.draftSkipTitle")}),e.jsx(fe,{children:h("editors.draftSkipDescription")})]}),e.jsxs("div",{className:"flex flex-wrap justify-end gap-2",children:[e.jsx(O,{type:"button",variant:"outline",size:"sm",onClick:()=>{b(null),C("planned")},children:h("editors.draftSkipPlanned")}),e.jsx(O,{type:"button",size:"sm",onClick:()=>{if(!w)return;const f=w;b(null),C(f,!0)},children:h("editors.draftSkipForce")})]})]})})]})}const ie=Object.entries(js).map(([s,o])=>({value:s,labelKey:o.labelKey,className:o.className,Icon:o.icon}));function _t({specName:s,value:o,onChange:x,expectedContentHash:p,disabled:d=!1,className:m}){const c=o||"medium",[t,u]=i.useState(c),[a,j]=i.useState(!1),[n,S]=i.useState(null),{t:w}=V("common"),b=ge();i.useEffect(()=>{u(o||"medium"),j(!1),S(null)},[o,s]);const h=ie.find(l=>l.value===t)||ie[1],N=async l=>{if(l===t)return;const C=t;u(l),j(!0),S(null);try{await L.updateSpec(s,{priority:l,expectedContentHash:p}),x?.(l),b()}catch(D){u(C);const f=D instanceof Error?D.message:w("editors.priorityError");S(f)}finally{j(!1)}};return e.jsxs("div",{className:"space-y-1",children:[e.jsxs(Ve,{value:t,onValueChange:l=>N(l),disabled:d||a,children:[e.jsx(qe,{className:M("h-7 w-fit min-w-0 sm:min-w-[100px] border-0 px-2 text-xs font-medium justify-center sm:justify-start",h.className,m,a&&"opacity-70"),"aria-label":w("editors.changePriority"),children:e.jsxs("div",{className:"flex items-center gap-1.5",children:[a?e.jsx(Ne,{className:"h-3.5 w-3.5 animate-spin"}):e.jsx(h.Icon,{className:"h-3.5 w-3.5"}),e.jsx(Ue,{placeholder:w("specsPage.filters.priority"),children:e.jsx("span",{className:"hidden sm:inline",children:w(h.labelKey)})})]})}),e.jsx(He,{children:ie.map(l=>e.jsx(Ke,{value:l.value,className:"flex items-center gap-2",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(l.Icon,{className:"h-4 w-4"}),e.jsx("span",{children:w(l.labelKey)})]})},l.value))})]}),n&&e.jsx("p",{className:"text-xs text-destructive",children:n})]})}function Rt({specName:s,value:o,onChange:x,expectedContentHash:p,disabled:d=!1,className:m,compact:c=!1}){const[t,u]=i.useState(o||[]),[a,j]=i.useState([]),[n,S]=i.useState(!1),[w,b]=i.useState(null),[h,N]=i.useState(!1),[l,C]=i.useState(""),{t:D}=V("common"),f=ge();i.useEffect(()=>{h&&a.length===0&&(async()=>{try{const E=await L.getSpecs(),R=new Set;E.forEach(H=>H.tags?.forEach(G=>R.add(G))),j(Array.from(R).sort())}catch(E){console.error("Failed to fetch tags:",E)}})()},[h,a.length]);const z=async k=>{const E=t;u(k),S(!0),b(null);try{await L.updateSpec(s,{tags:k,expectedContentHash:p}),x?.(k),f()}catch(R){u(E);const H=R instanceof Error?R.message:D("editors.tagsError");b(H)}finally{S(!1)}},r=k=>{const E=k.trim();if(!E)return;if(t.includes(E)){b(D("editors.tagExists"));return}const R=[...t,E];z(R),C(""),N(!1)},T=k=>{const E=t.filter(R=>R!==k);z(E)},I=i.useMemo(()=>{const k=l.toLowerCase();return a.filter(E=>!t.includes(E)).filter(E=>!k||E.toLowerCase().includes(k))},[a,t,l]),A=l.trim()&&!t.includes(l.trim())&&!a.includes(l.trim()),q=3,Q=c&&t.length>q?t.slice(0,q):t,U=t.length-Q.length,W=k=>e.jsxs(me,{variant:"outline",className:M("text-xs pr-1 gap-1",d&&"opacity-50"),children:[k,!d&&e.jsx("button",{onClick:()=>T(k),disabled:n,className:"ml-1 rounded-full hover:bg-muted p-0.5 transition-colors","aria-label":D("editors.removeTag",{tag:k}),children:e.jsx($e,{className:"h-3 w-3"})})]},k);return e.jsx("div",{className:M("relative",m),children:e.jsxs("div",{className:"flex gap-1 flex-wrap items-center",children:[Q.map(W),U>0&&e.jsxs(ce,{children:[e.jsx(le,{asChild:!0,children:e.jsxs(me,{variant:"outline",className:"cursor-pointer hover:bg-muted h-6 px-2 text-xs",children:["+",U]})}),e.jsx(de,{className:"w-64 p-2",align:"start",children:e.jsx("div",{className:"flex flex-wrap gap-1",children:t.map(W)})})]}),!d&&e.jsxs(ce,{open:h,onOpenChange:N,children:[e.jsx(le,{asChild:!0,children:e.jsx(O,{variant:"outline",size:"sm",className:"h-6 px-2 text-xs",disabled:n,"aria-label":D("editors.addTag"),children:n?e.jsx(Ne,{className:"h-3 w-3 animate-spin"}):e.jsx(ee,{className:"h-3 w-3"})})}),e.jsxs(de,{className:"w-56 p-0",align:"start",children:[e.jsxs(Pe,{children:[e.jsx(ze,{placeholder:D("editors.searchTag"),value:l,onValueChange:C}),e.jsxs(Fe,{children:[e.jsx(Ie,{children:A?e.jsxs(se,{onSelect:()=>r(l),className:"cursor-pointer",children:[e.jsx(ee,{className:"mr-2 h-4 w-4"}),D("editors.createTag",{tag:l.trim()})]}):e.jsx("span",{className:"text-muted-foreground px-2 py-1.5 text-sm",children:D("editors.noTagResults")})}),I.length>0&&e.jsx(Ce,{heading:D("editors.existingTags"),children:I.slice(0,10).map(k=>e.jsx(se,{value:k,onSelect:()=>r(k),className:"cursor-pointer",children:k},k))}),A&&I.length>0&&e.jsx(Ce,{heading:D("editors.createSection"),children:e.jsxs(se,{onSelect:()=>r(l),className:"cursor-pointer",children:[e.jsx(ee,{className:"mr-2 h-4 w-4"}),D("editors.createTag",{tag:l.trim()})]})})]})]}),w&&e.jsx("p",{className:"text-xs text-destructive px-2 pb-2",children:w})]})]})]})})}function Pt({spec:s,basePath:o,displayTitle:x,tags:p,updatedRelative:d,isFocusMode:m,setIsFocusMode:c,headerRef:t,machineModeEnabled:u,isMachineAvailable:a,applySpecPatch:j,onOpenTimeline:n,onOpenRelationships:S,onOpenSessions:w,onOpenMobile:b,timelineDialogOpen:h,setTimelineDialogOpen:N,currentTokenCount:l,currentValidationStatus:C,asyncMetadata:D,onOpenTokenDialog:f,onOpenValidationDialog:z,t:r,i18n:T}){const I=l!==void 0||C!==void 0;return e.jsx("header",{ref:t,className:"lg:sticky lg:top-0 lg:z-20 border-b bg-card",children:e.jsx(je,{padding:"none",contentClassName:M("px-4 sm:px-6 lg:px-8",m?"py-1.5":"py-2 sm:py-3"),children:m?e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[e.jsxs("h1",{className:"text-base font-semibold tracking-tight truncate",children:[s.specNumber&&e.jsxs("span",{className:"text-muted-foreground",children:["#",s.specNumber," "]}),x]}),e.jsx(ys,{status:s.status||"planned"}),e.jsx(vs,{priority:s.priority||"medium"}),s.children&&s.children.length>0&&e.jsx(Te,{count:s.children.length}),e.jsx(Ee,{count:l,size:"sm",onClick:f}),e.jsx(Oe,{status:C,errorCount:D.validationErrors,size:"sm",onClick:z})]}),e.jsx(O,{type:"button",variant:"ghost",size:"sm",onClick:()=>c(!1),className:"h-7 px-2 text-xs text-muted-foreground hover:text-foreground shrink-0",title:r("specDetail.buttons.exitFocus"),children:e.jsx(mt,{className:"h-4 w-4"})})]}):e.jsxs(e.Fragment,{children:[s.parent&&e.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-muted-foreground mb-3",children:[e.jsxs(Qe,{to:`${o}/specs/${s.parent}`,className:"hover:text-primary hover:underline flex items-center gap-1 group",children:[e.jsx(Ws,{className:"h-3 w-3 group-hover:text-primary"}),e.jsx("span",{className:"font-medium",children:s.parent})]}),e.jsx(bs,{className:"h-3 w-3 opacity-50"}),e.jsx("span",{className:"truncate opacity-70",children:x})]}),e.jsxs("div",{className:"flex items-center gap-2 mb-1.5 sm:mb-2",children:[s.children&&s.children.length>0&&e.jsx(Te,{iconOnly:!0}),e.jsxs("h1",{className:"text-lg sm:text-xl font-bold tracking-tight",children:[s.specNumber&&e.jsxs("span",{className:"text-muted-foreground",children:["#",s.specNumber," "]}),x]}),e.jsxs(O,{variant:"ghost",size:"icon",className:"lg:hidden h-8 w-8 -mr-2 shrink-0 text-muted-foreground",onClick:b,children:[e.jsx(ws,{className:"h-5 w-5"}),e.jsx("span",{className:"sr-only",children:r("specDetail.toggleSidebar")})]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(At,{specName:s.specName,value:s.status,expectedContentHash:s.contentHash,disabled:u&&!a(),onChange:A=>j({status:A})}),e.jsx(_t,{specName:s.specName,value:s.priority,expectedContentHash:s.contentHash,disabled:u&&!a(),onChange:A=>j({priority:A})}),I&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"h-4 w-px bg-border mx-1 hidden sm:block"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ee,{count:l,size:"md",onClick:f}),e.jsx(Oe,{status:C,errorCount:D.validationErrors,size:"md",onClick:z})]})]}),e.jsx("div",{className:"h-4 w-px bg-border mx-1 hidden sm:block"}),e.jsx(Rt,{specName:s.specName,value:p,expectedContentHash:s.contentHash,disabled:u&&!a(),onChange:A=>j({tags:A}),compact:!0,className:"min-w-0"})]}),u&&!a()&&e.jsx("div",{className:"text-xs text-destructive mt-2",children:r("machines.unavailable")}),e.jsxs("div",{className:"flex flex-wrap gap-2 sm:gap-4 text-xs text-muted-foreground mt-1.5 sm:mt-2",children:[e.jsxs("span",{className:"hidden sm:inline",children:[r("specDetail.metadata.created"),": ",De(s.createdAt,T.language)]}),e.jsx("span",{className:"hidden sm:inline",children:"•"}),e.jsxs("span",{children:[r("specDetail.metadata.updated"),": ",De(s.updatedAt,T.language),d&&e.jsxs("span",{className:"ml-1 text-[11px] text-muted-foreground/80",children:["(",d,")"]})]}),e.jsx("span",{className:"hidden sm:inline",children:"•"}),e.jsxs("span",{className:"hidden md:inline",children:[r("specDetail.metadata.name"),": ",s.specName]}),s.metadata?.assignee?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"hidden sm:inline",children:"•"}),e.jsxs("span",{className:"hidden sm:inline",children:[r("specDetail.metadata.assignee"),": ",String(s.metadata.assignee)]})]}):null]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2 mt-2",children:[e.jsxs(ue,{open:h,onOpenChange:N,children:[e.jsxs(O,{type:"button",variant:"outline",size:"sm","aria-haspopup":"dialog","aria-expanded":h,onClick:n,className:"h-8 rounded-full border px-3 text-xs font-medium text-muted-foreground transition-colors hover:text-foreground",children:[e.jsx(_e,{className:"mr-1.5 h-3.5 w-3.5"}),r("specDetail.buttons.viewTimeline")]}),e.jsxs(pe,{className:"w-[min(900px,90vw)] max-w-3xl max-h-[90vh] overflow-y-auto",children:[e.jsxs(he,{children:[e.jsx(xe,{children:r("specDetail.dialogs.timelineTitle")}),e.jsx(fe,{children:r("specDetail.dialogs.timelineDescription")})]}),e.jsx("div",{className:"rounded-xl border border-border bg-muted/30 p-4",children:e.jsx(bt,{createdAt:s.createdAt,updatedAt:s.updatedAt,completedAt:s.completedAt,status:s.status||"planned",labels:{created:r("specTimeline.events.created"),inProgress:r("specTimeline.events.inProgress"),complete:r("specTimeline.events.complete"),archived:r("specTimeline.events.archived"),awaiting:r("specTimeline.state.awaiting"),queued:r("specTimeline.state.queued"),pending:r("specTimeline.state.pending")},language:T.language})})]})]}),e.jsxs(O,{type:"button",variant:"outline",size:"sm","aria-haspopup":"dialog",onClick:S,className:M("h-8 rounded-full border px-3 text-xs font-medium text-muted-foreground transition-colors hover:text-foreground"),children:[e.jsx(We,{className:"mr-1.5 h-3.5 w-3.5"}),r("relationships.button")]}),e.jsxs(O,{type:"button",variant:"outline",size:"sm",onClick:w,className:"h-8 rounded-full border px-3 text-xs font-medium text-muted-foreground transition-colors hover:text-foreground",children:[e.jsx(Ss,{className:"mr-1.5 h-3.5 w-3.5"}),r("navigation.sessions")]}),e.jsxs(O,{type:"button",variant:"outline",size:"sm",onClick:()=>c(!0),className:"hidden lg:inline-flex h-8 rounded-full border px-3 text-xs font-medium text-muted-foreground transition-colors hover:text-foreground",title:r("specDetail.buttons.focus"),children:[e.jsx(lt,{className:"mr-1.5 h-3.5 w-3.5"}),r("specDetail.buttons.focus")]})]})]})})})}function zt({subSpecs:s,currentSubSpec:o,onSwitch:x,t:p}){return s.length===0?null:e.jsx("div",{className:"border-t bg-muted/30",children:e.jsx(je,{padding:"none",contentClassName:"px-4 sm:px-6 lg:px-8 overflow-x-auto",children:e.jsxs("div",{className:"flex gap-1 py-2 min-w-max",children:[e.jsxs("button",{onClick:()=>x(null),className:`flex items-center gap-2 px-3 sm:px-4 py-2 text-xs sm:text-sm font-medium rounded-md whitespace-nowrap transition-colors ${o?"text-muted-foreground hover:text-foreground hover:bg-muted/50":"bg-background text-foreground shadow-sm"}`,children:[e.jsx(ks,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:p("specDetail.tabs.overview")})]}),s.map(d=>{const m=d.icon;return e.jsxs("button",{onClick:()=>x(d.file??null),className:`flex items-center gap-2 px-3 sm:px-4 py-2 text-xs sm:text-sm font-medium rounded-md whitespace-nowrap transition-colors ${o===d.file?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground hover:bg-muted/50"}`,children:[e.jsx(m,{className:`h-4 w-4 ${d.color}`}),e.jsx("span",{className:"hidden sm:inline",children:d.name})]},d.file)})]})})})}function Ft({content:s,specName:o="",basePath:x="",onChecklistToggle:p}){const d=Cs(o,x,p);return e.jsx("article",{className:"prose prose-sm sm:prose-base dark:prose-invert max-w-none",children:e.jsx(Ts,{remarkPlugins:[Ms,Ls,As],rehypePlugins:[Ds,Es,Os],components:d,children:s})})}function It({displayContent:s,specName:o,basePath:x,hasSubSpecs:p,onChecklistToggle:d}){const[m,c]=i.useState(()=>typeof window<"u"?window.innerWidth>=1024:!0),t=i.useRef(null),u=i.useCallback(a=>{t.current&&(t.current.disconnect(),t.current=null),a&&(c(a.clientWidth>=1024),t.current=new ResizeObserver(j=>{for(const n of j)c(n.contentRect.width>=1024)}),t.current.observe(a))},[]);return i.useEffect(()=>()=>{t.current&&t.current.disconnect()},[]),e.jsxs(e.Fragment,{children:[e.jsx(je,{padding:"none",contentClassName:M("flex flex-col w-full",m?"lg:flex-row items-start":""),children:e.jsxs("div",{ref:u,className:"flex w-full",children:[e.jsx("main",{className:"flex-1 px-4 sm:px-6 lg:px-8 py-3 sm:py-6 min-w-0",children:e.jsx(Ft,{content:s,specName:o,basePath:x,onChecklistToggle:d})}),e.jsx("aside",{className:M("w-72 shrink-0 px-6 py-6 sticky overflow-y-auto scrollbar-auto-hide",m?"block":"hidden",p?"top-[calc(16.375rem-3.5rem)] h-[calc(100vh-16.375rem)]":"top-[calc(13.125rem-3.5rem)] h-[calc(100vh-13.125rem)]"),children:e.jsx(Zs,{content:s})})]})}),e.jsx("div",{className:m?"hidden":"block",children:e.jsx(Js,{content:s})}),e.jsx(_s,{targetId:"spec-detail-main"})]})}function Le(s,o,x){const p=s.split(`
|
|
2
|
-
`),d=o.trim().toLowerCase();for(let m=0;m<p.length;m++){const c=p[m],t=c.trim().toLowerCase();if((t.startsWith("- [ ]")||t.startsWith("- [x]"))&&t.includes(d)){p[m]=x?c.replace(/- \[[ ]\]/,"- [x]"):c.replace(/- \[[xX]\]/,"- [ ]");break}}return p.join(`
|
|
3
|
-
`)}function Gt(){const{specName:s,projectId:o}=Rs(),[x]=Ps(),p=Be(),{currentProject:d}=zs(),m=o??d?.id,c=m?`/projects/${m}`:"/projects",{machineModeEnabled:t,isMachineAvailable:u}=Fs(),{t:a,i18n:j}=V(["common","errors"]),[n,S]=i.useState(null),[w,b]=i.useState(!0),[h,N]=i.useState(null),l=x.get("subspec"),C=i.useRef(null),[D,f]=i.useState(!1),[z,r]=i.useState(!1),[T,I]=i.useState(!1),[A,q]=i.useState(!1),[Q,U]=i.useState(!1),[W,k]=i.useState(null),[E,R]=i.useState(!1),[H,G]=i.useState(!1),[Ge,te]=i.useState(null),[ae,ne]=i.useState({}),{setMobileOpen:ye}=wt(),{openDrawer:Xe}=Is(),X=$s(m??null).data??[],_=Bs(m??null,s??null),B=Vs(),ve=i.useCallback(g=>kt(g,a),[a]),be=i.useCallback(async()=>{b(!0),await _.refetch()},[_]);i.useEffect(()=>{if(!n?.specName||!m)return;ne({});const g=n.specName;(async()=>{try{const y=await B.getSpecTokens(m,g);ne(v=>({...v,tokenCount:y.tokenCount,tokenStatus:y.tokenStatus}))}catch(y){console.debug("Failed to async fetch tokens",y)}})(),(async()=>{try{const y=await B.getSpecValidation(m,g);ne(v=>({...v,validationStatus:y.status,validationErrors:y.errors.length}))}catch(y){console.debug("Failed to async fetch validation",y)}})()},[B,m,n?.specName]),i.useEffect(()=>{_.data&&(S(_.data),N(null),b(!1))},[_.data]),i.useEffect(()=>{_.error&&(N(ve(_.error)),b(!1))},[ve,_.error]),i.useEffect(()=>{_.isLoading&&b(!0)},[_.isLoading,s,m]),i.useEffect(()=>{!A||!m||!n?.specName||(U(!0),B.getSpecTokens(m,n.specName).then(g=>k(g)).catch(()=>k(null)).finally(()=>U(!1)))},[B,m,n?.specName,A]),i.useEffect(()=>{!E||!m||!n?.specName||(G(!0),B.getSpecValidation(m,n.specName).then(g=>te(g)).catch(()=>te(null)).finally(()=>G(!1)))},[B,m,n?.specName,E]);const Ye=i.useMemo(()=>n?.specName?X.filter(g=>(g.specIds?.includes(n.specName)??!1)&&(g.status==="running"||g.status==="pending")).length:0,[X,n?.specName]),Ze=i.useMemo(()=>n?.specName?X.filter(g=>g.specIds?.includes(n.specName)??!1).length:0,[X,n?.specName]),Y=i.useMemo(()=>{const g=n?.subSpecs??n?.metadata?.sub_specs;return Array.isArray(g)?g.map(y=>{if(!y||typeof y!="object")return null;const v=y,$=typeof v.content=="string"?v.content:typeof v.contentMd=="string"?v.contentMd:null;if(typeof $!="string")return null;const P=typeof v.filename=="string"?v.filename:typeof v.file=="string"?v.file:typeof v.name=="string"?v.name:"",K=Dt(P);return{name:Et(P),content:$,file:P,icon:K.icon,color:K.color}}).filter(Boolean):[]},[n]),Je=g=>{S(y=>y&&{...y,...g})},es=i.useCallback(async(g,y)=>{if(n?.specName){S(l?v=>{if(!v||!v.subSpecs)return v;const $=v.subSpecs.map(P=>{if(P.file===l){const K=Le(P.content||P.contentMd||"",g,y);return{...P,content:K,contentMd:K}}return P});return{...v,subSpecs:$}}:v=>{if(!v)return v;const $=Le(v.contentMd||"",g,y);return{...v,contentMd:$}});try{await L.toggleSpecChecklist(n.specName,[{itemText:g,checked:y}],{subspec:l||void 0}),_.refetch()}catch(v){console.error("Failed to toggle checklist item:",v),_.refetch()}}},[n?.specName,l,_]),ss=g=>{const y=g?`${c}/specs/${s}?subspec=${g}`:`${c}/specs/${s}`;p(y)};let we=n?.content||n?.contentMd||"";if(l&&n&&Y.length>0){const g=Y.find(y=>y.file===l);g&&(we=g.content??g.contentMd??"")}const ts=n?.title||n?.specName||"",Se=i.useMemo(()=>n?.tags||[],[n?.tags]),as=n?.updatedAt?Ae(n.updatedAt,j.language):null,ns=ae.tokenCount??n?.tokenCount,rs=ae.validationStatus??n?.validationStatus;return i.useEffect(()=>{const g=()=>{let $=0;window.innerWidth>=1024&&C.current&&($+=C.current.offsetHeight-56);const P=document.querySelector("#spec-detail-main");P&&(P.style.scrollPaddingTop=`${$}px`)};g(),window.addEventListener("resize",g);const y=new ResizeObserver(g);return C.current&&y.observe(C.current),()=>{window.removeEventListener("resize",g),y.disconnect(),document.documentElement.style.scrollPaddingTop=""}},[n,Se]),w?e.jsx(qs,{}):h||!n?e.jsx(Us,{icon:Hs,title:a("specDetail.state.unavailableTitle"),description:h||a("specDetail.state.unavailableDescription"),tone:"error",actions:e.jsxs(e.Fragment,{children:[e.jsx(Qe,{to:`${c}/specs`,className:"inline-flex",children:e.jsx(O,{variant:"outline",size:"sm",className:"gap-2",children:a("specDetail.links.backToSpecs")})}),e.jsxs(O,{variant:"secondary",size:"sm",className:"gap-2",onClick:()=>{be()},children:[e.jsx(et,{className:"h-4 w-4"}),a("actions.retry")]}),e.jsx("a",{href:"https://github.com/codervisor/lean-spec/issues",target:"_blank",rel:"noreferrer",className:"inline-flex",children:e.jsx(O,{variant:"ghost",size:"sm",className:"gap-2",children:a("specDetail.links.reportIssue")})})]})}):e.jsxs(Ks,{className:"flex-1 min-w-0",children:[e.jsxs("div",{id:"spec-detail-main",className:"overflow-y-auto h-[calc(100vh-3.5rem)]",children:[e.jsxs("div",{className:"lg:hidden sticky top-0 z-20 flex items-center justify-between bg-background/95 backdrop-blur border-b px-3 py-2",children:[e.jsx("span",{className:"text-sm font-semibold",children:a("specsNavSidebar.title")}),e.jsx(O,{size:"sm",variant:"outline",onClick:()=>ye(!0),children:a("actions.openSidebar")})]}),e.jsx(Pt,{spec:n,basePath:c,displayTitle:ts,tags:Se,updatedRelative:as,isFocusMode:T,setIsFocusMode:I,headerRef:C,machineModeEnabled:t,isMachineAvailable:u,applySpecPatch:Je,onOpenTimeline:()=>f(!0),onOpenRelationships:()=>r(!0),onOpenSessions:()=>Xe(n.specName),onOpenMobile:()=>ye(!0),timelineDialogOpen:D,setTimelineDialogOpen:f,activeSessionsCount:Ye,totalSessionsCount:Ze,currentTokenCount:ns,currentValidationStatus:rs,asyncMetadata:ae,onOpenTokenDialog:()=>{m&&q(!0)},onOpenValidationDialog:()=>{m&&R(!0)},t:a,i18n:j}),e.jsx(zt,{subSpecs:Y,currentSubSpec:l,onSwitch:ss,t:a}),e.jsx(It,{displayContent:we,specName:s,basePath:c,hasSubSpecs:Y.length>0,onChecklistToggle:es})]}),n&&e.jsx(Lt,{spec:n,open:z,onOpenChange:r,basePath:c,disabled:t&&!u(),onUpdated:()=>{be()}}),n?.specName&&A&&e.jsx(Gs,{open:A,onClose:()=>{q(!1),k(null)},specName:n.specName,data:W,loading:Q}),n?.specName&&E&&e.jsx(Xs,{open:E,onClose:()=>{R(!1),te(null)},specName:n.specName,data:Ge,loading:H})]})}export{Gt as SpecDetailPage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{h as Xe,r,u as xe,j as e,cI as Oe,cc as Ye,cb as Je,bX as es,bU as ss,f as A,c8 as ge,ca as fe,bW as ts,bD as J,bE as $e,cJ as hs,c9 as as,cK as xs,cL as gs,bn as fs,b0 as Ns,br as Ge,bo as bs,b5 as Se,b6 as De,a as q,b8 as Me,bf as Pe,cM as js,cN as ys,cO as vs,aT as rs,aX as ws,aY as ks,aZ as Cs,a_ as Ss,a$ as Y,cE as Ds,cP as Ms,cQ as Ps,c5 as Ts,cR as Ls,cS as Te,cn as As,L as Is,cT as Os,bg as Es,bh as Vs,cU as Bs,cV as $s,cW as Hs,cX as Le,cY as qs,bl as zs,cZ as _s,c_ as Ks,c7 as Ue,aS as Ae,c$ as Rs,C as Fs,l as Qs,bm as Gs,bs as Ze,D as Us,b as Zs,c as Ws,d as Xs,b1 as Ys}from"./index-DSWQaVP_.js";import{C as Js,T as Ne,V as be,a as et,b as st}from"./validation-badge-DKLDRlSe.js";import{F as tt,a as at}from"./funnel-x-DD5BpUpW.js";import{R as We}from"./refresh-ccw-CqpLwlfM.js";import"./token-utils-x_d_uTQu.js";import"./info-BoE52mzX.js";const rt=[["path",{d:"M20 10a1 1 0 0 0 1-1V6a1 1 0 0 0-1-1h-2.5a1 1 0 0 1-.8-.4l-.9-1.2A1 1 0 0 0 15 3h-2a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1Z",key:"hod4my"}],["path",{d:"M20 21a1 1 0 0 0 1-1v-3a1 1 0 0 0-1-1h-2.9a1 1 0 0 1-.88-.55l-.42-.85a1 1 0 0 0-.92-.6H13a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1Z",key:"w4yl2u"}],["path",{d:"M3 5a2 2 0 0 0 2 2h3",key:"f2jnh7"}],["path",{d:"M3 3v13a2 2 0 0 0 2 2h3",key:"k8epm1"}]],ee=Xe("folder-tree",rt);const nt=[["rect",{width:"7",height:"7",x:"3",y:"3",rx:"1",key:"1g98yp"}],["rect",{width:"7",height:"7",x:"14",y:"3",rx:"1",key:"6d4xhi"}],["rect",{width:"7",height:"7",x:"14",y:"14",rx:"1",key:"nxv5o0"}],["rect",{width:"7",height:"7",x:"3",y:"14",rx:"1",key:"1bb6yr"}]],ot=Xe("layout-grid",nt),it=3,Ee={draft:{icon:ss,titleKey:"status.draft",colorClass:"text-slate-600 dark:text-slate-300",bgClass:"bg-slate-50 dark:bg-slate-900/20",borderClass:"border-slate-200 dark:border-slate-800"},planned:{icon:es,titleKey:"status.planned",colorClass:"text-blue-600 dark:text-blue-400",bgClass:"bg-blue-50 dark:bg-blue-900/20",borderClass:"border-blue-200 dark:border-blue-800"},"in-progress":{icon:Je,titleKey:"status.inProgress",colorClass:"text-orange-600 dark:text-orange-400",bgClass:"bg-orange-50 dark:bg-orange-900/20",borderClass:"border-orange-200 dark:border-orange-800"},complete:{icon:Ye,titleKey:"status.complete",colorClass:"text-green-600 dark:text-green-400",bgClass:"bg-green-50 dark:bg-green-900/20",borderClass:"border-green-200 dark:border-green-800"},archived:{icon:Oe,titleKey:"status.archived",colorClass:"text-gray-600 dark:text-gray-400",bgClass:"bg-gray-50 dark:bg-gray-900/20",borderClass:"border-gray-200 dark:border-gray-800"}};function Ve({spec:n,basePath:s,canEdit:m=!0,draggingId:o,onDragStart:a,onDragEnd:x,onTokenClick:c,onValidationClick:l,onPriorityChange:N,childCount:j,isExpanded:M,onToggle:h}){const T=j!==void 0&&h!==void 0;return e.jsxs("div",{className:A("bg-background rounded-xl border border-primary/20 shadow-sm relative overflow-hidden group/parent hover:border-primary/50 hover:shadow-md transition-all",o===n.specName&&"opacity-50",m?"cursor-move":"cursor-not-allowed opacity-70"),draggable:m,onDragStart:a?v=>a(n,v):void 0,onDragEnd:x,children:[e.jsx("div",{className:"absolute top-0 left-0 right-0 h-1 bg-gradient-to-r from-primary/40 to-primary/10"}),e.jsxs("div",{className:"p-3 pb-2 flex flex-col gap-2",children:[e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs(ge,{to:`${s}/specs/${n.specName}`,className:"flex-1 min-w-0 group hover:text-primary transition-colors",children:[e.jsxs("div",{className:"flex items-center gap-1.5 mb-0.5",children:[e.jsxs("span",{className:"text-[10px] font-mono font-medium text-primary/70 bg-primary/5 px-1 rounded",children:["#",n.specNumber||n.specName.split("-")[0].replace(/^0+/,"")]}),T&&e.jsx(ee,{className:"h-3 w-3 text-primary/40"})]}),e.jsx("h4",{className:"font-semibold text-sm truncate leading-tight",title:n.title||n.specName,children:n.title||n.specName})]}),T&&e.jsx("button",{onClick:v=>{v.preventDefault(),h()},className:"p-1 hover:bg-muted rounded-md text-muted-foreground transition-colors",children:M?e.jsx(J,{className:"h-4 w-4"}):e.jsx($e,{className:"h-4 w-4"})})]}),n.tags&&n.tags.length>0&&e.jsxs("div",{className:"flex flex-wrap gap-1",children:[n.tags.slice(0,3).map(v=>e.jsx("span",{className:"text-[10px] bg-secondary text-secondary-foreground px-1.5 py-0.5 rounded-full",children:v},v)),n.tags.length>3&&e.jsxs("span",{className:"text-[10px] text-muted-foreground",children:["+",n.tags.length-3]})]}),e.jsxs("div",{className:"flex items-center justify-between gap-2 pt-1",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[n.status&&Ee[n.status]&&(()=>{const v=Ee[n.status],d=v.icon;return e.jsx(d,{className:A("h-3.5 w-3.5",v.colorClass)})})(),n.priority&&e.jsx(fe,{priority:n.priority,className:"h-5 text-[10px] px-1.5",editable:!!N&&m,onChange:v=>N?.(n,v)}),T&&e.jsxs("span",{className:"text-[10px] text-muted-foreground flex items-center gap-1",title:`${j} children`,children:[e.jsx(ts,{className:"h-3 w-3"}),j]})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(Ne,{count:n.tokenCount,size:"sm",onClick:c?()=>c(n.specName):void 0,className:"h-5 px-1.5 scale-90 origin-right"}),n.validationStatus&&n.validationStatus!=="pass"&&e.jsx(be,{status:n.validationStatus,size:"sm",onClick:l?()=>l(n.specName):void 0,className:"h-5 px-1.5 scale-90 origin-right"})]})]})]}),T&&!M&&e.jsx("div",{onClick:h,className:"bg-muted/30 p-1 flex justify-center cursor-pointer hover:bg-muted/50 transition-colors border-t border-border/20",children:e.jsx(J,{className:"h-3 w-3 text-muted-foreground/50"})})]})}function ct({parentName:n,specs:s,parentSpec:m,basePath:o,onTokenClick:a,onValidationClick:x,onPriorityChange:c,canEdit:l,draggingId:N,onDragStart:j,onDragEnd:M}){const h=`leanspec_board_expanded_${n}`,T=s.length<=it,[v,d]=r.useState(()=>{try{const S=sessionStorage.getItem(h);return S!==null?S==="true":T}catch{return T}}),P=()=>{const S=!v;d(S);try{sessionStorage.setItem(h,String(S))}catch{}};return e.jsxs("div",{className:"space-y-2 mt-4 first:mt-0",children:[m?e.jsx(Ve,{spec:m,childCount:s.length,isExpanded:v,onToggle:P,basePath:o,canEdit:l,draggingId:N,onDragStart:j,onDragEnd:M,onTokenClick:a,onValidationClick:x,onPriorityChange:c}):e.jsxs("div",{className:"flex items-center gap-2 px-1 pb-1 border-b border-border/30 cursor-pointer hover:bg-muted/20 rounded p-1",onClick:P,children:[e.jsx(ee,{className:"h-3.5 w-3.5 text-primary/70"}),e.jsx("h5",{className:"text-xs font-semibold text-foreground/80 truncate flex-1",title:n,children:n}),e.jsx("span",{className:"text-[10px] bg-muted px-1.5 py-0.5 rounded-full text-muted-foreground font-mono",children:s.length}),v?e.jsx(J,{className:"h-3 w-3 text-muted-foreground"}):e.jsx($e,{className:"h-3 w-3 text-muted-foreground"})]}),v&&e.jsx("div",{className:A("space-y-2 transition-all",m&&"pl-2 border-l-2 border-border/30 ml-2"),children:s.map(S=>e.jsx(Ve,{spec:S,basePath:o,canEdit:l,draggingId:N,onDragStart:j,onDragEnd:M,onTokenClick:a,onValidationClick:x,onPriorityChange:c},S.specName))})]})}const lt=r.memo(function({specs:s,onStatusChange:m,onPriorityChange:o,basePath:a="/projects",canEdit:x=!0,groupByParent:c=!1,showArchived:l=!1,onTokenClick:N,onValidationClick:j}){const[M,h]=r.useState(null),[T,v]=r.useState(null),{t:d}=xe("common"),P=r.useMemo(()=>new Map(s.map(t=>[t.specName,t])),[s]),S=r.useMemo(()=>{const p=s.some(w=>w.status==="draft")?["draft","planned","in-progress","complete"]:["planned","in-progress","complete"];return l&&p.push("archived"),p},[l,s]),V=r.useMemo(()=>{const t={draft:[],planned:[],"in-progress":[],complete:[],archived:[]};return s.forEach(p=>{const w=p.status;w&&t[w].push(p)}),t},[s]),z=(t,p)=>{x&&(h(t.specName),p.dataTransfer.effectAllowed="move")},B=()=>{h(null),v(null)},I=t=>{t.currentTarget.contains(t.relatedTarget)||v(null)},F=(t,p)=>{x&&(p.preventDefault(),p.dataTransfer.dropEffect="move",T!==t&&v(t))},G=(t,p)=>{if(x&&(p.preventDefault(),v(null),M)){const w=s.find($=>$.specName===M);w&&w.status!==t&&m(w,t),h(null)}},se=(t,p=!1)=>e.jsx("div",{draggable:x,onDragStart:w=>z(t,w),onDragEnd:B,className:A("bg-background rounded-xl border shadow-sm cursor-move hover:border-primary/50 transition-all group/card relative",p?"p-2.5 border-border/50 text-sm shadow-none bg-background/50":"p-4",M===t.specName&&"opacity-50",!x&&"cursor-not-allowed opacity-70"),children:e.jsxs(ge,{to:`${a}/specs/${t.specName}`,className:"select-none h-full flex flex-col",children:[t.children&&t.children.length>0&&!p&&e.jsx("div",{className:"absolute top-3 right-3 text-primary/50",title:d("specs.hierarchy.umbrella"),children:e.jsx(ee,{className:"w-4 h-4"})}),e.jsxs("div",{className:"text-xs text-muted-foreground font-mono mb-1 flex items-center gap-1",children:[e.jsxs("span",{className:A(p&&"text-[10px]"),children:["#",t.specNumber||t.specName.split("-")[0].replace(/^0+/,"")]}),p&&t.children&&t.children.length>0&&e.jsx(ee,{className:"w-3 h-3 text-primary/40 ml-1"})]}),e.jsxs("div",{className:A("space-y-1 mb-3 flex-1",p?"mb-1.5":"mb-4"),children:[e.jsx("h4",{className:A("font-semibold leading-snug group-hover/card:text-primary transition-colors pr-6",p?"text-xs":"text-base"),children:t.title||t.specName}),!p&&e.jsx("div",{className:"text-xs text-muted-foreground font-mono truncate",children:t.specName}),t.parent&&!c&&e.jsxs("div",{className:"flex items-center text-xs text-muted-foreground mt-1 bg-muted/30 p-1 rounded w-fit max-w-full",children:[e.jsx(Js,{className:"h-3 w-3 mr-1 flex-shrink-0"}),e.jsx("span",{className:"truncate",children:d("specs.hierarchy.inParent",{parent:t.parent})})]})]}),t.tags&&t.tags.length>0&&e.jsxs("div",{className:A("flex flex-wrap gap-1.5 mb-3",p?"mb-1.5":"mb-3"),children:[t.tags.slice(0,p?2:4).map(w=>e.jsx("span",{className:"text-[10px] px-2 py-0.5 bg-secondary/30 border border-border/50 rounded-md text-muted-foreground font-mono truncate max-w-[120px]",children:w},w)),t.tags.length>(p?2:4)&&e.jsxs("span",{className:"text-[10px] px-1.5 py-0.5 bg-secondary/20 border border-border/30 rounded-md text-muted-foreground/70 font-mono",children:["+",t.tags.length-(p?2:4)]})]}),e.jsxs("div",{className:"flex items-center justify-between gap-2 mt-auto",children:[t.priority&&e.jsx(fe,{priority:t.priority,className:A("rounded-md",p?"h-5 text-[10px] px-1.5 scale-90 origin-left":"h-6 px-2.5"),iconOnly:p,editable:!!o&&x,onChange:w=>o?.(t,w)}),e.jsxs("div",{className:"flex items-center gap-1.5 justify-end ml-auto",children:[e.jsx(Ne,{count:t.tokenCount,size:"sm",onClick:N?()=>N(t.specName):void 0,className:A(p&&"px-1.5 h-5 scale-90 origin-right"),showIcon:!p}),e.jsx(be,{status:t.validationStatus,size:"sm",onClick:j?()=>j(t.specName):void 0,className:A(p&&"px-1.5 h-5 scale-90 origin-right")}),t.children&&t.children.length>0&&!p&&e.jsxs("span",{className:"text-[10px] px-2 py-0.5 bg-primary/10 border border-primary/20 rounded-md text-primary font-medium flex items-center gap-1",children:[e.jsx(ts,{className:"h-3 w-3"}),t.children.length]})]})]})]})},t.specName),U=t=>{if(!c)return e.jsx("div",{className:"space-y-2",children:t.map(C=>se(C))});const p=[],w=[],$=new Set;return s.forEach(C=>{C.children&&C.children.length>0&&C.children.forEach(E=>$.add(E))}),t.forEach(C=>{$.has(C.specName)||(C.children&&C.children.length>0?p.push(C):w.push(C))}),p.sort((C,E)=>C.specName.localeCompare(E.specName)),e.jsxs("div",{className:"space-y-2",children:[w.map(C=>e.jsx(Ve,{spec:C,basePath:a,canEdit:x,draggingId:M,onDragStart:z,onDragEnd:B,onTokenClick:N,onValidationClick:j,onPriorityChange:o},C.specName)),p.map(C=>{const E=(C.children||[]).map(R=>P.get(R)).filter(R=>R!==void 0);return e.jsx(ct,{parentName:C.specName,specs:E,parentSpec:C,basePath:a,canEdit:x,draggingId:M,onDragStart:z,onDragEnd:B,onTokenClick:N,onValidationClick:j,onPriorityChange:o},C.specName)})]})},k=t=>{if(!c)return t.length;const p=new Set;return s.forEach(w=>{w.children&&w.children.length>0&&w.children.forEach($=>p.add($))}),t.filter(w=>!p.has(w.specName)).length};return e.jsx("div",{className:"flex flex-col md:flex-row gap-3 sm:gap-4 md:gap-6 h-full pb-2 md:snap-x md:snap-mandatory overflow-y-auto md:overflow-y-hidden md:overflow-x-auto",children:S.map(t=>{const p=Ee[t],w=V[t]||[],$=p.icon,C=T===t;return e.jsxs("div",{className:A("flex-shrink-0 w-80 flex flex-col rounded-lg bg-secondary/30 border border-transparent transition-colors",C&&"bg-secondary/60 border-primary/50 ring-2 ring-primary/20"),onDragOver:E=>F(t,E),onDragLeave:I,onDrop:E=>G(t,E),children:[e.jsx("div",{className:A("p-3 flex items-center justify-between border-b sticky top-0 z-10 backdrop-blur-sm bg-opacity-90",p.borderClass,p.bgClass,"rounded-t-lg"),children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx($,{className:A("w-4 h-4",p.colorClass)}),e.jsx("span",{className:A("font-medium text-sm",p.colorClass),children:d(p.titleKey)}),e.jsx("span",{className:"text-xs px-2 py-0.5 bg-background/50 rounded-full text-muted-foreground",children:k(w)})]})}),e.jsx("div",{className:"flex-1 p-2 overflow-y-auto",children:U(w)})]},t)})})});function ns(n,s){const m=[...n];switch(s){case"id-asc":m.sort((o,a)=>(o.specNumber||0)-(a.specNumber||0));break;case"priority-desc":m.sort((o,a)=>{const x={critical:4,high:3,medium:2,low:1},c=x[o.priority||""]||0,N=(x[a.priority||""]||0)-c;return N!==0?N:(a.specNumber||0)-(o.specNumber||0)});break;case"priority-asc":m.sort((o,a)=>{const x={critical:4,high:3,medium:2,low:1},c=x[o.priority||""]||0,l=x[a.priority||""]||0,N=c-l;return N!==0?N:(a.specNumber||0)-(o.specNumber||0)});break;case"updated-desc":m.sort((o,a)=>{const x="updatedAt"in o?o.updatedAt:void 0,c="updatedAt"in a?a.updatedAt:void 0;if(!x)return 1;if(!c)return-1;const l=new Date(x).getTime(),j=new Date(c).getTime()-l;return j!==0?j:(a.specNumber||0)-(o.specNumber||0)});break;case"title-asc":m.sort((o,a)=>{const x=(o.title||o.specName).toLowerCase(),c=(a.title||a.specName).toLowerCase(),l=x.localeCompare(c);return l!==0?l:(a.specNumber||0)-(o.specNumber||0)});break;default:m.sort((o,a)=>(a.specNumber||0)-(o.specNumber||0));break}return m}const dt=r.memo(function n({node:s,basePath:m,depth:o=0,sortBy:a="id-desc",onTokenClick:x,onValidationClick:c,onNodeStatusChange:l,onNodePriorityChange:N}){const[j,M]=r.useState(o<1),h=s.childNodes&&s.childNodes.length>0,T=r.useCallback(d=>{d.stopPropagation(),M(P=>!P)},[]),v=r.useMemo(()=>h?ns(s.childNodes,a):[],[h,s.childNodes,a]);return e.jsxs("div",{className:"space-y-1",children:[e.jsx("div",{className:A("border rounded-lg bg-background transition-colors","hover:bg-secondary/50"),children:e.jsxs("div",{className:"flex items-start",children:[e.jsx("div",{className:A("w-8 h-full px-2 py-5 cursor-pointer text-muted-foreground hover:text-foreground flex items-center",!h&&"invisible pointer-events-none"),onClick:T,children:h&&e.jsx($e,{className:A("h-4 w-4 transition-transform",j&&"rotate-90")})}),e.jsxs(ge,{to:`${m}/specs/${s.specName}`,className:"flex-1 p-4 pl-0 block",children:[e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[h&&e.jsx(ee,{className:"h-3.5 w-3.5 text-primary/70"}),e.jsxs("span",{className:"text-xs font-mono text-muted-foreground bg-secondary px-1.5 py-0.5 rounded",children:["#",s.specNumber]}),e.jsx("h3",{className:"font-medium truncate",children:s.title||s.specName})]}),e.jsx("p",{className:"text-sm text-muted-foreground truncate",children:s.specName})]}),e.jsxs("div",{className:"flex gap-2 items-center flex-shrink-0 flex-wrap justify-end",children:[s.status&&e.jsx(as,{status:s.status,editable:!!l,onChange:d=>l?.(s.specName,d)}),s.priority&&e.jsx(fe,{priority:s.priority,editable:!!N,onChange:d=>N?.(s.specName,d)}),e.jsx(Ne,{count:s.tokenCount,size:"sm",onClick:x?()=>x(s.specName):void 0}),e.jsx(be,{status:s.validationStatus,size:"sm",onClick:c?()=>c(s.specName):void 0})]})]}),s.tags&&s.tags.length>0&&e.jsx("div",{className:"flex gap-2 mt-3 flex-wrap",children:s.tags.map(d=>e.jsx("span",{className:"text-xs px-2 py-0.5 bg-secondary rounded text-secondary-foreground",children:d},d))})]})]})}),h&&e.jsx(xs,{open:j,children:e.jsx(gs,{forceMount:j?!0:void 0,children:e.jsx("div",{className:"ml-4 pl-4 border-l-2 border-border/40 space-y-2 mt-2 mb-4",children:v.map(d=>e.jsx(n,{node:d,basePath:m,depth:o+1,sortBy:a,onTokenClick:x,onValidationClick:c,onNodeStatusChange:l,onNodePriorityChange:N},d.specName))})})})]})});function Be(n,s){const m=[];for(const o of n)if(s.has(o.specName)){const a=o.childNodes?Be(o.childNodes,s):[];m.push({...o,childNodes:a})}else if(o.childNodes&&o.childNodes.length>0){const a=Be(o.childNodes,s);a.length>0&&m.push({...o,childNodes:a})}return m}const mt=r.memo(function({specs:s,hierarchy:m,basePath:o="/projects",sortBy:a="id-desc",onTokenClick:x,onValidationClick:c,onStatusChange:l,onPriorityChange:N}){const j=r.useMemo(()=>new Set(s.map(d=>d.specName)),[s]),M=r.useMemo(()=>new Map(s.map(d=>[d.specName,d])),[s]),h=r.useCallback((d,P)=>{const S=M.get(d);S&&l&&l(S,P)},[M,l]),T=r.useCallback((d,P)=>{const S=M.get(d);S&&N&&N(S,P)},[M,N]),v=r.useMemo(()=>{let d;return m!==void 0?d=Be(m,j):d=hs(s),ns(d,a)},[m,s,a,j]);return s.length===0?null:e.jsx("div",{className:"h-full overflow-y-auto space-y-2",children:v.map(d=>e.jsx(dt,{node:d,basePath:o,depth:0,sortBy:a,onTokenClick:x,onValidationClick:c,onNodeStatusChange:l?h:void 0,onNodePriorityChange:N?T:void 0},d.specName))})}),Ie=120,ut=120,pt=r.memo(function({spec:s,basePath:m,onTokenClick:o,onValidationClick:a,onStatusChange:x,onPriorityChange:c}){return e.jsx(ge,{to:`${m}/specs/${s.specName}`,className:"block border rounded-lg hover:bg-secondary/50 transition-colors bg-background",children:e.jsxs("div",{className:"flex items-start",children:[e.jsx("div",{className:"w-8 h-full invisible flex items-center text-muted-foreground"}),e.jsxs("div",{className:"flex-1 p-4 pl-0",children:[e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsxs("span",{className:"text-xs font-mono text-muted-foreground bg-secondary px-1.5 py-0.5 rounded",children:["#",s.specNumber]}),e.jsx("h3",{className:"font-medium truncate",children:s.title})]}),e.jsx("p",{className:"text-sm text-muted-foreground truncate",children:s.specName})]}),e.jsxs("div",{className:"flex gap-2 items-center flex-shrink-0 flex-wrap justify-end",children:[s.status&&e.jsx(as,{status:s.status,editable:!!x,onChange:l=>x?.(s,l)}),s.priority&&e.jsx(fe,{priority:s.priority,editable:!!c,onChange:l=>c?.(s,l)}),e.jsx(Ne,{count:s.tokenCount,size:"sm",onClick:()=>o(s.specName)}),e.jsx(be,{status:s.validationStatus,size:"sm",onClick:()=>a(s.specName)})]})]}),s.tags&&s.tags.length>0&&e.jsx("div",{className:"flex gap-2 mt-3 flex-wrap",children:s.tags.map(l=>e.jsx("span",{className:"text-xs px-2 py-0.5 bg-secondary rounded text-secondary-foreground",children:l},l))})]})]})})}),ht=r.memo(function({specs:s,hierarchy:m,basePath:o="/projects",groupByParent:a=!1,sortBy:x="id-desc",onTokenClick:c,onValidationClick:l,onStatusChange:N,onPriorityChange:j}){const{t:M}=xe("common"),[h,T]=r.useState(Ie);r.useEffect(()=>{if(a)return;const d=s.length,P=Math.min(Ie,d);if(typeof window>"u")return;let S=null,V=!1;const z=()=>{if(V||(T(P),d<=Ie))return;const B=()=>{V||T(I=>{const F=Math.min(I+ut,d);return F<d&&!V&&(S=window.requestAnimationFrame(B)),F})};S=window.requestAnimationFrame(B)};return S=window.requestAnimationFrame(z),()=>{V=!0,S!==null&&window.cancelAnimationFrame(S)}},[a,s.length]);const v=r.useMemo(()=>a?s:s.slice(0,h),[a,s,h]);return s.length===0?e.jsx("div",{className:"text-center py-12 text-muted-foreground border rounded-lg bg-secondary/10",children:M("specsPage.list.empty")}):a?e.jsx(mt,{specs:s,hierarchy:m,basePath:o,sortBy:x,onTokenClick:c,onValidationClick:l,onStatusChange:N,onPriorityChange:j}):e.jsxs("div",{className:"h-full overflow-y-auto space-y-2",children:[v.map(d=>e.jsx(pt,{spec:d,basePath:o,onTokenClick:P=>c?.(P),onValidationClick:P=>l?.(P),onStatusChange:N,onPriorityChange:j},d.specName)),!a&&h<s.length&&e.jsx("div",{className:"py-3 text-center text-xs text-muted-foreground",children:M("specsPage.list.loadingMore",{visible:h,total:s.length,defaultValue:"Rendering {{visible}} / {{total}} specs..."})})]})});function xt({searchQuery:n,onSearchChange:s,statusFilter:m,onStatusFilterChange:o,priorityFilter:a,onPriorityFilterChange:x,tagFilter:c,onTagFilterChange:l,sortBy:N,onSortByChange:j,uniqueStatuses:M,uniquePriorities:h,uniqueTags:T,onClearFilters:v,totalSpecs:d,filteredCount:P,viewMode:S,onViewModeChange:V,groupByParent:z,onGroupByParentChange:B,showValidationIssuesOnly:I,onShowValidationIssuesOnlyChange:F,showArchived:G,onShowArchivedChange:se,loadingValidation:U}){const{t:k}=xe("common"),[t,p]=r.useState(n);r.useEffect(()=>{p(n)},[n]),r.useEffect(()=>{const f=setTimeout(()=>{t!==n&&s(t)},120);return()=>clearTimeout(f)},[t,s,n]);const w={draft:ss,planned:es,"in-progress":Je,complete:Ye,archived:Oe},$={critical:rs,high:vs,medium:ys,low:js},C={draft:"status.draft",planned:"status.planned","in-progress":"status.inProgress",complete:"status.complete",archived:"status.archived"},E={critical:"priority.critical",high:"priority.high",medium:"priority.medium",low:"priority.low"},R=f=>C[f]?k(C[f]):f,Z=f=>E[f]?k(E[f]):f,te=n||m.length>0||a.length>0||c.length>0||I,W=z||I||G,je=f=>{o(m.includes(f)?m.filter(O=>O!==f):[...m,f])},ce=f=>{x(a.includes(f)?a.filter(O=>O!==f):[...a,f])},ye=f=>{l(c.includes(f)?c.filter(O=>O!==f):[...c,f])};return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"relative",children:[e.jsx(fs,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 w-4 h-4 text-muted-foreground"}),e.jsx(Ns,{type:"text",placeholder:k("specsPage.searchPlaceholder"),value:t,onChange:f=>p(f.target.value),className:"w-full pl-10 pr-10 py-2"}),t&&e.jsx("button",{type:"button",className:"absolute right-3 top-1/2 transform -translate-y-1/2 text-muted-foreground hover:text-foreground",onClick:()=>{p(""),s("")},children:e.jsx(Ge,{className:"w-4 h-4"})})]}),t&&e.jsx("p",{className:"text-xs text-muted-foreground pl-1",children:k("specsPage.searchHint")})]}),e.jsxs("div",{className:"flex flex-wrap gap-3 items-center justify-between",children:[e.jsxs("div",{className:"flex flex-wrap gap-3 items-center",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[e.jsx(bs,{className:"w-4 h-4"}),e.jsx("span",{className:"text-sm font-medium",children:k("specsNavSidebar.filtersLabel")})]}),e.jsxs(Se,{children:[e.jsx(De,{asChild:!0,children:e.jsxs(q,{variant:"outline",className:"w-[140px] justify-between h-9 px-3",children:[e.jsx("span",{className:"truncate",children:m.length===0?k("specsPage.filters.statusAll"):m.length===1?R(m[0]):`${m.length} ${k("specsNavSidebar.selected")}`}),e.jsx(J,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx(Me,{className:"w-[180px] p-1",align:"start",children:e.jsx("div",{className:"space-y-1",children:M.map(f=>{const O=w[f],K=m.includes(f);return e.jsxs("div",{className:"flex items-center gap-2 px-2 py-1.5 rounded-md hover:bg-accent cursor-pointer group",onClick:()=>je(f),children:[e.jsx("div",{className:A("flex items-center justify-center w-4 h-4 border rounded transition-colors",K?"bg-primary border-primary text-primary-foreground":"group-hover:border-primary/50"),children:K&&e.jsx(Pe,{className:"h-3 w-3"})}),e.jsxs("div",{className:"flex items-center gap-2 flex-1",children:[O&&e.jsx(O,{className:"h-4 w-4"}),e.jsx("span",{className:"text-sm",children:R(f)})]})]},f)})})})]}),e.jsxs(Se,{children:[e.jsx(De,{asChild:!0,children:e.jsxs(q,{variant:"outline",className:"w-[140px] justify-between h-9 px-3",children:[e.jsx("span",{className:"truncate",children:a.length===0?k("specsPage.filters.priorityAll"):a.length===1?Z(a[0]):`${a.length} ${k("specsNavSidebar.selected")}`}),e.jsx(J,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx(Me,{className:"w-[180px] p-1",align:"start",children:e.jsx("div",{className:"space-y-1",children:h.map(f=>{const O=$[f],K=a.includes(f);return e.jsxs("div",{className:"flex items-center gap-2 px-2 py-1.5 rounded-md hover:bg-accent cursor-pointer group",onClick:()=>ce(f),children:[e.jsx("div",{className:A("flex items-center justify-center w-4 h-4 border rounded transition-colors",K?"bg-primary border-primary text-primary-foreground":"group-hover:border-primary/50"),children:K&&e.jsx(Pe,{className:"h-3 w-3"})}),e.jsxs("div",{className:"flex items-center gap-2 flex-1",children:[O&&e.jsx(O,{className:"h-4 w-4"}),e.jsx("span",{className:"text-sm",children:Z(f)})]})]},f)})})})]}),e.jsxs(Se,{children:[e.jsx(De,{asChild:!0,children:e.jsxs(q,{variant:"outline",className:"w-[140px] justify-between h-9 px-3",children:[e.jsx("span",{className:"truncate",children:c.length===0?k("specsNavSidebar.select.tag.all"):c.length===1?c[0]:`${c.length} ${k("specsNavSidebar.selected")}`}),e.jsx(J,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx(Me,{className:"w-[180px] p-1",align:"start",children:e.jsx("div",{className:"space-y-1 max-h-48 overflow-y-auto",children:T.map(f=>{const O=c.includes(f);return e.jsxs("div",{className:"flex items-center gap-2 px-2 py-1.5 rounded-md hover:bg-accent cursor-pointer group",onClick:()=>ye(f),children:[e.jsx("div",{className:A("flex items-center justify-center w-4 h-4 border rounded transition-colors",O?"bg-primary border-primary text-primary-foreground":"group-hover:border-primary/50"),children:O&&e.jsx(Pe,{className:"h-3 w-3"})}),e.jsx("span",{className:"text-sm flex-1 break-all",children:f})]},f)})})})]}),e.jsxs(ws,{value:N,onValueChange:j,children:[e.jsx(ks,{className:"w-[160px]",children:e.jsx(Cs,{placeholder:k("specsPage.filters.sort")})}),e.jsxs(Ss,{children:[e.jsx(Y,{value:"id-desc",children:k("specsPage.filters.sortOptions.id-desc")}),e.jsx(Y,{value:"id-asc",children:k("specsPage.filters.sortOptions.id-asc")}),e.jsx(Y,{value:"updated-desc",children:k("specsPage.filters.sortOptions.updated-desc")}),e.jsx(Y,{value:"title-asc",children:k("specsPage.filters.sortOptions.title-asc")}),e.jsx(Y,{value:"priority-desc",children:k("specsPage.filters.sortOptions.priority-desc")}),e.jsx(Y,{value:"priority-asc",children:k("specsPage.filters.sortOptions.priority-asc")})]})]}),te&&e.jsxs(q,{onClick:v,variant:"ghost",size:"sm",className:"h-9 gap-1",children:[e.jsx(Ge,{className:"w-4 h-4"}),k("specsNavSidebar.clearFilters")]}),e.jsxs("span",{className:"text-sm text-muted-foreground flex items-center gap-1.5",children:[U&&I&&e.jsx(Ds,{className:"w-3 h-3 animate-spin"}),k("specsPage.filters.filteredCount",{filtered:P,total:d})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(Ms,{children:[e.jsx(Ps,{asChild:!0,children:e.jsxs(q,{variant:W?"secondary":"outline",size:"sm",className:"h-9 gap-1.5",children:[e.jsx(Ts,{className:A("w-4 h-4",W?"text-primary":"text-muted-foreground")}),e.jsx("span",{className:"hidden sm:inline",children:k("specsPage.filters.settings")})]})}),e.jsxs(Ls,{align:"end",className:"w-48",children:[e.jsxs(Te,{checked:z,onCheckedChange:B,children:[e.jsx(ee,{className:"w-4 h-4 mr-2"}),k("specsPage.filters.groupByParent")]}),e.jsxs(Te,{checked:I,onCheckedChange:F,children:[e.jsx(As,{className:"w-4 h-4 mr-2"}),k("specsPage.filters.withErrors")]}),e.jsxs(Te,{checked:G,onCheckedChange:se,children:[e.jsx(Oe,{className:"w-4 h-4 mr-2"}),k("specsPage.filters.showArchived")]})]})]}),e.jsxs("div",{className:"flex items-center gap-1 bg-secondary/50 p-1 rounded-lg border h-9",children:[e.jsxs(q,{variant:S==="list"?"secondary":"ghost",size:"sm",onClick:()=>V("list"),className:A("h-7",S==="list"&&"bg-background shadow-sm"),title:k("specsPage.views.listTooltip"),children:[e.jsx(Is,{className:"w-4 h-4 mr-1.5"}),k("specsPage.views.list")]}),e.jsxs(q,{variant:S==="board"?"secondary":"ghost",size:"sm",onClick:()=>V("board"),className:A("h-7",S==="board"&&"bg-background shadow-sm"),title:k("specsPage.views.boardTooltip"),children:[e.jsx(ot,{className:"w-4 h-4 mr-1.5"}),k("specsPage.views.board")]})]})]})]})]})}function gt(n){const[s,m]=r.useState(null),[o,a]=r.useState(!1),[x,c]=r.useState(!1),[l,N]=r.useState(null),[j,M]=r.useState(!1),[h,T]=r.useState(!1),[v,d]=r.useState(null),P=Os(),S=r.useCallback(()=>{a(!1),c(!1),N(null)},[]),V=r.useCallback(()=>{M(!1),T(!1),d(null)},[]),z=r.useCallback(I=>{n&&(m(I),a(!0))},[n]),B=r.useCallback(I=>{n&&(m(I),M(!0))},[n]);return r.useEffect(()=>{!o||!s||!n||(c(!0),P.getSpecTokens(n,s).then(I=>N(I)).catch(()=>N(null)).finally(()=>c(!1)))},[s,P,n,o]),r.useEffect(()=>{!j||!s||!n||(T(!0),P.getSpecValidation(n,s).then(I=>d(I)).catch(()=>d(null)).finally(()=>T(!1)))},[s,P,n,j]),{activeSpecName:s,tokenDialogOpen:o,tokenDialogLoading:x,tokenDialogData:l,closeTokenDialog:S,handleTokenClick:z,validationDialogOpen:j,validationDialogLoading:h,validationDialogData:v,closeValidationDialog:V,handleValidationClick:B}}const ft=120;function kt(){const{projectId:n}=Es(),{currentProject:s}=Vs(),m=n??s?.id,o=m?`/projects/${m}`:"/projects",{machineModeEnabled:a,isMachineAvailable:x}=Bs(),c=$s(m??null,{hierarchy:!0}),l=r.useMemo(()=>c.data?.specs??[],[c.data]),N=Hs(),j=r.useCallback(g=>{N.setQueriesData({queryKey:Le.lists()},b=>{if(!b)return b;if(Array.isArray(b))return g(b);if(typeof b=="object"&&b&&"specs"in b){const D=b;return{...D,specs:g(D.specs??[])}}return b})},[N]),M=r.useMemo(()=>c.data?.hierarchy,[c.data]),{t:h}=xe("common"),T=c.isLoading&&!c.data,v=c.error?h("specsPage.state.errorDescription"):null,{activeSpecName:d,tokenDialogOpen:P,tokenDialogLoading:S,tokenDialogData:V,closeTokenDialog:z,handleTokenClick:B,validationDialogOpen:I,validationDialogLoading:F,validationDialogData:G,closeValidationDialog:se,handleValidationClick:U}=gt(m),{statusFilter:k,priorityFilter:t,tagFilter:p,sortBy:w,hierarchyView:$,showArchived:C,pageViewMode:E,showValidationIssuesOnly:R,setStatusFilter:Z,setPriorityFilter:te,setTagFilter:W,setSortBy:je,setHierarchyView:ce,setShowArchived:ye,setPageViewMode:f,setShowValidationIssuesOnly:O}=qs(),[K]=zs(),le=r.useMemo(()=>({tag:K.get("tag"),query:K.get("q"),view:K.get("view"),groupByParent:K.get("groupByParent")}),[K]),os=le.query??"",ve=le.tag,de=le.view,we=le.groupByParent,[He,qe]=r.useState(os),ae=r.useDeferredValue(He),me=_s(m??null,ae),re=r.useMemo(()=>k.filter(g=>g!=="archived"),[k]),ue=r.useMemo(()=>ve?[ve]:p,[ve,p]),ne=r.useMemo(()=>we==="1"||we==="true"?!0:$,[we,$]),ze=r.useMemo(()=>de==="board"||de==="list"?de:E,[de,E]),is=r.useCallback(g=>ce(g),[ce]),cs=r.useCallback(g=>f(g),[f]),ls=r.useMemo(()=>l.map(g=>g.specName),[l]),Q=Ks(m??null,ls),[X,pe]=r.useState(null);r.useEffect(()=>{if(!Q.data)return;const g=Q.data;j(b=>b.map(D=>{const y=g.specs[D.specName];return y?{...D,tokenCount:y.tokenCount,tokenStatus:y.tokenStatus,validationStatus:y.validationStatus}:D}))},[Q.data,j]);const _e=r.useMemo(()=>{if(!Q.data)return{};const g={};for(const[b,D]of Object.entries(Q.data.specs))g[b]=D.validationStatus;return g},[Q.data]),ds=Q.isLoading,he=r.useCallback(async(g,b,D=!1)=>{if(!(a&&!x())){j(y=>y.map(u=>u.specName===g.specName?{...u,status:b}:u));try{await Ue.updateSpec(g.specName,{status:b,expectedContentHash:g.contentHash,force:D}),N.invalidateQueries({queryKey:Le.lists()})}catch(y){j(u=>u.map(i=>i.specName===g.specName?{...i,status:g.status}:i)),console.error("Failed to update status:",y)}}},[x,a,N,j]),Ke=r.useCallback((g,b)=>{if(g.status==="draft"&&(b==="in-progress"||b==="complete")){pe({spec:g,nextStatus:b});return}he(g,b)},[he]),Re=r.useCallback(async(g,b)=>{if(a&&!x())return;const D=g.priority;j(y=>y.map(u=>u.specName===g.specName?{...u,priority:b}:u));try{await Ue.updateSpec(g.specName,{priority:b,expectedContentHash:g.contentHash}),N.invalidateQueries({queryKey:Le.lists()})}catch(y){j(u=>u.map(i=>i.specName===g.specName?{...i,priority:D}:i)),console.error("Failed to update priority:",y)}},[x,a,N,j]),ke=r.useCallback(()=>{c.refetch()},[c]),ms=r.useMemo(()=>{const g=l.map(y=>y.status).filter(y=>!!y),b=Array.from(new Set(g)).filter(y=>C||y!=="archived"),D={draft:0,planned:1,"in-progress":2,complete:3,archived:4};return b.sort((y,u)=>D[y]-D[u])},[l,C]),us=r.useMemo(()=>{const g=Array.from(new Set(l.map(D=>D.priority).filter(Boolean))),b={critical:1,high:2,medium:3,low:4};return g.sort((D,y)=>(b[D]||999)-(b[y]||999))},[l]),ps=r.useMemo(()=>Array.from(new Set(l.flatMap(b=>b.tags||[]))).sort((b,D)=>b.toLowerCase().localeCompare(D.toLowerCase())),[l]),Fe=r.useCallback(()=>{qe(""),Z([]),te([]),W([]),O(!1)},[Z,te,W,O]),Qe=r.useCallback((g,b)=>{const D=new Map;for(const i of b){const L=i.parent;L&&(D.has(L)||D.set(L,[]),D.get(L).push(i))}const y=new Set(g.map(i=>i.specName||i.id)),u=i=>{const L=D.get(i);if(L)for(const _ of L){const H=_.specName||_.id;H&&!y.has(H)&&(y.add(H),u(H))}};for(const i of g)u(i.specName||i.id||"");return b.filter(i=>y.has(i.specName||i.id||""))},[]),oe=r.useMemo(()=>{let g=l;const b=ae&&me.data;if(b){const u=new Set(me.data.results.map(i=>i.specName));g=l.filter(i=>u.has(i.specName))}let D=g.filter(u=>{if(!C&&u.status==="archived")return!1;if(ae&&!b){const i=ae.toLowerCase();if(!(u.specName.toLowerCase().includes(i)||(u.title?u.title.toLowerCase().includes(i):!1)||u.tags?.some(_=>_.toLowerCase().includes(i))))return!1}if(re.length>0&&u.status&&!re.includes(u.status)||t.length>0&&u.priority&&!t.includes(u.priority)||ue.length>0&&!u.tags?.some(i=>ue.includes(i)))return!1;if(R){const i=_e[u.specName],L=u.validationStatus||i;if(!(L&&L!=="pass"))return!1}return!0});ne&&(re.length>0||t.length>0)&&(D=Qe(D,l));const y=[...D];if(b){const u=new Map(me.data.results.map((i,L)=>[i.specName,L]));y.sort((i,L)=>(u.get(i.specName)??9999)-(u.get(L.specName)??9999))}else switch(w){case"id-asc":y.sort((u,i)=>(u.specNumber||0)-(i.specNumber||0));break;case"priority-desc":y.sort((u,i)=>{const L={critical:4,high:3,medium:2,low:1},_=L[u.priority||""]||0,ie=(L[i.priority||""]||0)-_;return ie!==0?ie:(i.specNumber||0)-(u.specNumber||0)});break;case"priority-asc":y.sort((u,i)=>{const L={critical:4,high:3,medium:2,low:1},_=L[u.priority||""]||0,H=L[i.priority||""]||0,ie=_-H;return ie!==0?ie:(i.specNumber||0)-(u.specNumber||0)});break;case"updated-desc":y.sort((u,i)=>{if(!u.updatedAt)return 1;if(!i.updatedAt)return-1;const L=new Date(u.updatedAt).getTime(),H=new Date(i.updatedAt).getTime()-L;return H!==0?H:(i.specNumber||0)-(u.specNumber||0)});break;case"title-asc":y.sort((u,i)=>{const L=(u.title||u.specName).toLowerCase(),_=(i.title||i.specName).toLowerCase(),H=L.localeCompare(_);return H!==0?H:(i.specNumber||0)-(u.specNumber||0)});break;default:y.sort((u,i)=>(i.specNumber||0)-(u.specNumber||0));break}return y},[t,ae,w,l,re,ue,ne,Qe,R,C,_e,me.data]),Ce=oe.length<=ft;return T?e.jsx(Ae,{children:e.jsx(Rs,{})}):v?e.jsx(Ae,{children:e.jsx(Fs,{children:e.jsxs(Qs,{className:"py-10 text-center space-y-3",children:[e.jsx("div",{className:"flex justify-center",children:e.jsx(rs,{className:"h-6 w-6 text-destructive"})}),e.jsx("div",{className:"text-lg font-semibold",children:h("specsPage.state.errorTitle")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:v||h("specsPage.state.errorDescription")}),e.jsx(q,{variant:"secondary",size:"sm",onClick:ke,className:"mt-2",children:h("actions.retry")})]})})}):e.jsxs(Ae,{className:"h-[calc(100vh-3.5rem)]",contentClassName:"flex h-full flex-col gap-4",children:[e.jsxs("div",{className:"flex flex-col gap-4 sticky top-0 bg-background mt-0 py-2 z-10",children:[e.jsx(Gs,{title:h("specsPage.title"),description:h("specsPage.description")}),a&&!x()&&e.jsx("div",{className:"text-xs text-destructive",children:h("machines.unavailable")}),e.jsx(xt,{searchQuery:He,onSearchChange:qe,statusFilter:re,onStatusFilterChange:Z,priorityFilter:t,onPriorityFilterChange:te,tagFilter:ue,onTagFilterChange:W,sortBy:w,onSortByChange:g=>je(g),uniqueStatuses:ms,uniquePriorities:us,uniqueTags:ps,onClearFilters:Fe,totalSpecs:l.length,filteredCount:oe.length,viewMode:ze,onViewModeChange:cs,groupByParent:ne,onGroupByParentChange:is,showValidationIssuesOnly:R,onShowValidationIssuesOnlyChange:O,showArchived:C,onShowArchivedChange:ye,loadingValidation:ds})]}),e.jsx("div",{className:"flex-1 min-h-0",children:l.length===0?e.jsx(Ze,{icon:tt,title:h("specsPage.state.noSpecsTitle"),description:h("specsPage.state.noSpecsDescription"),actions:e.jsxs(q,{variant:"secondary",size:"sm",onClick:ke,children:[e.jsx(We,{className:"h-4 w-4 mr-2"}),h("specsPage.buttons.refreshList")]})}):oe.length===0?e.jsx(Ze,{icon:at,title:h("specsPage.state.noFiltersTitle"),description:h("specsPage.state.noFiltersDescription"),actions:e.jsxs("div",{className:"flex gap-2 flex-wrap justify-center",children:[e.jsx(q,{variant:"outline",size:"sm",onClick:Fe,children:h("specsNavSidebar.clearFilters")}),e.jsxs(q,{variant:"secondary",size:"sm",onClick:ke,children:[e.jsx(We,{className:"h-4 w-4 mr-2"}),h("specsPage.buttons.reloadData")]})]})}):ze==="list"?e.jsx(ht,{specs:oe,hierarchy:M,basePath:o,groupByParent:ne,sortBy:w,onTokenClick:B,onValidationClick:U,onStatusChange:Ce?Ke:void 0,onPriorityChange:Ce?Re:void 0}):e.jsx(lt,{specs:oe,onStatusChange:Ke,onPriorityChange:Ce?Re:void 0,canEdit:!a||x(),basePath:o,groupByParent:ne,showArchived:C,onTokenClick:B,onValidationClick:U})}),d&&P&&e.jsx(et,{open:P,onClose:z,specName:d,data:V,loading:S}),d&&I&&e.jsx(st,{open:I,onClose:se,specName:d,data:G,loading:F}),e.jsx(Us,{open:!!X,onOpenChange:g=>!g&&pe(null),children:e.jsxs(Zs,{children:[e.jsxs(Ws,{children:[e.jsx(Xs,{children:h("editors.draftSkipTitle")}),e.jsx(Ys,{children:h("editors.draftSkipDescription")})]}),e.jsxs("div",{className:"flex flex-wrap justify-end gap-2",children:[e.jsx(q,{variant:"outline",onClick:()=>{X&&(he(X.spec,"planned"),pe(null))},children:h("editors.draftSkipPlanned")}),e.jsx(q,{onClick:()=>{X&&(he(X.spec,X.nextStatus,!0),pe(null))},children:h("editors.draftSkipForce")})]})]})})]})}export{kt as SpecsPage};
|