specrails-desktop 2.18.2 → 2.19.1
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/README.md +1 -1
- package/client/dist/assets/{ActivityFeedPage-mGnv5SOe.js → ActivityFeedPage-C0_k6n5T.js} +1 -1
- package/client/dist/assets/AgentBrowserCapture-NHUCEnTh.js +1 -0
- package/client/dist/assets/AgentModeCodePane-jddXrhPY.js +2 -0
- package/client/dist/assets/AgentsPage-BPjf6bId.js +86 -0
- package/client/dist/assets/AnalyticsPage-BaJjj5mO.js +1 -0
- package/client/dist/assets/{BarChart-BqHUOnl9.js → BarChart-HPiao--v.js} +1 -1
- package/client/dist/assets/CodePage-CAD4KfkC.js +2 -0
- package/client/dist/assets/{DesktopAnalyticsPage-CR-m97Ui.js → DesktopAnalyticsPage-B2RBxIvj.js} +1 -1
- package/client/dist/assets/DocsDialog-BJDvUEGj.js +11 -0
- package/client/dist/assets/DocsPage-B6H-DBs8.js +11 -0
- package/client/dist/assets/{ExportDropdown-C-o1Q4ef.js → ExportDropdown-CYMcbLTD.js} +1 -1
- package/client/dist/assets/IntegrationsPage-Dx_UpQVk.js +3 -0
- package/client/dist/assets/JobDetailPage-BlTnsRAN.js +16 -0
- package/client/dist/assets/JobsPage-EB0PbXOk.js +1 -0
- package/client/dist/assets/LoopBuilderPage-DfWfhhJY.js +7 -0
- package/client/dist/assets/LoopsPage-DCVATTv5.js +1 -0
- package/client/dist/assets/{addspec-B9dY_F5T.js → addspec-BXV6sx5l.js} +1 -1
- package/client/dist/assets/{addspec-tbxr3sHa.js → addspec-CS895X6A.js} +1 -1
- package/client/dist/assets/{addspec-W0r16BOC2.js → addspec-CXfEOrD42.js} +1 -1
- package/client/dist/assets/{addspec-D43TlMVp2.js → addspec-D28kw9ow2.js} +1 -1
- package/client/dist/assets/{addspec-B9nhMikb.js → addspec-D39EEg02.js} +1 -1
- package/client/dist/assets/{addspec-DfgIZ5lO.js → addspec-DC1tgsFG.js} +1 -1
- package/client/dist/assets/{addspec-BtNaJHu2.js → addspec-DcHALPEp.js} +1 -1
- package/client/dist/assets/{addspec-BloGn_ey.js → addspec-DxW6oPsk.js} +1 -1
- package/client/dist/assets/{agent-Bm2tPrdr.js → agent-B5Ycau5M.js} +1 -1
- package/client/dist/assets/{agent-DMUrz9ZS2.js → agent-BEz08l4_2.js} +1 -1
- package/client/dist/assets/{agent-C4bO1l_v.js → agent-BIX51CEA.js} +1 -1
- package/client/dist/assets/{agent-9WdSxPU5.js → agent-Bc9Kwf65.js} +1 -1
- package/client/dist/assets/{agent-pO8x4jbR.js → agent-BiM7puyn.js} +1 -1
- package/client/dist/assets/{agent-CgKsh88Z2.js → agent-C0kYSv3m2.js} +1 -1
- package/client/dist/assets/agent-CCzWlfqs.js +1 -0
- package/client/dist/assets/{agent-ASIyVcg0.js → agent-DiCSo31C.js} +1 -1
- package/client/dist/assets/{agents-DfGvYtpq2.js → agents-BFrHy5d-2.js} +1 -1
- package/client/dist/assets/{agents-Dli56gr82.js → agents-BFy2Kq_k2.js} +1 -1
- package/client/dist/assets/{agents-C07al8rI.js → agents-BXDCFJQa.js} +1 -1
- package/client/dist/assets/{agents-BAxAwHy-.js → agents-BySH0Gvw.js} +1 -1
- package/client/dist/assets/{agents-Eqw_AQ6H.js → agents-CTdwacTO.js} +1 -1
- package/client/dist/assets/{agents-BjT_xLjv.js → agents-Cev2oFfX.js} +1 -1
- package/client/dist/assets/{agents-BUYBb825.js → agents-CsDEv4Fj.js} +1 -1
- package/client/dist/assets/{agents-52t8NVpS.js → agents-z0kA-y0Q.js} +1 -1
- package/client/dist/assets/dashboard-Bl2_Yjs6.js +1 -0
- package/client/dist/assets/dashboard-C_vS9RaM2.js +1 -0
- package/client/dist/assets/dashboard-CcEpALV_.js +1 -0
- package/client/dist/assets/dashboard-CfltY66K.js +1 -0
- package/client/dist/assets/dashboard-CoED_41r.js +1 -0
- package/client/dist/assets/dashboard-DLeC5ziO.js +1 -0
- package/client/dist/assets/dashboard-DxEPkALo2.js +1 -0
- package/client/dist/assets/dashboard-MgDVmaYS2.js +1 -0
- package/client/dist/assets/{dist-js-CUegfF6k.js → dist-js-ClEfL6Bo.js} +1 -1
- package/client/dist/assets/{dist-js-BHhtSerX.js → dist-js-b2_z7zAi.js} +1 -1
- package/client/dist/assets/index-9yNUBwEi.css +2 -0
- package/client/dist/assets/{index-B7vB20Jw.js → index-BeujshsU.js} +57 -57
- package/client/dist/assets/{lib-PQoHlR5u.js → lib-CfphudAm.js} +1 -1
- package/client/dist/assets/loops-BEUiCzEI.js +1 -0
- package/client/dist/assets/loops-BlrQiK122.js +1 -0
- package/client/dist/assets/loops-Bs0ectZ32.js +1 -0
- package/client/dist/assets/loops-CLZV8HHY2.js +1 -0
- package/client/dist/assets/loops-CQuuMlyZ.js +1 -0
- package/client/dist/assets/loops-DuuWQWTI.js +1 -0
- package/client/dist/assets/loops-KOTryzk5.js +1 -0
- package/client/dist/assets/loops-t1mUZtf0.js +1 -0
- package/client/dist/assets/nav--1ErXZrS.js +1 -0
- package/client/dist/assets/nav-18nqSJ8h.js +1 -0
- package/client/dist/assets/nav-BuonHb17.js +1 -0
- package/client/dist/assets/nav-C-sCoOLY2.js +1 -0
- package/client/dist/assets/nav-ClXz_3Ic2.js +1 -0
- package/client/dist/assets/nav-CtqgSQeE2.js +1 -0
- package/client/dist/assets/nav-S3YvCaVv.js +1 -0
- package/client/dist/assets/nav-czg8NkN-.js +1 -0
- package/client/dist/assets/settings-BOZBX-Vq.js +1 -0
- package/client/dist/assets/settings-CX29QcQW.js +1 -0
- package/client/dist/assets/settings-CfOWHPzc2.js +1 -0
- package/client/dist/assets/settings-DaXhxNug2.js +1 -0
- package/client/dist/assets/settings-DmyDpuzu.js +1 -0
- package/client/dist/assets/settings-DwPRLcxr2.js +1 -0
- package/client/dist/assets/settings-MjYVJvDE.js +1 -0
- package/client/dist/assets/settings-zJFdTzKE.js +1 -0
- package/client/dist/assets/{setup-BYoDYoPY2.js → setup-BmXfxlzA2.js} +1 -1
- package/client/dist/assets/{setup-faMApo0U2.js → setup-BxVydxbl2.js} +1 -1
- package/client/dist/assets/{setup-C5UbM0RP.js → setup-DIRZ1Lf-.js} +1 -1
- package/client/dist/assets/{setup-Bf9eLKxU.js → setup-DwbKSnKQ.js} +1 -1
- package/client/dist/assets/{setup-JFkWWZnR.js → setup-Dx13pESZ.js} +1 -1
- package/client/dist/assets/{setup-CqGrWb6G.js → setup-G4ZvDKxX.js} +1 -1
- package/client/dist/assets/{setup-tloaTobG2.js → setup-SLAi4xxQ2.js} +1 -1
- package/client/dist/assets/{setup-4us-Bz3H.js → setup-Z01j3st4.js} +1 -1
- package/client/dist/assets/{upload-PnJDPHZH.js → upload-Ox9jUq1X.js} +1 -1
- package/client/dist/assets/{value-BTDefcOV.js → value-BeQVX5gN.js} +1 -1
- package/client/dist/index.html +10 -10
- package/docs/codex.md +5 -5
- package/docs/customizing.md +4 -4
- package/docs/gemini.md +2 -2
- package/docs/getting-started.md +1 -1
- package/docs/guide/de/integrations/1-ai-providers.md +2 -2
- package/docs/guide/de/integrations/5-mcp-server.md +20 -1
- package/docs/guide/de/pipeline/1-rails-and-jobs.md +4 -4
- package/docs/guide/de/pipeline/2-the-job-detail-view.md +1 -1
- package/docs/guide/de/pipeline/4-picking-an-engine-per-rail.md +2 -2
- package/docs/guide/de/pipeline/5-the-loop-builder.md +2 -2
- package/docs/guide/en/integrations/1-ai-providers.md +2 -2
- package/docs/guide/en/integrations/5-mcp-server.md +20 -1
- package/docs/guide/en/pipeline/1-rails-and-jobs.md +4 -4
- package/docs/guide/en/pipeline/2-the-job-detail-view.md +1 -1
- package/docs/guide/en/pipeline/4-picking-an-engine-per-rail.md +2 -2
- package/docs/guide/en/pipeline/5-the-loop-builder.md +2 -2
- package/docs/guide/es/integrations/1-ai-providers.md +2 -2
- package/docs/guide/es/integrations/5-mcp-server.md +20 -1
- package/docs/guide/es/pipeline/1-rails-and-jobs.md +4 -4
- package/docs/guide/es/pipeline/2-the-job-detail-view.md +1 -1
- package/docs/guide/es/pipeline/4-picking-an-engine-per-rail.md +2 -2
- package/docs/guide/es/pipeline/5-the-loop-builder.md +2 -2
- package/docs/guide/fr/integrations/1-ai-providers.md +2 -2
- package/docs/guide/fr/integrations/5-mcp-server.md +20 -1
- package/docs/guide/fr/pipeline/1-rails-and-jobs.md +4 -4
- package/docs/guide/fr/pipeline/2-the-job-detail-view.md +1 -1
- package/docs/guide/fr/pipeline/4-picking-an-engine-per-rail.md +2 -2
- package/docs/guide/fr/pipeline/5-the-loop-builder.md +2 -2
- package/docs/guide/it/integrations/1-ai-providers.md +2 -2
- package/docs/guide/it/integrations/5-mcp-server.md +20 -1
- package/docs/guide/it/pipeline/1-rails-and-jobs.md +4 -4
- package/docs/guide/it/pipeline/2-the-job-detail-view.md +1 -1
- package/docs/guide/it/pipeline/4-picking-an-engine-per-rail.md +2 -2
- package/docs/guide/it/pipeline/5-the-loop-builder.md +2 -2
- package/docs/guide/ja/integrations/1-ai-providers.md +2 -2
- package/docs/guide/ja/integrations/5-mcp-server.md +20 -1
- package/docs/guide/ja/pipeline/1-rails-and-jobs.md +4 -4
- package/docs/guide/ja/pipeline/2-the-job-detail-view.md +1 -1
- package/docs/guide/ja/pipeline/4-picking-an-engine-per-rail.md +2 -2
- package/docs/guide/ja/pipeline/5-the-loop-builder.md +2 -2
- package/docs/guide/pt/integrations/1-ai-providers.md +2 -2
- package/docs/guide/pt/integrations/5-mcp-server.md +20 -1
- package/docs/guide/pt/pipeline/1-rails-and-jobs.md +4 -4
- package/docs/guide/pt/pipeline/2-the-job-detail-view.md +1 -1
- package/docs/guide/pt/pipeline/4-picking-an-engine-per-rail.md +2 -2
- package/docs/guide/pt/pipeline/5-the-loop-builder.md +2 -2
- package/docs/guide/zh/integrations/1-ai-providers.md +2 -2
- package/docs/guide/zh/integrations/5-mcp-server.md +20 -1
- package/docs/guide/zh/pipeline/1-rails-and-jobs.md +4 -4
- package/docs/guide/zh/pipeline/2-the-job-detail-view.md +1 -1
- package/docs/guide/zh/pipeline/4-picking-an-engine-per-rail.md +2 -2
- package/docs/guide/zh/pipeline/5-the-loop-builder.md +2 -2
- package/docs/internals/switch-to-agent-mode-design.md +301 -0
- package/docs/internals/visual-design-audit.md +184 -0
- package/docs/mcp.md +26 -1
- package/docs/running-pipelines.md +10 -10
- package/docs/tracking-cost.md +1 -1
- package/package.json +1 -1
- package/server/dist/agent-chat-manager.js +107 -33
- package/server/dist/agent-chat-router.js +170 -8
- package/server/dist/agent-cwd-manager.js +2 -47
- package/server/dist/agent-operator-prompt.js +277 -0
- package/server/dist/agent-store.js +27 -5
- package/server/dist/attachment-manager.js +138 -0
- package/server/dist/desktop-db.js +15 -0
- package/server/dist/loop-factory.js +12 -2
- package/server/dist/mcp/guide.js +186 -51
- package/server/dist/mcp/tools/analytics.js +1 -1
- package/server/dist/mcp/tools/app-settings.js +45 -5
- package/server/dist/mcp/tools/chat.js +9 -2
- package/server/dist/mcp/tools/code.js +3 -2
- package/server/dist/mcp/tools/jobs.js +18 -6
- package/server/dist/mcp/tools/loops.js +57 -5
- package/server/dist/mcp/tools/meta.js +43 -3
- package/server/dist/mcp/tools/rails.js +6 -6
- package/server/dist/mcp/tools/setup.js +2 -1
- package/server/dist/mcp/tools/specs.js +60 -38
- package/server/dist/mcp/tools/types.js +17 -8
- package/server/dist/mcp/tools/watch.js +71 -8
- package/server/dist/project-router-helpers.js +1 -1
- package/server/dist/project-router-tickets.js +43 -4
- package/server/dist/providers/claude-adapter.js +6 -0
- package/server/dist/providers/codex-adapter.js +10 -0
- package/server/dist/providers/gemini-adapter.js +3 -0
- package/server/dist/rails-router.js +8 -17
- package/server/dist/spec-models.js +1 -0
- package/client/dist/assets/AgentsPage-BH1isg5j.js +0 -86
- package/client/dist/assets/AnalyticsPage-ByyshYRI.js +0 -1
- package/client/dist/assets/CodePage-CU7T_HYs.js +0 -2
- package/client/dist/assets/DocsDialog-CEmZp_8V.js +0 -11
- package/client/dist/assets/DocsPage-DYbAQ1AT.js +0 -11
- package/client/dist/assets/IntegrationsPage-C6fKdwVH.js +0 -3
- package/client/dist/assets/JobDetailPage-CKfIfBgE.js +0 -16
- package/client/dist/assets/JobsPage-nBng0riZ.js +0 -1
- package/client/dist/assets/LoopBuilderPage-Co_TYqYk.js +0 -7
- package/client/dist/assets/LoopsPage-a2hd37Ya.js +0 -1
- package/client/dist/assets/agent-Dwkz5mPS.js +0 -1
- package/client/dist/assets/dashboard-BTiH361F.js +0 -1
- package/client/dist/assets/dashboard-COSm_14E.js +0 -1
- package/client/dist/assets/dashboard-CfOs70FN2.js +0 -1
- package/client/dist/assets/dashboard-Cyzp4ox9.js +0 -1
- package/client/dist/assets/dashboard-CzHDp14_2.js +0 -1
- package/client/dist/assets/dashboard-D6Woy2B5.js +0 -1
- package/client/dist/assets/dashboard-DwbH4oVH.js +0 -1
- package/client/dist/assets/dashboard-cWhU3krA2.js +0 -1
- package/client/dist/assets/index-B0FxQALR.css +0 -2
- package/client/dist/assets/loops-BDhEfnx82.js +0 -1
- package/client/dist/assets/loops-BM5QggwH.js +0 -1
- package/client/dist/assets/loops-CPjLAAxj.js +0 -1
- package/client/dist/assets/loops-D8Iu6Jss.js +0 -1
- package/client/dist/assets/loops-DKnk79TB2.js +0 -1
- package/client/dist/assets/loops-DLW0aFMm.js +0 -1
- package/client/dist/assets/loops-Dcv3dFy_2.js +0 -1
- package/client/dist/assets/loops-y7wFRx6M.js +0 -1
- package/client/dist/assets/nav-1hj2izqB2.js +0 -1
- package/client/dist/assets/nav-BBUKMAu-2.js +0 -1
- package/client/dist/assets/nav-CLqkP-26.js +0 -1
- package/client/dist/assets/nav-Cv46L837.js +0 -1
- package/client/dist/assets/nav-DE3yWQw6.js +0 -1
- package/client/dist/assets/nav-DgA-rjLk2.js +0 -1
- package/client/dist/assets/nav-EG2pr6vN.js +0 -1
- package/client/dist/assets/nav-r3mIJVfU.js +0 -1
- package/client/dist/assets/settings-BKmORxlB2.js +0 -1
- package/client/dist/assets/settings-BVv2JgQ8.js +0 -1
- package/client/dist/assets/settings-Bghm3pAV.js +0 -1
- package/client/dist/assets/settings-BuC_aplX.js +0 -1
- package/client/dist/assets/settings-Bw_Qk8E32.js +0 -1
- package/client/dist/assets/settings-CAKgJv7p.js +0 -1
- package/client/dist/assets/settings-CEUgk1Ck.js +0 -1
- package/client/dist/assets/settings-C_PDE20s2.js +0 -1
- /package/client/dist/assets/{activity-Uj576ckT.js → activity-BlvN5rhP.js} +0 -0
- /package/client/dist/assets/{activity-w1qMFwxh.js → activity-C5SeKbom.js} +0 -0
- /package/client/dist/assets/{activity-BySXFT2J2.js → activity-DIJexk6v2.js} +0 -0
- /package/client/dist/assets/{activity-B82z3Pna.js → activity-DLdwUYv7.js} +0 -0
- /package/client/dist/assets/{activity-BVpZrs0J.js → activity-DOKV_Wyf.js} +0 -0
- /package/client/dist/assets/{activity-BId0pwuS2.js → activity-DVuiy8TI2.js} +0 -0
- /package/client/dist/assets/{activity-DIWnV0Pl.js → activity-Dsf3J7iW.js} +0 -0
- /package/client/dist/assets/{agentstudio-C7xxqVWn.js → agentstudio-B8H2H4Db2.js} +0 -0
- /package/client/dist/assets/{agentstudio-D-UoNAIA.js → agentstudio-B9zthaTJ.js} +0 -0
- /package/client/dist/assets/{agentstudio-0o3XKrcy.js → agentstudio-BDMpU01s.js} +0 -0
- /package/client/dist/assets/{agentstudio-Bu8m5jDw.js → agentstudio-CSZo7p8K.js} +0 -0
- /package/client/dist/assets/{agentstudio-ObTpVbBP.js → agentstudio-CdD6J23W.js} +0 -0
- /package/client/dist/assets/{agentstudio-PzFB3vfh2.js → agentstudio-D80fZu_M2.js} +0 -0
- /package/client/dist/assets/{agentstudio-OJjjz6Uf2.js → agentstudio-EuKglkaF2.js} +0 -0
- /package/client/dist/assets/{aiedit-DRrNiaB4.js → aiedit-B_VOTUo42.js} +0 -0
- /package/client/dist/assets/{aiedit-sP_iao2j.js → aiedit-Cxoe_0wv.js} +0 -0
- /package/client/dist/assets/{aiedit-DAM_WRAl2.js → aiedit-D59sPapq2.js} +0 -0
- /package/client/dist/assets/{aiedit-BaLZalLa.js → aiedit-DX3BBpXF.js} +0 -0
- /package/client/dist/assets/{aiedit-BIQqv2XM2.js → aiedit-GYOYWCHJ2.js} +0 -0
- /package/client/dist/assets/{aiedit-BjlUzasF.js → aiedit-TON-4N9S.js} +0 -0
- /package/client/dist/assets/{aiedit-BmDufyGU.js → aiedit-ybQmdsST.js} +0 -0
- /package/client/dist/assets/{analytics-MVJRjcY52.js → analytics-B2jjXLCP2.js} +0 -0
- /package/client/dist/assets/{analytics-C4z_NgJZ.js → analytics-BTkXLTfa.js} +0 -0
- /package/client/dist/assets/{analytics-DL2vJCbq.js → analytics-BotqRU_R.js} +0 -0
- /package/client/dist/assets/{analytics-e1mkNTgy2.js → analytics-Ck3vl2Qo2.js} +0 -0
- /package/client/dist/assets/{analytics-Ds_PNxtO2.js → analytics-CqMJQb7N.js} +0 -0
- /package/client/dist/assets/{analytics-B_rxNC9X.js → analytics-DGOoMkaZ.js} +0 -0
- /package/client/dist/assets/{analytics-BDqqCzN9.js → analytics-DL7uwNAI2.js} +0 -0
- /package/client/dist/assets/{attachments-BP0Ac1yt.js → attachments-7w-BR2V2.js} +0 -0
- /package/client/dist/assets/{attachments-CPBVeHX72.js → attachments-B5QX1Xfa2.js} +0 -0
- /package/client/dist/assets/{attachments-Db7JfA8a.js → attachments-BcE7kZG-2.js} +0 -0
- /package/client/dist/assets/{attachments-CJaO1vCH.js → attachments-BsJJXFzT.js} +0 -0
- /package/client/dist/assets/{attachments-8QCKHCEF2.js → attachments-Cbh4AwjP.js} +0 -0
- /package/client/dist/assets/{attachments-CV2uaTGE.js → attachments-D0fGlFve.js} +0 -0
- /package/client/dist/assets/{attachments-CaOjdN332.js → attachments-D3DJpd3e2.js} +0 -0
- /package/client/dist/assets/{browser-C9rUUxo4.js → browser-9GR11iTi.js} +0 -0
- /package/client/dist/assets/{browser-CEqx11iy.js → browser-BOxg0p3n.js} +0 -0
- /package/client/dist/assets/{browser-543jbxE4.js → browser-BSh8xUWV.js} +0 -0
- /package/client/dist/assets/{browser-CLC0etB_2.js → browser-CaV3BJNY2.js} +0 -0
- /package/client/dist/assets/{browser-0xeW8fUa2.js → browser-CmWGMRGf2.js} +0 -0
- /package/client/dist/assets/{browser-ExmELH702.js → browser-D6wbpBOL2.js} +0 -0
- /package/client/dist/assets/{browser-DyG2l9Wa.js → browser-dsgDU1HB.js} +0 -0
- /package/client/dist/assets/{chat-DagUyoVA.js → chat-B90iLDI4.js} +0 -0
- /package/client/dist/assets/{chat-Cu6F3d6g2.js → chat-CAo0jCnj2.js} +0 -0
- /package/client/dist/assets/{chat-CN8BMAMc.js → chat-CW54IP3u.js} +0 -0
- /package/client/dist/assets/{chat-NQPCBQo72.js → chat-CYHUUW0p2.js} +0 -0
- /package/client/dist/assets/{chat-CCytD3P8.js → chat-D1PXX_p2.js} +0 -0
- /package/client/dist/assets/{chat-IjutwlBg.js → chat-DhpcWjOf.js} +0 -0
- /package/client/dist/assets/{chat-vVpwkOp52.js → chat-cFG-UfRA2.js} +0 -0
- /package/client/dist/assets/{code-Dhb6jbAU.js → code--qUk_yn-.js} +0 -0
- /package/client/dist/assets/{code-Ce-nBIwj.js → code-B1aOMCVV.js} +0 -0
- /package/client/dist/assets/{code-BaG05zK62.js → code-B5UrmjaE2.js} +0 -0
- /package/client/dist/assets/{code-Dap54vOb.js → code-CjBHU0nw.js} +0 -0
- /package/client/dist/assets/{code-_NOCo-Ol2.js → code-Cjv4_HkK2.js} +0 -0
- /package/client/dist/assets/{code-32l6Naxu2.js → code-D7GLAjrz2.js} +0 -0
- /package/client/dist/assets/{code-C5cibF2F.js → code-DZKjfzBN.js} +0 -0
- /package/client/dist/assets/{commands-Cc2WpuXa.js → commands-B9XaopQC.js} +0 -0
- /package/client/dist/assets/{commands-k9wbNYoi.js → commands-BCx1uDIE.js} +0 -0
- /package/client/dist/assets/{commands-CM99Upsz2.js → commands-Bhw9Hqsa2.js} +0 -0
- /package/client/dist/assets/{commands-Bc8y9eNo2.js → commands-D0RnooQF2.js} +0 -0
- /package/client/dist/assets/{commands-Bl3-KVfj.js → commands-DuaQT-it.js} +0 -0
- /package/client/dist/assets/{commands-DASXJD-l.js → commands-MqNuGGO4.js} +0 -0
- /package/client/dist/assets/{commands-C5WQ9blx2.js → commands-oB9q2vy_2.js} +0 -0
- /package/client/dist/assets/{common-CHARW6MZ2.js → common-BXzqeuiC2.js} +0 -0
- /package/client/dist/assets/{common-0aY9HQBP.js → common-BaJ6MF7T.js} +0 -0
- /package/client/dist/assets/{common-CQCJzAQq2.js → common-C-jaOdxz2.js} +0 -0
- /package/client/dist/assets/{common-DNhhqjlJ.js → common-CKjy-R8-.js} +0 -0
- /package/client/dist/assets/{common-YdyZtmaI2.js → common-CRd-Ge5u2.js} +0 -0
- /package/client/dist/assets/{common-5jScBJqt.js → common-DPGR3Tfo.js} +0 -0
- /package/client/dist/assets/{common-BdaRciTu.js → common-wEB9RBdf.js} +0 -0
- /package/client/dist/assets/{explore-ChtxIiSM.js → explore-B_79NLR5.js} +0 -0
- /package/client/dist/assets/{explore-BzdMEpuf.js → explore-D-htKul_.js} +0 -0
- /package/client/dist/assets/{explore-B82VMUJ_.js → explore-D5b2jgvR.js} +0 -0
- /package/client/dist/assets/{explore-DfcUfiPw2.js → explore-Dvp-5qOw2.js} +0 -0
- /package/client/dist/assets/{explore-CbW0381i2.js → explore-FaKfWCr72.js} +0 -0
- /package/client/dist/assets/{explore-BGz1rvQE.js → explore-IS8VyaSZ.js} +0 -0
- /package/client/dist/assets/{explore-yRF7wFSp2.js → explore-OZhWV0Eb2.js} +0 -0
- /package/client/dist/assets/{format-command-D96da4fZ.js → format-command-CHImQv6W.js} +0 -0
- /package/client/dist/assets/{integrations-CnrX7vqw2.js → integrations-B97cGWfo2.js} +0 -0
- /package/client/dist/assets/{integrations-BJvrlcc7.js → integrations-Bp3leAh3.js} +0 -0
- /package/client/dist/assets/{integrations-CPKYkG36.js → integrations-C3Ma3GdM.js} +0 -0
- /package/client/dist/assets/{integrations-BA5pM05t.js → integrations-C5MUA-0-.js} +0 -0
- /package/client/dist/assets/{integrations-B0OBPU9_.js → integrations-CiQbCn_W.js} +0 -0
- /package/client/dist/assets/{integrations-DeJFRyXz2.js → integrations-Du_0rDfi2.js} +0 -0
- /package/client/dist/assets/{integrations-DBou159M2.js → integrations-t4X5UVcx2.js} +0 -0
- /package/client/dist/assets/{jira-mi37H4Kt.js → jira-B1XaR6fj.js} +0 -0
- /package/client/dist/assets/{jira-Srx2P5zS.js → jira-BCHx9zUF.js} +0 -0
- /package/client/dist/assets/{jira-DeotPx6P2.js → jira-BqXyykbt2.js} +0 -0
- /package/client/dist/assets/{jira-BwLBgmfI2.js → jira-BzFvFn7t2.js} +0 -0
- /package/client/dist/assets/{jira-BDgxAFTF2.js → jira-D6IDTIsc2.js} +0 -0
- /package/client/dist/assets/{jira-NwlUCcQD.js → jira-DSZ5xFRl.js} +0 -0
- /package/client/dist/assets/{jira-D3GGzXOI.js → jira-DdEKW9Pu.js} +0 -0
- /package/client/dist/assets/{jobs-D8adm2BX.js → jobs-BX9dP3Qn.js} +0 -0
- /package/client/dist/assets/{jobs-B56vQEkh2.js → jobs-BgHEgCWk2.js} +0 -0
- /package/client/dist/assets/{jobs-K_Y8KAZ2.js → jobs-CU-khJTt.js} +0 -0
- /package/client/dist/assets/{jobs-BYIk6Tg_.js → jobs-Ce0SE81t.js} +0 -0
- /package/client/dist/assets/{jobs-C-lM-iax2.js → jobs-CeOcGHd_2.js} +0 -0
- /package/client/dist/assets/{jobs-CYdevGgT.js → jobs-Ct5v2p6T.js} +0 -0
- /package/client/dist/assets/{jobs-OwM0ZWhI2.js → jobs-m7L0K9uC2.js} +0 -0
- /package/client/dist/assets/{mcp-D3E4_Mmk2.js → mcp-4QbfLPa4.js} +0 -0
- /package/client/dist/assets/{mcp-B6nwJJmR.js → mcp-CXy61khH.js} +0 -0
- /package/client/dist/assets/{mcp-CNgFiTEh.js → mcp-CmOBPDjE.js} +0 -0
- /package/client/dist/assets/{mcp-mupPuPDO2.js → mcp-NlLc9T8u2.js} +0 -0
- /package/client/dist/assets/{mcp-B4irfLJ2.js → mcp-_DUUXTHB2.js} +0 -0
- /package/client/dist/assets/{mcp-BP7PpbDr2.js → mcp-dlOyUQQy2.js} +0 -0
- /package/client/dist/assets/{mcp-BOoEGTSQ.js → mcp-zqSVP7nA.js} +0 -0
- /package/client/dist/assets/{specs-D4z5d8uq.js → specs-57pue7UQ.js} +0 -0
- /package/client/dist/assets/{specs-CWNKAScX2.js → specs-BWQ-0EXt2.js} +0 -0
- /package/client/dist/assets/{specs-B8mwScoM2.js → specs-BYSOlQRw2.js} +0 -0
- /package/client/dist/assets/{specs-B5XOoH-02.js → specs-CkP0B28v2.js} +0 -0
- /package/client/dist/assets/{specs-DgvIRZtM.js → specs-RSYuLgF4.js} +0 -0
- /package/client/dist/assets/{specs-DuRzE5wE.js → specs-d-zU7_3Q.js} +0 -0
- /package/client/dist/assets/{specs-Bj_3fDrQ.js → specs-nM5Cpcqe.js} +0 -0
- /package/client/dist/assets/{terminal-DoMTHedv2.js → terminal-Adi3W-GZ2.js} +0 -0
- /package/client/dist/assets/{terminal-DOwfkxqa2.js → terminal-BA6FCZna2.js} +0 -0
- /package/client/dist/assets/{terminal-CH0fdHvP.js → terminal-BCIUSkrg.js} +0 -0
- /package/client/dist/assets/{terminal-B2sExUis.js → terminal-C8KlD61D.js} +0 -0
- /package/client/dist/assets/{terminal-DjSSa5qP.js → terminal-D3RTuBwy.js} +0 -0
- /package/client/dist/assets/{terminal-w0i-OCp32.js → terminal-DCkOEjSj2.js} +0 -0
- /package/client/dist/assets/{terminal-CPMigUX7.js → terminal-DOuNm2BI.js} +0 -0
- /package/client/dist/assets/{tickets-D00mSt832.js → tickets-B2q36GlQ2.js} +0 -0
- /package/client/dist/assets/{tickets-CQTana1u.js → tickets-Bsyv_znj.js} +0 -0
- /package/client/dist/assets/{tickets-D7CSuWjO.js → tickets-C_UPra_1.js} +0 -0
- /package/client/dist/assets/{tickets-heDAaj8C2.js → tickets-D72LbUtU2.js} +0 -0
- /package/client/dist/assets/{tickets-DvbFg_-c2.js → tickets-DDjU7UfE2.js} +0 -0
- /package/client/dist/assets/{tickets-onKZz6Dd.js → tickets-DR4ZrPMf.js} +0 -0
- /package/client/dist/assets/{tickets-Dq7HDy8n.js → tickets-DiUA3rXq.js} +0 -0
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as e}from"./chunk-BNv3lrIs.js";import{t}from"./clsx-1dnHRn8W.js";import{Cn as n,Jt as r,T as i,Tn as a,Ut as o,Yt as s,c,cn as l,jn as u,kn as d,ln as f,qt as p,s as m,sn as h,st as g}from"./index-B7vB20Jw.js";import{t as _}from"./ExportDropdown-C-o1Q4ef.js";import{A as v,B as y,C as b,D as x,E as S,F as ee,G as te,H as C,I as w,J as T,K as E,L as D,M as O,N as k,O as A,P as j,Q as M,R as N,S as P,T as F,V as ne,X as I,Z as L,_ as R,_t as z,a as B,at as re,b as V,c as H,ct as ie,et as ae,f as oe,g as se,gt as U,h as ce,i as W,j as le,k as ue,l as de,lt as G,m as fe,n as pe,nt as me,o as he,ot as ge,p as _e,pt as K,q as ve,r as ye,rt as be,s as xe,st as Se,t as Ce,tt as we,ut as q,v as Te,x as Ee,y as De,z as Oe}from"./BarChart-BqHUOnl9.js";var ke=p(`arrow-down-right`,[[`path`,{d:`m7 7 10 10`,key:`1fmybs`}],[`path`,{d:`M17 7v10H7`,key:`6fjiku`}]]),J=e(u(),1),Y=l();function X(e){return e>=100?`$${e.toFixed(0)}`:e>=10?`$${e.toFixed(1)}`:`$${e.toFixed(2)}`}function Ae(e){return e>=1e3?`$${(e/1e3).toFixed(1)}k`:`$${e.toFixed(2)}`}function je(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}k`:`${e}`}var Me=[`job`,`explore-spec`,`quick-spec`,`ai-edit`,`smash`,`file-summary`,`loop`];function Ne({data:e,loading:t}){let{t:r}=n(`analytics`),[i,a]=(0,J.useState)(0),s=(0,J.useRef)(0);if((0,J.useEffect)(()=>{if(!e)return;let t=e.summary.totalCostUsd;if(s.current===0&&t>0){let e=performance.now(),n=r=>{let i=Math.min(1,(r-e)/600),o=1-(1-i)**3;a(0+(t-0)*o),i<1&&requestAnimationFrame(n)};requestAnimationFrame(n)}else a(t);s.current=t},[e]),t&&!e)return(0,Y.jsx)(`div`,{className:`h-44 rounded-xl border border-border/40 bg-card/40 animate-pulse`});if(!e)return null;let l=e.summary.totalCostUsd,u=e.summary.totalRuns,d=e.summary.totalTokens??0,f=e.summary.totalEstimatedCostUsd??0,p=e.summary.deltaPct,h=e.trackingStartedAt,g=f>0,_=Me.map(t=>{let n=e.bySurface.find(e=>e.surface===t);return{surface:t,costUsd:n?.costUsd??0,count:n?.count??0}});return(0,Y.jsxs)(`div`,{className:`rounded-xl border border-border/50 bg-gradient-to-br from-card/80 to-card/40 p-5`,children:[(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-end justify-between gap-3 mb-4`,children:[(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`div`,{className:`text-[11px] uppercase tracking-wider text-muted-foreground mb-1`,children:r(`hero.spending`)}),(0,Y.jsxs)(`div`,{className:`flex items-baseline gap-3`,children:[(0,Y.jsx)(`div`,{className:`text-5xl font-semibold tabular-nums tracking-tight`,children:Ae(i)}),p!==null&&(0,Y.jsxs)(`span`,{className:`inline-flex items-center gap-0.5 text-xs font-medium ${p>=0?`text-accent-warning`:`text-accent-success`}`,children:[p>=0?(0,Y.jsx)(o,{className:`w-3 h-3`}):(0,Y.jsx)(ke,{className:`w-3 h-3`}),r(`hero.vsPrev`,{pct:Math.abs(p).toFixed(0)})]})]}),(0,Y.jsxs)(`div`,{className:`text-xs text-muted-foreground mt-1 tabular-nums flex items-center gap-2`,children:[(0,Y.jsx)(`span`,{children:r(`hero.invocations`,{count:u})}),d>0&&(0,Y.jsx)(`span`,{className:`text-muted-foreground/80`,title:r(`hero.tokensTooltip`),children:r(`hero.tokens`,{tokens:je(d)})}),g&&(0,Y.jsx)(`span`,{className:`text-[10px] text-muted-foreground/70 italic`,title:r(`hero.includesEstimatedTooltip`,{amount:X(f)}),children:r(`hero.includesEstimated`,{amount:X(f)})})]})]}),u===0&&h&&(0,Y.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:r(`hero.trackingStarted`,{date:h.slice(0,10)})})]}),u===0?(0,Y.jsxs)(`div`,{className:`rounded-lg border border-dashed border-border/40 p-6 text-center`,children:[(0,Y.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:r(`hero.emptyState`)}),(0,Y.jsx)(`p`,{className:`text-xs text-muted-foreground/70 mt-1`,children:h?r(`hero.trackingStarted`,{date:h.slice(0,10)}):r(`hero.trackingStartedFallback`)})]}):(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`div`,{className:`h-3 w-full rounded-full overflow-hidden bg-background-deep flex`,children:_.map(e=>{let t=l>0?e.costUsd/l*100:0;return t===0?null:(0,Y.jsx)(`div`,{className:`h-full ${m[e.surface].dot}`,style:{width:`${t}%`},title:r(`hero.segmentTitle`,{label:c[e.surface],value:X(e.costUsd)})},e.surface)})}),(0,Y.jsx)(`div`,{className:`mt-3 flex flex-wrap items-center gap-x-5 gap-y-1.5 text-xs`,children:_.filter(e=>e.costUsd>0).map(e=>(0,Y.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 tabular-nums`,children:[(0,Y.jsx)(`span`,{className:`w-2 h-2 rounded-full ${m[e.surface].dot}`}),(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:c[e.surface]}),(0,Y.jsx)(`span`,{className:`text-foreground font-medium`,children:X(e.costUsd)}),(0,Y.jsx)(`span`,{className:`text-muted-foreground/60`,children:`·`}),(0,Y.jsx)(`span`,{className:`text-muted-foreground/80`,children:e.count})]},e.surface))})]})]})}var Pe={claude:`Claude`,codex:`Codex`,gemini:`Gemini`},Fe={claude:`bg-accent-info`,codex:`bg-accent-highlight`,gemini:`bg-accent-success`};function Ie(e){return e>=100?`$${e.toFixed(0)}`:e>=10?`$${e.toFixed(1)}`:e>=.01?`$${e.toFixed(2)}`:`$${e.toFixed(4)}`}function Le(e){return Pe[e]??e}function Re(e){return Fe[e]??`bg-accent-secondary`}function ze({data:e,loading:t}){let{t:r}=n(`analytics`);if(t&&!e)return(0,Y.jsx)(`div`,{className:`h-32 rounded-xl border border-border/40 bg-card/40 animate-pulse`});if(!e||e.byProvider.length===0||e.byProvider.length===1)return null;let i=e.byProvider.reduce((e,t)=>e+t.costUsd+t.estimatedCostUsd,0);return(0,Y.jsxs)(`div`,{className:`rounded-xl border border-border/50 bg-card/40 p-4`,children:[(0,Y.jsx)(`div`,{className:`flex items-baseline justify-between mb-3`,children:(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`div`,{className:`text-[11px] uppercase tracking-wider text-muted-foreground`,children:r(`providerCard.title`)}),(0,Y.jsx)(`div`,{className:`text-xs text-muted-foreground/70 mt-0.5`,children:(0,Y.jsx)(a,{ns:`analytics`,i18nKey:`providerCard.description`,components:{tilde:(0,Y.jsx)(`span`,{className:`font-medium`})}})})]})}),i===0?(0,Y.jsx)(`div`,{className:`text-xs text-muted-foreground italic`,children:r(`providerCard.noCost`)}):(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`div`,{className:`h-2 w-full rounded-full overflow-hidden bg-background-deep flex mb-3`,children:e.byProvider.map(e=>{let t=e.costUsd+e.estimatedCostUsd,n=i>0?t/i*100:0;if(n===0)return null;let a=`${e.costUsd===0&&e.estimatedCostUsd>0?`~`:``}${Ie(t)}`;return(0,Y.jsx)(`div`,{className:`h-full ${Re(e.provider)}`,style:{width:`${n}%`},title:r(`providerCard.segmentTitle`,{label:Le(e.provider),value:a,count:e.count})},e.provider)})}),(0,Y.jsx)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-2`,children:e.byProvider.map(e=>(0,Y.jsx)(Be,{entry:e},e.provider))})]})]})}function Be({entry:e}){let{t}=n(`analytics`),r=e.costUsd+e.estimatedCostUsd,i=e.costUsd===0&&e.estimatedCostUsd>0,a=e.count>0&&e.costUsd===0&&e.estimatedCostUsd===0;return(0,Y.jsxs)(`div`,{className:`flex items-center gap-2.5 rounded-md border border-border/30 px-2.5 py-1.5`,children:[(0,Y.jsx)(`span`,{className:`w-2 h-2 rounded-full shrink-0 ${Re(e.provider)}`}),(0,Y.jsx)(`span`,{className:`text-xs font-medium`,children:Le(e.provider)}),(0,Y.jsx)(`span`,{className:`text-[10px] text-muted-foreground tabular-nums`,children:t(`runs`,{count:e.count})}),a?(0,Y.jsx)(`span`,{className:`ml-auto text-xs font-medium text-muted-foreground/80 italic`,title:t(`providerCard.costUnavailableTooltip`),children:t(`providerCard.costUnavailable`)}):(0,Y.jsxs)(`span`,{className:`ml-auto text-xs font-medium tabular-nums`,children:[i?`~`:``,Ie(r)]})]})}var Ve=[`option`,`isActive`];function Z(){return Z=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},Z.apply(null,arguments)}function He(e,t){if(e==null)return{};var n,r,i=Ue(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function Ue(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}function We(e){var{option:t,isActive:n}=e,r=He(e,Ve);return typeof t==`string`?J.createElement(P,Z({option:J.createElement(Se,Z({type:t},r)),isActive:n,shapeType:`symbols`},r)):J.createElement(P,Z({option:t,isActive:n,shapeType:`symbols`},r))}var Ge=ae([(e,t,n,r,i,a,o)=>N(e,void 0,void 0,o),(e,t,n,r,i,a,o)=>k(e,`xAxis`,t,o),(e,t,n,r,i,a,o)=>j(e,`xAxis`,t,o),(e,t,n,r,i,a,o)=>k(e,`yAxis`,n,o),(e,t,n,r,i,a,o)=>j(e,`yAxis`,n,o),(e,t,n,r)=>w(e,`zAxis`,r,!1),ae([ee,(e,t,n,r,i)=>i],(e,t)=>e.filter(e=>e.type===`scatter`).find(e=>e.id===t)),(e,t,n,r,i,a)=>a],(e,t,n,r,i,a,o,s)=>{var{chartData:c,dataStartIndex:l,dataEndIndex:u}=e;if(o!=null){var d=o?.data!=null&&o.data.length>0?o.data:c?.slice(l,u+1);if(!(d==null||t==null||r==null||n==null||i==null||n?.length===0||i?.length===0))return st({displayedData:d,xAxis:t,yAxis:r,zAxis:a,scatterSettings:o,xAxisTicks:n,yAxisTicks:i,cells:s})}}),Ke=[`id`],qe=[`onMouseEnter`,`onClick`,`onMouseLeave`],Je=[`animationBegin`,`animationDuration`,`animationEasing`,`hide`,`isAnimationActive`,`legendType`,`lineJointType`,`lineType`,`shape`,`xAxisId`,`yAxisId`,`zAxisId`];function Ye(e,t){if(e==null)return{};var n,r,i=Xe(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function Xe(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}function Q(){return Q=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},Q.apply(null,arguments)}function Ze(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function $(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?Ze(Object(n),!0).forEach(function(t){Qe(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Ze(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Qe(e,t,n){return(t=$e(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function $e(e){var t=et(e,`string`);return typeof t==`symbol`?t:t+``}function et(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}var tt=e=>{var{dataKey:t,name:n,fill:r,legendType:i,hide:a}=e;return[{inactive:a,dataKey:t,type:i,color:r,value:L(n,t),payload:e}]},nt=J.memo(e=>{var{dataKey:t,points:n,stroke:r,strokeWidth:i,fill:a,name:o,hide:s,tooltipType:c,id:l}=e,u={dataDefinedOnItem:n?.map(e=>e.tooltipPayload),getPosition:e=>{var t;return n==null||(t=n[Number(e)])==null?void 0:t.tooltipPosition},settings:{stroke:r,strokeWidth:i,fill:a,nameKey:void 0,dataKey:t,name:L(o,t),hide:s,type:c,color:a,unit:``,graphicalItemId:l}};return J.createElement(Te,{tooltipEntrySettings:u})});function rt(e){var{points:t,props:n}=e,{line:r,lineType:i,lineJointType:a}=n;if(!r)return null;var o=U(n),s=z(r),c,l;if(i===`joint`)c=t.map(e=>({x:e.cx??null,y:e.cy??null}));else if(i===`fitting`){var{xmin:u,xmax:d,a:f,b:p}=ie(t),m=e=>f*e+p;c=[{x:u,y:m(u)},{x:d,y:m(d)}]}var h=$($($({},o),{},{fill:`none`,stroke:o&&o.fill},s),{},{points:c});return l=J.isValidElement(r)?J.cloneElement(r,h):typeof r==`function`?r(h):J.createElement(ne,Q({},h,{type:a})),J.createElement(K,{className:`recharts-scatter-line`,key:`recharts-scatter-line`},l)}function it(e){var{showLabels:t,points:n,children:r}=e,i=te(),a=(0,J.useMemo)(()=>n?.map(e=>{var t={x:e.x??0,y:e.y??0,width:e.width,height:e.height,lowerWidth:e.width,upperWidth:e.width};return $($({},t),{},{value:void 0,payload:e.payload,viewBox:t,parentViewBox:i,fill:void 0})}),[i,n]);return J.createElement(F,{value:t?a:void 0},r)}function at(e){var{points:t,allOtherScatterProps:n}=e,{shape:r,activeShape:i,dataKey:a}=n,{id:o}=n,s=Ye(n,Ke),c=me(le),{onMouseEnter:l,onClick:u,onMouseLeave:d}=n,f=Ye(n,qe),p=V(l,a,o),m=Ee(d),h=De(u,a,o);if(!ge(t))return null;var g=U(s);return J.createElement(J.Fragment,null,J.createElement(rt,{points:t,props:s}),t.map((e,t)=>{var n=i!=null&&i!==!1,a=n&&c===String(t),s=n&&a?i:r,l=$($($({},g),e),{},{index:t,[T]:String(o)});return J.createElement(v,{key:`symbol-${e?.cx}-${e?.cy}-${e?.size}-${t}`,zIndex:a?D.activeDot:void 0},J.createElement(K,Q({className:`recharts-scatter-symbol`},re(f,e,t),{onMouseEnter:p(e,t),onMouseLeave:m(e,t),onClick:h(e,t)}),J.createElement(We,Q({option:s,isActive:a},l))))}))}function ot(e){var{previousPointsRef:t,props:n}=e,{points:r,isAnimationActive:i,animationBegin:a,animationDuration:o,animationEasing:s}=n,c=t.current,l=Oe(n,`recharts-scatter-`),[u,d]=(0,J.useState)(!1),f=(0,J.useCallback)(()=>{d(!1)},[]),p=(0,J.useCallback)(()=>{d(!0)},[]),m=!u;return J.createElement(it,{showLabels:m,points:r},n.children,J.createElement(y,{animationId:l,begin:a,duration:o,isActive:i,easing:s,onAnimationEnd:f,onAnimationStart:p,key:l},e=>{var i=e===1?r:r?.map((t,n)=>{var r=c&&c[n];return r?$($({},t),{},{cx:t.cx==null?void 0:G(r.cx,t.cx,e),cy:t.cy==null?void 0:G(r.cy,t.cy,e),size:G(r.size,t.size,e)}):$($({},t),{},{size:G(0,t.size,e)})});return e>0&&(t.current=i),J.createElement(K,null,J.createElement(at,{points:i,allOtherScatterProps:n,showLabels:m}))}),J.createElement(S,{label:n.label}))}function st(e){var{displayedData:t,xAxis:n,yAxis:r,zAxis:i,scatterSettings:a,xAxisTicks:o,yAxisTicks:s,cells:c}=e,l=q(n.dataKey)?a.dataKey:n.dataKey,u=q(r.dataKey)?a.dataKey:r.dataKey,d=i&&i.dataKey,f=i?i.range:O.range,p=f&&f[0],m=n.scale.bandwidth?n.scale.bandwidth():0,h=r.scale.bandwidth?r.scale.bandwidth():0;return t.map((e,t)=>{var f=M(e,l),g=M(e,u),_=!q(d)&&M(e,d)||`-`,v=[{name:q(n.dataKey)?a.name:n.name||String(n.dataKey),unit:n.unit||``,value:f,payload:e,dataKey:l,type:a.tooltipType,graphicalItemId:a.id},{name:q(r.dataKey)?a.name:r.name||String(r.dataKey),unit:r.unit||``,value:g,payload:e,dataKey:u,type:a.tooltipType,graphicalItemId:a.id}];_!==`-`&&i!=null&&v.push({name:i.name||i.dataKey,unit:i.unit||``,value:_,payload:e,dataKey:d,type:a.tooltipType,graphicalItemId:a.id});var y=I({axis:n,ticks:o,bandSize:m,entry:e,index:t,dataKey:l}),b=I({axis:r,ticks:s,bandSize:h,entry:e,index:t,dataKey:u}),x=_!==`-`&&i!=null?i.scale.map(_):p,S=x==null?0:Math.sqrt(Math.max(x,0)/Math.PI);return $($({},e),{},{cx:y,cy:b,x:y==null?void 0:y-S,y:b==null?void 0:b-S,width:2*S,height:2*S,size:x,node:{x:f,y:g,z:_},tooltipPayload:v,tooltipPosition:{x:y,y:b},payload:e},c&&c[t]&&c[t].props)})}var ct=(e,t,n)=>({x:e.cx,y:e.cy,value:Number(n===`x`?e.node.x:e.node.y),errorVal:M(e,t)});function lt(e){var{hide:n,points:r,className:i,needClip:a,xAxisId:o,yAxisId:s,id:c}=e,l=(0,J.useRef)(null);if(n)return null;var u=t(`recharts-scatter`,i),d=c;return J.createElement(v,{zIndex:e.zIndex},J.createElement(K,{className:u,clipPath:a?`url(#clipPath-${d})`:void 0,id:c},a&&J.createElement(`defs`,null,J.createElement(he,{clipPathId:d,xAxisId:o,yAxisId:s})),J.createElement(H,{xAxisId:o,yAxisId:s,data:r,dataPointFormatter:ct,errorBarOffset:0},J.createElement(K,{key:`recharts-scatter-symbols`},J.createElement(ot,{props:e,previousPointsRef:l})))))}var ut={xAxisId:0,yAxisId:0,zAxisId:0,label:!1,line:!1,legendType:`circle`,lineType:`joint`,lineJointType:`linear`,shape:`circle`,hide:!1,isAnimationActive:`auto`,animationBegin:0,animationDuration:400,animationEasing:`linear`,zIndex:D.scatter};function dt(e){var t=be(e,ut),{animationBegin:n,animationDuration:r,animationEasing:i,hide:a,isAnimationActive:o,legendType:s,lineJointType:c,lineType:l,shape:u,xAxisId:d,yAxisId:f,zAxisId:p}=t,m=Ye(t,Je),{needClip:h}=xe(d,f),g=(0,J.useMemo)(()=>b(e.children,x),[e.children]),_=ve(),v=me(t=>Ge(t,d,f,p,e.id,g,_));return h==null||v==null?null:J.createElement(J.Fragment,null,J.createElement(nt,{dataKey:e.dataKey,points:v,stroke:e.stroke,strokeWidth:e.strokeWidth,fill:e.fill,name:e.name,hide:e.hide,tooltipType:e.tooltipType,id:e.id}),J.createElement(lt,Q({},m,{xAxisId:d,yAxisId:f,zAxisId:p,lineType:l,lineJointType:c,legendType:s,shape:u,hide:a,isAnimationActive:o,animationBegin:n,animationDuration:r,animationEasing:i,points:v,needClip:h})))}function ft(e){var t=be(e,ut),n=ve();return J.createElement(se,{id:t.id,type:`scatter`},e=>J.createElement(J.Fragment,null,J.createElement(R,{legendPayload:tt(t)}),J.createElement(ce,{type:`scatter`,id:e,data:t.data,xAxisId:t.xAxisId,yAxisId:t.yAxisId,zAxisId:t.zAxisId,dataKey:t.dataKey,hide:t.hide,name:t.name,tooltipType:t.tooltipType,isPanorama:n}),J.createElement(dt,Q({},t,{id:e}))))}var pt=J.memo(ft,C);pt.displayName=`Scatter`;function mt(e){var t=we(),n=(0,J.useRef)(null);return(0,J.useLayoutEffect)(()=>{n.current===null?t(oe(e)):n.current!==e&&t(fe({prev:n.current,next:e})),n.current=e},[e,t]),(0,J.useLayoutEffect)(()=>()=>{n.current&&=(t(_e(n.current)),null)},[t]),null}var ht={zAxisId:0,range:O.range,scale:O.scale,type:O.type};function gt(e){var t=be(e,ht);return J.createElement(mt,{domain:t.domain,id:t.zAxisId,dataKey:t.dataKey,name:t.name,unit:t.unit,range:t.range,scale:t.scale,type:t.type,allowDuplicatedCategory:O.allowDuplicatedCategory,allowDataOverflow:O.allowDataOverflow,reversed:O.reversed,includeHidden:O.includeHidden})}gt.displayName=`ZAxis`;var _t=[`item`],vt=(0,J.forwardRef)((e,t)=>J.createElement(pe,{chartName:`ScatterChart`,defaultTooltipEventType:`item`,validateTooltipEventTypes:_t,tooltipPayloadSearcher:ue,categoricalChartProps:e,ref:t}));function yt({data:e,loading:t}){let{t:r}=n(`analytics`);if(t&&!e)return(0,Y.jsx)(`div`,{className:`h-[220px] rounded-xl border border-border/40 bg-card/40 animate-pulse`});if(!e)return null;let i={jobs:r(`surfaces.job`),explore:r(`surfaces.exploreSpec`),quick:r(`surfaces.quickSpec`),refine:r(`surfaces.aiEdit`),fileSummaries:r(`surfaces.fileSummary`),smash:r(`surfaces.smash`),loop:r(`surfaces.loop`)},a=e.dailyTimeline.map(e=>({date:e.date.slice(5),[i.jobs]:e.jobsCostUsd,[i.explore]:e.exploreCostUsd,[i.quick]:e.quickCostUsd,[i.refine]:e.aiEditCostUsd,[i.fileSummaries]:e.fileSummaryCostUsd??0,[i.smash]:e.smashCostUsd??0,[i.loop]:e.loopCostUsd??0})),o=e.dailyTimeline.every(e=>e.jobsCostUsd+e.exploreCostUsd+e.quickCostUsd+e.aiEditCostUsd+(e.fileSummaryCostUsd??0)+(e.smashCostUsd??0)+(e.loopCostUsd??0)===0);return(0,Y.jsxs)(`div`,{className:`rounded-xl border border-border/50 bg-card/40 p-4`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,Y.jsx)(`h2`,{className:`text-xs font-medium text-muted-foreground uppercase tracking-wider`,children:r(`timeline.title`)}),(0,Y.jsx)(`span`,{className:`text-[10px] text-muted-foreground/70`,children:r(`timeline.subtitle`)})]}),o?(0,Y.jsx)(`div`,{className:`h-40 flex items-center justify-center text-xs text-muted-foreground/70`,children:r(`timeline.empty`)}):(0,Y.jsx)(`div`,{className:`h-[220px]`,children:(0,Y.jsx)(E,{width:`100%`,height:`100%`,children:(0,Y.jsxs)(Ce,{data:a,margin:{top:10,right:10,left:-8,bottom:0},children:[(0,Y.jsx)(de,{strokeDasharray:`2 4`,stroke:`currentColor`,className:`text-border/30`,vertical:!1}),(0,Y.jsx)(W,{dataKey:`date`,tick:{fontSize:10},stroke:`currentColor`,className:`text-muted-foreground`}),(0,Y.jsx)(ye,{tick:{fontSize:10},stroke:`currentColor`,className:`text-muted-foreground`,tickFormatter:e=>`$${e}`}),(0,Y.jsx)(A,{contentStyle:{backgroundColor:`var(--popover)`,border:`1px solid var(--border)`,fontSize:11,borderRadius:6},formatter:(e,t)=>[`$${typeof e==`number`?e.toFixed(2):`—`}`,String(t)]}),(0,Y.jsx)(B,{dataKey:i.jobs,stackId:`a`,fill:`var(--accent-info, #5fa8d3)`}),(0,Y.jsx)(B,{dataKey:i.explore,stackId:`a`,fill:`var(--accent-highlight, #c084fc)`}),(0,Y.jsx)(B,{dataKey:i.quick,stackId:`a`,fill:`var(--accent-secondary, #f7768e)`}),(0,Y.jsx)(B,{dataKey:i.refine,stackId:`a`,fill:`var(--accent-success, #50fa7b)`}),(0,Y.jsx)(B,{dataKey:i.fileSummaries,stackId:`a`,fill:`var(--accent-warning, #f1fa8c)`}),(0,Y.jsx)(B,{dataKey:i.smash,stackId:`a`,fill:`var(--accent-highlight, #c084fc)`}),(0,Y.jsx)(B,{dataKey:i.loop,stackId:`a`,fill:`var(--accent-primary, #7aa2f7)`})]})})})]})}function bt(e){return e==null?`—`:e<.005?`$${e.toFixed(4)}`:e<1?`$${e.toFixed(3)}`:`$${e.toFixed(2)}`}function xt(e){return e==null?`—`:e<1e3?`${e} ms`:e<6e4?`${(e/1e3).toFixed(1)}s`:`${Math.floor(e/6e4)}m ${Math.floor(e%6e4/1e3)}s`}function St({values:e}){let t=Math.max(1e-4,...e);return(0,Y.jsx)(`div`,{className:`flex items-end gap-[1px] h-5`,children:e.map((e,n)=>(0,Y.jsx)(`div`,{className:`w-[3px] rounded-sm bg-foreground/40`,style:{height:`${Math.max(2,e/t*20)}px`}},n))})}function Ct({mode:e,label:t,accentClass:r}){let{t:i}=n(`analytics`),o=e.mode===`explore`&&e.totalRuns<5,s=(e.estimatedCostUsd??0)>0;return(0,Y.jsxs)(`div`,{className:`flex-1 p-4 first:pr-2 last:pl-2`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 mb-2`,children:[(0,Y.jsx)(`span`,{className:`w-1.5 h-1.5 rounded-full ${r}`}),(0,Y.jsx)(`span`,{className:`text-xs font-medium uppercase tracking-wider text-muted-foreground`,children:t})]}),o?(0,Y.jsxs)(`div`,{className:`py-3`,children:[(0,Y.jsx)(`p`,{className:`text-sm text-foreground`,children:i(`quickVsExplore.sparseCta`)}),(0,Y.jsx)(`p`,{className:`text-xs text-muted-foreground mt-1`,children:i(`quickVsExplore.runsSoFar`,{count:e.totalRuns})})]}):(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`div`,{className:`text-3xl font-semibold tabular-nums tracking-tight`,"data-estimated":s?`true`:void 0,title:s?i(`quickVsExplore.estimatedTooltip`):void 0,children:[s&&e.avgCostPerSpec!=null?`~`:``,bt(e.avgCostPerSpec)]}),(0,Y.jsx)(`div`,{className:`text-[11px] text-muted-foreground mt-0.5`,children:i(`quickVsExplore.perSpec`)}),(0,Y.jsx)(`div`,{className:`mt-3`,children:(0,Y.jsx)(St,{values:e.sparkline.length>0?e.sparkline:[0]})}),(0,Y.jsxs)(`div`,{className:`mt-3 space-y-0.5 text-xs tabular-nums text-muted-foreground`,children:[(0,Y.jsx)(`div`,{children:(0,Y.jsx)(a,{ns:`analytics`,i18nKey:`quickVsExplore.createdRuns`,values:{created:e.ticketsCreated,runs:e.totalRuns},components:{strong:(0,Y.jsx)(`span`,{className:`text-foreground font-medium`})}})}),(0,Y.jsx)(`div`,{children:i(`quickVsExplore.avgDuration`,{duration:xt(e.avgDurationMs)})}),(0,Y.jsx)(`div`,{className:`truncate`,children:e.dominantModel??`—`})]})]})]})}function wt({data:e,loading:t}){let{t:r}=n(`analytics`);if(t&&!e)return(0,Y.jsx)(`div`,{className:`h-[220px] rounded-xl border border-border/40 bg-card/40 animate-pulse`});if(!e)return null;let i=e.byMode.find(e=>e.mode===`quick`),a=e.byMode.find(e=>e.mode===`explore`);if(!i||!a)return null;let o=i.avgCostPerSpec&&a.avgCostPerSpec&&i.avgCostPerSpec>0?a.avgCostPerSpec/i.avgCostPerSpec:null,s=o!==null&&i.totalRuns>=1&&a.totalRuns>=5,c=(i.estimatedCostUsd??0)>0||(a.estimatedCostUsd??0)>0;return(0,Y.jsxs)(`div`,{className:`rounded-xl border border-border/50 bg-card/40`,children:[(0,Y.jsx)(`div`,{className:`px-4 pt-3 pb-1`,children:(0,Y.jsx)(`h2`,{className:`text-xs font-medium text-muted-foreground uppercase tracking-wider`,children:r(`quickVsExplore.title`)})}),(0,Y.jsxs)(`div`,{className:`flex divide-x divide-border/40`,children:[(0,Y.jsx)(Ct,{mode:i,label:r(`quickVsExplore.quick`),accentClass:`bg-accent-secondary`}),(0,Y.jsx)(Ct,{mode:a,label:r(`quickVsExplore.explore`),accentClass:`bg-accent-highlight`})]}),s&&(0,Y.jsx)(`div`,{className:`px-4 pb-3 -mt-1`,children:(0,Y.jsx)(`div`,{className:`text-center text-[11px] text-muted-foreground tabular-nums`,children:(0,Y.jsxs)(`span`,{className:`px-2`,children:[`━━━━━━ `,r(`quickVsExplore.ratio`,{ratio:o.toFixed(1)}),` ━━━━━━`]})})}),c&&(0,Y.jsx)(`div`,{className:`px-4 pb-3 -mt-1`,"data-testid":`quick-vs-explore-estimated-footnote`,children:(0,Y.jsx)(`p`,{className:`text-[10px] text-muted-foreground`,children:r(`quickVsExplore.estimatedFootnote`)})})]})}function Tt({data:e,loading:t,onSelectModel:r,activeModel:i}){let{t:a}=n(`analytics`);if(t&&!e)return(0,Y.jsx)(`div`,{className:`h-[220px] rounded-xl border border-border/40 bg-card/40 animate-pulse`});if(!e)return null;let o=e.byModel.reduce((e,t)=>e+t.costUsd,0),s=e.byModel.slice(0,5);return(0,Y.jsxs)(`div`,{className:`rounded-xl border border-border/50 bg-card/40 p-4`,children:[(0,Y.jsx)(`h2`,{className:`text-xs font-medium text-muted-foreground uppercase tracking-wider mb-3`,children:a(`models.title`)}),s.length===0?(0,Y.jsx)(`div`,{className:`h-32 flex items-center justify-center text-xs text-muted-foreground/70`,children:a(`models.empty`)}):(0,Y.jsx)(`ul`,{className:`space-y-1.5`,children:s.map(e=>{let t=o>0?e.costUsd/o*100:0,n=i===e.model,s=(e.estimatedCostUsd??0)>0;return(0,Y.jsx)(`li`,{children:(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>r(e.model,e.provider),className:`w-full text-left group rounded-md px-2 py-1.5 transition-colors ${n?`bg-accent-highlight/10 ring-1 ring-accent-highlight/30`:`hover:bg-accent/30`}`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center justify-between text-[12px] mb-1 tabular-nums`,children:[(0,Y.jsx)(`span`,{className:`truncate font-medium`,children:e.model}),(0,Y.jsxs)(`span`,{className:`text-muted-foreground`,title:s?a(`models.estimatedTooltip`):void 0,children:[s?`~`:``,`$`,e.costUsd.toFixed(2),` · `,e.count]})]}),(0,Y.jsx)(`div`,{className:`h-1.5 rounded-full bg-background-deep overflow-hidden`,children:(0,Y.jsx)(`div`,{className:`h-full ${n?`bg-accent-highlight`:`bg-foreground/40 group-hover:bg-foreground/60`} transition-colors`,style:{width:`${t}%`}})})]})},`${e.provider??`claude`}:${e.model}`)})})]})}var Et={job:`var(--accent-info, #5fa8d3)`,"quick-spec":`var(--accent-secondary, #f7768e)`,"explore-spec":`var(--accent-highlight, #c084fc)`,"ai-edit":`var(--accent-success, #50fa7b)`,smash:`var(--accent-highlight, #c084fc)`,"file-summary":`var(--accent-warning, #f1fa8c)`,loop:`var(--accent-primary, #7aa2f7)`},Dt=Object.keys(c);function Ot({data:e,loading:t,onSelectPoint:r}){let{t:i}=n(`analytics`);if(t&&!e)return(0,Y.jsx)(`div`,{className:`h-[260px] rounded-xl border border-border/40 bg-card/40 animate-pulse`});if(!e)return null;let a=Dt,o=a.map(t=>({surface:t,points:e.scatter.filter(e=>e.surface===t).map(e=>({id:e.id,x:e.numTurns??Math.round((e.durationMs??0)/1e3),y:e.costUsd,surface:t,ticketId:e.ticketId,startedAt:e.startedAt,raw:e}))})),s=e.scatter.length===0,l=e.scatterTruncated===!0,u=e.scatterTotal??e.scatter.length;return(0,Y.jsxs)(`div`,{className:`rounded-xl border border-border/50 bg-card/40 p-4`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,Y.jsx)(`h2`,{className:`text-xs font-medium text-muted-foreground uppercase tracking-wider`,children:i(`scatter.title`)}),(0,Y.jsx)(`div`,{className:`flex flex-wrap items-center gap-2 text-[10px]`,children:a.map(e=>(0,Y.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,Y.jsx)(`span`,{className:`w-1.5 h-1.5 rounded-full`,style:{background:Et[e]}}),(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:c[e]})]},e))})]}),l&&!s&&(0,Y.jsx)(`div`,{"data-testid":`scatter-truncation-notice`,className:`mb-2 text-[10px] text-accent-warning`,children:i(`scatter.truncated`,{shown:e.scatter.length,total:u})}),s?(0,Y.jsx)(`div`,{className:`h-40 flex items-center justify-center text-xs text-muted-foreground/70`,children:i(`scatter.empty`)}):(0,Y.jsx)(`div`,{className:`h-[260px]`,children:(0,Y.jsx)(E,{width:`100%`,height:`100%`,children:(0,Y.jsxs)(vt,{margin:{top:10,right:10,left:-8,bottom:5},children:[(0,Y.jsx)(de,{strokeDasharray:`2 4`,stroke:`currentColor`,className:`text-border/30`}),(0,Y.jsx)(W,{type:`number`,dataKey:`x`,name:`turns`,tick:{fontSize:10},stroke:`currentColor`,className:`text-muted-foreground`,label:{value:i(`scatter.turnsLabel`),position:`insideBottomRight`,offset:-2,fontSize:10,fill:`currentColor`}}),(0,Y.jsx)(ye,{type:`number`,dataKey:`y`,name:`cost`,tick:{fontSize:10},stroke:`currentColor`,className:`text-muted-foreground`,tickFormatter:e=>`$${e.toFixed(e<1?2:0)}`}),(0,Y.jsx)(gt,{range:[40,80]}),(0,Y.jsx)(A,{cursor:{strokeDasharray:`3 3`},contentStyle:{backgroundColor:`var(--popover)`,border:`1px solid var(--border)`,fontSize:11,borderRadius:6},formatter:(e,t)=>{let n=String(t);return n===`cost`&&typeof e==`number`?[`$${e.toFixed(3)}`,i(`scatter.costLabel`)]:[String(e),n===`turns`?i(`scatter.turnsLabel`):n]}}),o.map(e=>(0,Y.jsx)(pt,{data:e.points,fill:Et[e.surface],onClick:e=>{let t=e;t?.raw&&r(t.raw)}},e.surface))]})})})]})}function kt({data:e,loading:t,onSelectTicket:r}){let{t:i}=n(`analytics`);if(t&&!e)return(0,Y.jsx)(`div`,{className:`h-40 rounded-xl border border-border/40 bg-card/40 animate-pulse`});if(!e)return null;let a=e.topTickets;return(0,Y.jsxs)(`div`,{className:`rounded-xl border border-border/50 bg-card/40 p-4`,children:[(0,Y.jsx)(`h2`,{className:`text-xs font-medium text-muted-foreground uppercase tracking-wider mb-3`,children:i(`topTickets.title`)}),a.length===0?(0,Y.jsx)(`div`,{className:`h-32 flex items-center justify-center text-xs text-muted-foreground/70`,children:i(`topTickets.empty`)}):(0,Y.jsx)(`ul`,{className:`divide-y divide-border/30`,children:a.map((e,t)=>{let n=Object.entries(e.bySurface).filter(([,e])=>e.count>0).map(([e,t])=>i(`topTickets.breakdownItem`,{n:t.count,label:c[e].toLowerCase()})).join(` + `),a=e.isUnattributed,o=a?i(`topTickets.unattributed`):e.ticketTitle?`#${e.ticketId} ${e.ticketTitle}`:i(`topTickets.deletedTicket`,{id:e.ticketId});return(0,Y.jsx)(`li`,{children:(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>r(e.ticketId),className:`w-full text-left flex items-center justify-between gap-3 py-2 px-1 hover:bg-accent/30 rounded transition-colors ${!e.ticketTitle&&!a?`opacity-50`:``}`,disabled:a,children:[(0,Y.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Y.jsx)(`div`,{className:`text-sm truncate`,children:o}),(0,Y.jsx)(`div`,{className:`text-[11px] text-muted-foreground truncate`,children:n||`—`})]}),(0,Y.jsxs)(`div`,{className:`text-right tabular-nums`,children:[(0,Y.jsxs)(`div`,{className:`text-sm font-medium`,children:[`$`,e.totalCostUsd.toFixed(2)]}),(0,Y.jsx)(`div`,{className:`text-[10px] text-muted-foreground`,children:i(`runs`,{count:e.totalRuns})})]})]})},`${e.ticketId??`u`}-${t}`)})})]})}var At={claude:`Claude`,codex:`Codex`,gemini:`Gemini`};function jt(e){return At[e]??e}function Mt(e){return e==null?`—`:e<.005?`$${e.toFixed(4)}`:`$${e.toFixed(2)}`}function Nt(e){return e==null?`—`:e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}function Pt(e){return e.surface_ref_id?.startsWith(`contract-refine:`)?!0:e.surface===`explore-spec`&&e.ticket_id!=null&&e.conversation_id!=null&&e.surface_ref_id===e.conversation_id&&e.model==null}function Ft(e){let t=new Map;for(let n of e)n.model&&(n.conversation_id&&t.set(`conversation:${n.conversation_id}`,n.model),n.ticket_id!=null&&n.surface===`explore-spec`&&t.set(`ticket:${n.ticket_id}:explore-spec`,n.model),n.ticket_id!=null&&n.surface===`quick-spec`&&t.set(`ticket:${n.ticket_id}:quick-spec`,n.model));return t}function It(e,t){if(e.model)return e.model;if(!Pt(e))return null;if(e.conversation_id){let n=t.get(`conversation:${e.conversation_id}`);if(n)return n}return e.ticket_id==null?null:t.get(`ticket:${e.ticket_id}:${e.surface}`)??null}function Lt({rows:e,loading:t,truncated:r,totalAvailable:i,tableFilters:a,onTableFiltersChange:o}){let{t:s}=n(`analytics`),[l,u]=(0,J.useState)(null),d=Ft(e),f=new Set(e.map(e=>e.provider??`claude`)).size>1,p=r||i>e.length;return(0,Y.jsxs)(`div`,{className:`rounded-xl border border-border/50 bg-card/40 p-4`,children:[(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3 mb-3`,children:[(0,Y.jsx)(`h2`,{className:`text-xs font-medium text-muted-foreground uppercase tracking-wider`,children:s(`table.title`)}),(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-[11px]`,children:[(0,Y.jsxs)(`select`,{value:a.status??``,onChange:e=>o({...a,status:e.target.value||void 0}),className:`h-7 px-2 rounded-md bg-background-deep border border-border/60 text-xs`,"aria-label":s(`table.statusFilterAria`),children:[(0,Y.jsx)(`option`,{value:``,children:s(`table.allStatus`)}),(0,Y.jsx)(`option`,{value:`success`,children:s(`table.success`)}),(0,Y.jsx)(`option`,{value:`failed`,children:s(`table.failed`)}),(0,Y.jsx)(`option`,{value:`aborted`,children:s(`table.aborted`)})]}),(0,Y.jsx)(`input`,{type:`number`,step:`0.01`,min:`0`,placeholder:s(`table.minCostPlaceholder`),value:a.minCostUsd??``,onChange:e=>{let t=e.target.value===``?void 0:parseFloat(e.target.value);o({...a,minCostUsd:Number.isNaN(t)?void 0:t})},className:`h-7 w-24 px-2 rounded-md bg-background-deep border border-border/60 text-xs tabular-nums`,"aria-label":s(`table.minCostFilterAria`)})]})]}),t?(0,Y.jsx)(`div`,{className:`h-32 rounded bg-card/30 animate-pulse`}):e.length===0?(0,Y.jsx)(`div`,{className:`h-32 flex items-center justify-center text-xs text-muted-foreground/70`,children:s(`table.empty`)}):(0,Y.jsx)(`div`,{className:`overflow-x-auto`,children:(0,Y.jsxs)(`table`,{className:`w-full text-[12px] tabular-nums`,children:[(0,Y.jsx)(`thead`,{className:`text-[10px] uppercase tracking-wider text-muted-foreground`,children:(0,Y.jsxs)(`tr`,{className:`text-left`,children:[(0,Y.jsx)(`th`,{className:`font-medium px-2 py-2`,children:s(`table.colSurface`)}),(0,Y.jsx)(`th`,{className:`font-medium px-2 py-2`,children:s(`table.colTicket`)}),(0,Y.jsx)(`th`,{className:`font-medium px-2 py-2 text-right`,children:s(`table.colCost`)}),(0,Y.jsx)(`th`,{className:`font-medium px-2 py-2 text-right`,children:s(`table.colTurns`)}),(0,Y.jsx)(`th`,{className:`font-medium px-2 py-2 text-right`,children:s(`table.colTokens`)}),(0,Y.jsx)(`th`,{className:`font-medium px-2 py-2`,children:s(`table.colModel`)}),f&&(0,Y.jsx)(`th`,{className:`font-medium px-2 py-2`,children:s(`table.colProvider`)}),(0,Y.jsx)(`th`,{className:`font-medium px-2 py-2`,children:s(`table.colStatus`)}),(0,Y.jsx)(`th`,{className:`font-medium px-2 py-2`,children:s(`table.colStarted`)})]})}),(0,Y.jsx)(`tbody`,{children:e.map(e=>{let t=e.surface,n=m[t],r=(e.tokens_in??0)+(e.tokens_out??0)+(e.tokens_cache_read??0)+(e.tokens_cache_create??0),i=Pt(e),a=i?s(`table.contractLayer`):c[t],o=It(e,d);return(0,Y.jsxs)(`tr`,{onClick:()=>u(l===e.id?null:e.id),className:`border-t border-border/30 hover:bg-accent/30 cursor-pointer`,children:[(0,Y.jsx)(`td`,{className:`px-2 py-2`,children:(0,Y.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 px-2 h-5 rounded-full text-[10px] font-medium ${n.bg} ${n.text}`,children:[(0,Y.jsx)(`span`,{className:`w-1.5 h-1.5 rounded-full ${n.dot}`}),a]})}),(0,Y.jsx)(`td`,{className:`px-2 py-2 max-w-[260px]`,children:e.ticket_id==null?e.ticket_title?(0,Y.jsx)(`span`,{className:`truncate block text-muted-foreground/90 italic`,title:s(`table.provisionalTitleTooltip`),children:e.ticket_title}):(0,Y.jsx)(`span`,{className:`text-muted-foreground/70`,children:`—`}):(0,Y.jsxs)(`span`,{className:`truncate block`,children:[`#`,e.ticket_id,` `,i?(0,Y.jsx)(`span`,{className:`text-muted-foreground/90`,children:s(`table.contractLayerRefinement`)}):e.ticket_title??(0,Y.jsx)(`span`,{className:`text-muted-foreground/70 italic`,children:s(`table.deleted`)})]})}),(0,Y.jsx)(`td`,{className:`px-2 py-2 text-right font-medium`,children:e.total_cost_usd_estimated===1&&e.total_cost_usd!=null?(0,Y.jsxs)(`span`,{title:s(`table.estimatedCostTooltip`),className:`text-muted-foreground/90`,children:[`~`,Mt(e.total_cost_usd)]}):Mt(e.total_cost_usd)}),(0,Y.jsx)(`td`,{className:`px-2 py-2 text-right`,children:Nt(e.num_turns)}),(0,Y.jsx)(`td`,{className:`px-2 py-2 text-right`,children:r>0?Nt(r):`—`}),(0,Y.jsxs)(`td`,{className:`px-2 py-2 max-w-[180px] truncate`,children:[o??`—`,o&&!e.model?(0,Y.jsx)(`span`,{className:`ml-1 text-[10px] text-muted-foreground/70`,children:s(`table.inferred`)}):null]}),f&&(0,Y.jsx)(`td`,{className:`px-2 py-2 text-muted-foreground`,children:jt(e.provider??`claude`)}),(0,Y.jsxs)(`td`,{className:`px-2 py-2`,children:[e.status===`success`?(0,Y.jsx)(`span`,{className:`text-accent-success/90`,children:`●`}):e.status===`failed`?(0,Y.jsx)(`span`,{className:`text-accent-warning`,children:`⚠`}):(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:`○`}),(0,Y.jsx)(`span`,{className:`ml-1 text-muted-foreground`,children:s(`table.statusValue.${e.status}`)})]}),(0,Y.jsx)(`td`,{className:`px-2 py-2 text-muted-foreground`,children:e.started_at.slice(0,16).replace(`T`,` `)})]},e.id)})})]})}),p&&e.length>0&&(0,Y.jsx)(`div`,{className:`mt-2 text-[11px] text-muted-foreground/80`,children:s(`table.truncated`,{shown:e.length,total:i.toLocaleString()})})]})}var Rt=[{value:`7d`,labelKey:`periods.d7`},{value:`30d`,labelKey:`periods.d30`},{value:`90d`,labelKey:`periods.d90`},{value:`all`,labelKey:`periods.all`}],zt=[{value:`all`,labelKey:`page.all`},{value:`job`,labelKey:`surfaces.job`},{value:`explore-spec`,labelKey:`surfaces.exploreSpec`},{value:`quick-spec`,labelKey:`surfaces.quickSpec`},{value:`ai-edit`,labelKey:`surfaces.aiEdit`},{value:`smash`,labelKey:`surfaces.smash`},{value:`file-summary`,labelKey:`surfaces.fileSummary`},{value:`loop`,labelKey:`surfaces.loop`}];function Bt(e){let t=new URLSearchParams;return e.period&&t.set(`period`,e.period),e.from&&t.set(`from`,e.from),e.to&&t.set(`to`,e.to),e.surface&&e.surface.length>0&&t.set(`surface`,e.surface.join(`,`)),e.provider&&e.provider.length>0&&t.set(`provider`,e.provider.join(`,`)),e.model&&e.model.length>0&&t.set(`model`,e.model.join(`,`)),e.modelKeys&&e.modelKeys.length>0&&e.model&&e.modelKeys.length===e.model.length&&t.set(`modelProvider`,e.modelKeys.map(e=>e.provider).join(`,`)),e.status&&t.set(`status`,e.status),typeof e.minCostUsd==`number`&&t.set(`minCostUsd`,String(e.minCostUsd)),typeof e.ticketId==`number`&&t.set(`ticketId`,String(e.ticketId)),typeof e.tzOffsetMinutes==`number`&&t.set(`tzOffsetMinutes`,String(e.tzOffsetMinutes)),e.sortBy&&t.set(`sortBy`,e.sortBy),t.toString()}function Vt(){let{t:e}=n(`analytics`),{activeProjectId:t,projects:a}=s(),[o,c]=d(),l=a.find(e=>e.id===t),u=l?r(l):[`claude`],p=u.length>1,m=o.get(`period`)??`30d`,v=(o.get(`surface`)??``).split(`,`).filter(Boolean),y=(o.get(`provider`)??``).split(`,`).filter(Boolean),b=o.get(`ticketId`),x=(o.get(`model`)??``).split(`,`).filter(Boolean),S=(o.get(`modelProvider`)??``).split(`,`).filter(Boolean),ee=x.length>0&&x.length===S.length?x.map((e,t)=>({provider:S[t],model:e})):void 0,te=(0,J.useMemo)(()=>-new Date().getTimezoneOffset(),[]),[C,w]=(0,J.useState)({period:m,surface:v.length>0?v:void 0,provider:y.length>0?y:void 0,ticketId:b?Number(b):void 0,model:x.length>0?x:void 0,modelKeys:ee,tzOffsetMinutes:te}),[T,E]=(0,J.useState)(null),[D,O]=(0,J.useState)(!0),[k,A]=(0,J.useState)(null),[j,M]=(0,J.useState)({}),[N,P]=(0,J.useState)(null),[F,ne]=(0,J.useState)(`recency`),I=(0,J.useRef)(new Map),L=(0,J.useRef)(0);(0,J.useEffect)(()=>{let e=new URLSearchParams;e.set(`period`,C.period),C.surface&&C.surface.length>0&&e.set(`surface`,C.surface.join(`,`)),C.provider&&C.provider.length>0&&e.set(`provider`,C.provider.join(`,`)),C.ticketId&&e.set(`ticketId`,String(C.ticketId)),C.model&&C.model.length>0&&(e.set(`model`,C.model.join(`,`)),C.modelKeys&&C.modelKeys.length===C.model.length&&e.set(`modelProvider`,C.modelKeys.map(e=>e.provider).join(`,`))),c(e,{replace:!0})},[C.period,C.surface,C.provider,C.ticketId,C.model,C.modelKeys,c]);let R=(0,J.useCallback)(async()=>{if(!t)return;let e=++L.current;A(null);let n=`${t}:${Bt(C)}`,r=I.current.get(n);r?(E(r),O(!1)):O(!0);try{let t=await fetch(`${f()}/spending?${Bt(C)}`);if(!t.ok)throw Error(`HTTP ${t.status}`);if(e!==L.current)return;let r=await t.json();I.current.set(n,r),E(r),O(!1)}catch(t){if(e!==L.current)return;A(t.message),O(!1)}},[t,C]),z=(0,J.useRef)(0),B=(0,J.useCallback)(async()=>{if(!t)return;let e=++z.current,n={...C};j.model&&(n.model=[j.model],n.modelKeys=void 0),j.status&&(n.status=j.status),typeof j.minCostUsd==`number`&&(n.minCostUsd=j.minCostUsd),n.sortBy=F;try{let t=await fetch(`${f()}/invocations?${Bt(n)}&limit=100`);if(!t.ok)throw Error(`HTTP ${t.status}`);let r=await t.json();if(e!==z.current)return;P(r)}catch{if(e!==z.current)return;P(null)}},[t,C,j,F]),re=(0,J.useRef)(t);(0,J.useEffect)(()=>{re.current!==t&&(re.current=t,E(null),P(null),O(!0))},[t]),(0,J.useEffect)(()=>{R()},[R]),(0,J.useEffect)(()=>{B()},[B]);let V=(0,J.useRef)(null),H=h();(0,J.useEffect)(()=>{let e=`analytics-spending`;return H.registerHandler(e,e=>{let n=e;n.type===`spending.invalidated`&&n.projectId===t&&(V.current&&clearTimeout(V.current),V.current=setTimeout(()=>{I.current.clear(),R(),B()},500))}),()=>{H.unregisterHandler(e),V.current&&clearTimeout(V.current)}},[H,t,R,B]);function ie(e){if(e===`all`){w(e=>({...e,surface:void 0}));return}w(t=>{let n=t.surface??[],r=n.includes(e)?n.filter(t=>t!==e):[...n,e];return{...t,surface:r.length>0?r:void 0}})}let ae=(0,J.useCallback)((e,t)=>{w(n=>{if(n.model?.length===1&&n.model[0]===e&&(t===void 0||n.modelKeys?.length===1&&n.modelKeys[0].provider===t))return{...n,model:void 0,modelKeys:void 0};let r=(T?.byModel??[]).filter(n=>n.model===e&&(t===void 0||n.provider===t)).map(e=>({provider:e.provider,model:e.model})),i=r.length>0?r.map(e=>e.model):[e];return{...n,model:i,modelKeys:r.length>0?r:void 0}})},[T]);function oe(){w(e=>({...e,model:void 0,modelKeys:void 0}))}function se(e){if(e===`all`){w(e=>({...e,provider:void 0}));return}w(t=>{let n=t.provider??[],r=n.includes(e)?n.filter(t=>t!==e):[...n,e];return{...t,provider:r.length>0?r:void 0}})}let U=C.surface,ce=!U||U.length===0,W=C.provider,le=!W||W.length===0,ue=(0,J.useMemo)(()=>{let e={period:C.period};return C.surface&&C.surface.length>0&&(e.surface=C.surface.join(`,`)),C.provider&&C.provider.length>0&&(e.provider=C.provider.join(`,`)),C.ticketId&&(e.ticketId=String(C.ticketId)),e},[C]),de=T?T.summary.totalRuns===0:!1;return(0,Y.jsxs)(`div`,{className:`flex flex-col gap-6 p-4 pb-12`,children:[(0,Y.jsxs)(`div`,{className:`sticky top-0 z-10 -mx-4 px-4 py-3 bg-background/95 backdrop-blur supports-[backdrop-filter]:bg-background/80 border-b border-border/40`,children:[(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Y.jsx)(`h1`,{className:`text-base font-semibold tracking-tight`,children:e(`page.title`)}),C.ticketId&&(0,Y.jsx)(`button`,{type:`button`,onClick:()=>w(e=>({...e,ticketId:void 0})),className:`inline-flex items-center gap-1 h-6 px-2 rounded-full text-[11px] font-medium bg-accent-highlight/15 text-accent-highlight ring-1 ring-accent-highlight/30 hover:bg-accent-highlight/25`,children:e(`page.ticketChip`,{id:C.ticketId})}),C.model&&C.model.length>0&&(0,Y.jsxs)(`button`,{type:`button`,"data-testid":`analytics-model-chip`,onClick:oe,title:e(`page.clearModelFilter`),className:`inline-flex items-center gap-1 h-6 px-2 rounded-full text-[11px] font-medium bg-accent-highlight/15 text-accent-highlight ring-1 ring-accent-highlight/30 hover:bg-accent-highlight/25`,children:[e(`page.modelChip`,{model:C.model[0]}),(0,Y.jsx)(`span`,{"aria-hidden":!0,className:`opacity-70`,children:`×`})]})]}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(`div`,{className:`flex items-center gap-1 rounded-md border border-border/60 bg-card/40 p-0.5`,children:Rt.map(t=>(0,Y.jsx)(`button`,{type:`button`,onClick:()=>w(e=>({...e,period:t.value})),className:`px-2.5 h-6 rounded text-[11px] font-medium transition-colors ${C.period===t.value?`bg-accent text-foreground`:`text-muted-foreground hover:text-foreground`}`,children:e(t.labelKey)},t.value))}),(0,Y.jsx)(_,{baseUrl:`${f()}/analytics/export`,params:ue,disabled:de}),(0,Y.jsx)(`button`,{type:`button`,onClick:()=>{I.current.clear(),R(),B()},className:`h-7 w-7 inline-flex items-center justify-center rounded-md border border-border/60 bg-card/50 text-muted-foreground hover:text-foreground hover:bg-accent/60`,title:e(`common:actions.refresh`),children:(0,Y.jsx)(g,{className:`w-3 h-3`})})]})]}),(0,Y.jsx)(`div`,{className:`mt-3 flex flex-wrap items-center gap-1.5`,children:zt.map(t=>(0,Y.jsx)(`button`,{type:`button`,onClick:()=>ie(t.value),className:`h-7 px-3 rounded-full text-[11px] font-medium transition-all ${(t.value===`all`?ce:U?.includes(t.value)??!1)?`bg-foreground/10 text-foreground ring-1 ring-foreground/20`:`text-muted-foreground hover:text-foreground hover:bg-accent/40`}`,children:e(t.labelKey)},t.value))}),p&&(0,Y.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-1.5`,"data-testid":`analytics-provider-chips`,children:[(0,Y.jsx)(`span`,{className:`text-[10px] uppercase tracking-wide text-muted-foreground/70 mr-1`,children:e(`page.engine`)}),(0,Y.jsx)(`button`,{type:`button`,onClick:()=>se(`all`),className:`h-7 px-3 rounded-full text-[11px] font-medium transition-all ${le?`bg-foreground/10 text-foreground ring-1 ring-foreground/20`:`text-muted-foreground hover:text-foreground hover:bg-accent/40`}`,children:e(`page.all`)}),u.map(e=>(0,Y.jsx)(`button`,{type:`button`,onClick:()=>se(e),className:`h-7 px-3 rounded-full text-[11px] font-medium transition-all ${W?.includes(e)??!1?`bg-foreground/10 text-foreground ring-1 ring-foreground/20`:`text-muted-foreground hover:text-foreground hover:bg-accent/40`}`,children:i(e)},e))]})]}),k&&(0,Y.jsxs)(`div`,{className:`rounded-lg border border-accent-warning/30 bg-accent-warning/10 p-4 flex items-center justify-between`,children:[(0,Y.jsx)(`p`,{className:`text-sm text-accent-warning`,children:e(`page.failedToLoad`,{error:k})}),(0,Y.jsxs)(`button`,{onClick:()=>R(),className:`flex items-center gap-1.5 h-7 px-3 rounded-md text-xs text-accent-warning border border-accent-warning/30 hover:bg-accent-warning/10`,children:[(0,Y.jsx)(g,{className:`w-3 h-3`}),e(`common:actions.retry`)]})]}),(0,Y.jsx)(Ne,{data:T,loading:D}),(0,Y.jsx)(ze,{data:T,loading:D}),(0,Y.jsx)(yt,{data:T,loading:D}),(0,Y.jsxs)(`div`,{className:`grid grid-cols-1 lg:grid-cols-2 gap-4`,children:[(0,Y.jsx)(wt,{data:T,loading:D}),(0,Y.jsx)(Tt,{data:T,loading:D,onSelectModel:ae,activeModel:C.model?.[0]})]}),(0,Y.jsx)(Ot,{data:T,loading:D,onSelectPoint:e=>{M(e=>({...e})),w(t=>({...t,ticketId:e.ticketId??void 0}))}}),(0,Y.jsx)(kt,{data:T,loading:D,onSelectTicket:e=>w(t=>({...t,ticketId:e??void 0}))}),(0,Y.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center justify-end gap-1.5`,"data-testid":`analytics-table-sort`,children:[(0,Y.jsx)(`span`,{className:`text-[10px] uppercase tracking-wide text-muted-foreground/70 mr-1`,children:e(`table.sortLabel`)}),[`recency`,`cost`].map(t=>(0,Y.jsx)(`button`,{type:`button`,"data-testid":`analytics-table-sort-${t}`,"aria-pressed":F===t,onClick:()=>ne(t),className:`h-6 px-2.5 rounded-full text-[11px] font-medium transition-all ${F===t?`bg-foreground/10 text-foreground ring-1 ring-foreground/20`:`text-muted-foreground hover:text-foreground hover:bg-accent/40`}`,children:e(t===`recency`?`table.sortRecency`:`table.sortCost`)},t))]}),(0,Y.jsx)(Lt,{rows:N?.rows??[],loading:D&&!N,truncated:(N?.truncated??!1)||(N?.totalAvailable??0)>(N?.rows.length??0),totalAvailable:N?.totalAvailable??0,tableFilters:j,onTableFiltersChange:M})]})]})}export{Vt as default};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/editor.main-G3Sl9C67.js","assets/chunk-BNv3lrIs.js","assets/preload-helper-DSXbuxSR.js","assets/editor.api2-T7u8kQWG.js","assets/editor-Br_kD0ds.css","assets/workers-CXcXtO3b.js","assets/monaco.contribution-PUeaZk8T.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{a as e}from"./chunk-BNv3lrIs.js";import{t}from"./preload-helper-DSXbuxSR.js";import{An as n,B as r,Cn as i,Ct as a,Dn as o,Dt as s,Et as c,G as l,Lt as u,Rt as d,Sn as f,St as p,Tt as m,Xt as h,Yt as g,a as _,at as v,b as y,bt as b,cn as x,jn as S,kn as C,kt as w,l as T,ln as E,q as D,qt as O,sn as ee,x as k,z as te,zt as A}from"./index-B7vB20Jw.js";var j=O(`file`,[[`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`}]]),M=O(`funnel`,[[`path`,{d:`M10 20a1 1 0 0 0 .553.895l2 1A1 1 0 0 0 14 21v-7a2 2 0 0 1 .517-1.341L21.74 4.67A1 1 0 0 0 21 3H3a1 1 0 0 0-.742 1.67l7.225 7.989A2 2 0 0 1 10 14z`,key:`sc7q7i`}]]),N=e(S(),1),P=e(n(),1);function F(e,t,n){let r=Array(e);return new Proxy(r,{get(r,i,a){if(typeof i==`string`){let a=i.charCodeAt(0);if(a>=48&&a<=57){let a=+i;if(Number.isInteger(a)&&a>=0&&a<e){let e=r[a];if(!e){let i=t[a*2];e=r[a]={index:a,key:n(a),start:i,size:t[a*2+1],end:i+t[a*2+1],lane:0}}return e}}if(i===`length`)return e}return Reflect.get(r,i,a)}})}function I(e,t,n){let r=n.initialDeps??[],i,a=!0;function o(){let o=e();return o.length!==r.length||o.some((e,t)=>r[t]!==e)?(r=o,i=t(...o),n?.onChange&&!(a&&n.skipInitialOnChange)&&n.onChange(i),a=!1,i):i}return o.updateDeps=e=>{r=e},o}function ne(e,t){if(e===void 0)throw Error(`Unexpected undefined${t?`: ${t}`:``}`);return e}var re=(e,t)=>Math.abs(e-t)<1.01,ie=(e,t,n)=>{let r;return function(...i){e.clearTimeout(r),r=e.setTimeout(()=>t.apply(this,i),n)}},L,R=()=>{if(L!==void 0)return L;if(typeof navigator>`u`)return L=!1;if(/iP(hone|od|ad)/.test(navigator.userAgent))return L=!0;let e=navigator.maxTouchPoints;return L=navigator.platform===`MacIntel`&&e!==void 0&&e>0},z=e=>{let{offsetWidth:t,offsetHeight:n}=e;return{width:t,height:n}},ae=e=>e,oe=e=>{let t=Math.max(e.startIndex-e.overscan,0),n=Math.min(e.endIndex+e.overscan,e.count-1)-t+1,r=Array(n);for(let e=0;e<n;e++)r[e]=t+e;return r},B=(e,t)=>{let n=e.scrollElement;if(!n)return;let r=e.targetWindow;if(!r)return;let i=e=>{let{width:n,height:r}=e;t({width:Math.round(n),height:Math.round(r)})};if(i(z(n)),!r.ResizeObserver)return()=>{};let a=new r.ResizeObserver(t=>{let r=()=>{let e=t[0];if(e?.borderBoxSize){let t=e.borderBoxSize[0];if(t){i({width:t.inlineSize,height:t.blockSize});return}}i(z(n))};e.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(r):r()});return a.observe(n,{box:`border-box`}),()=>{a.unobserve(n)}},V={passive:!0},H=typeof window>`u`?!0:`onscrollend`in window,U=(e,t,n)=>{let r=e.scrollElement;if(!r)return;let i=e.targetWindow;if(!i)return;let a=e.options.useScrollendEvent&&H,o=0,s=a?null:ie(i,()=>t(o,!1),e.options.isScrollingResetDelay),c=e=>()=>{o=n(r),s?.(),t(o,e)},l=c(!0),u=c(!1);return r.addEventListener(`scroll`,l,V),a&&r.addEventListener(`scrollend`,u,V),()=>{r.removeEventListener(`scroll`,l),a&&r.removeEventListener(`scrollend`,u)}},W=(e,t)=>U(e,t,t=>{let{horizontal:n,isRtl:r}=e.options;return n?t.scrollLeft*(r&&-1||1):t.scrollTop}),se=(e,t,n)=>{if(t?.borderBoxSize){let e=t.borderBoxSize[0];if(e)return Math.round(e[n.options.horizontal?`inlineSize`:`blockSize`])}return e[n.options.horizontal?`offsetWidth`:`offsetHeight`]},G=(e,{adjustments:t=0,behavior:n},r)=>{var i,a;(a=(i=r.scrollElement)?.scrollTo)==null||a.call(i,{[r.options.horizontal?`left`:`top`]:e+t,behavior:n})},ce=class{constructor(e){this.unsubs=[],this.scrollElement=null,this.targetWindow=null,this.isScrolling=!1,this.scrollState=null,this.measurementsCache=[],this._flatMeasurements=null,this.itemSizeCache=new Map,this.itemSizeCacheVersion=0,this.laneAssignments=new Map,this.pendingMin=null,this.prevLanes=void 0,this.lanesChangedFlag=!1,this.lanesSettling=!1,this.scrollRect=null,this.scrollOffset=null,this.scrollDirection=null,this.scrollAdjustments=0,this._iosDeferredAdjustment=0,this._iosTouching=!1,this._iosJustTouchEnded=!1,this._iosTouchEndTimerId=null,this._intendedScrollOffset=null,this.elementsCache=new Map,this.now=()=>{var e;return((e=this.targetWindow?.performance)?.now)?.call(e)??Date.now()},this.observer=(()=>{let e=null,t=()=>e||(!this.targetWindow||!this.targetWindow.ResizeObserver?null:e=new this.targetWindow.ResizeObserver(e=>{e.forEach(e=>{let t=()=>{let t=e.target,n=this.indexFromElement(t);if(!t.isConnected){this.observer.unobserve(t);for(let[e,n]of this.elementsCache)if(n===t){this.elementsCache.delete(e);break}return}this.shouldMeasureDuringScroll(n)&&this.resizeItem(n,this.options.measureElement(t,e,this))};this.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(t):t()})}));return{disconnect:()=>{var n;(n=t())==null||n.disconnect(),e=null},observe:e=>t()?.observe(e,{box:`border-box`}),unobserve:e=>t()?.unobserve(e)}})(),this.range=null,this.setOptions=e=>{let t={debug:!1,initialOffset:0,overscan:1,paddingStart:0,paddingEnd:0,scrollPaddingStart:0,scrollPaddingEnd:0,horizontal:!1,getItemKey:ae,rangeExtractor:oe,onChange:()=>{},measureElement:se,initialRect:{width:0,height:0},scrollMargin:0,gap:0,indexAttribute:`data-index`,initialMeasurementsCache:[],lanes:1,isScrollingResetDelay:150,enabled:!0,isRtl:!1,useScrollendEvent:!1,useAnimationFrameWithResizeObserver:!1,laneAssignmentMode:`estimate`};for(let n in e){let r=e[n];r!==void 0&&(t[n]=r)}this.options=t},this.notify=e=>{var t,n;(n=(t=this.options).onChange)==null||n.call(t,this,e)},this.maybeNotify=I(()=>(this.calculateRange(),[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]),e=>{this.notify(e)},{key:!1,debug:()=>this.options.debug,initialDeps:[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]}),this.cleanup=()=>{this.unsubs.filter(Boolean).forEach(e=>e()),this.unsubs=[],this.observer.disconnect(),this.rafId!=null&&this.targetWindow&&(this.targetWindow.cancelAnimationFrame(this.rafId),this.rafId=null),this.scrollState=null,this.scrollElement=null,this.targetWindow=null},this._didMount=()=>()=>{this.cleanup()},this._willUpdate=()=>{let e=this.options.enabled?this.options.getScrollElement():null;if(this.scrollElement!==e){if(this.cleanup(),!e){this.maybeNotify();return}if(this.scrollElement=e,this.scrollElement&&`ownerDocument`in this.scrollElement?this.targetWindow=this.scrollElement.ownerDocument.defaultView:this.targetWindow=this.scrollElement?.window??null,this.elementsCache.forEach(e=>{this.observer.observe(e)}),this.unsubs.push(this.options.observeElementRect(this,e=>{this.scrollRect=e,this.maybeNotify()})),this.unsubs.push(this.options.observeElementOffset(this,(e,t)=>{this._intendedScrollOffset!==null&&Math.abs(e-this._intendedScrollOffset)<1.5&&(e=this._intendedScrollOffset),this._intendedScrollOffset=null,this.scrollAdjustments=0,this.scrollDirection=t?this.getScrollOffset()<e?`forward`:`backward`:null,this.scrollOffset=e,this.isScrolling=t,this._flushIosDeferredIfReady(),this.scrollState&&this.scheduleScrollReconcile(),this.maybeNotify()})),`addEventListener`in this.scrollElement){let e=this.scrollElement,t=()=>{this._iosTouching=!0,this._iosJustTouchEnded=!1,this._iosTouchEndTimerId!==null&&this.targetWindow!=null&&(this.targetWindow.clearTimeout(this._iosTouchEndTimerId),this._iosTouchEndTimerId=null)},n=()=>{this._iosTouching=!1,!(!R()||this.targetWindow==null)&&(this._iosJustTouchEnded=!0,this._iosTouchEndTimerId=this.targetWindow.setTimeout(()=>{this._iosJustTouchEnded=!1,this._iosTouchEndTimerId=null,this._flushIosDeferredIfReady()},150))};e.addEventListener(`touchstart`,t,V),e.addEventListener(`touchend`,n,V),this.unsubs.push(()=>{e.removeEventListener(`touchstart`,t),e.removeEventListener(`touchend`,n),this._iosTouchEndTimerId!==null&&this.targetWindow!=null&&(this.targetWindow.clearTimeout(this._iosTouchEndTimerId),this._iosTouchEndTimerId=null)})}this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})}},this._flushIosDeferredIfReady=()=>{if(this._iosDeferredAdjustment===0||this.isScrolling||this._iosTouching||this._iosJustTouchEnded)return;let e=this.getScrollOffset(),t=this.getMaxScrollOffset();if(e<0||e>t)return;let n=this._iosDeferredAdjustment;this._iosDeferredAdjustment=0,this._scrollToOffset(e,{adjustments:this.scrollAdjustments+=n,behavior:void 0})},this.rafId=null,this.getSize=()=>this.options.enabled?(this.scrollRect=this.scrollRect??this.options.initialRect,this.scrollRect[this.options.horizontal?`width`:`height`]):(this.scrollRect=null,0),this.getScrollOffset=()=>this.options.enabled?(this.scrollOffset=this.scrollOffset??(typeof this.options.initialOffset==`function`?this.options.initialOffset():this.options.initialOffset),this.scrollOffset):(this.scrollOffset=null,0),this.getFurthestMeasurement=(e,t)=>{let n=new Map,r=new Map;for(let i=t-1;i>=0;i--){let t=e[i];if(n.has(t.lane))continue;let a=r.get(t.lane);if(a==null||t.end>a.end?r.set(t.lane,t):t.end<a.end&&n.set(t.lane,!0),n.size===this.options.lanes)break}return r.size===this.options.lanes?Array.from(r.values()).sort((e,t)=>e.end===t.end?e.index-t.index:e.end-t.end)[0]:void 0},this.getMeasurementOptions=I(()=>[this.options.count,this.options.paddingStart,this.options.scrollMargin,this.options.getItemKey,this.options.enabled,this.options.lanes,this.options.laneAssignmentMode],(e,t,n,r,i,a,o)=>(this.prevLanes!==void 0&&this.prevLanes!==a&&(this.lanesChangedFlag=!0),this.prevLanes=a,this.pendingMin=null,{count:e,paddingStart:t,scrollMargin:n,getItemKey:r,enabled:i,lanes:a,laneAssignmentMode:o}),{key:!1}),this.getMeasurements=I(()=>[this.getMeasurementOptions(),this.itemSizeCacheVersion],({count:e,paddingStart:t,scrollMargin:n,getItemKey:r,enabled:i,lanes:a,laneAssignmentMode:o},s)=>{let c=this.itemSizeCache;if(!i)return this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),[];if(this.laneAssignments.size>e)for(let t of this.laneAssignments.keys())t>=e&&this.laneAssignments.delete(t);this.lanesChangedFlag&&(this.lanesChangedFlag=!1,this.lanesSettling=!0,this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),this.pendingMin=null),this.measurementsCache.length===0&&!this.lanesSettling&&(this.measurementsCache=this.options.initialMeasurementsCache,this.measurementsCache.forEach(e=>{this.itemSizeCache.set(e.key,e.size)}));let l=this.lanesSettling?0:this.pendingMin??0;if(this.pendingMin=null,this.lanesSettling&&this.measurementsCache.length===e&&(this.lanesSettling=!1),a===1){let i=this.options.gap,a=e*2,o=this._flatMeasurements;if(!o||o.length<a){let e=new Float64Array(a);o&&l>0&&e.set(o.subarray(0,l*2)),o=e,this._flatMeasurements=o}let s;if(l===0)s=t+n;else{let e=l-1;s=o[e*2]+o[e*2+1]+i}for(let t=l;t<e;t++){let e=r(t),n=c.get(e),a=typeof n==`number`?n:this.options.estimateSize(t);o[t*2]=s,o[t*2+1]=a,s+=a+i}let u=F(e,o,r);return this.measurementsCache=u,u}let u=this.measurementsCache.slice(0,l),d=Array(a).fill(void 0);for(let e=0;e<l;e++){let t=u[e];t&&(d[t.lane]=e)}for(let i=l;i<e;i++){let e=r(i),a=this.laneAssignments.get(i),s,l,f=o===`estimate`||c.has(e);if(a!==void 0&&this.options.lanes>1){s=a;let e=d[s],r=e===void 0?void 0:u[e];l=r?r.end+this.options.gap:t+n}else{let e=this.options.lanes===1?u[i-1]:this.getFurthestMeasurement(u,i);l=e?e.end+this.options.gap:t+n,s=e?e.lane:i%this.options.lanes,this.options.lanes>1&&f&&this.laneAssignments.set(i,s)}let p=c.get(e),m=typeof p==`number`?p:this.options.estimateSize(i),h=l+m;u[i]={index:i,start:l,size:m,end:h,key:e,lane:s},d[s]=i}return this.measurementsCache=u,u},{key:!1,debug:()=>this.options.debug}),this.calculateRange=I(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(e,t,n,r)=>this.range=e.length>0&&t>0?ue({measurements:e,outerSize:t,scrollOffset:n,lanes:r,flat:r===1&&this._flatMeasurements!=null?this._flatMeasurements:null}):null,{key:!1,debug:()=>this.options.debug}),this.getVirtualIndexes=I(()=>{let e=null,t=null,n=this.calculateRange();return n&&(e=n.startIndex,t=n.endIndex),this.maybeNotify.updateDeps([this.isScrolling,e,t]),[this.options.rangeExtractor,this.options.overscan,this.options.count,e,t]},(e,t,n,r,i)=>r===null||i===null?[]:e({startIndex:r,endIndex:i,overscan:t,count:n}),{key:!1,debug:()=>this.options.debug}),this.indexFromElement=e=>{let t=this.options.indexAttribute,n=e.getAttribute(t);return n?parseInt(n,10):(console.warn(`Missing attribute name '${t}={index}' on measured element.`),-1)},this.shouldMeasureDuringScroll=e=>{if(!this.scrollState||this.scrollState.behavior!==`smooth`)return!0;let t=this.scrollState.index??this.getVirtualItemForOffset(this.scrollState.lastTargetOffset)?.index;if(t!==void 0&&this.range){let n=Math.max(this.options.overscan,Math.ceil((this.range.endIndex-this.range.startIndex)/2)),r=Math.max(0,t-n),i=Math.min(this.options.count-1,t+n);return e>=r&&e<=i}return!0},this.measureElement=e=>{if(!e){this.elementsCache.forEach((e,t)=>{e.isConnected||(this.observer.unobserve(e),this.elementsCache.delete(t))});return}let t=this.indexFromElement(e),n=this.options.getItemKey(t),r=this.elementsCache.get(n);r!==e&&(r&&this.observer.unobserve(r),this.observer.observe(e),this.elementsCache.set(n,e)),(!this.isScrolling||this.scrollState)&&this.shouldMeasureDuringScroll(t)&&this.resizeItem(t,this.options.measureElement(e,void 0,this))},this.resizeItem=(e,t)=>{if(e<0||e>=this.options.count)return;let n,r,i,a=this._flatMeasurements;if(this.options.lanes===1&&a!==null)i=this.options.getItemKey(e),r=a[e*2],n=a[e*2+1];else{let t=this.measurementsCache[e];if(!t)return;i=t.key,r=t.start,n=t.size}let o=t-(this.itemSizeCache.get(i)??n);o!==0&&(this.scrollState?.behavior!==`smooth`&&(this.shouldAdjustScrollPositionOnItemSizeChange===void 0?r<this.getScrollOffset()+this.scrollAdjustments&&this.scrollDirection!==`backward`:this.shouldAdjustScrollPositionOnItemSizeChange(this.measurementsCache[e]??{index:e,key:i,start:r,size:n,end:r+n,lane:0},o,this))&&(R()&&(this.isScrolling||this._iosTouching||this._iosJustTouchEnded)?this._iosDeferredAdjustment+=o:this._scrollToOffset(this.getScrollOffset(),{adjustments:this.scrollAdjustments+=o,behavior:void 0})),(this.pendingMin===null||e<this.pendingMin)&&(this.pendingMin=e),this.itemSizeCache.set(i,t),this.itemSizeCacheVersion++,this.notify(!1))},this.getVirtualItems=I(()=>[this.getVirtualIndexes(),this.getMeasurements()],(e,t)=>{let n=[];for(let r=0,i=e.length;r<i;r++){let i=t[e[r]];n.push(i)}return n},{key:!1,debug:()=>this.options.debug}),this.getVirtualItemForOffset=e=>{let t=this.getMeasurements();if(t.length===0)return;let n=this._flatMeasurements,r=this.options.lanes===1&&n!=null;return ne(t[le(0,t.length-1,r?e=>n[e*2]:e=>ne(t[e]).start,e)])},this.getMaxScrollOffset=()=>{if(!this.scrollElement)return 0;if(`scrollHeight`in this.scrollElement)return this.options.horizontal?this.scrollElement.scrollWidth-this.scrollElement.clientWidth:this.scrollElement.scrollHeight-this.scrollElement.clientHeight;{let e=this.scrollElement.document.documentElement;return this.options.horizontal?e.scrollWidth-this.scrollElement.innerWidth:e.scrollHeight-this.scrollElement.innerHeight}},this.getOffsetForAlignment=(e,t,n=0)=>{if(!this.scrollElement)return 0;let r=this.getSize(),i=this.getScrollOffset();t===`auto`&&(t=e>=i+r?`end`:`start`),t===`center`?e+=(n-r)/2:t===`end`&&(e-=r);let a=this.getMaxScrollOffset();return Math.max(Math.min(a,e),0)},this.getOffsetForIndex=(e,t=`auto`)=>{e=Math.max(0,Math.min(e,this.options.count-1));let n=this.getSize(),r=this.getScrollOffset(),i=this.measurementsCache[e];if(!i)return;if(t===`auto`)if(i.end>=r+n-this.options.scrollPaddingEnd)t=`end`;else if(i.start<=r+this.options.scrollPaddingStart)t=`start`;else return[r,t];if(t===`end`&&e===this.options.count-1)return[this.getMaxScrollOffset(),t];let a=t===`end`?i.end+this.options.scrollPaddingEnd:i.start-this.options.scrollPaddingStart;return[this.getOffsetForAlignment(a,t,i.size),t]},this.scrollToOffset=(e,{align:t=`start`,behavior:n=`auto`}={})=>{let r=this.getOffsetForAlignment(e,t),i=this.now();this.scrollState={index:null,align:t,behavior:n,startedAt:i,lastTargetOffset:r,stableFrames:0},this._scrollToOffset(r,{adjustments:void 0,behavior:n}),this.scheduleScrollReconcile()},this.scrollToIndex=(e,{align:t=`auto`,behavior:n=`auto`}={})=>{e=Math.max(0,Math.min(e,this.options.count-1));let r=this.getOffsetForIndex(e,t);if(!r)return;let[i,a]=r,o=this.now();this.scrollState={index:e,align:a,behavior:n,startedAt:o,lastTargetOffset:i,stableFrames:0},this._scrollToOffset(i,{adjustments:void 0,behavior:n}),this.scheduleScrollReconcile()},this.scrollBy=(e,{behavior:t=`auto`}={})=>{let n=this.getScrollOffset()+e,r=this.now();this.scrollState={index:null,align:`start`,behavior:t,startedAt:r,lastTargetOffset:n,stableFrames:0},this._scrollToOffset(n,{adjustments:void 0,behavior:t}),this.scheduleScrollReconcile()},this.getTotalSize=()=>{let e=this.getMeasurements(),t;if(e.length===0)t=this.options.paddingStart;else if(this.options.lanes===1){let n=e.length-1,r=this._flatMeasurements;t=r==null?e[n]?.end??0:r[n*2]+r[n*2+1]}else{let n=Array(this.options.lanes).fill(null),r=e.length-1;for(;r>=0&&n.some(e=>e===null);){let t=e[r];n[t.lane]===null&&(n[t.lane]=t.end),r--}t=Math.max(...n.filter(e=>e!==null))}return Math.max(t-this.options.scrollMargin+this.options.paddingEnd,0)},this.takeSnapshot=()=>{let e=[];if(this.itemSizeCache.size===0)return e;let t=this.getMeasurements();for(let n of t)n&&this.itemSizeCache.has(n.key)&&e.push({index:n.index,key:n.key,start:n.start,size:n.size,end:n.end,lane:n.lane});return e},this._scrollToOffset=(e,{adjustments:t,behavior:n})=>{this._intendedScrollOffset=e+(t??0),this.options.scrollToFn(e,{behavior:n,adjustments:t},this)},this.measure=()=>{this.pendingMin=null,this.itemSizeCache.clear(),this.laneAssignments.clear(),this.itemSizeCacheVersion++,this.notify(!1)},this.setOptions(e)}scheduleScrollReconcile(){if(!this.targetWindow){this.scrollState=null;return}this.rafId??=this.targetWindow.requestAnimationFrame(()=>{this.rafId=null,this.reconcileScroll()})}reconcileScroll(){if(!this.scrollState||!this.scrollElement)return;if(this.now()-this.scrollState.startedAt>5e3){this.scrollState=null;return}let e=this.scrollState.index==null?void 0:this.getOffsetForIndex(this.scrollState.index,this.scrollState.align),t=e?e[0]:this.scrollState.lastTargetOffset,n=t!==this.scrollState.lastTargetOffset;if(!n&&re(t,this.getScrollOffset())){if(this.scrollState.stableFrames++,this.scrollState.stableFrames>=1){this.getScrollOffset()!==t&&this._scrollToOffset(t,{adjustments:void 0,behavior:`auto`}),this.scrollState=null;return}}else if(this.scrollState.stableFrames=0,n){let e=this.getSize()||600,n=Math.abs(t-this.getScrollOffset()),r=this.scrollState.behavior===`smooth`&&n>e;this.scrollState.lastTargetOffset=t,r||(this.scrollState.behavior=`auto`),this._scrollToOffset(t,{adjustments:void 0,behavior:r?`smooth`:`auto`})}this.scheduleScrollReconcile()}},le=(e,t,n,r)=>{for(;e<=t;){let i=(e+t)/2|0,a=n(i);if(a<r)e=i+1;else if(a>r)t=i-1;else return i}return e>0?e-1:0};function ue({measurements:e,outerSize:t,scrollOffset:n,lanes:r,flat:i}){let a=e.length-1,o=i?e=>i[e*2]:t=>e[t].start,s=i?e=>i[e*2]+i[e*2+1]:t=>e[t].end;if(e.length<=r)return{startIndex:0,endIndex:a};let c=le(0,a,o,n),l=c;if(r===1)for(;l<a&&s(l)<n+t;)l++;else if(r>1){let i=Array(r).fill(0);for(;l<a&&i.some(e=>e<n+t);){let t=e[l];i[t.lane]=t.end,l++}let o=Array(r).fill(n+t);for(;c>=0&&o.some(e=>e>=n);){let t=e[c];o[t.lane]=t.start,c--}c=Math.max(0,c-c%r),l=Math.min(a,l+(r-1-l%r))}return{startIndex:c,endIndex:l}}var de=typeof document<`u`?N.useLayoutEffect:N.useEffect;function K({useFlushSync:e=!0,...t}){let n=N.useReducer(e=>e+1,0)[1],r={...t,onChange:(r,i)=>{var a;e&&i?(0,P.flushSync)(n):n(),(a=t.onChange)==null||a.call(t,r,i)}},[i]=N.useState(()=>new ce(r));return i.setOptions(r),de(()=>i._didMount(),[]),de(()=>i._willUpdate()),i}function fe(e){return K({observeElementRect:B,observeElementOffset:W,scrollToFn:G,...e})}var q=x(),J=e=>`specrails-desktop:code-tree-filter:${e}`,Y=e=>`specrails-desktop:code-tree-collapsed:${e}`;function X(e){return e.split(`/`).length-1}function pe(e){let t=e.lastIndexOf(`/`);return t>=0?e.slice(t+1):e}function me(e){return e?e.length>10?e.slice(0,10):e:null}function he(e){return e===`created`?`added`:e===`modified`?`changed`:e===`deleted`?`deleted`:null}function ge(e,t){if(t.size===0)return!1;let n=e.split(`/`);for(let e=1;e<n.length;e++)if(t.has(n.slice(0,e).join(`/`)))return!0;return!1}function _e({onOpenFile:e,selectedPath:t,filterJobId:n,filterTicketId:r}){let{t:o}=i(`code`),{activeProjectId:s}=g(),{openTicketDetail:c}=T(),{registerHandler:u,unregisterHandler:f}=ee(),[m,_]=(0,N.useState)(()=>{if(!s)return`touched-by-ai`;try{let e=localStorage.getItem(J(s));if(e===`all`||e===`touched-by-ai`)return e}catch{}return`touched-by-ai`});(0,N.useEffect)(()=>{if(s)try{localStorage.setItem(J(s),m)}catch{}},[m,s]);let[v,y]=(0,N.useState)(()=>{if(!s)return new Set;try{let e=localStorage.getItem(Y(s));if(!e)return new Set;let t=JSON.parse(e);if(Array.isArray(t))return new Set(t.filter(e=>typeof e==`string`))}catch{}return new Set});(0,N.useEffect)(()=>{if(s)try{localStorage.setItem(Y(s),JSON.stringify([...v]))}catch{}},[v,s]);let x=(0,N.useCallback)(e=>{y(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),S=(0,N.useCallback)(()=>{y(new Set)},[]),{data:C,refresh:w,isFirstLoad:D}=h({namespace:`code-tree:${m}:${m===`touched-by-ai`?`${n??`all-jobs`}:${r??`all-specs`}`:`all`}`,projectId:s,initialValue:[],fetcher:(0,N.useCallback)(async()=>{let e=[],t=null;for(let i=0;i<100;i+=1){let i=new URLSearchParams({withProvenance:`1`,filter:m});m===`touched-by-ai`&&n&&i.set(`jobId`,n),m===`touched-by-ai`&&typeof r==`number`&&i.set(`ticketId`,String(r)),t&&i.set(`cursor`,t);let a=await fetch(`${E()}/code/tree?${i.toString()}`);if(!a.ok)break;let o=await a.json().catch(()=>({}));if(Array.isArray(o.entries)&&e.push(...o.entries),!o.nextCursor)break;t=o.nextCursor}return e},[m,n,r])}),O=(0,N.useRef)(s);(0,N.useEffect)(()=>{O.current=s},[s]),(0,N.useEffect)(()=>{if(!s)return;let e=`code-tree-${s}`;return u(e,e=>{let t=e;t.projectId===O.current&&t.type===`file.provenance_updated`&&w()}),()=>f(e)},[s,u,f,w]);let k=(0,N.useRef)(null),te=(0,N.useMemo)(()=>(C??[]).filter(e=>!ge(e.path,v)),[C,v]),M=(0,N.useCallback)(()=>{y(new Set((C??[]).filter(e=>e.kind===`dir`).map(e=>e.path)))},[C]),P=fe({count:te.length,getScrollElement:()=>k.current,estimateSize:()=>28,overscan:12,initialRect:{width:320,height:600},observeElementRect:(e,t)=>{let n=e.scrollElement;if(!n)return()=>{};let r=()=>{let e=n.getBoundingClientRect(),r=e.height||n.clientHeight||600;t({width:e.width||n.clientWidth||320,height:r})};if(r(),typeof ResizeObserver<`u`){let e=new ResizeObserver(r);return e.observe(n),()=>e.disconnect()}return()=>{}}}),F=te.length===0,I=(0,N.useMemo)(()=>(C??[]).filter(e=>e.kind===`file`).length,[C]);return(0,q.jsxs)(`div`,{className:`flex flex-col h-full`,"data-testid":`file-tree`,children:[(0,q.jsxs)(`div`,{className:`px-2 py-2 border-b border-border text-xs space-y-2`,children:[(0,q.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,q.jsx)(`button`,{type:`button`,onClick:()=>_(`touched-by-ai`),className:l(`px-2 py-1 rounded-md transition-colors`,m===`touched-by-ai`?`bg-accent-primary/20 text-accent-primary`:`text-muted-foreground hover:text-foreground hover:bg-muted/50`),"aria-pressed":m===`touched-by-ai`,children:o(n?`tree.jobFiles`:r?`tree.specFiles`:`tree.touchedByAi`)}),(0,q.jsx)(`button`,{type:`button`,onClick:()=>_(`all`),className:l(`px-2 py-1 rounded-md transition-colors`,m===`all`?`bg-accent-primary/20 text-accent-primary`:`text-muted-foreground hover:text-foreground hover:bg-muted/50`),"aria-pressed":m===`all`,children:o(`tree.allFiles`)}),(0,q.jsx)(`div`,{className:`flex-1`}),(0,q.jsx)(`button`,{type:`button`,onClick:M,title:o(`tree.collapseAll`),className:`px-1.5 py-1 rounded-md text-muted-foreground hover:text-foreground hover:bg-muted/50`,"aria-label":o(`tree.collapseAll`),children:(0,q.jsx)(d,{className:`w-3.5 h-3.5`})}),(0,q.jsx)(`button`,{type:`button`,onClick:S,title:o(`tree.expandAll`),className:`px-1.5 py-1 rounded-md text-muted-foreground hover:text-foreground hover:bg-muted/50`,"aria-label":o(`tree.expandAll`),children:(0,q.jsx)(A,{className:`w-3.5 h-3.5`})})]}),m===`touched-by-ai`&&I>0&&(0,q.jsx)(`div`,{className:`flex items-center justify-between gap-2 text-[11px] text-muted-foreground`,children:(0,q.jsx)(`span`,{children:o(`tree.touchedCount`,{count:I})})})]}),F&&D?(0,q.jsx)(`div`,{className:`flex-1 flex items-center justify-center px-4 text-center`,"data-testid":`file-tree-loading`,children:(0,q.jsx)(`p`,{className:`text-xs text-muted-foreground animate-pulse`,children:o(`tree.loadingFiles`)})}):F&&m===`touched-by-ai`?(0,q.jsxs)(`div`,{className:`flex-1 flex flex-col items-center justify-center px-4 text-center gap-3`,children:[(0,q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:o(`tree.emptyTouched`)}),(0,q.jsx)(`button`,{type:`button`,onClick:()=>_(`all`),className:`text-xs px-3 py-1.5 rounded-md bg-accent-primary/20 text-accent-primary hover:bg-accent-primary/30`,children:o(`tree.showAllFiles`)})]}):F?(0,q.jsx)(`div`,{className:`flex-1 flex items-center justify-center text-xs text-muted-foreground px-4 text-center`,children:o(`tree.noFiles`)}):(0,q.jsx)(`div`,{ref:k,className:`flex-1 overflow-auto`,"data-testid":`file-tree-scroller`,children:(0,q.jsx)(`div`,{style:{height:P.getTotalSize(),position:`relative`,width:`100%`},children:P.getVirtualItems().map(n=>{let r=te[n.index],i=X(r.path)*12,s=r.kind===`file`&&r.path===t,u=r.provenance?.createdByTicketId,f=r.provenance?.modifiedByTicketIds??[],m=r.provenance?.latest??null,h=me(m?.jobId),g=he(m?.kind),_=r.kind===`dir`,y=_&&v.has(r.path),S=r.provenance?.touchedFileCount??0;return(0,q.jsxs)(`div`,{style:{position:`absolute`,top:0,left:0,transform:`translateY(${n.start}px)`,height:n.size,width:`100%`},className:l(`flex items-center gap-2 px-2 text-xs cursor-pointer hover:bg-muted/50`,s&&`bg-muted text-foreground`),onClick:()=>{_?x(r.path):e(r.path)},role:`button`,tabIndex:0,"aria-expanded":_?!y:void 0,"data-testid":`file-tree-row-${r.path}`,children:[(0,q.jsxs)(`span`,{style:{paddingLeft:i},className:`flex items-center gap-1 min-w-0 flex-1`,children:[_?(0,q.jsxs)(q.Fragment,{children:[y?(0,q.jsx)(d,{className:`w-3 h-3 text-muted-foreground flex-shrink-0`}):(0,q.jsx)(A,{className:`w-3 h-3 text-muted-foreground flex-shrink-0`}),y?(0,q.jsx)(p,{className:`w-3.5 h-3.5 text-accent-info flex-shrink-0`}):(0,q.jsx)(a,{className:`w-3.5 h-3.5 text-accent-info flex-shrink-0`})]}):(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`span`,{className:`w-3 flex-shrink-0`}),(0,q.jsx)(j,{className:`w-3.5 h-3.5 text-muted-foreground flex-shrink-0`})]}),(0,q.jsx)(`span`,{className:`truncate ml-0.5`,children:pe(r.path)})]}),(0,q.jsxs)(`span`,{className:`flex items-center gap-1 flex-shrink-0`,children:[_&&S>0&&(0,q.jsx)(`span`,{className:`text-[10px] px-1.5 py-0.5 rounded bg-muted/60 text-muted-foreground`,title:o(`tree.folderTouched`,{count:S}),children:S}),!_&&g&&(0,q.jsx)(`span`,{className:l(`text-[10px] px-1.5 py-0.5 rounded`,m?.kind===`created`&&`bg-accent-success/15 text-accent-success`,m?.kind===`modified`&&`bg-accent-info/15 text-accent-info`,m?.kind===`deleted`&&`bg-destructive/15 text-destructive`),title:m?.kind===`created`?o(`tree.latestTitleCreated`):m?.kind===`deleted`?o(`tree.latestTitleDeleted`):o(`tree.latestTitleModified`),children:o(`action.${g}`)}),!_&&h&&(0,q.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-[10px] px-1.5 py-0.5 rounded bg-muted/60 text-muted-foreground font-mono`,title:o(`tree.jobTitle`,{jobId:m?.jobId??``}),children:[(0,q.jsx)(b,{className:`h-3 w-3`}),h]}),!_&&typeof u==`number`&&(0,q.jsxs)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),c(u)},className:`text-[10px] px-1.5 py-0.5 rounded bg-accent-success/20 text-accent-success`,"data-testid":`provenance-chip-created-${u}`,title:o(`tree.createdBySpec`,{id:u}),children:[`#`,u]}),!_&&f.slice(0,2).map(e=>(0,q.jsxs)(`button`,{type:`button`,onClick:t=>{t.stopPropagation(),c(e)},className:`text-[10px] px-1.5 py-0.5 rounded bg-accent-info/15 text-accent-info`,"data-testid":`provenance-chip-modified-${e}`,title:o(`tree.modifiedBySpec`,{id:e}),children:[`#`,e]},e))]})]},r.path)})})})]})}function ve(e){return new Worker(`/assets/editor.worker-Bd9IXS8d.js`,{name:e?.name})}function ye(e){return new Worker(`/assets/json.worker-DzV-CpCQ.js`,{name:e?.name})}function be(e){return new Worker(`/assets/css.worker-Wv5dxAWO.js`,{name:e?.name})}function xe(e){return new Worker(`/assets/html.worker-CQP8QQsS.js`,{name:e?.name})}function Se(e){return new Worker(`/assets/ts.worker-METxwbDZ.js`,{name:e?.name})}var Ce=!1;function we(e){let t=e.trim().match(/^hsl\(\s*([-\d.]+)[\s,]+([\d.]+)%[\s,]+([\d.]+)%\s*\)$/i);return t?[parseFloat(t[1]),parseFloat(t[2]),parseFloat(t[3])]:null}function Z(e,t=`#1e1e1e`){if(e.startsWith(`#`))return e;let n=we(e);if(!n)return t;let[r,i,a]=n,o=i/100,s=a/100,c=(1-Math.abs(2*s-1))*o,l=(r%360+360)%360/60,u=c*(1-Math.abs(l%2-1)),d=0,f=0,p=0;l<1?(d=c,f=u):l<2?(d=u,f=c):l<3?(f=c,p=u):l<4?(f=u,p=c):l<5?(d=u,p=c):(d=c,p=u);let m=s-c/2,h=e=>Math.round((e+m)*255).toString(16).padStart(2,`0`);return`#${h(d)}${h(f)}${h(p)}`}function Te(e){return`specrails-${e}`}function Ee(e,t){let n=Te(t.id),r=t.xterm,i=Z(r.background),a=Z(r.foreground),o=Z(r.brightBlack),s=Z(r.magenta),c=Z(r.yellow),l=Z(r.cyan),u=Z(r.blue),d=Z(r.green),f=Z(r.brightBlack),p=Z(r.brightCyan),m=Z(r.red),h=Z(r.selectionBackground);return e.editor.defineTheme(n,{base:t.scheme===`light`?`vs`:`vs-dark`,inherit:!0,rules:[{token:``,foreground:a.slice(1)},{token:`comment`,foreground:f.slice(1),fontStyle:`italic`},{token:`keyword`,foreground:s.slice(1)},{token:`string`,foreground:c.slice(1)},{token:`number`,foreground:l.slice(1)},{token:`constant`,foreground:p.slice(1)},{token:`constant.numeric`,foreground:l.slice(1)},{token:`type`,foreground:d.slice(1)},{token:`type.identifier`,foreground:d.slice(1)},{token:`identifier`,foreground:a.slice(1)},{token:`function`,foreground:u.slice(1)},{token:`tag`,foreground:m.slice(1)},{token:`attribute.name`,foreground:p.slice(1)},{token:`attribute.value`,foreground:c.slice(1)},{token:`delimiter`,foreground:o.slice(1)},{token:`operator`,foreground:o.slice(1)}],colors:{"editor.background":i,"editor.foreground":a,"editorLineNumber.foreground":o,"editorLineNumber.activeForeground":a,"editorCursor.foreground":Z(r.cursor),"editor.selectionBackground":h,"editor.inactiveSelectionBackground":h,"editor.lineHighlightBackground":Z(r.black),"editor.lineHighlightBorder":Z(r.black),"editorGutter.background":i,"editorWhitespace.foreground":o,"editorIndentGuide.background1":Z(r.black),"editorIndentGuide.activeBackground1":o,"scrollbarSlider.background":`${o}55`,"scrollbarSlider.hoverBackground":`${o}88`,"scrollbarSlider.activeBackground":`${o}bb`,"minimap.background":i}}),n}function De(){Ce||=(self.MonacoEnvironment={getWorker(e,t){switch(t){case`json`:return new ye;case`css`:case`scss`:case`less`:return new be;case`html`:case`handlebars`:case`razor`:return new xe;case`typescript`:case`javascript`:return new Se;default:return new ve}}},!0)}function Oe({content:e,language:n,readOnly:r,onChange:a}){let{t:o}=i(`code`),s=_(),c=(0,N.useRef)(null),l=(0,N.useRef)(null),u=(0,N.useRef)(null),[d,f]=(0,N.useState)(!1),p=(0,N.useRef)(e),m=(0,N.useRef)(n),h=(0,N.useRef)(s),g=(0,N.useRef)(r),v=(0,N.useRef)(a);return(0,N.useEffect)(()=>{p.current=e},[e]),(0,N.useEffect)(()=>{m.current=n},[n]),(0,N.useEffect)(()=>{h.current=s},[s]),(0,N.useEffect)(()=>{g.current=r},[r]),(0,N.useEffect)(()=>{v.current=a},[a]),(0,N.useEffect)(()=>{let e=!1;return De(),t(()=>import(`./editor.main-G3Sl9C67.js`).then(t=>{if(e||!c.current)return;u.current=t;let n=Ee(t,h.current),r=t.editor.create(c.current,{value:p.current,language:m.current,readOnly:g.current,theme:n,minimap:{enabled:!1},lineNumbers:`on`,scrollBeyondLastLine:!1,automaticLayout:!0,fontSize:13});r.onDidChangeModelContent(()=>{v.current?.(r.getValue())}),l.current=r}),__vite__mapDeps([0,1,2,3,4,5,6])).catch(()=>{e||f(!0)}),()=>{e=!0,l.current?.dispose?.(),l.current=null}},[]),(0,N.useEffect)(()=>{let t=l.current;t&&t.getValue?.()!==e&&t.setValue?.(e)},[e]),(0,N.useEffect)(()=>{l.current?.updateOptions?.({readOnly:r})},[r]),(0,N.useEffect)(()=>{let e=u.current,t=l.current;if(!e||!t)return;let r=t.getModel?.();r&&e.editor.setModelLanguage(r,n)},[n]),(0,N.useEffect)(()=>{let e=u.current;if(!e)return;let t=Ee(e,s);e.editor.setTheme(t)},[s]),d?(0,q.jsxs)(`div`,{className:`w-full h-full flex flex-col items-center justify-center gap-2 text-sm text-muted-foreground`,"data-testid":`monaco-load-error`,children:[(0,q.jsx)(`span`,{children:o(`monaco.loadFailed`)}),(0,q.jsx)(`button`,{type:`button`,onClick:()=>window.location.reload(),className:`rounded-md bg-accent-primary/15 px-3 py-1 text-xs text-accent-primary hover:bg-accent-primary/25`,children:o(`monaco.reload`)})]}):(0,q.jsx)(`div`,{ref:c,className:`w-full h-full`,"data-testid":`monaco-host`})}var ke=(0,N.lazy)(async()=>({default:Oe}));function Ae({content:e,language:t,readOnly:n=!0,onChange:r}){let{t:a}=i(`code`);return(0,q.jsx)(N.Suspense,{fallback:(0,q.jsx)(`div`,{className:`w-full h-full flex items-center justify-center text-sm text-muted-foreground animate-pulse`,children:a(`monaco.loadingEditor`)}),children:(0,q.jsx)(ke,{content:e,language:t,readOnly:n,onChange:r})})}function je(e,t){if(!e)return null;let n=Date.parse(e);if(Number.isNaN(n))return null;let r=Math.round((n-Date.now())/1e3),i=new Intl.RelativeTimeFormat(t,{numeric:`auto`}),a=Math.abs(r);return a<60?i.format(r,`second`):a<3600?i.format(Math.round(r/60),`minute`):a<86400?i.format(Math.round(r/3600),`hour`):i.format(Math.round(r/86400),`day`)}function Me({path:e,summary:t,stale:n,regenerating:r,generateDisabledReason:a,onCollapse:o}){let{t:s,i18n:c}=i(`code`),{openTicketDetail:d}=T();if(!t)return(0,q.jsx)(`div`,{className:`border-b border-border px-4 py-3 bg-surface`,"data-testid":`summary-header-empty`,children:(0,q.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,q.jsxs)(`div`,{className:`flex flex-col gap-0.5 min-w-0`,children:[(0,q.jsx)(`span`,{className:`text-xs text-muted-foreground truncate`,children:e}),(0,q.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:a?s(`summary.unavailable`,{reason:a}):s(`summary.empty`)})]}),o&&(0,q.jsxs)(`button`,{type:`button`,onClick:o,className:`inline-flex items-center gap-1 rounded-md px-2 py-1 text-[11px] text-muted-foreground hover:bg-muted/50 hover:text-foreground`,children:[(0,q.jsx)(u,{className:`h-3.5 w-3.5`}),s(`summary.hide`)]})]})});let f=je(t.generatedAt,c.language),p=t.triggeredBy?.ticketId,m=t.triggeredBy?.modifiedTicketIds??[];return(0,q.jsx)(`div`,{className:`border-b border-border px-4 py-3 bg-surface`,"data-testid":`summary-header`,children:(0,q.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,q.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,q.jsx)(`span`,{className:`text-xs text-muted-foreground truncate`,children:e}),n&&(0,q.jsx)(`span`,{className:l(`text-[10px] px-1.5 py-0.5 rounded bg-accent-warning/20 text-accent-warning font-medium`),"data-testid":`summary-stale-badge`,children:s(`summary.stale`)}),r&&(0,q.jsx)(`span`,{className:`w-1.5 h-1.5 rounded-full bg-accent-primary animate-pulse`,"aria-hidden":!0})]}),(0,q.jsx)(`p`,{className:`text-sm text-foreground mt-1`,children:t.summary}),(0,q.jsxs)(`div`,{className:`flex items-center gap-2 mt-2 flex-wrap`,children:[typeof p==`number`&&(0,q.jsxs)(`button`,{type:`button`,onClick:()=>d(p),className:`text-[10px] px-1.5 py-0.5 rounded bg-accent-success/20 text-accent-success`,children:[`#`,p]}),m.map(e=>(0,q.jsxs)(`button`,{type:`button`,onClick:()=>d(e),className:`text-[10px] px-1.5 py-0.5 rounded bg-accent-info/15 text-accent-info`,children:[`#`,e]},e)),f&&(0,q.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:f})]})]}),o&&(0,q.jsxs)(`button`,{type:`button`,onClick:o,className:`inline-flex items-center gap-1 rounded-md px-2 py-1 text-[11px] text-muted-foreground hover:bg-muted/50 hover:text-foreground`,children:[(0,q.jsx)(u,{className:`h-3.5 w-3.5`}),s(`summary.hide`)]})]})})}function Ne({content:e}){return(0,q.jsx)(k,{remarkPlugins:[y],children:e})}function Pe(e,t){return t===`markdown`||t===`md`?!0:/\.(md|mdx|markdown)$/i.test(e)}var Q=180,Fe=120,Ie=240;function Le(e){return e?`specrails-desktop:code-summary-collapsed:${e}`:null}function Re(e){return e?`specrails-desktop:code-history-height:${e}`:null}function ze(e){return e?`specrails-desktop:code-history-collapsed:${e}`:null}function Be(e){let t=Re(e);if(!t)return Q;try{let e=localStorage.getItem(t),n=e?Number(e):NaN;return Number.isFinite(n)&&n>0?n:Q}catch{return Q}}function Ve(e,t){let n=Re(e);if(n)try{localStorage.setItem(n,String(Math.round(t)))}catch{}}function He(e){let t=Le(e);if(!t)return!1;try{return localStorage.getItem(t)===`true`}catch{return!1}}function Ue(e,t){let n=Le(e);if(n)try{localStorage.setItem(n,t?`true`:`false`)}catch{}}function We(e){let t=ze(e);if(!t)return!1;try{return localStorage.getItem(t)===`true`}catch{return!1}}function Ge(e,t){let n=ze(e);if(n)try{localStorage.setItem(n,t?`true`:`false`)}catch{}}function Ke(e,t){let n=Math.max(Fe,t-Ie);return Math.min(Math.max(e,Fe),n)}function qe({relPath:e,onFilterJob:t,onSummaryActionChange:n,onCopyPathActionChange:a}){let{t:o}=i(`code`),{activeProjectId:s}=g(),{openTicketDetail:c}=T(),{registerHandler:l,unregisterHandler:d}=ee(),p=r({allowMove:!1}),m=(0,N.useRef)(null),[h,_]=(0,N.useState)(null),[v,y]=(0,N.useState)(!0),[b,x]=(0,N.useState)(!1),[S,C]=(0,N.useState)(!1),[w,D]=(0,N.useState)(()=>He(s)),[O,k]=(0,N.useState)(()=>Be(s)),[j,M]=(0,N.useState)(()=>We(s)),P=(0,N.useRef)(s);(0,N.useEffect)(()=>{P.current=s},[s]);let F=(0,N.useRef)(e);(0,N.useEffect)(()=>{F.current=e},[e]),(0,N.useEffect)(()=>{let e=m.current?.clientHeight||window.innerHeight;D(He(s)),k(Ke(Be(s),e)),M(We(s))},[s]);let I=(0,N.useCallback)(e=>{let t=e.clientY,n=O,r=m.current?.clientHeight||window.innerHeight,i=e.currentTarget;try{i.setPointerCapture(e.pointerId)}catch{}function a(e){k(Ke(n+(t-e.clientY),r))}function o(){window.removeEventListener(`pointermove`,a),window.removeEventListener(`pointerup`,o),window.removeEventListener(`pointercancel`,o),k(e=>{let t=Ke(e,r);return Ve(s,t),t})}window.addEventListener(`pointermove`,a),window.addEventListener(`pointerup`,o),window.addEventListener(`pointercancel`,o)},[s,O]),ne=(0,N.useCallback)(()=>{let e=Ke(Q,m.current?.clientHeight||window.innerHeight);k(e),Ve(s,e)},[s]),re=(0,N.useCallback)(()=>{D(e=>{let t=!e;return Ue(s,t),t})},[s]),ie=(0,N.useCallback)(()=>{M(e=>{let t=!e;return Ge(s,t),t})},[s]);(0,N.useEffect)(()=>{x(!1),C(!1),V(`preview`),U(!1)},[e]);let L=(0,N.useRef)(0),R=(0,N.useCallback)(async()=>{let t=++L.current;y(!0);try{let n=await fetch(`${E()}/code/file?path=${encodeURIComponent(e)}`);if(t!==L.current)return;if(!n.ok){_(null);return}let r=await n.json();if(t!==L.current)return;_(r)}catch{t===L.current&&_(null)}finally{t===L.current&&y(!1)}},[e,s]);(0,N.useEffect)(()=>{R()},[R]),(0,N.useEffect)(()=>{if(!s)return;let e=`code-file-${s}`;return l(e,e=>{let t=e;t.projectId===P.current&&(t.type===`file.summary_updated`&&t.path===F.current?(x(!1),R()):t.type===`file.summary_failed`&&t.path===F.current?(f.error(t.reason??o(`summary.generationFailed`)),x(!1)):t.type===`file.summary_skipped`&&t.path===F.current&&(t.reason&&f(o(`summary.skipped`,{reason:t.reason})),x(!1)))}),()=>d(e)},[s,l,d,R,o]);let z=(0,N.useCallback)(async t=>{x(!0);try{let n=await fetch(`${E()}/code/file/regenerate-summary?path=${encodeURIComponent(e)}`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({overrideBudget:t})}),r=await n.json().catch(()=>({}));if(!n.ok){x(!1);let e=typeof r.skipped==`string`?r.skipped:null;f.error(e?o(`summary.skipped`,{reason:e}):o(`summary.generationFailed`));return}if(r.skipped===`budget`){x(!1),C(!0);return}if(r.skipped){x(!1),f(o(`summary.skipped`,{reason:r.skipped}));return}await R(),x(!1)}catch{x(!1),f.error(o(`summary.generationFailed`))}},[R,e,o]),ae=(0,N.useCallback)(async()=>{let t=h?.absolutePath??e;try{await navigator.clipboard?.writeText(t),f.success(o(`viewer.pathCopied`))}catch{f.error(o(`viewer.copyPathFailed`))}},[h,e,o]),oe=(0,N.useMemo)(()=>Pe(e,h?.language),[e,h?.language]),[B,V]=(0,N.useState)(`preview`),[H,U]=(0,N.useState)(!1),[W,se]=(0,N.useState)(``),[G,ce]=(0,N.useState)(!1),le=h?.content!==void 0&&!h.binary&&!h.tooLarge&&h.reason!==`not-found`,ue=(0,N.useCallback)(()=>{se(h?.content??``),V(`raw`),U(!0)},[h]),de=(0,N.useCallback)(async()=>{ce(!0);try{let t=await fetch(`${E()}/code/file`,{method:`PUT`,headers:{"content-type":`application/json`},body:JSON.stringify({path:e,content:W})});if(!t.ok){let e=await t.json().catch(()=>({}));f.error(e.error??o(`viewer.saveFailed`));return}f.success(o(`viewer.saved`)),U(!1),R()}catch{f.error(o(`viewer.saveFailed`))}finally{ce(!1)}},[e,W,o,R]),K=h?.summary??null,fe=!!h?.summaryStale,J=h?.provenance??[],Y=h?.reason===`not-found`,X=Y?o(`summary.reason.missing`):h?.binary?o(`summary.reason.binary`):h?.tooLarge?o(`summary.reason.tooLarge`):null;return(0,N.useEffect)(()=>{if(n){if(v&&!h){n(null);return}return n({hasSummary:!!K,regenerating:b,disabledReason:X,onClick:()=>z(!1)}),()=>n(null)}},[h,z,v,n,b,K,X]),(0,N.useEffect)(()=>{if(a){if(v&&!h){a(null);return}return a({onClick:ae}),()=>a(null)}},[ae,h,v,a]),v&&!h?(0,q.jsx)(`div`,{className:`flex-1 flex items-center justify-center text-sm text-muted-foreground animate-pulse`,children:o(`viewer.loadingFile`)}):(0,q.jsxs)(`div`,{ref:m,className:`flex flex-col h-full`,"data-testid":`file-viewer`,children:[w?(0,q.jsxs)(`div`,{className:`flex h-8 shrink-0 items-center justify-between border-b border-border bg-surface px-4`,"data-testid":`summary-header-collapsed`,children:[(0,q.jsx)(`span`,{className:`truncate text-xs text-muted-foreground`,children:e}),(0,q.jsxs)(`button`,{type:`button`,onClick:re,className:`inline-flex items-center gap-1 rounded-md px-2 py-1 text-[11px] text-muted-foreground hover:bg-muted/50 hover:text-foreground`,children:[(0,q.jsx)(A,{className:`h-3.5 w-3.5`}),o(`viewer.showSummary`)]})]}):(0,q.jsx)(Me,{path:e,summary:K,stale:fe,regenerating:b,generateDisabledReason:X,onCollapse:re}),(0,q.jsxs)(`div`,{className:`px-4 py-1 border-b border-border flex items-center justify-between gap-3`,children:[(0,q.jsx)(`div`,{className:`flex items-center gap-2 min-w-0`,children:oe&&h?.content!==void 0&&!h.binary&&!h.tooLarge&&(0,q.jsxs)(`div`,{className:`flex items-center gap-1 text-[11px]`,role:`group`,"aria-label":o(`viewer.markdownViewMode`),children:[(0,q.jsx)(`button`,{type:`button`,onClick:()=>V(`preview`),"aria-pressed":B===`preview`,className:B===`preview`?`px-2 py-1 rounded-md bg-accent-primary/20 text-accent-primary`:`px-2 py-1 rounded-md text-muted-foreground hover:text-foreground hover:bg-muted/50`,children:o(`viewer.preview`)}),(0,q.jsx)(`button`,{type:`button`,onClick:()=>V(`raw`),"aria-pressed":B===`raw`,className:B===`raw`?`px-2 py-1 rounded-md bg-accent-primary/20 text-accent-primary`:`px-2 py-1 rounded-md text-muted-foreground hover:text-foreground hover:bg-muted/50`,children:o(`viewer.raw`)})]})}),(0,q.jsxs)(`div`,{className:`flex items-center gap-1 text-[11px] shrink-0`,children:[le&&!H&&(0,q.jsx)(`button`,{type:`button`,onClick:ue,className:`px-2 py-1 rounded-md text-muted-foreground hover:text-foreground hover:bg-muted/50`,children:o(`viewer.edit`)}),H&&(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`button`,{type:`button`,onClick:()=>U(!1),disabled:G,className:`px-2 py-1 rounded-md text-muted-foreground hover:text-foreground hover:bg-muted/50 disabled:opacity-50`,children:o(`actions.cancel`,{ns:`common`})}),(0,q.jsx)(`button`,{type:`button`,onClick:de,disabled:G,className:`px-2 py-1 rounded-md bg-accent-primary/20 text-accent-primary hover:bg-accent-primary/30 disabled:opacity-50`,children:o(G?`viewer.saving`:`viewer.save`)})]})]})]}),(0,q.jsx)(`div`,{className:`flex-1 overflow-hidden`,children:Y?(0,q.jsx)(`div`,{className:`h-full flex items-center justify-center text-sm text-muted-foreground`,"data-testid":`file-missing`,children:o(`viewer.missingFile`)}):h?.binary?(0,q.jsx)(`div`,{className:`h-full flex items-center justify-center text-sm text-muted-foreground`,"data-testid":`file-binary`,children:o(`viewer.binaryFile`)}):h?.tooLarge?(0,q.jsx)(`div`,{className:`h-full flex items-center justify-center text-sm text-muted-foreground`,"data-testid":`file-too-large`,children:o(`viewer.tooLarge`,{size:Math.round((h.sizeBytes??0)/1024/1024)})}):h?.content===void 0?(0,q.jsx)(`div`,{className:`h-full flex items-center justify-center text-sm text-muted-foreground`,children:o(`viewer.noContent`)}):H?(0,q.jsx)(Ae,{content:W,language:h.language??`plaintext`,readOnly:!1,onChange:se}):oe&&B===`preview`?(0,q.jsx)(`div`,{className:`h-full overflow-auto px-6 py-4 prose prose-invert prose-sm max-w-none prose-p:my-2 prose-headings:mt-4 prose-headings:mb-2 prose-pre:bg-muted/40 prose-pre:rounded-md prose-code:before:content-none prose-code:after:content-none`,"data-testid":`markdown-preview`,children:(0,q.jsx)(Ne,{content:h.content})}):(0,q.jsx)(Ae,{content:h.content,language:h.language??`plaintext`})}),J.length>0&&(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(`div`,{role:`separator`,"aria-orientation":`horizontal`,"aria-label":o(`history.resize`),onPointerDown:j?void 0:I,onDoubleClick:j?void 0:ne,className:j?`flex h-8 shrink-0 items-center justify-between border-t border-border bg-card/35 px-4`:`flex h-8 shrink-0 cursor-row-resize items-center justify-between border-y border-border/40 bg-card/35 px-4 hover:bg-accent-primary/10`,title:j?void 0:o(`resizer.hint`),"data-testid":`code-history-resizer`,children:[(0,q.jsx)(`span`,{className:`text-[11px] font-medium uppercase tracking-wider text-muted-foreground`,children:o(`history.title`,{count:J.length})}),(0,q.jsxs)(`button`,{type:`button`,onPointerDown:e=>e.stopPropagation(),onClick:ie,className:`inline-flex items-center gap-1 rounded-md px-2 py-1 text-[11px] text-muted-foreground hover:bg-muted/50 hover:text-foreground`,children:[j?(0,q.jsx)(u,{className:`h-3.5 w-3.5`}):(0,q.jsx)(A,{className:`h-3.5 w-3.5`}),o(j?`history.show`:`history.hide`)]})]}),!j&&(0,q.jsx)(Je,{rows:J,onOpenTicket:c,onFilterJob:t,height:O})]}),S&&(0,q.jsxs)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/50`,role:`dialog`,"aria-modal":`true`,"data-testid":`budget-prompt`,onClick:p.guardBackdrop(()=>C(!1)),children:[(0,q.jsxs)(`div`,{ref:p.panelRef,onClick:e=>e.stopPropagation(),className:`bg-card border border-border rounded-lg p-4 w-80 flex flex-col gap-3`,style:p.panelStyle,children:[(0,q.jsx)(`p`,{className:`text-sm text-foreground`,children:o(`viewer.budgetPrompt`)}),(0,q.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,q.jsx)(`button`,{type:`button`,onClick:()=>C(!1),className:`text-xs px-3 py-1.5 rounded-md text-muted-foreground hover:text-foreground`,children:o(`common:actions.cancel`)}),(0,q.jsx)(`button`,{type:`button`,onClick:()=>{C(!1),z(!0)},className:`text-xs px-3 py-1.5 rounded-md bg-accent-primary text-white`,children:o(`common:actions.confirm`)})]})]}),(0,q.jsx)(te,{handles:p.resizeHandles})]})]})}function Je({rows:e,onOpenTicket:t,onFilterJob:n,height:r}){let{t:a}=i(`code`),[o,l]=(0,N.useState)(null),[u,d]=(0,N.useState)({});if(e.length===0)return null;async function f(e,t){if(o===t){l(null);return}if(l(t),!(!e.jobId||u[t])){d(e=>({...e,[t]:`loading`}));try{let n=new URLSearchParams({jobId:e.jobId,path:e.path}),r=await fetch(`${E()}/code/diff?${n.toString()}`);if(r.status===404){d(e=>({...e,[t]:`missing`}));return}if(!r.ok)throw Error(`diff failed`);let i=await r.json();d(e=>({...e,[t]:{patch:i.patch??``,truncated:i.truncated===!0}}))}catch{d(e=>({...e,[t]:`missing`}))}}}return(0,q.jsx)(`div`,{className:`shrink-0 border-t border-border bg-card/40 px-4 py-3 overflow-hidden`,style:{height:r},"data-testid":`file-provenance-timeline`,children:(0,q.jsx)(`div`,{className:`h-full overflow-auto space-y-1`,children:e.map((e,r)=>{let i=e.kind===`created`?c:e.kind===`deleted`?s:m,l=e.jobId?e.jobId.length>12?e.jobId.slice(0,12):e.jobId:a(`history.unknownJob`),d=`${e.jobId??`job`}:${e.path}:${e.at}:${r}`,p=u[d];return(0,q.jsxs)(`div`,{className:`rounded-md hover:bg-muted/40`,children:[(0,q.jsxs)(`div`,{className:`grid grid-cols-[minmax(72px,auto)_minmax(0,1fr)_auto] items-center gap-2 text-xs px-2 py-1.5`,children:[(0,q.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 min-w-0`,children:[(0,q.jsx)(i,{className:`h-3.5 w-3.5 text-muted-foreground shrink-0`}),(0,q.jsx)(`span`,{className:`capitalize`,children:a(`kind.${e.kind}`)})]}),(0,q.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 min-w-0 text-muted-foreground`,children:[(0,q.jsx)(b,{className:`h-3.5 w-3.5 shrink-0`}),e.jobId&&n?(0,q.jsx)(`button`,{type:`button`,onClick:()=>n(e.jobId),className:`font-mono truncate hover:text-foreground`,title:a(`history.filterByJob`,{jobId:e.jobId}),children:l}):(0,q.jsx)(`span`,{className:`font-mono truncate`,title:e.jobId??void 0,children:l}),e.jobId&&(0,q.jsx)(`button`,{type:`button`,onClick:()=>f(e,d),className:`shrink-0 rounded bg-muted/60 px-1.5 py-0.5 text-[10px] text-muted-foreground hover:bg-muted hover:text-foreground`,children:a(`history.diff`)}),typeof e.ticketId==`number`&&(0,q.jsx)(`button`,{type:`button`,onClick:()=>t(e.ticketId),className:`shrink-0 rounded bg-accent-primary/15 px-1.5 py-0.5 text-[10px] text-accent-primary hover:bg-accent-primary/25`,title:a(`history.openSpec`,{ticketId:e.ticketId}),children:a(`history.specChip`,{ticketId:e.ticketId})})]}),(0,q.jsx)(`time`,{className:`text-[11px] text-muted-foreground`,dateTime:new Date(e.at).toISOString(),children:new Date(e.at).toLocaleString()})]}),o===d&&(0,q.jsx)(`div`,{className:`px-2 pb-2`,children:p===`loading`?(0,q.jsx)(`div`,{className:`rounded-md bg-muted/35 px-2 py-2 text-[11px] text-muted-foreground`,children:a(`history.loadingDiff`)}):p===`missing`||!p?(0,q.jsx)(`div`,{className:`rounded-md bg-muted/35 px-2 py-2 text-[11px] text-muted-foreground`,children:a(`history.diffUnavailable`)}):(0,q.jsxs)(`pre`,{className:`max-h-72 overflow-auto rounded-md bg-muted/50 px-2 py-2 font-mono text-[11px] leading-relaxed text-foreground/85`,children:[p.patch,p.truncated?`\n${a(`history.diffTruncated`)}`:``]})})]},d)})})})}var Ye=320,Xe=240,Ze=520;function Qe(e){return e?`specrails-desktop:code-tree-width:${e}`:null}function $e(e){let t=Qe(e);if(!t)return Ye;try{let e=localStorage.getItem(t),n=e?Number(e):NaN;return Number.isFinite(n)&&n>0?n:Ye}catch{return Ye}}function et(e,t){let n=Qe(e);if(n)try{localStorage.setItem(n,String(Math.round(t)))}catch{}}function $(e,t){let n=Math.max(Xe,t-Ze);return Math.min(Math.max(e,Xe),n)}function tt(){let{t:e}=i(`code`),{activeProjectId:t}=g(),[n]=C(),r=o(),a=(0,N.useRef)(null),[s,c]=(0,N.useState)(n.get(`path`)),[l,u]=(0,N.useState)(null),[d,f]=(0,N.useState)(null),[p,m]=(0,N.useState)(()=>$e(t)),h=n.get(`jobId`),_=(0,N.useMemo)(()=>{let e=n.get(`ticketId`);if(!e)return null;let t=Number(e);return Number.isInteger(t)&&t>0?t:null},[n]),[v,y]=(0,N.useState)(_==null?``:String(_));(0,N.useEffect)(()=>{let e=n.get(`path`);e!==s&&c(e)},[n]),(0,N.useEffect)(()=>{y(_==null?``:String(_))},[_]),(0,N.useEffect)(()=>{let e=a.current?.clientWidth||window.innerWidth;m($($e(t),e))},[t]),(0,N.useEffect)(()=>{let e=a.current;if(!e||typeof ResizeObserver>`u`)return;let t=new ResizeObserver(e=>{let t=e[0]?.contentRect.width;typeof t==`number`&&m(e=>$(e,t))});return t.observe(e),()=>t.disconnect()},[]);let b=(0,N.useCallback)(e=>{let n=e.clientX,r=p,i=a.current?.clientWidth||window.innerWidth,o=e.currentTarget;try{o.setPointerCapture(e.pointerId)}catch{}function s(e){m($(r+(e.clientX-n),i))}function c(){window.removeEventListener(`pointermove`,s),window.removeEventListener(`pointerup`,c),window.removeEventListener(`pointercancel`,c),m(e=>{let n=$(e,i);return et(t,n),n})}window.addEventListener(`pointermove`,s),window.addEventListener(`pointerup`,c),window.addEventListener(`pointercancel`,c)},[t,p]),x=(0,N.useCallback)(()=>{let e=$(Ye,a.current?.clientWidth||window.innerWidth);m(e),et(t,e)},[t]),S=(0,N.useCallback)(e=>{c(e);let t=new URLSearchParams(n);t.set(`path`,e),r({pathname:`/code`,search:`?${t.toString()}`},{replace:!0})},[r,n]),w=(0,N.useCallback)(e=>{let t=new URLSearchParams(n);t.set(`jobId`,e),t.delete(`ticketId`),r({pathname:`/code`,search:`?${t.toString()}`},{replace:!0})},[r,n]),T=(0,N.useCallback)(()=>{let e=new URLSearchParams(n);e.delete(`jobId`),e.delete(`ticketId`),r({pathname:`/code`,search:e.toString()?`?${e.toString()}`:``},{replace:!0})},[r,n]),E=(0,N.useCallback)(e=>{let t=Number(e.trim());if(!Number.isInteger(t)||t<=0){T();return}let i=new URLSearchParams(n);i.set(`ticketId`,String(t)),i.delete(`jobId`),r({pathname:`/code`,search:`?${i.toString()}`},{replace:!0})},[T,r,n]);return(0,q.jsxs)(`div`,{ref:a,className:`flex h-full w-full`,"data-testid":`code-page`,children:[(0,q.jsx)(`aside`,{className:`overflow-hidden flex flex-col shrink-0`,style:{width:p},children:(0,q.jsx)(_e,{onOpenFile:S,selectedPath:s,filterJobId:h,filterTicketId:_},t??`no-project`)}),(0,q.jsx)(`div`,{role:`separator`,"aria-orientation":`vertical`,"aria-label":e(`page.resizeFileTree`),onPointerDown:b,onDoubleClick:x,className:`relative w-1.5 shrink-0 cursor-col-resize select-none touch-none border-x border-border/40 hover:bg-accent-primary/20 focus-visible:outline-none focus-visible:bg-accent-primary/30`,title:e(`resizer.hint`),"data-testid":`code-tree-resizer`}),(0,q.jsxs)(`main`,{className:`flex-1 overflow-hidden flex flex-col`,children:[(0,q.jsx)(nt,{jobId:h,ticketId:_,ticketInput:v,onTicketInputChange:y,onApplyTicket:E,onClear:T,summaryAction:l,copyPathAction:d}),(h||_)&&(0,q.jsx)(rt,{jobId:h,ticketId:_,onOpenFile:S}),s?(0,q.jsx)(qe,{relPath:s,onFilterJob:w,onSummaryActionChange:u,onCopyPathActionChange:f}):(0,q.jsx)(`div`,{className:`h-full flex items-center justify-center text-sm text-muted-foreground`,children:e(`page.selectFile`)})]})]})}function nt({jobId:e,ticketId:t,ticketInput:n,onTicketInputChange:r,onApplyTicket:a,onClear:o,summaryAction:s,copyPathAction:c}){let{t:l}=i(`code`),u=t?`spec`:e?`job-context`:`all`;return(0,q.jsx)(`div`,{className:`border-b border-border bg-background/80 px-4 py-2`,"data-testid":`code-provenance-toolbar`,children:(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,q.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-xs font-medium text-muted-foreground`,children:[(0,q.jsx)(M,{className:`h-3.5 w-3.5`}),l(`toolbar.scope`)]}),(0,q.jsx)(`button`,{type:`button`,onClick:o,"aria-pressed":u===`all`,className:u===`all`?`rounded-md bg-accent-primary/20 px-2 py-1 text-xs text-accent-primary`:`rounded-md px-2 py-1 text-xs text-muted-foreground hover:bg-muted/50 hover:text-foreground`,children:l(`toolbar.allAi`)}),(0,q.jsxs)(`div`,{className:`flex items-center gap-1 rounded-md border border-border/70 bg-card/40 px-1 py-1`,children:[(0,q.jsx)(`button`,{type:`button`,onClick:()=>a(n),"aria-pressed":u===`spec`,className:u===`spec`?`rounded bg-accent-success/20 px-2 py-0.5 text-xs text-accent-success`:`rounded px-2 py-0.5 text-xs text-muted-foreground hover:bg-muted/50 hover:text-foreground`,children:l(`toolbar.spec`)}),(0,q.jsx)(`input`,{value:n,onChange:e=>r(e.target.value),onKeyDown:e=>{e.key===`Enter`&&a(n)},placeholder:l(`toolbar.ticketIdPlaceholder`),inputMode:`numeric`,className:`h-6 w-20 bg-transparent px-1 font-mono text-xs outline-none placeholder:text-muted-foreground/60`})]}),(0,q.jsx)(`div`,{className:`flex-1`}),c&&(0,q.jsx)(`button`,{type:`button`,onClick:c.onClick,className:`inline-flex items-center gap-1.5 rounded-md px-2.5 py-1 text-xs text-muted-foreground hover:bg-muted/50 hover:text-foreground`,children:l(`toolbar.copyFilePath`)}),s&&(0,q.jsxs)(`button`,{type:`button`,onClick:s.onClick,disabled:s.regenerating||!!s.disabledReason,"aria-label":s.hasSummary?l(`toolbar.regenerateSummary`):l(`toolbar.generateSummary`),className:`inline-flex items-center gap-1.5 rounded-md bg-accent-primary/15 px-2.5 py-1 text-xs text-accent-primary hover:bg-accent-primary/25 disabled:opacity-50`,title:s.disabledReason?l(`toolbar.summaryUnavailable`,{reason:s.disabledReason}):void 0,children:[(0,q.jsx)(v,{className:s.regenerating?`h-3.5 w-3.5 animate-spin`:`h-3.5 w-3.5`}),s.hasSummary?s.regenerating?l(`toolbar.regenerating`):l(`toolbar.regenerateSummary`):s.regenerating?l(`toolbar.generating`):l(`toolbar.generateSummary`)]}),u===`job-context`&&(0,q.jsx)(`span`,{className:`rounded-md bg-accent-info/15 px-2 py-1 text-xs text-accent-info`,children:l(`toolbar.jobContext`)}),(e||t)&&(0,q.jsxs)(`button`,{type:`button`,onClick:o,className:`inline-flex items-center gap-1 rounded-md px-2 py-1 text-xs text-muted-foreground hover:bg-muted/50 hover:text-foreground`,children:[(0,q.jsx)(D,{className:`h-3.5 w-3.5`}),l(`toolbar.clear`)]})]})})}function rt({jobId:e,ticketId:t,onOpenFile:n}){let{t:r}=i(`code`),[a,o]=(0,N.useState)(null);(0,N.useEffect)(()=>{let n=!1,r=new URLSearchParams;return e&&r.set(`jobId`,e),t&&r.set(`ticketId`,String(t)),fetch(`${E()}/code/provenance?${r.toString()}`).then(e=>e.ok?e.json():[]).then(e=>{n||o(Array.isArray(e)?e:[])}).catch(()=>{n||o([])}),()=>{n=!0}},[e,t]);let s=(0,N.useMemo)(()=>{let e=a??[];return{created:e.filter(e=>e.kind===`created`),modified:e.filter(e=>e.kind===`modified`),deleted:e.filter(e=>e.kind===`deleted`)}},[a]),c=a?.length??0;return(0,q.jsx)(`section`,{className:`border-b border-border bg-card/35 px-4 py-3`,"data-testid":`provenance-result-panel`,children:(0,q.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,q.jsxs)(`div`,{className:`min-w-0`,children:[(0,q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,q.jsx)(`h2`,{className:`text-sm font-semibold truncate`,children:e?r(`provenancePanel.jobTitle`,{jobId:e}):r(`provenancePanel.specTitle`,{ticketId:t})}),(0,q.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,children:r(`provenancePanel.touchedFiles`,{count:c})})]}),(0,q.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-2`,children:[(0,q.jsx)(it,{label:r(`action.added`),rows:s.created,icon:`created`,onOpenFile:n}),(0,q.jsx)(it,{label:r(`action.changed`),rows:s.modified,icon:`modified`,onOpenFile:n}),(0,q.jsx)(it,{label:r(`action.deleted`),rows:s.deleted,icon:`deleted`,onOpenFile:n})]})]}),(0,q.jsx)(`div`,{className:`flex items-center gap-1 shrink-0`,children:e&&(0,q.jsxs)(`a`,{href:`/jobs/${encodeURIComponent(e)}`,className:`inline-flex items-center gap-1 rounded-md px-2 py-1 text-xs text-muted-foreground hover:bg-muted/50 hover:text-foreground`,children:[(0,q.jsx)(w,{className:`h-3.5 w-3.5`}),r(`provenancePanel.log`)]})})]})})}function it({label:e,rows:t,icon:n,onOpenFile:r}){return(0,q.jsxs)(`details`,{className:`group min-w-[180px] max-w-[320px]`,children:[(0,q.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center gap-1.5 rounded-md bg-muted/35 px-2 py-1 text-xs hover:bg-muted/55`,children:[(0,q.jsx)(n===`created`?c:n===`deleted`?s:m,{className:`h-3.5 w-3.5 text-muted-foreground`}),(0,q.jsx)(`span`,{children:e}),(0,q.jsx)(`span`,{className:`text-muted-foreground`,children:t.length})]}),t.length>0&&(0,q.jsx)(`div`,{className:`mt-1 max-h-28 overflow-auto rounded-md border border-border/60 bg-background/60 p-1`,children:t.map((e,t)=>(0,q.jsx)(`button`,{type:`button`,onClick:()=>r(e.path),className:`block w-full truncate rounded px-1.5 py-1 text-left font-mono text-[11px] text-muted-foreground hover:bg-muted/50 hover:text-foreground`,title:e.path,children:e.path},`${e.path}-${e.jobId??`job`}-${e.at}-${t}`))})]})}export{tt as default};
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import{a as e}from"./chunk-BNv3lrIs.js";import{Cn as t,F as n,G as r,N as i,P as a,R as o,Rt as s,Tt as c,Vt as l,b as u,cn as d,jn as f,mt as p,x as m}from"./index-B7vB20Jw.js";import{t as h}from"./lib-PQoHlR5u.js";import{t as g}from"./atom-one-dark-BrRN8wBy.js";var _=e(f(),1),v=d();function y({categories:e,activeCategory:n,activeSlug:i,onSelect:a,onHome:o}){let{t:s}=t(`integrations`);return(0,v.jsxs)(`nav`,{className:`w-56 flex-shrink-0 border-r border-border overflow-y-auto py-4 px-3`,children:[(0,v.jsxs)(`button`,{onClick:o,className:`flex items-center gap-2 mb-4 px-2 text-xs font-bold text-muted-foreground hover:text-foreground transition-colors`,children:[(0,v.jsx)(l,{className:`w-3.5 h-3.5`}),s(`docs.title`)]}),(0,v.jsx)(`div`,{className:`space-y-4`,children:e.map(e=>(0,v.jsxs)(`div`,{children:[(0,v.jsxs)(`div`,{className:`px-2 mb-1 flex items-center justify-between`,children:[(0,v.jsx)(`span`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wider`,children:e.name}),e.docs.length>0&&(0,v.jsx)(`span`,{className:`text-[9px] font-medium text-muted-foreground/60 bg-muted/40 rounded px-1 py-0.5 leading-none`,children:e.docs.length})]}),e.docs.length===0?(0,v.jsx)(`p`,{className:`px-2 text-xs text-muted-foreground italic`,children:s(`docs.sidebarEmpty`)}):(0,v.jsx)(`ul`,{className:`space-y-0.5`,children:e.docs.map(t=>(0,v.jsx)(`li`,{children:(0,v.jsxs)(`button`,{onClick:()=>a(e.slug,t.slug),className:r(`w-full flex items-center gap-1.5 px-2 py-1 rounded-md text-xs transition-colors text-left`,n===e.slug&&i===t.slug?`bg-accent text-foreground`:`text-muted-foreground hover:text-foreground hover:bg-accent/50`),children:[(0,v.jsx)(c,{className:`w-3 h-3 flex-shrink-0`}),t.title]})},t.slug))})]},e.slug))})]})}function b({categories:e,onSelect:n}){let{t:r}=t(`integrations`),i=e.reduce((e,t)=>e+t.docs.length,0),a=e.filter(e=>e.docs.length>0).length;return(0,v.jsxs)(`div`,{className:`max-w-2xl mx-auto py-8 px-6`,children:[(0,v.jsxs)(`div`,{className:`mb-8`,children:[(0,v.jsx)(`h1`,{className:`text-xl font-bold mb-2`,children:r(`docs.title`)}),(0,v.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:i===0?r(`docs.indexEmpty`):r(`docs.summary`,{documents:r(`docs.documentCount`,{count:i}),categories:r(`docs.categoryCount`,{count:a})})})]}),(0,v.jsx)(`div`,{className:`space-y-6`,children:e.map(e=>(0,v.jsxs)(`div`,{children:[(0,v.jsx)(`h2`,{className:`text-sm font-semibold text-muted-foreground uppercase tracking-wider mb-2`,children:e.name}),e.docs.length===0?(0,v.jsx)(`p`,{className:`text-xs text-muted-foreground italic pl-2`,children:r(`docs.categoryEmpty`)}):(0,v.jsx)(`ul`,{className:`space-y-1`,children:e.docs.map(t=>(0,v.jsx)(`li`,{children:(0,v.jsxs)(`button`,{onClick:()=>n(e.slug,t.slug),className:`w-full flex items-center gap-2 px-3 py-2 rounded-md text-sm hover:bg-accent transition-colors group text-left`,children:[(0,v.jsx)(c,{className:`w-3.5 h-3.5 text-muted-foreground flex-shrink-0`}),(0,v.jsx)(`span`,{className:`text-foreground group-hover:text-foreground`,children:t.title}),(0,v.jsx)(s,{className:`w-3 h-3 text-muted-foreground ml-auto md:opacity-0 md:group-hover:opacity-100 transition-opacity`})]})},t.slug))})]},e.slug))})]})}var x=(0,_.memo)(function({content:e,currentCategory:t,onNavigateDoc:n}){return(0,v.jsx)(m,{remarkPlugins:[u],rehypePlugins:[h],components:{a({href:e,children:r,...i}){return(0,v.jsx)(`a`,{href:e,onClick:r=>{if(!e)return;if(/^[a-z][a-z0-9+.-]*:/i.test(e)){r.preventDefault(),window.open(e,`_blank`,`noopener,noreferrer`);return}if(e.startsWith(`#`))return;r.preventDefault();let i=g(e,t);i&&n(i.category,i.slug)},...i,children:r})}},children:e})});function S({category:e,slug:n,lang:r,onNotFound:i,onNavigate:a,scrollContainerRef:o}){let{t:s}=t(`integrations`),[c,l]=(0,_.useState)(null),[u,d]=(0,_.useState)(null),f=(0,_.useRef)(0);return(0,_.useEffect)(()=>{let t=++f.current;d(null),fetch(`/api/docs/${e}/${n}?lang=${encodeURIComponent(r)}`).then(async e=>{if(e.status===404){i();return}if(!e.ok)throw Error(`HTTP ${e.status}`);return e.json()}).then(e=>{t===f.current&&e&&(l(e),o.current&&(o.current.scrollTop=0))}).catch(e=>{t===f.current&&d(e instanceof Error?e.message:s(`docs.loadError`))})},[e,n,r,i,o]),!c&&!u?(0,v.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,v.jsx)(p,{className:`w-4 h-4 animate-spin text-muted-foreground`})}):u&&!c?(0,v.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,v.jsx)(`p`,{className:`text-sm text-destructive`,children:u})}):c?(0,v.jsx)(`article`,{className:`max-w-2xl mx-auto py-8 px-6`,children:(0,v.jsx)(`div`,{className:`prose prose-sm max-w-none
|
|
2
|
-
prose-headings:text-foreground prose-headings:font-bold
|
|
3
|
-
prose-p:text-foreground/90
|
|
4
|
-
prose-a:text-accent-primary prose-a:no-underline hover:prose-a:underline
|
|
5
|
-
prose-strong:text-foreground
|
|
6
|
-
prose-code:text-accent-info prose-code:bg-card prose-code:px-1 prose-code:py-0.5 prose-code:rounded prose-code:text-xs
|
|
7
|
-
prose-pre:bg-card prose-pre:border prose-pre:border-border prose-pre:rounded-md prose-pre:p-0 prose-pre:overflow-x-auto
|
|
8
|
-
prose-blockquote:border-l-accent-primary prose-blockquote:text-muted-foreground
|
|
9
|
-
prose-hr:border-border
|
|
10
|
-
prose-th:text-foreground prose-td:text-foreground/90
|
|
11
|
-
prose-li:text-foreground/90`,children:(0,v.jsx)(x,{content:c.content,currentCategory:c.category,onNavigateDoc:a})})}):null}function C({open:e,onClose:r}){let{t:s,i18n:c}=t(`integrations`),l=c.language||`en`,[u,d]=(0,_.useState)(null),[f,m]=(0,_.useState)(!0),[h,g]=(0,_.useState)(),[x,C]=(0,_.useState)(),w=(0,_.useRef)(null);(0,_.useEffect)(()=>{e&&(m(!0),fetch(`/api/docs?lang=${encodeURIComponent(l)}`).then(e=>e.json()).then(e=>d(e)).catch(()=>d({categories:[]})).finally(()=>m(!1)))},[e,l]);let T=(0,_.useCallback)((e,t)=>{g(e),C(t)},[]),E=(0,_.useCallback)(()=>{g(void 0),C(void 0)},[]),D=!!(h&&x);return(0,v.jsx)(i,{open:e,onOpenChange:e=>{e||r()},children:(0,v.jsxs)(a,{movableResizable:!0,className:`max-w-5xl max-h-[90vh] overflow-hidden p-0 flex flex-col`,children:[(0,v.jsx)(o,{className:`sr-only`,children:s(`docs.title`)}),(0,v.jsx)(n,{className:`sr-only`,children:s(`docs.dialogDescription`)}),(0,v.jsxs)(`div`,{className:`flex flex-1 overflow-hidden`,children:[f?(0,v.jsx)(`div`,{className:`w-56 flex-shrink-0 border-r border-border flex items-center justify-center`,children:(0,v.jsx)(p,{className:`w-3.5 h-3.5 animate-spin text-muted-foreground`})}):(0,v.jsx)(y,{categories:u?.categories??[],activeCategory:h,activeSlug:x,onSelect:T,onHome:E}),(0,v.jsx)(`main`,{ref:w,className:`flex-1 overflow-y-auto`,children:D&&h&&x?(0,v.jsx)(S,{category:h,slug:x,lang:l,onNotFound:E,onNavigate:T,scrollContainerRef:w}):u&&(0,v.jsx)(b,{categories:u.categories,onSelect:T})})]})]})})}var w=(0,_.memo)(C);export{w as default};
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import{a as e}from"./chunk-BNv3lrIs.js";import{Cn as t,Dn as n,En as r,G as i,On as a,Rt as o,Tt as s,Vt as c,b as l,cn as u,jn as d,mt as f,x as p}from"./index-B7vB20Jw.js";import{t as m}from"./lib-PQoHlR5u.js";import{t as h}from"./atom-one-dark-BrRN8wBy.js";var g=e(d(),1),_=u();function v({categories:e,activeCategory:n,activeSlug:a}){let{t:o}=t(`integrations`);return(0,_.jsxs)(`nav`,{className:`w-56 flex-shrink-0 border-r border-border overflow-y-auto py-4 px-3`,children:[(0,_.jsxs)(r,{to:`/docs`,className:`flex items-center gap-2 mb-4 px-2 text-xs font-bold text-muted-foreground hover:text-foreground transition-colors`,children:[(0,_.jsx)(c,{className:`w-3.5 h-3.5`}),o(`docs.title`)]}),(0,_.jsx)(`div`,{className:`space-y-4`,children:e.map(e=>(0,_.jsxs)(`div`,{children:[(0,_.jsxs)(`div`,{className:`px-2 mb-1 flex items-center justify-between`,children:[(0,_.jsx)(`span`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wider`,children:e.name}),e.docs.length>0&&(0,_.jsx)(`span`,{className:`text-[9px] font-medium text-muted-foreground/60 bg-muted/40 rounded px-1 py-0.5 leading-none`,children:e.docs.length})]}),e.docs.length===0?(0,_.jsx)(`p`,{className:`px-2 text-xs text-muted-foreground italic`,children:o(`docs.sidebarEmpty`)}):(0,_.jsx)(`ul`,{className:`space-y-0.5`,children:e.docs.map(t=>{let o=n===e.slug&&a===t.slug;return(0,_.jsx)(`li`,{children:(0,_.jsxs)(r,{to:`/docs/${e.slug}/${t.slug}`,className:i(`flex items-center gap-1.5 px-2 py-1 rounded-md text-xs transition-colors`,o?`bg-accent text-foreground`:`text-muted-foreground hover:text-foreground hover:bg-accent/50`),children:[(0,_.jsx)(s,{className:`w-3 h-3 flex-shrink-0`}),t.title]})},t.slug)})})]},e.slug))})]})}function y({categories:e}){let{t:n}=t(`integrations`),i=e.reduce((e,t)=>e+t.docs.length,0),a=e.filter(e=>e.docs.length>0).length;return(0,_.jsxs)(`div`,{className:`max-w-2xl mx-auto py-8 px-6`,children:[(0,_.jsxs)(`div`,{className:`mb-8`,children:[(0,_.jsx)(`h1`,{className:`text-xl font-bold mb-2`,children:n(`docs.title`)}),(0,_.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:i===0?n(`docs.indexEmpty`):n(`docs.summary`,{documents:n(`docs.documentCount`,{count:i}),categories:n(`docs.categoryCount`,{count:a})})})]}),(0,_.jsx)(`div`,{className:`space-y-6`,children:e.map(e=>(0,_.jsxs)(`div`,{children:[(0,_.jsx)(`h2`,{className:`text-sm font-semibold text-muted-foreground uppercase tracking-wider mb-2`,children:e.name}),e.docs.length===0?(0,_.jsx)(`p`,{className:`text-xs text-muted-foreground italic pl-2`,children:n(`docs.categoryEmpty`)}):(0,_.jsx)(`ul`,{className:`space-y-1`,children:e.docs.map(t=>(0,_.jsx)(`li`,{children:(0,_.jsxs)(r,{to:`/docs/${e.slug}/${t.slug}`,className:`flex items-center gap-2 px-3 py-2 rounded-md text-sm hover:bg-accent transition-colors group`,children:[(0,_.jsx)(s,{className:`w-3.5 h-3.5 text-muted-foreground flex-shrink-0`}),(0,_.jsx)(`span`,{className:`text-foreground group-hover:text-foreground`,children:t.title}),(0,_.jsx)(o,{className:`w-3 h-3 text-muted-foreground ml-auto md:opacity-0 md:group-hover:opacity-100 transition-opacity`})]})},t.slug))})]},e.slug))})]})}var b=(0,g.memo)(function({content:e,currentCategory:t,onNavigateDoc:n}){return(0,_.jsx)(p,{remarkPlugins:[l],rehypePlugins:[m],components:{a({href:e,children:r,...i}){return(0,_.jsx)(`a`,{href:e,onClick:r=>{if(!e)return;if(/^[a-z][a-z0-9+.-]*:/i.test(e)){r.preventDefault(),window.open(e,`_blank`,`noopener,noreferrer`);return}if(e.startsWith(`#`))return;r.preventDefault();let i=h(e,t);i&&n(i.category,i.slug)},...i,children:r})}},children:e})});function x({category:e,slug:r,lang:i,scrollContainerRef:a}){let{t:o}=t(`integrations`),[s,c]=(0,g.useState)(null),[l,u]=(0,g.useState)(null),d=(0,g.useRef)(0),p=n();return(0,g.useEffect)(()=>{let t=++d.current;u(null),fetch(`/api/docs/${e}/${r}?lang=${encodeURIComponent(i)}`).then(async e=>{if(e.status===404){p(`/docs`,{replace:!0});return}if(!e.ok)throw Error(`HTTP ${e.status}`);return e.json()}).then(e=>{t===d.current&&e&&(c(e),a.current&&(a.current.scrollTop=0))}).catch(e=>{t===d.current&&u(e instanceof Error?e.message:o(`docs.loadError`))})},[e,r,i,p,a]),!s&&!l?(0,_.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,_.jsx)(f,{className:`w-4 h-4 animate-spin text-muted-foreground`})}):l&&!s?(0,_.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,_.jsx)(`p`,{className:`text-sm text-destructive`,children:l})}):s?(0,_.jsx)(`article`,{className:`max-w-2xl mx-auto py-8 px-6`,children:(0,_.jsx)(`div`,{className:`prose prose-sm max-w-none
|
|
2
|
-
prose-headings:text-foreground prose-headings:font-bold
|
|
3
|
-
prose-p:text-foreground/90
|
|
4
|
-
prose-a:text-accent-primary prose-a:no-underline hover:prose-a:underline
|
|
5
|
-
prose-strong:text-foreground
|
|
6
|
-
prose-code:text-accent-info prose-code:bg-card prose-code:px-1 prose-code:py-0.5 prose-code:rounded prose-code:text-xs
|
|
7
|
-
prose-pre:bg-card prose-pre:border prose-pre:border-border prose-pre:rounded-md prose-pre:p-0 prose-pre:overflow-x-auto
|
|
8
|
-
prose-blockquote:border-l-accent-primary prose-blockquote:text-muted-foreground
|
|
9
|
-
prose-hr:border-border
|
|
10
|
-
prose-th:text-foreground prose-td:text-foreground/90
|
|
11
|
-
prose-li:text-foreground/90`,children:(0,_.jsx)(b,{content:s.content,currentCategory:s.category,onNavigateDoc:(e,t)=>p(`/docs/${e}/${t}`)})})}):null}function S(){let{category:e,slug:n}=a(),{i18n:r}=t(`integrations`),i=r.language||`en`,[o,s]=(0,g.useState)(null),[c,l]=(0,g.useState)(!0),u=(0,g.useRef)(null);(0,g.useEffect)(()=>{fetch(`/api/docs?lang=${encodeURIComponent(i)}`).then(e=>e.json()).then(e=>s(e)).catch(()=>s({categories:[]})).finally(()=>l(!1))},[i]);let d=!!(e&&n);return(0,_.jsxs)(`div`,{className:`flex h-full overflow-hidden`,children:[c?(0,_.jsx)(`div`,{className:`w-56 flex-shrink-0 border-r border-border flex items-center justify-center`,children:(0,_.jsx)(f,{className:`w-3.5 h-3.5 animate-spin text-muted-foreground`})}):(0,_.jsx)(v,{categories:o?.categories??[],activeCategory:e,activeSlug:n}),(0,_.jsx)(`main`,{ref:u,className:`flex-1 overflow-y-auto`,children:d&&e&&n?(0,_.jsx)(x,{category:e,slug:n,lang:i,scrollContainerRef:u}):o&&(0,_.jsx)(y,{categories:o.categories})})]})}export{S as default};
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import{a as e}from"./chunk-BNv3lrIs.js";import{At as t,B as n,Cn as r,Ft as i,Jt as a,L as o,M as s,N as c,P as l,Pt as u,R as d,Sn as f,Tn as p,W as m,X as h,Xt as g,Y as _,Yt as v,cn as y,ct as b,j as x,jn as S,ln as C,mt as w,sn as T,t as E,ut as D,z as O}from"./index-B7vB20Jw.js";var k=e(S(),1),A=y(),j=[`todo`,`in_progress`,`done`,`cancelled`],M={todo:`todo`,in_progress:`inProgress`,done:`done`,cancelled:`cancelled`};function N({state:e,onChanged:t}){let{t:n}=r(`jira`),i=e.connection,[a,o]=(0,k.useState)(i.enabled),[s,c]=(0,k.useState)(!1),[l,u]=(0,k.useState)(!1),[d,p]=(0,k.useState)([]),[h,g]=(0,k.useState)([]),[_,v]=(0,k.useState)(i.discardStatus??``),[y,b]=(0,k.useState)(i.statusMap??{}),S=e.outbox??{pending:0,inflight:0,done:0,dead:0},C=(0,k.useCallback)(async()=>{try{let{ops:e}=await x.listOutbox(`dead`);p(e)}catch{p([])}},[]);(0,k.useEffect)(()=>{C()},[C]),(0,k.useEffect)(()=>{let e=!1;return x.listStatuses().then(({statuses:t})=>{e||g(t)}).catch(()=>{e||g([])}),()=>{e=!0}},[]);async function w(e){let r=_;v(e);try{await x.patchConnection({discardStatus:e||null}),t()}catch(e){v(r),f.error(F(e,n))}}async function T(e,r){let i=y,a={...y,[e]:r||void 0};b(a);let o=Object.fromEntries(Object.entries(a).filter(([,e])=>e));try{await x.patchConnection({statusMap:Object.keys(o).length?o:null}),t()}catch(e){b(i),f.error(F(e,n))}}async function E(){let e=!a;o(e),u(!0);try{await x.setEnabled(e)}catch(t){o(!e),f.error(F(t,n))}finally{u(!1)}}async function D(){c(!0);try{let e=await x.syncNow();f.success(n(`status.syncedToast`,{count:e.upserted}))}catch(e){f.error(F(e,n))}finally{c(!1)}}async function O(){if(window.confirm(n(`status.disconnectConfirm`))){u(!0);try{await x.disconnect(),f.success(n(`status.disconnectedToast`)),t()}catch(e){f.error(F(e,n))}finally{u(!1)}}}async function N(e){try{await x.retryOutbox(e),await C()}catch(e){f.error(F(e,n))}}let I=S.pending+S.inflight;return(0,A.jsxs)(`div`,{className:`space-y-4`,"data-testid":`jira-connected`,children:[(0,A.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`p`,{className:`text-sm font-medium text-foreground`,children:n(`status.connected`,{key:i.jiraProjectKey})}),(0,A.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[i.baseUrl,` · `,i.deployment===`cloud`?n(`review.cloud`):n(`review.dc`)]})]}),(0,A.jsx)(`a`,{href:`${i.baseUrl}/browse/${i.jiraProjectKey}`,target:`_blank`,rel:`noreferrer`,className:`text-xs text-accent-primary hover:underline`,children:n(`badge.openInJira`)})]}),(0,A.jsxs)(`div`,{className:`flex items-center justify-between rounded-md border border-border p-3`,children:[(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`p`,{className:`text-sm font-medium`,children:n(`status.enabledLabel`)}),(0,A.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:n(a?`status.enabledHelp`:`status.pausedHelp`)})]}),(0,A.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":a,"aria-label":n(`status.enabledLabel`),disabled:l,onClick:E,className:`relative inline-flex h-5 w-9 shrink-0 items-center rounded-full transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 ${a?`bg-accent-success`:`bg-input`}`,children:(0,A.jsx)(`span`,{className:`inline-block h-3.5 w-3.5 rounded-full bg-background shadow-sm transition-transform ${a?`translate-x-4`:`translate-x-0.5`}`})})]}),(0,A.jsxs)(`div`,{className:`rounded-md border border-border p-3`,"data-testid":`jira-status-map`,children:[(0,A.jsx)(`p`,{className:`text-sm font-medium`,children:n(`wizard.step3Title`)}),(0,A.jsx)(`p`,{className:`mt-0.5 mb-2 text-xs text-muted-foreground`,children:n(`mapping.intro`)}),(0,A.jsx)(`div`,{className:`space-y-2`,children:j.map(e=>(0,A.jsxs)(`label`,{className:`flex items-center justify-between gap-3`,children:[(0,A.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:n(`mapping.${M[e]}`)}),(0,A.jsxs)(`select`,{value:y[e]??``,onChange:t=>void T(e,t.target.value),className:`w-44 rounded-md border border-border bg-background px-2 py-1.5 text-sm`,"data-testid":`jira-statusmap-${e}`,children:[(0,A.jsx)(`option`,{value:``,children:n(`mapping.auto`)}),h.map(e=>(0,A.jsx)(`option`,{value:e.name,children:e.name},e.id)),y[e]&&!h.some(t=>t.name===y[e])&&(0,A.jsx)(`option`,{value:y[e],children:y[e]})]})]},e))})]}),(0,A.jsxs)(`div`,{className:`rounded-md border border-border p-3`,children:[(0,A.jsx)(`p`,{className:`text-sm font-medium`,children:n(`discard.configLabel`)}),(0,A.jsx)(`p`,{className:`mt-0.5 mb-2 text-xs text-muted-foreground`,children:n(`discard.configHelp`)}),(0,A.jsxs)(`select`,{value:_,onChange:e=>void w(e.target.value),className:`w-full rounded-md border border-border bg-background px-2 py-1.5 text-sm`,"data-testid":`jira-discard-status-select`,children:[(0,A.jsx)(`option`,{value:``,children:n(`discard.configNone`)}),h.map(e=>(0,A.jsx)(`option`,{value:e.name,children:e.name},e.id)),_&&!h.some(e=>e.name===_)&&(0,A.jsx)(`option`,{value:_,children:_})]})]}),(0,A.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,A.jsx)(m,{variant:`outline`,size:`sm`,onClick:D,disabled:s,children:n(s?`status.syncing`:`status.syncNow`)}),(0,A.jsx)(m,{variant:`ghost`,size:`sm`,onClick:O,disabled:l,className:`text-destructive`,children:n(`status.disconnect`)})]}),(0,A.jsxs)(`div`,{className:`rounded-md border border-border p-3`,"data-testid":`jira-outbox`,children:[(0,A.jsx)(`p`,{className:`text-sm font-medium`,children:n(`outbox.title`)}),S.dead>0?(0,A.jsx)(`p`,{className:`mt-1 text-xs text-accent-warning`,children:n(`outbox.dead`,{count:S.dead})}):I>0?(0,A.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:n(`outbox.pending`,{count:I})}):(0,A.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:n(`outbox.allSynced`)}),d.length>0&&(0,A.jsxs)(`div`,{className:`mt-2 space-y-2`,children:[(0,A.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:n(`outbox.deadHelp`)}),d.map(e=>(0,A.jsxs)(`div`,{className:`flex items-center justify-between gap-2 rounded border border-border/60 px-2 py-1`,children:[(0,A.jsxs)(`span`,{className:`truncate text-xs`,children:[P(e,n),` · `,e.deadReason??e.lastError??``]}),(0,A.jsx)(m,{variant:`outline`,size:`sm`,onClick:()=>N(e.id),children:n(`outbox.retry`)})]},e.id))]})]})]})}function P(e,t){return e.opType===`transition`?t(`outbox.opTransition`):e.opType===`comment`?t(`outbox.opComment`):t(`outbox.opCreate`)}function F(e,t){return e instanceof Error?e.message:t(`errors.generic`)}function I({activeProjectId:e}){let{t}=r(`integrations`),[n,a]=(0,k.useState)(null),[u,f]=(0,k.useState)(!0),[p,m]=(0,k.useState)(!1),[h,g]=(0,k.useState)(!1),_=(0,k.useCallback)(async()=>{try{a(await x.getConnection())}catch{a({connected:!1})}finally{f(!1)}},[]);if((0,k.useEffect)(()=>{!s||!e||(f(!0),_())},[e,_]),!s)return null;let v=!!(n?.connected&&n.connection);return(0,A.jsxs)(`div`,{className:`rounded-lg border border-border bg-card p-4 flex flex-col gap-3 h-full`,"data-testid":`jira-integration-card`,children:[(0,A.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,A.jsx)(`div`,{className:`grid place-items-center w-9 h-9 rounded-md bg-accent-info/15 text-accent-info shrink-0`,children:(0,A.jsx)(D,{className:`w-4 h-4`})}),(0,A.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,A.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,A.jsx)(`h3`,{className:`text-sm font-semibold`,children:t(`jiraCard.title`)}),v&&(0,A.jsxs)(`span`,{className:`text-[10px] px-1.5 py-0.5 rounded bg-accent-success/20 text-accent-success flex items-center gap-1`,"data-testid":`jira-connected-badge`,children:[(0,A.jsx)(i,{className:`w-3 h-3`}),` `,t(`jiraCard.connected`)]})]}),(0,A.jsx)(`p`,{className:`text-[10px] text-muted-foreground mt-0.5`,children:t(`jiraCard.category`)})]})]}),(0,A.jsx)(`p`,{className:`text-xs text-muted-foreground leading-relaxed`,children:v&&n?.connection?t(`jiraCard.connectedDescription`,{key:n.connection.jiraProjectKey}):t(`jiraCard.description`)}),(0,A.jsxs)(`ul`,{className:`text-xs space-y-1 list-disc pl-4 text-foreground/80`,children:[(0,A.jsx)(`li`,{children:t(`jiraCard.bullet1`)}),(0,A.jsx)(`li`,{children:t(`jiraCard.bullet2`)}),(0,A.jsx)(`li`,{children:t(`jiraCard.bullet3`)})]}),(0,A.jsx)(`div`,{className:`text-[10px] text-muted-foreground`,children:t(`jiraCard.requires`)}),(0,A.jsx)(`div`,{className:`mt-auto pt-2 flex items-center justify-end gap-2`,children:u?(0,A.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`…`}):v?(0,A.jsx)(`button`,{type:`button`,onClick:()=>g(!0),"data-testid":`jira-manage-btn`,className:`text-xs px-3 py-1.5 rounded-md border border-border hover:bg-muted/30 inline-flex items-center gap-1.5`,children:t(`jiraCard.manage`)}):(0,A.jsxs)(`button`,{type:`button`,onClick:()=>m(!0),"data-testid":`jira-connect-btn`,className:`text-xs px-3 py-1.5 rounded-md bg-accent-primary text-white hover:opacity-90 inline-flex items-center gap-1.5`,children:[(0,A.jsx)(D,{className:`w-3.5 h-3.5`}),t(`jiraCard.connect`)]})}),(0,A.jsx)(c,{open:p,onOpenChange:m,children:(0,A.jsxs)(l,{className:`max-w-lg`,children:[(0,A.jsx)(o,{children:(0,A.jsx)(d,{children:t(`jiraCard.modalTitle`)})}),(0,A.jsx)(E,{onConnected:()=>{m(!1),_()},onSkip:()=>m(!1)})]})}),(0,A.jsx)(c,{open:h,onOpenChange:g,children:(0,A.jsxs)(l,{className:`max-w-lg`,children:[(0,A.jsx)(o,{children:(0,A.jsx)(d,{children:t(`jiraCard.manageTitle`)})}),n?.connected&&n.connection&&(0,A.jsx)(N,{state:n,onChanged:()=>{_().then(()=>g(!1))}})]})})]})}function L(){let{t:e}=r(`integrations`),{activeProjectId:t,projects:n}=v(),i=n.find(e=>e.id===t),o=i?a(i).includes(`claude`):!0,{registerHandler:c,unregisterHandler:l}=T(),u=(0,k.useRef)(t);(0,k.useEffect)(()=>{u.current=t},[t]);let[d,f]=(0,k.useState)(null),[p,m]=(0,k.useState)(null),{data:h,isLoading:y,isFirstLoad:x,refresh:S}=g({namespace:`plugins`,projectId:t,initialValue:[],fetcher:(0,k.useCallback)(async()=>{let e=await fetch(`${C()}/plugins`);if(!e.ok)throw Error(`HTTP ${e.status}`);return(await e.json()).plugins??[]},[])});(0,k.useEffect)(()=>(c(`integrations-page`,e=>{let t=e;t.type&&(t.projectId&&t.projectId!==u.current||t.type.startsWith(`plugin.`)&&S())}),()=>l(`integrations-page`)),[c,l,S]),(0,k.useEffect)(()=>{f(!y&&!h?`Failed to load plugins`:null)},[y,h]);let w=(0,k.useMemo)(()=>(h??[]).filter(e=>e.status!==`orphan`),[h]),E=(0,k.useMemo)(()=>(h??[]).filter(e=>e.status===`orphan`),[h]);return t?(0,A.jsxs)(`div`,{className:`flex flex-col h-full`,children:[(0,A.jsxs)(`div`,{className:`flex-shrink-0 border-b border-border px-6 pt-4 pb-3 flex items-center gap-2`,children:[(0,A.jsx)(b,{className:`w-4 h-4 text-accent-primary`}),(0,A.jsxs)(`div`,{className:`flex-1`,children:[(0,A.jsx)(`h1`,{className:`text-lg font-semibold`,children:e(`page.title`)}),(0,A.jsx)(`p`,{className:`text-xs text-muted-foreground mt-0.5`,children:e(`page.subtitle`)})]})]}),(0,A.jsx)(`div`,{className:`flex-1 overflow-auto p-6`,children:x&&y?(0,A.jsx)(q,{}):d&&o?(0,A.jsx)(J,{onRetry:S}):(0,A.jsxs)(A.Fragment,{children:[(0,A.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4`,children:[(0,A.jsx)(I,{activeProjectId:t}),o&&w.map(e=>(0,A.jsx)(R,{plugin:e,isInstalling:p===e.name,onInstall:()=>m(e.name),onCloseInstall:()=>{m(null),S()}},e.name))]}),o&&E.length>0&&(0,A.jsxs)(`div`,{className:`mt-10`,children:[(0,A.jsxs)(`h2`,{className:`text-sm font-semibold text-muted-foreground mb-3 flex items-center gap-2`,children:[(0,A.jsx)(_,{className:`w-3.5 h-3.5`}),` `,e(`page.deprecated`)]}),(0,A.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4`,children:E.map(e=>(0,A.jsx)(U,{plugin:e,onRemoved:S},e.name))})]}),!s&&(!o||w.length===0)&&(0,A.jsx)(Y,{})]})})]}):(0,A.jsx)(`div`,{className:`flex flex-col items-center justify-center h-full text-muted-foreground text-sm`,children:e(`page.selectProject`)})}function R({plugin:e,isInstalling:n,onInstall:a,onCloseInstall:o}){let{t:s}=r(`integrations`),[c,l]=(0,k.useState)(!1);return(0,A.jsxs)(`div`,{className:`rounded-lg border border-border bg-card p-4 flex flex-col gap-3 h-full`,children:[(0,A.jsx)(`div`,{className:`flex items-start gap-2`,children:(0,A.jsxs)(`div`,{className:`flex-1`,children:[(0,A.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,A.jsx)(`h3`,{className:`text-sm font-semibold`,children:e.name}),(0,A.jsxs)(`span`,{className:`text-[10px] px-1.5 py-0.5 rounded bg-muted text-muted-foreground`,children:[`v`,e.version]}),e.status===`installed`&&(0,A.jsxs)(`span`,{className:`text-[10px] px-1.5 py-0.5 rounded bg-accent-success/20 text-accent-success flex items-center gap-1`,children:[(0,A.jsx)(i,{className:`w-3 h-3`}),` `,s(`card.statusActive`)]}),e.status===`deactivated`&&(0,A.jsxs)(`span`,{className:`text-[10px] px-1.5 py-0.5 rounded bg-muted text-muted-foreground flex items-center gap-1`,children:[(0,A.jsx)(u,{className:`w-3 h-3`}),` `,s(`card.statusDeactivated`)]}),e.status===`degraded`&&(0,A.jsxs)(`span`,{className:`text-[10px] px-1.5 py-0.5 rounded bg-accent-warning/20 text-accent-warning flex items-center gap-1`,children:[(0,A.jsx)(_,{className:`w-3 h-3`}),` `,s(`card.statusDegraded`)]}),e.updateAvailable&&(0,A.jsxs)(`span`,{className:`text-[10px] px-1.5 py-0.5 rounded bg-accent-info/20 text-accent-info flex items-center gap-1`,children:[(0,A.jsx)(t,{className:`w-3 h-3`}),` `,s(`card.updateAvailable`)]})]}),e.category&&(0,A.jsx)(`p`,{className:`text-[10px] text-muted-foreground mt-0.5`,children:e.category})]})}),(0,A.jsx)(`p`,{className:`text-xs text-muted-foreground leading-relaxed`,children:e.description}),e.whatItDoes.length>0&&(0,A.jsx)(`ul`,{className:`text-xs space-y-1 list-disc pl-4 text-foreground/80`,children:e.whatItDoes.map((e,t)=>(0,A.jsx)(`li`,{children:e},t))}),e.requirements.length>0&&(0,A.jsx)(`div`,{className:`text-[10px] text-muted-foreground`,children:s(`card.requires`,{list:e.requirements.map(e=>`${e.name}${e.minVersion?` ≥ ${e.minVersion}`:``}`).join(`, `)})}),e.healthReason&&e.status===`degraded`&&(0,A.jsx)(`div`,{className:`text-[11px] text-accent-warning`,children:e.healthReason}),e.status===`deactivated`&&(0,A.jsx)(`div`,{className:`text-[11px] text-muted-foreground leading-relaxed`,children:(0,A.jsx)(p,{t:s,i18nKey:`card.deactivatedHint`,components:{strong:(0,A.jsx)(`strong`,{})}})}),e.marketplaceConflicts&&e.marketplaceConflicts.length>0&&(0,A.jsx)(H,{pluginName:e.name,conflicts:e.marketplaceConflicts}),e.marketplaceCachedButDisabled&&e.marketplaceCachedButDisabled.length>0&&(0,A.jsx)(B,{keys:e.marketplaceCachedButDisabled}),e.updateAvailable&&(0,A.jsx)(V,{pluginName:e.name}),(0,A.jsx)(`div`,{className:`mt-auto pt-2 flex items-center justify-end gap-2`,children:e.status===`not-installed`?(0,A.jsx)(`button`,{type:`button`,onClick:a,className:`text-xs px-3 py-1.5 rounded-md bg-accent-primary text-white hover:opacity-90`,children:s(`card.install`)}):(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(z,{pluginName:e.name,active:e.status===`installed`}),(0,A.jsxs)(`button`,{type:`button`,onClick:()=>l(!0),className:`text-xs px-3 py-1.5 rounded-md border border-border hover:bg-destructive/10 hover:text-destructive flex items-center gap-1.5`,children:[(0,A.jsx)(h,{className:`w-3 h-3`}),` `,s(`card.uninstall`)]})]})}),n&&(0,A.jsx)(W,{pluginName:e.name,onClose:o}),c&&(0,A.jsx)(G,{pluginName:e.name,onClose:()=>l(!1),onUninstalled:()=>{l(!1)}})]})}function z({pluginName:e,active:t}){let{t:n}=r(`integrations`),[i,a]=(0,k.useState)(!1),[o,s]=(0,k.useState)(null);return(0,A.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,A.jsx)(`button`,{type:`button`,disabled:i,onClick:async()=>{a(!0),s(null);try{let n=`${C()}/plugins/${e}/${t?`deactivate`:`activate`}`,r=await fetch(n,{method:`POST`});if(!r.ok)throw Error((await r.json()).error??`HTTP ${r.status}`)}catch(e){s(e.message)}finally{a(!1)}},role:`switch`,"aria-checked":t,className:`relative inline-flex items-center h-5 w-9 rounded-full transition-colors disabled:opacity-50 ${t?`bg-accent-success`:`bg-muted`}`,title:n(t?`toggle.titleActive`:`toggle.titleDeactivated`),children:(0,A.jsx)(`span`,{className:`inline-block h-4 w-4 rounded-full bg-white shadow transition-transform ${t?`translate-x-4`:`translate-x-0.5`}`})}),(0,A.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:n(t?`card.statusActive`:`common:states.off`)}),o&&(0,A.jsx)(`span`,{className:`text-[10px] text-destructive`,children:o})]})}function B({keys:e}){let{t}=r(`integrations`);return(0,A.jsxs)(`div`,{className:`text-[11px] rounded-md border border-yellow-500/30 aurora-light:border-accent-warning/30 bg-yellow-500/5 aurora-light:bg-accent-warning/10 p-2 leading-relaxed space-y-1`,children:[(0,A.jsxs)(`div`,{className:`flex items-start gap-1.5`,children:[(0,A.jsx)(_,{className:`w-3 h-3 text-yellow-500 aurora-light:text-accent-warning mt-0.5 flex-shrink-0`}),(0,A.jsx)(`span`,{children:(0,A.jsx)(p,{t,i18nKey:`cachedNotice.body`,components:{strong:(0,A.jsx)(`strong`,{}),code:(0,A.jsx)(`code`,{className:`bg-muted px-1 rounded`})}})})]}),(0,A.jsx)(`div`,{className:`pl-5 space-y-0.5`,children:e.map(e=>(0,A.jsxs)(`pre`,{className:`text-[10px] bg-muted/40 rounded px-1.5 py-0.5 inline-block font-mono`,children:[`/plugin uninstall `,e]},e))}),(0,A.jsx)(`div`,{className:`pl-5 text-[10px] text-muted-foreground`,children:t(`cachedNotice.runInstruction`)})]})}function V({pluginName:e}){let{t:n}=r(`integrations`),[i,a]=(0,k.useState)(!1),[o,s]=(0,k.useState)(null);return(0,A.jsxs)(`div`,{className:`text-[11px] rounded-md border border-accent-info/30 bg-accent-info/5 p-2 leading-relaxed space-y-1.5`,children:[(0,A.jsxs)(`div`,{className:`flex items-start gap-1.5`,children:[(0,A.jsx)(t,{className:`w-3 h-3 text-accent-info mt-0.5 flex-shrink-0`}),(0,A.jsx)(`span`,{children:(0,A.jsx)(p,{t:n,i18nKey:`update.body`,components:{code:(0,A.jsx)(`code`,{className:`bg-muted px-1 rounded`})}})})]}),(0,A.jsxs)(`button`,{type:`button`,disabled:i,onClick:async()=>{a(!0),s(null);try{let t=await fetch(`${C()}/plugins/${e}/update`,{method:`POST`});if(!t.ok)throw Error((await t.json()).error??`HTTP ${t.status}`)}catch(e){s(e.message)}finally{a(!1)}},className:`text-[10px] px-2 py-0.5 rounded border border-accent-info/40 hover:bg-accent-info/10 disabled:opacity-50 flex items-center gap-1`,children:[i&&(0,A.jsx)(w,{className:`w-2.5 h-2.5 animate-spin`}),(0,A.jsx)(p,{t:n,i18nKey:`update.button`,components:{code:(0,A.jsx)(`code`,{})}})]}),o&&(0,A.jsx)(`div`,{className:`text-destructive text-[10px]`,children:o})]})}function H({pluginName:e,conflicts:t}){let{t:n}=r(`integrations`),[i,a]=(0,k.useState)(null),[o,s]=(0,k.useState)(null),c=async e=>{a(e),s(null);try{let t=await fetch(`${C()}/plugins/_marketplace/disable`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({key:e})});if(!t.ok)throw Error((await t.json()).error??`HTTP ${t.status}`)}catch(e){s(e.message)}finally{a(null)}};return(0,A.jsxs)(`div`,{className:`text-[11px] rounded-md border border-yellow-500/30 aurora-light:border-accent-warning/30 bg-yellow-500/5 aurora-light:bg-accent-warning/10 p-2 leading-relaxed space-y-1.5`,children:[(0,A.jsxs)(`div`,{className:`flex items-start gap-1.5`,children:[(0,A.jsx)(_,{className:`w-3 h-3 text-yellow-500 aurora-light:text-accent-warning mt-0.5 flex-shrink-0`}),(0,A.jsx)(`span`,{children:(0,A.jsx)(p,{t:n,i18nKey:`conflict.body`,values:{name:e},components:{strong:(0,A.jsx)(`strong`,{})}})})]}),(0,A.jsx)(`div`,{className:`flex flex-wrap gap-1.5 pt-1`,children:t.map(e=>(0,A.jsxs)(`button`,{type:`button`,disabled:i===e,onClick:()=>c(e),className:`text-[10px] px-2 py-0.5 rounded border border-yellow-500/40 aurora-light:border-accent-warning/40 hover:bg-yellow-500/10 aurora-light:hover:bg-accent-warning/10 disabled:opacity-50 flex items-center gap-1`,children:[i===e&&(0,A.jsx)(w,{className:`w-2.5 h-2.5 animate-spin`}),(0,A.jsx)(p,{t:n,i18nKey:`conflict.disableButton`,values:{key:e},components:{code:(0,A.jsx)(`code`,{})}})]},e))}),o&&(0,A.jsx)(`div`,{className:`text-destructive`,children:o})]})}function U({plugin:e,onRemoved:t}){let{t:n}=r(`integrations`),[i,a]=(0,k.useState)(!1);return(0,A.jsxs)(`div`,{className:`rounded-lg border border-yellow-500/30 aurora-light:border-accent-warning/30 bg-yellow-500/5 aurora-light:bg-accent-warning/10 p-4 flex flex-col gap-3`,children:[(0,A.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,A.jsx)(`h3`,{className:`text-sm font-semibold`,children:e.name}),(0,A.jsx)(`span`,{className:`text-[10px] px-1.5 py-0.5 rounded bg-yellow-500/20 aurora-light:bg-accent-warning/15 text-yellow-500 aurora-light:text-accent-warning`,children:n(`orphan.badge`)})]}),(0,A.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e.description}),(0,A.jsx)(`div`,{className:`flex items-center justify-end`,children:(0,A.jsxs)(`button`,{type:`button`,disabled:i,onClick:async()=>{a(!0);try{await fetch(`${C()}/plugins/${e.name}`,{method:`DELETE`}),t()}finally{a(!1)}},className:`text-xs px-3 py-1.5 rounded-md border border-border hover:bg-destructive/10 hover:text-destructive flex items-center gap-1.5`,children:[(0,A.jsx)(h,{className:`w-3 h-3`}),` `,n(`orphan.removeButton`)]})})]})}function W({pluginName:e,onClose:n}){let{t:a}=r(`integrations`),[o,s]=(0,k.useState)(null),[c,l]=(0,k.useState)(null),[d,f]=(0,k.useState)(!1),[p,m]=(0,k.useState)(null),[h,g]=(0,k.useState)([]),[v,y]=(0,k.useState)(null),[b,x]=(0,k.useState)([]),{registerHandler:S,unregisterHandler:E}=T(),D=(0,k.useCallback)(()=>{s(null),l(null),fetch(`${C()}/plugins/${e}/preview-install`).then(e=>e.ok?e.json():Promise.reject(Error(`HTTP ${e.status}`))).then(e=>s(e)).catch(e=>l(e.message))},[e]);(0,k.useEffect)(()=>{D()},[D]),(0,k.useEffect)(()=>(S(`install-${e}`,t=>{let n=t;if(n.type===`plugin.install_progress`&&n.name===e&&n.line&&g(e=>[...e,n.line]),n.type===`plugin.prereq_install_progress`&&n.line&&x(e=>[...e,n.line]),n.type===`plugin.prereq_installed`){y(null);let e=n.reason;e&&x(t=>[...t,`► ${e}`]),n.ok&&D()}}),()=>E(`install-${e}`)),[e,S,E,D]);let O=async e=>{y(e),x([a(`installDialog.installingPrereq`,{name:e})]);try{await fetch(`${C()}/plugins/_prerequisites/${e}/install`,{method:`POST`})}catch(e){x(t=>[...t,a(`installDialog.prereqStartFailed`,{message:e.message})]),y(null)}},j=(o?.requirements??[]).every(e=>e.installed&&e.executable&&e.meetsMinimum);return(0,A.jsxs)(K,{onClose:n,title:a(`installDialog.title`,{name:e}),children:[c&&(0,A.jsx)(`div`,{className:`text-xs text-destructive`,children:c}),!o&&!c&&(0,A.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-muted-foreground`,children:[(0,A.jsx)(w,{className:`w-3 h-3 animate-spin`}),` `,a(`installDialog.computingChanges`)]}),o&&(0,A.jsxs)(A.Fragment,{children:[o.platformNote&&(0,A.jsxs)(`div`,{className:`flex items-start gap-2 p-2.5 rounded-md border border-yellow-500/30 aurora-light:border-accent-warning/30 bg-yellow-500/5 aurora-light:bg-accent-warning/10 text-[11px] leading-relaxed`,children:[(0,A.jsx)(_,{className:`w-3.5 h-3.5 text-yellow-500 aurora-light:text-accent-warning mt-0.5 flex-shrink-0`}),(0,A.jsx)(`span`,{children:o.platformNote})]}),(0,A.jsxs)(`section`,{children:[(0,A.jsx)(`h4`,{className:`text-xs font-semibold mb-1.5`,children:a(`installDialog.filesHeading`)}),(0,A.jsx)(`ul`,{className:`text-xs space-y-0.5 font-mono`,children:o.files.map((e,t)=>(0,A.jsxs)(`li`,{className:e.op===`create`?`text-accent-success`:`text-accent-info`,children:[e.op===`create`?`+ `:`~ `,e.path,e.summary&&(0,A.jsxs)(`span`,{className:`text-muted-foreground`,children:[` `,e.summary]})]},t))})]}),o.requirements.length>0&&(0,A.jsxs)(`section`,{children:[(0,A.jsx)(`h4`,{className:`text-xs font-semibold mb-1.5`,children:a(`installDialog.prerequisites`)}),(0,A.jsx)(`ul`,{className:`text-xs space-y-1`,children:o.requirements.map(e=>{let t=e.installed&&e.executable&&e.meetsMinimum,n=e.name===`uv`;return(0,A.jsxs)(`li`,{className:`flex items-center gap-2`,children:[t?(0,A.jsx)(i,{className:`w-3 h-3 text-accent-success`}):(0,A.jsx)(u,{className:`w-3 h-3 text-accent-warning`}),(0,A.jsxs)(`span`,{children:[e.name,e.minVersion?` ≥ ${e.minVersion}`:``]}),e.version&&(0,A.jsxs)(`span`,{className:`text-muted-foreground`,children:[`(`,e.version,`)`]}),!t&&n&&(0,A.jsxs)(`button`,{type:`button`,disabled:v===e.name,onClick:()=>O(e.name),className:`ml-auto text-[10px] px-2 py-0.5 rounded border border-border hover:bg-muted disabled:opacity-50 flex items-center gap-1`,children:[v===e.name&&(0,A.jsx)(w,{className:`w-2.5 h-2.5 animate-spin`}),a(`installDialog.autoInstall`)]})]},e.name)})}),b.length>0&&(0,A.jsx)(`pre`,{className:`mt-2 text-[11px] bg-muted/40 rounded p-2 max-h-24 overflow-auto font-mono`,children:b.join(`
|
|
2
|
-
`)})]}),h.length>0&&(0,A.jsxs)(`section`,{children:[(0,A.jsx)(`h4`,{className:`text-xs font-semibold mb-1.5`,children:a(`installDialog.progress`)}),(0,A.jsx)(`pre`,{className:`text-[11px] bg-muted/40 rounded p-2 max-h-32 overflow-auto font-mono`,children:h.join(`
|
|
3
|
-
`)})]}),p&&(0,A.jsx)(`div`,{className:`text-xs text-destructive`,children:p})]}),(0,A.jsxs)(`div`,{className:`flex justify-end gap-2 pt-2`,children:[(0,A.jsx)(`button`,{type:`button`,onClick:n,className:`text-xs px-3 py-1.5 rounded-md border border-border`,children:a(`common:actions.cancel`)}),(0,A.jsxs)(`button`,{type:`button`,disabled:!o||!j||d,onClick:async()=>{f(!0),m(null);try{let t=await fetch(`${C()}/plugins/${e}/install`,{method:`POST`});if(!t.ok)throw Error((await t.json()).error??`HTTP ${t.status}`);setTimeout(n,1500)}catch(e){m(e.message)}finally{f(!1)}},className:`text-xs px-3 py-1.5 rounded-md bg-accent-primary text-white disabled:opacity-50 flex items-center gap-1.5`,children:[d?(0,A.jsx)(w,{className:`w-3 h-3 animate-spin`}):(0,A.jsx)(t,{className:`w-3 h-3`}),a(`card.install`)]})]})]})}function G({pluginName:e,onClose:t,onUninstalled:n}){let{t:i}=r(`integrations`),[a,o]=(0,k.useState)(!1),[s,c]=(0,k.useState)(null);return(0,A.jsxs)(K,{onClose:t,title:i(`uninstallDialog.title`,{name:e}),children:[(0,A.jsx)(`p`,{className:`text-xs`,children:(0,A.jsx)(p,{t:i,i18nKey:`uninstallDialog.body`,components:{code:(0,A.jsx)(`code`,{})}})}),s&&(0,A.jsx)(`div`,{className:`text-xs text-destructive`,children:s}),(0,A.jsxs)(`div`,{className:`flex justify-end gap-2 pt-2`,children:[(0,A.jsx)(`button`,{type:`button`,onClick:t,className:`text-xs px-3 py-1.5 rounded-md border border-border`,children:i(`common:actions.cancel`)}),(0,A.jsxs)(`button`,{type:`button`,disabled:a,onClick:async()=>{o(!0);try{let t=await fetch(`${C()}/plugins/${e}`,{method:`DELETE`});if(!t.ok)throw Error((await t.json()).error??`HTTP ${t.status}`);n()}catch(e){c(e.message)}finally{o(!1)}},className:`text-xs px-3 py-1.5 rounded-md bg-destructive text-white disabled:opacity-50 flex items-center gap-1.5`,children:[a&&(0,A.jsx)(w,{className:`w-3 h-3 animate-spin`}),i(`card.uninstall`)]})]})]})}function K({title:e,onClose:t,children:r}){let{panelRef:i,panelStyle:a,headerHandleProps:o,resizeHandles:s,isFloating:c,guardBackdrop:l}=n();return(0,A.jsxs)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/40`,role:`dialog`,tabIndex:-1,onClick:l(t),children:[(0,A.jsxs)(`div`,{ref:i,className:`bg-card border border-border rounded-lg shadow-xl w-full max-w-md p-5 flex flex-col gap-3`,onClick:e=>e.stopPropagation(),style:a,children:[(0,A.jsx)(`h3`,{className:`text-sm font-semibold ${c?`cursor-grab active:cursor-grabbing`:``}`,...o,children:e}),r]}),(0,A.jsx)(O,{handles:s})]})}function q(){return(0,A.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4`,children:Array.from({length:3},(e,t)=>(0,A.jsx)(`div`,{className:`rounded-lg border border-border bg-card p-4 h-40 animate-pulse`},t))})}function J({onRetry:e}){let{t}=r(`integrations`);return(0,A.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-12 gap-3 text-sm text-muted-foreground`,children:[(0,A.jsx)(_,{className:`w-5 h-5 text-destructive`}),(0,A.jsx)(`p`,{children:t(`page.loadError`)}),(0,A.jsx)(`button`,{type:`button`,onClick:e,className:`text-xs px-3 py-1.5 rounded-md border border-border`,children:t(`common:actions.retry`)})]})}function Y(){let{t:e}=r(`integrations`);return(0,A.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-12 gap-2 text-sm text-muted-foreground`,children:[(0,A.jsx)(b,{className:`w-6 h-6`}),(0,A.jsx)(`p`,{children:e(`page.empty`)})]})}export{L as default};
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import{a as e}from"./chunk-BNv3lrIs.js";import{A as t,At as n,Cn as r,D as i,Dn as a,En as o,Ft as s,G as c,Lt as l,Nt as u,O as d,On as f,Pt as p,Qt as m,Rt as h,Sn as g,U as ee,W as _,Yt as v,Zt as y,_t as b,b as x,cn as S,f as C,jn as w,jt as T,l as te,ln as E,mt as D,nt as ne,o as O,ot as k,p as A,qt as j,rt as M,sn as re,u as N,x as P,zt as F}from"./index-B7vB20Jw.js";import{t as I}from"./lib-PQoHlR5u.js";import{t as ie}from"./format-command-D96da4fZ.js";var L=j(`clock`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 6v6l4 2`,key:`mmk7yg`}]]),R=e(w(),1),z=S();function ae({phases:e,phaseDefinitions:n}){return n.length===0?null:(0,z.jsx)(`div`,{className:`flex items-center`,children:n.map((r,a)=>{let o=e[r.key]??`idle`,s=a<n.length-1?e[n[a+1].key]??`idle`:null;return(0,z.jsxs)(`div`,{className:`flex items-center`,children:[(0,z.jsxs)(i,{children:[(0,z.jsx)(t,{asChild:!0,children:(0,z.jsxs)(`div`,{className:`flex flex-col items-center gap-1.5 cursor-default px-4`,children:[(0,z.jsx)(oe,{state:o}),(0,z.jsx)(`span`,{className:c(`text-xs font-medium transition-colors`,o===`running`?`text-blue-400 aurora-light:text-accent-info`:o===`done`?`text-emerald-400 aurora-light:text-accent-success`:o===`error`?`text-red-400 aurora-light:text-destructive`:`text-muted-foreground/40`),children:r.label})]})}),(0,z.jsxs)(d,{side:`bottom`,className:`max-w-[200px]`,children:[(0,z.jsx)(`p`,{className:`font-medium`,children:r.label}),(0,z.jsx)(`p`,{className:`text-muted-foreground mt-0.5`,children:r.description})]})]}),s!==null&&(0,z.jsx)(`div`,{className:c(`h-px w-12 -mt-5 shrink-0 transition-all duration-300`,s===`done`||o===`done`?`bg-emerald-500/30 aurora-light:bg-accent-success/40`:s===`running`?`bg-blue-400/40 aurora-light:bg-accent-info/40`:`bg-border/30`)})]},r.key)})})}function oe({state:e}){return(0,z.jsxs)(`div`,{className:c(`flex items-center justify-center w-10 h-10 rounded-full transition-all duration-300`,e===`running`?`bg-blue-500/10 aurora-light:bg-accent-info/10 ring-1 ring-blue-400/30 aurora-light:ring-accent-info/30 animate-pulse`:e===`done`?`bg-emerald-500/10 aurora-light:bg-accent-success/10`:e===`error`?`bg-red-500/10 aurora-light:bg-destructive/10`:`bg-muted/20`),children:[e===`running`&&(0,z.jsx)(D,{className:`w-6 h-6 text-blue-400 aurora-light:text-accent-info animate-spin`}),e===`done`&&(0,z.jsx)(s,{className:`w-6 h-6 text-emerald-400 aurora-light:text-accent-success`}),e===`error`&&(0,z.jsx)(p,{className:`w-6 h-6 text-red-400 aurora-light:text-destructive`}),e===`idle`&&(0,z.jsx)(u,{className:`w-6 h-6 text-muted-foreground/20`})]})}function se(e,t){let n=(typeof t==`number`?t:new Date(t).getTime())-new Date(e).getTime();if(!Number.isFinite(n)||n<0)return`—`;let r=Math.round(n/1e3);if(r<60)return`${r}s`;let i=Math.floor(r/60),a=r%60;return i<60?`${i}m ${a}s`:`${Math.floor(i/60)}h ${i%60}m`}function B(e){let t=new Set;for(let n of e)if(n.event_type===`log`)try{let e=(JSON.parse(n.payload).line??``).match(/(?:Writing|Editing|Created?|Updated?)\s+(?:file:\s*)?([\w./\-]+\.\w+)/i);e&&t.add(e[1])}catch{}return Array.from(t).slice(0,20)}var V={steps:0,actionKey:``,actionArg:``,lastSeenIdx:0};function ce(e,t){if(t.type===`reset`)return V;if(t.type===`consume`){let{events:n}=t,r=e.lastSeenIdx>n.length?n.length:e.lastSeenIdx;if(n.length<=r)return r===e.lastSeenIdx?e:{...e,lastSeenIdx:r};let{steps:i,actionKey:a,actionArg:o}=e;for(let e=r;e<n.length;e++){let t=A(n[e]);t.step&&(i+=t.stepCount??1),t.actionKey&&(a=t.actionKey,o=t.actionArg??``)}return{steps:i,actionKey:a,actionArg:o,lastSeenIdx:n.length}}return e}function le({job:e,events:t,defaultOpen:n=!0,pipelineTotals:i,phases:a,phaseDefinitions:o}){let{t:l}=r(`jobs`),[u,d]=(0,R.useState)(n),f=(0,R.useMemo)(()=>B(t),[t]),m=e.status===`running`,h=e.status===`completed`,[g,ee]=(0,R.useState)(()=>Date.now());(0,R.useEffect)(()=>{if(!m)return;let e=window.setInterval(()=>ee(Date.now()),1e3);return()=>window.clearInterval(e)},[m]);let[_,v]=(0,R.useReducer)(ce,V),y=(0,R.useRef)(e.id);(0,R.useEffect)(()=>{y.current!==e.id&&(y.current=e.id,v({type:`reset`})),v({type:`consume`,events:t})},[e.id,t]);let[b,x]=(0,R.useState)(!0);(0,R.useEffect)(()=>{if(!m)return;x(!0);let e=window.setTimeout(()=>x(!1),8e3);return()=>window.clearTimeout(e)},[m,e.id]);let S=e.finished_at?se(e.started_at,e.finished_at):m?se(e.started_at,g):`—`,w=!!e.total_cost_usd_estimated,T=e.total_cost_usd==null?null:`${w?`~`:``}$${e.total_cost_usd.toFixed(4)}`,te=e.num_turns==null?null:String(e.num_turns),E=e.tokens_in==null?null:(e.tokens_in??0)+(e.tokens_out??0)+(e.tokens_cache_read??0)+(e.tokens_cache_create??0),ne=E==null?null:`${(E/1e3).toFixed(1)}k`,O=(0,R.useMemo)(()=>!a||!o?null:o.find(e=>a[e.key]===`running`)?.label??null,[a,o]),k=m&&_.steps===0?`connecting`:_.actionKey||`thinking`,A=C.has(k)&&_.actionArg!==``,j=C.has(k)&&!A?`working`:k,M=A?l(`statusPanel.activity.${j}`,{arg:_.actionArg}):l(`statusPanel.activity.${j}`),re=O??(m&&_.steps===0?l(`statusPanel.activity.starting`):null),N=_.steps>0?l(`statusPanel.steps`,{count:_.steps}):null,P=l(m?`statusPanel.inProgress`:h?`statusPanel.completed`:`statusPanel.failed`),I=m?`border-accent-info/20 bg-accent-info/5`:h?`border-emerald-500/20 aurora-light:border-accent-success/30 bg-emerald-500/5 aurora-light:bg-accent-success/5`:`border-red-500/20 aurora-light:border-destructive/30 bg-red-500/5 aurora-light:bg-destructive/5`,ie=m?D:h?s:p,L=m?`w-4 h-4 text-accent-info shrink-0 animate-spin`:h?`w-4 h-4 text-emerald-400 aurora-light:text-accent-success shrink-0`:`w-4 h-4 text-red-400 aurora-light:text-destructive shrink-0`;return(0,z.jsxs)(`div`,{className:c(`mx-4 my-2 rounded-xl border transition-colors duration-500`,I),children:[(0,z.jsxs)(`button`,{type:`button`,onClick:()=>d(!u),className:`w-full flex items-center gap-3 px-4 py-3`,children:[(0,z.jsx)(ie,{className:L,"aria-hidden":`true`}),(0,z.jsx)(`span`,{className:`text-sm font-semibold flex-1 text-left`,children:P}),(0,z.jsxs)(`div`,{className:`flex items-center gap-3 text-[11px] text-muted-foreground`,children:[(0,z.jsx)(`span`,{className:`tabular-nums`,children:S}),m?N&&(0,z.jsx)(`span`,{className:`tabular-nums`,children:N}):(0,z.jsxs)(z.Fragment,{children:[T&&(0,z.jsx)(`span`,{className:`tabular-nums text-yellow-400 aurora-light:text-accent-warning`,children:T}),f.length>0&&(0,z.jsx)(`span`,{children:l(`statusPanel.filesCount`,{count:f.length})})]})]}),(0,z.jsx)(F,{className:c(`w-4 h-4 text-muted-foreground/40 transition-transform duration-150 shrink-0`,u&&`rotate-180`)})]}),u&&(0,z.jsx)(`div`,{className:`px-4 pb-4 space-y-3 border-t border-border/20`,children:m?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`p`,{className:`pt-3 text-[10px] text-muted-foreground/50 uppercase tracking-wider`,children:l(`statusPanel.zoneInProgress`)}),(0,z.jsxs)(`div`,{className:`flex flex-col sm:flex-row gap-3 sm:items-stretch`,children:[(0,z.jsxs)(`div`,{className:`bg-muted/20 rounded-lg px-3 py-2 sm:w-44 shrink-0`,children:[(0,z.jsxs)(`p`,{className:`flex items-center gap-1.5 text-[10px] text-muted-foreground/50 uppercase tracking-wider`,children:[l(`statusPanel.duration`),(0,z.jsx)(`span`,{className:`inline-block w-1.5 h-1.5 rounded-full bg-accent-info animate-pulse`,title:l(`statusPanel.liveTooltip`),"aria-label":l(`statusPanel.liveTooltip`)})]}),(0,z.jsx)(`p`,{className:`text-sm font-semibold tabular-nums mt-0.5 text-accent-info`,children:S})]}),(0,z.jsxs)(`div`,{className:`flex-1 flex items-center gap-2 bg-muted/10 rounded-lg px-3 py-2 min-w-0`,children:[(0,z.jsx)(D,{className:`w-3.5 h-3.5 text-accent-info shrink-0 animate-spin`,"aria-hidden":`true`}),re&&(0,z.jsx)(`span`,{className:`text-[11px] font-medium px-1.5 py-0.5 rounded bg-accent-info/15 text-accent-info shrink-0`,children:re}),(0,z.jsx)(`span`,{className:`text-xs text-muted-foreground truncate flex-1 min-w-0`,children:M}),N&&(0,z.jsxs)(`span`,{className:`text-[11px] text-muted-foreground/60 tabular-nums shrink-0`,children:[`· `,N]})]})]}),b&&(0,z.jsx)(`p`,{className:`text-[11px] text-muted-foreground/40 leading-snug`,children:l(`statusPanel.explainer`)}),(0,z.jsx)(`p`,{className:`pt-1 text-[10px] text-muted-foreground/50 uppercase tracking-wider border-t border-accent-info/10 mt-1`,children:l(`statusPanel.zoneFinalPending`)}),(0,z.jsxs)(`div`,{className:`grid grid-cols-3 gap-2`,children:[(0,z.jsx)(W,{label:l(`statusPanel.cost`),caption:l(`statusPanel.pendingCaption`),tooltip:l(`statusPanel.costTooltip`)}),(0,z.jsx)(W,{label:l(`statusPanel.turns`),caption:l(`statusPanel.pendingCaption`),tooltip:l(`statusPanel.pendingTooltip`)}),(0,z.jsx)(W,{label:l(`statusPanel.tokens`),caption:l(`statusPanel.pendingCaption`),tooltip:l(`statusPanel.pendingTooltip`)})]})]}):(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`p`,{className:`pt-3 text-[10px] text-muted-foreground/50 uppercase tracking-wider`,children:l(`statusPanel.zoneFinal`)}),(0,z.jsxs)(`div`,{className:`grid grid-cols-2 sm:grid-cols-4 gap-2`,children:[(0,z.jsx)(H,{label:l(`statusPanel.duration`),value:S}),(0,z.jsx)(U,{label:l(`statusPanel.cost`),value:T,valueClass:`text-yellow-400 aurora-light:text-accent-warning`,naCaption:l(`statusPanel.notAvailable`)}),(0,z.jsx)(U,{label:l(`statusPanel.turns`),value:te,naCaption:l(`statusPanel.notAvailable`)}),(0,z.jsx)(U,{label:l(`statusPanel.tokens`),value:ne,naCaption:l(`statusPanel.notAvailable`)})]}),i&&(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`p`,{className:`text-[10px] text-muted-foreground/50 uppercase tracking-wider mb-1.5`,children:l(`statusPanel.pipelineTotal`,{count:i.jobCount})}),(0,z.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,z.jsx)(H,{label:l(`statusPanel.totalCost`),value:`$${i.totalCostUsd.toFixed(4)}`,valueClass:`text-yellow-400 aurora-light:text-accent-warning`}),(0,z.jsx)(H,{label:l(`statusPanel.totalTokens`),value:`${((i.totalTokensIn+i.totalTokensOut+i.totalTokensCacheRead+i.totalTokensCacheCreate)/1e3).toFixed(1)}k`})]})]}),f.length>0&&(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`p`,{className:`text-[10px] text-muted-foreground/50 uppercase tracking-wider mb-1.5`,children:l(`statusPanel.filesModified`)}),(0,z.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:f.map(e=>(0,z.jsx)(`code`,{className:`text-[10px] font-mono bg-muted/30 px-2 py-0.5 rounded text-cyan-400/80 aurora-light:text-accent-info`,children:e},e))})]})]})})]})}function H({label:e,value:t,valueClass:n}){return(0,z.jsxs)(`div`,{className:`bg-muted/20 rounded-lg px-3 py-2`,children:[(0,z.jsx)(`p`,{className:`text-[10px] text-muted-foreground/50 uppercase tracking-wider`,children:e}),(0,z.jsx)(`p`,{className:c(`text-sm font-semibold tabular-nums mt-0.5`,n),children:t})]})}function U({label:e,value:t,valueClass:n,naCaption:r}){return(0,z.jsxs)(`div`,{className:`bg-muted/20 rounded-lg px-3 py-2`,children:[(0,z.jsx)(`p`,{className:`text-[10px] text-muted-foreground/50 uppercase tracking-wider`,children:e}),(0,z.jsx)(`p`,{className:c(`text-sm font-semibold tabular-nums mt-0.5`,t==null?`text-muted-foreground`:n),children:t??`—`}),t==null&&(0,z.jsx)(`p`,{className:`text-[10px] text-muted-foreground/30 mt-0.5`,children:r})]})}function W({label:e,caption:t,tooltip:n}){return(0,z.jsxs)(`div`,{className:`bg-muted/20 rounded-lg px-3 py-2 ring-1 ring-accent-info/10`,title:n,children:[(0,z.jsxs)(`p`,{className:`flex items-center gap-1 text-[10px] text-muted-foreground/50 uppercase tracking-wider`,children:[e,(0,z.jsx)(L,{className:`w-2.5 h-2.5 text-muted-foreground/30`,"aria-hidden":`true`})]}),(0,z.jsx)(`p`,{className:`text-sm font-semibold tabular-nums mt-0.5 text-muted-foreground/40`,children:`—`}),(0,z.jsx)(`p`,{className:`text-[10px] text-muted-foreground/30 mt-0.5`,children:t})]})}var G=4;function ue({tickets:e,onTicketClick:t}){let{t:n}=r(`jobs`),[i,a]=(0,R.useState)(!1);if(e.length===0)return null;let o=e.length>=G&&!i?e.slice(0,1):e,s=e.length-o.length;return(0,z.jsxs)(`div`,{className:`rounded-xl border border-border/40 bg-card/40 px-4 py-3 space-y-1.5`,children:[o.map(e=>(0,z.jsx)(K,{ticket:e,onClick:()=>t(e.id)},e.id)),s>0&&(0,z.jsxs)(`button`,{type:`button`,onClick:()=>a(!0),className:`flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground transition-colors`,children:[n(`ticketHeader.showMore`,{count:s}),(0,z.jsx)(F,{className:`w-3 h-3`})]}),i&&e.length>=G&&(0,z.jsxs)(`button`,{type:`button`,onClick:()=>a(!1),className:`flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground transition-colors`,children:[n(`ticketHeader.showLess`),(0,z.jsx)(l,{className:`w-3 h-3`})]})]})}function K({ticket:e,onClick:t}){let{t:n}=r(`jobs`),i=e.title==null,a=`inline-flex items-center px-1.5 py-0.5 rounded-md text-[11px] font-mono tabular-nums shrink-0`;return i?(0,z.jsx)(`div`,{className:`flex items-center gap-2 min-w-0`,children:(0,z.jsx)(`span`,{className:c(a,`text-muted-foreground bg-muted/20 select-none`),title:n(`ticketHeader.deletedTooltip`),children:n(`ticketHeader.deletedTicket`,{id:e.id})})}):(0,z.jsxs)(`button`,{type:`button`,onClick:t,className:`flex items-center gap-2 min-w-0 w-full text-left group`,title:e.title??void 0,children:[(0,z.jsxs)(`span`,{className:c(a,`text-accent-primary bg-accent-primary/10 group-hover:bg-accent-primary/20 transition-colors`),children:[`#`,e.id]}),(0,z.jsx)(`span`,{className:`text-lg font-semibold text-foreground truncate group-hover:text-accent-primary transition-colors`,children:e.title})]})}function q(e){let t=e.trimStart();return!!(/^#{1,6}\s/.test(t)||/^[-*+]\s/.test(t)||/^\d+\.\s/.test(t)||/^\|.+\|/.test(t)||t.startsWith("```")||t.startsWith(`> `)||/\*\*[^*]+\*\*/.test(e)||/`[^`]+`/.test(e)||/\[.+\]\(.+\)/.test(e)||/^(-{3,}|_{3,}|\*{3,})$/.test(t)||/^- \[[ x]\]\s/.test(t))}function de(e,t){let n=`${e.id??t}`,r=e.timestamp;if(e.event_type===`log`)try{let t=JSON.parse(e.payload).line??``;return t.trim()?t.startsWith(`▸`)||t.match(/^(architect|developer|reviewer|ship|analyst)\s*:/i)?{id:n,content:t,type:`phase`,timestamp:r}:e.source===`stderr`?{id:n,content:t,type:`stderr`,timestamp:r}:q(t)?{id:n,content:t,type:`assistant`,timestamp:r}:{id:n,content:t,type:`plain`,timestamp:r}:null}catch{return null}if(e.event_type!==`log`&&e.event_type!==`result`)return null;if(e.event_type===`result`)try{let t=JSON.parse(e.payload),i=[];return t.duration_ms&&i.push(`${(t.duration_ms/1e3).toFixed(1)}s`),t.total_cost_usd&&i.push(`$${t.total_cost_usd.toFixed(4)}`),t.num_turns&&i.push(m.t(`jobs:logViewer.turns`,{count:t.num_turns})),{id:n,content:`▸ ${m.t(`jobs:logViewer.completed`)}${i.length?` — ${i.join(` · `)}`:``}`,type:`result`,timestamp:r}}catch{return null}return null}function fe(e){let t=`none`,n=[];for(let r of e){let e=r.type;if(e!==`plain`&&e!==`log`){t=`none`,n.push(r);continue}let i=r.content;i.startsWith(`--- `)?(t=`saw_minus`,n.push({...r,type:`diff-meta`})):t===`saw_minus`&&i.startsWith(`+++ `)?(t=`active`,n.push({...r,type:`diff-meta`})):t===`active`&&i.startsWith(`@@ `)?n.push({...r,type:`diff-hunk`}):t===`active`&&i.startsWith(`+`)&&!i.startsWith(`+++`)?n.push({...r,type:`diff-add`}):t===`active`&&i.startsWith(`-`)&&!i.startsWith(`---`)?n.push({...r,type:`diff-remove`}):(t===`active`&&(i.startsWith(` `)||i===``)||(t=`none`),n.push(r))}return n}function J(e){let t=[{key:`__preamble__`,header:null,lines:[]}];for(let n of e)n.type===`phase`?t.push({key:n.id,header:n,lines:[]}):t[t.length-1].lines.push(n);return t.filter(e=>e.header!==null||e.lines.length>0)}function pe({events:e,isLoading:t}){let{t:n,i18n:i}=r(`jobs`),[a,o]=(0,R.useState)(``),[s,c]=(0,R.useState)(!0),[l,u]=(0,R.useState)(new Set),d=(0,R.useRef)(null),f=(0,R.useRef)(null),{processedLines:p,groups:m,totalLines:h}=(0,R.useMemo)(()=>{let t=e.map((e,t)=>de(e,t)).filter(e=>e!==null),n=[];for(let e of t){let t=n.length>0?n[n.length-1]:null;e.type===`assistant`&&t?.type===`assistant`?t.content+=`
|
|
2
|
-
`+e.content:n.push({...e})}let r=fe(n);return{processedLines:r,groups:J(r),totalLines:r.length}},[e,i.language]),ee=(0,R.useMemo)(()=>{if(!a)return h;let e=a.toLowerCase();return p.filter(t=>t.content.toLowerCase().includes(e)).length},[a,p,h]),v=(0,R.useCallback)(()=>{let e=f.current;e&&(e.scrollTop=e.scrollHeight)},[]);(0,R.useEffect)(()=>{s&&v()},[e.length,s,v]);function y(){let e=f.current;e&&c(e.scrollHeight-e.scrollTop-e.clientHeight<50)}function b(e){u(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})}return t?(0,z.jsx)(`div`,{className:`flex-1 flex items-center justify-center`,children:(0,z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:n(`logViewer.loading`)})}):h===0?(0,z.jsx)(`div`,{className:`flex-1 flex items-center justify-center`,children:(0,z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:n(`logViewer.empty`)})}):(0,z.jsxs)(`div`,{className:`flex flex-col h-full`,children:[(0,z.jsxs)(`div`,{className:`px-4 py-2 border-b border-border flex items-center gap-2`,children:[(0,z.jsxs)(`div`,{className:`relative flex-1 max-w-xs`,children:[(0,z.jsx)(M,{className:`absolute left-2.5 top-1/2 -translate-y-1/2 w-3 h-3 text-muted-foreground`}),(0,z.jsx)(O,{placeholder:n(`logViewer.filterPlaceholder`),value:a,onChange:e=>o(e.target.value),className:`pl-7 h-7`})]}),(0,z.jsx)(_,{variant:`ghost`,size:`sm`,className:`h-7 px-2 text-muted-foreground/50 hover:text-foreground`,onClick:()=>{let e=p.map(e=>e.content).join(`
|
|
3
|
-
`);navigator.clipboard.writeText(e).then(()=>{g.success(n(`logViewer.copySuccess`))}).catch(()=>{g.error(n(`logViewer.copyFailed`))})},children:(0,z.jsx)(T,{className:`w-3.5 h-3.5`})}),(0,z.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:n(`logViewer.lineCount`,{filtered:ee,total:h})})]}),(0,z.jsxs)(`div`,{ref:f,className:`flex-1 overflow-y-auto p-2 text-xs relative`,onScroll:y,children:[m.map(e=>(0,z.jsx)(Y,{group:e,filter:a,collapsed:l.has(e.key),onToggle:()=>b(e.key)},e.key)),(0,z.jsx)(`div`,{ref:d})]}),!s&&(0,z.jsxs)(_,{size:`sm`,variant:`secondary`,onClick:()=>{c(!0),v()},className:`absolute bottom-16 right-6 h-7 gap-1 shadow-lg`,children:[(0,z.jsx)(F,{className:`w-3 h-3`}),n(`logViewer.jumpToBottom`)]})]})}var Y=(0,R.memo)(function({group:e,filter:t,collapsed:n,onToggle:i}){let{t:a}=r(`jobs`),o=t?e.lines.filter(e=>e.content.toLowerCase().includes(t.toLowerCase())):e.lines;if(e.header===null)return o.length===0?null:(0,z.jsx)(`div`,{children:o.map((e,t)=>(0,z.jsx)(Z,{line:e,even:t%2==0},e.id))});let s=e.header.content;return(0,z.jsxs)(`div`,{className:`mt-3 rounded-md overflow-hidden border border-border/20`,children:[(0,z.jsxs)(`button`,{type:`button`,onClick:i,className:c(`flex items-center gap-2 w-full text-left px-3 py-2`,`bg-primary/5 border-b border-primary/20`,`hover:bg-primary/10 transition-colors duration-150 cursor-pointer`),children:[(0,z.jsx)(h,{className:c(`w-3 h-3 text-primary/60 shrink-0 transition-transform duration-150`,!n&&`rotate-90`)}),(0,z.jsx)(`span`,{className:`flex-1 text-[12px] font-semibold text-foreground leading-none`,children:s}),e.header.timestamp&&(0,z.jsx)(`span`,{className:`text-[10px] text-muted-foreground/40 font-mono tabular-nums shrink-0`,children:new Date(e.header.timestamp).toLocaleTimeString(`en`,{hour:`2-digit`,minute:`2-digit`,second:`2-digit`,hour12:!1})}),(0,z.jsx)(`span`,{className:`text-[10px] text-muted-foreground/40 shrink-0`,children:a(`logViewer.phaseLines`,{count:e.lines.length})})]}),!n&&(0,z.jsx)(`div`,{className:`bg-muted/5`,children:o.length===0?(0,z.jsx)(`p`,{className:`px-4 py-2 text-[10px] text-muted-foreground/40 italic`,children:a(t?`logViewer.noMatchingLines`:`logViewer.noOutput`)}):o.map((e,t)=>(0,z.jsx)(Z,{line:e,even:t%2==0},e.id))})]})}),X=[I],Z=(0,R.memo)(function({line:e,even:t}){let n=e.type===`assistant`,r=e.type===`diff-add`,i=e.type===`diff-remove`,a=e.type===`diff-meta`,o=e.type===`diff-hunk`;return(0,z.jsxs)(`div`,{className:c(`flex items-start gap-2 group px-2 py-0.5 rounded-sm`,!(r||i||a||o)&&(t?`bg-muted/20`:`bg-transparent`),e.type===`result`&&`bg-emerald-500/5 aurora-light:bg-accent-success/10 border-l-2 border-emerald-500/40 aurora-light:border-accent-success/40 mt-2 py-2`,r&&`bg-emerald-500/8 aurora-light:bg-accent-success/10 border-l-2 border-emerald-500/50 aurora-light:border-accent-success/50`,i&&`bg-red-500/8 aurora-light:bg-destructive/10 border-l-2 border-red-500/50 aurora-light:border-destructive/50`,a&&`bg-accent-primary/5 border-l-2 border-accent-primary/30`,o&&`bg-accent-info/5 border-l-2 border-accent-info/30`),children:[e.timestamp&&(0,z.jsx)(`span`,{className:`text-[10px] text-muted-foreground/40 shrink-0 mt-0.5 w-[52px] font-mono tabular-nums`,children:new Date(e.timestamp).toLocaleTimeString(`en`,{hour:`2-digit`,minute:`2-digit`,second:`2-digit`,hour12:!1})}),n?(0,z.jsx)(`div`,{className:`flex-1 min-w-0 prose prose-invert prose-xs max-w-none
|
|
4
|
-
prose-p:my-1 prose-p:leading-relaxed
|
|
5
|
-
prose-headings:mt-2 prose-headings:mb-1 prose-headings:text-sm prose-headings:font-semibold
|
|
6
|
-
prose-ul:my-1 prose-ol:my-1 prose-li:my-0
|
|
7
|
-
prose-code:text-cyan-300 prose-code:text-[11px] prose-code:bg-muted/40 prose-code:px-1 prose-code:py-0.5 prose-code:rounded
|
|
8
|
-
prose-pre:my-1 prose-pre:bg-muted/30 prose-pre:rounded-md prose-pre:p-2 prose-pre:text-[11px]
|
|
9
|
-
prose-strong:text-foreground prose-em:text-foreground/70
|
|
10
|
-
prose-a:text-blue-400 prose-a:no-underline hover:prose-a:underline
|
|
11
|
-
prose-table:my-2 prose-table:text-[11px]
|
|
12
|
-
prose-thead:border-border prose-thead:bg-muted/30
|
|
13
|
-
prose-th:px-3 prose-th:py-1.5 prose-th:text-left prose-th:font-semibold prose-th:text-foreground/90
|
|
14
|
-
prose-td:px-3 prose-td:py-1.5 prose-td:border-border
|
|
15
|
-
prose-tr:border-border
|
|
16
|
-
text-foreground/80`,children:(0,z.jsx)(P,{remarkPlugins:[x],rehypePlugins:X,children:e.content})}):(0,z.jsx)(`span`,{className:c(`flex-1 break-all leading-relaxed whitespace-pre-wrap font-mono`,e.type===`tool-use`&&`text-cyan-400/80 aurora-light:text-accent-info text-[11px]`,e.type===`stderr`&&`text-orange-400 aurora-light:text-accent-warning`,e.type===`result`&&`text-emerald-400 aurora-light:text-accent-success font-medium`,e.type===`log`&&`text-foreground/60`,e.type===`plain`&&`text-foreground/70`,e.type===`tool-result`&&`text-muted-foreground/50`,r&&`text-emerald-400 aurora-light:text-accent-success`,i&&`text-red-400 aurora-light:text-destructive`,a&&`text-accent-primary/80`,o&&`text-accent-info/80`),children:e.content})]})}),me={running:{variant:`running`,labelKey:`statusLabel.running`,tooltipKey:`statusTooltip.running`},completed:{variant:`success`,labelKey:`statusLabel.completed`,tooltipKey:`statusTooltip.completed`},failed:{variant:`failed`,labelKey:`statusLabel.failed`,tooltipKey:`statusTooltip.failed`},canceled:{variant:`canceled`,labelKey:`statusLabel.canceled`,tooltipKey:`statusTooltip.canceled`},queued:{variant:`queued`,labelKey:`statusLabel.queued`,tooltipKey:`statusTooltip.queued`}};function Q(){let{t:e}=r(`jobs`),{id:l}=f(),{activeProjectId:u,projects:p}=v(),m=p.find(e=>e.id===u)?.provider,x=a(),{openTicketDetail:S}=te(),[C,w]=(0,R.useState)(null),[T,O]=(0,R.useState)([]),[A,j]=(0,R.useState)([]),[M,P]=(0,R.useState)({}),[F,I]=(0,R.useState)([]),[L,oe]=(0,R.useState)(!0),[se,B]=(0,R.useState)(!1),[V,ce]=(0,R.useState)(null),[H,U]=(0,R.useState)(!1),[W,G]=(0,R.useState)(``),[K,q]=(0,R.useState)(!1),[de,fe]=(0,R.useState)(!1);(0,R.useEffect)(()=>{if(!l)return;let e=new AbortController;w(null),O([]),j([]),P({}),oe(!0),B(!1);async function t(){try{let t=await fetch(`${E()}/jobs/${l}`,{signal:e.signal});if(t.status===404){B(!0);return}if(!t.ok)throw Error(`Failed to fetch job`);let n=await t.json();w(n.job),O(n.events)}catch(e){if(e.name===`AbortError`)return;B(!0)}finally{e.signal.aborted||oe(!1)}}return t(),()=>e.abort()},[l,u]),(0,R.useEffect)(()=>{if(!C?.pipeline_id){I([]);return}let e=C.pipeline_id;fetch(`${E()}/pipelines/${e}`).then(e=>e.ok?e.json():null).then(e=>{e?.jobs&&I(e.jobs)}).catch(()=>{})},[C?.pipeline_id,C?.status]);let J=(0,R.useRef)(u);J.current=u;let Y=(0,R.useRef)([]),X=(0,R.useRef)(null),Z=(0,R.useCallback)(()=>{X.current=null;let e=Y.current;e.length!==0&&(Y.current=[],O(t=>{let n=[...t,...e];return n.length>1e4?n.slice(n.length-8e3):n}))},[]),Q=(0,R.useCallback)(e=>{let t=Y.current;t.push(e),t.length>1e4&&(Y.current=t.slice(-8e3)),X.current||=requestAnimationFrame(Z)},[Z]);(0,R.useEffect)(()=>()=>{X.current&&cancelAnimationFrame(X.current)},[]);let he=(0,R.useCallback)(e=>{let t=e;if(!(J.current&&t.projectId&&t.projectId!==J.current)){if(t.type===`init`){let e=t.phaseDefinitions??[];j(e);let n={};for(let r of e)n[r.key]=t.phases?.[r.key]??`idle`;P(n)}else if(t.type===`event`&&t.jobId===l)Q({id:Date.now(),job_id:l??``,seq:t.seq??0,event_type:t.event_type,source:t.source,payload:t.payload,timestamp:t.timestamp});else if(t.type===`log`&&t.processId===l)Q({id:Date.now(),job_id:l??``,seq:0,event_type:`log`,source:t.source,payload:JSON.stringify({line:t.line}),timestamp:t.timestamp});else if(t.type===`job.turn_user`&&t.jobId===l)U(!0);else if(t.type===`job.turn_done`&&t.jobId===l)ce(t.totals),U(!1);else if(t.type===`job.finalized`&&t.jobId===l){U(!1),q(!1);let e=t.totals;e&&ce(e),fetch(`${E()}/jobs/${l}`).then(e=>e.json()).then(e=>w(e.job)).catch(()=>{})}else if(t.type===`phase`){let e=t.phase,n=t.state;P(t=>({...t,[e]:n}))}else if(t.type===`queue`){let e=t.jobs?.find(e=>e.id===l);if(e){let t=e.status;w(e=>e&&{...e,status:t}),(t===`completed`||t===`failed`||t===`canceled`)&&fetch(`${E()}/jobs/${l}`).then(e=>e.json()).then(e=>w(e.job)).catch(()=>{})}}}},[l,Q]),{registerHandler:ge,unregisterHandler:_e}=re();(0,R.useEffect)(()=>(ge(`job-detail-${l}`,he),()=>_e(`job-detail-${l}`)),[l,he,ge,_e]),(0,R.useEffect)(()=>{if(!l||!C||C.status!==`running`||C.hasTelemetry)return;let e=setInterval(()=>{fetch(`${E()}/jobs/${l}`).then(e=>e.ok?e.json():null).then(e=>{e?.job?.hasTelemetry&&w(e=>e&&{...e,hasTelemetry:!0})}).catch(()=>{})},8e3);return()=>clearInterval(e)},[l,C?.status,C?.hasTelemetry]);async function ve(){if(l)try{let t=await fetch(`${E()}/jobs/${l}`,{method:`DELETE`});if(t.ok)(await t.json()).status===`deleted`?(g.success(e(`detail.toast.jobDeleted`)),x(`/jobs`)):g.success(e(`detail.toast.cancelSignalSent`),{description:e(`detail.toast.cancelSignalSentDescription`)});else{let n=await t.json();g.error(e(`detail.toast.failed`),{description:n.error})}}catch{g.error(e(`detail.toast.networkError`))}}async function ye(){if(!(!l||K)){q(!0);try{let t=await fetch(`${E()}/jobs/${l}/finalize`,{method:`POST`});if(t.ok)g.success(e(`detail.toast.finalizeScheduled`));else{let n=await t.json().catch(()=>({}));g.error(e(`detail.toast.finalizeFailed`),{description:n.error}),q(!1)}}catch{g.error(e(`detail.toast.networkError`)),q(!1)}}}async function be(){let t=W.trim();if(!(!l||!t||de)){fe(!0);try{let n=await fetch(`${E()}/jobs/${l}/messages`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({text:t})});if(n.ok)G(``);else{let t=await n.json().catch(()=>({}));g.error(e(`detail.toast.sendFailed`),{description:t.error})}}catch{g.error(e(`detail.toast.networkError`))}finally{fe(!1)}}}async function xe(){if(C)try{let t=await fetch(`${E()}/jobs/${C.id}/diagnostic`);if(!t.ok){let n=await t.json().catch(()=>({}));throw Error(n.error??e(`detail.toast.exportFailedHttp`,{status:t.status}))}let n=await t.blob(),r=URL.createObjectURL(n),i=new Date().toISOString().slice(0,10),a=document.createElement(`a`);a.href=r,a.download=`specrails-diagnostic-${C.id}-${i}.zip`,document.body.appendChild(a),a.click(),a.remove(),URL.revokeObjectURL(r)}catch(t){g.error(e(`detail.toast.exportFailed`),{description:t.message})}}async function Se(){if(C)try{let t=await fetch(`${E()}/spawn`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({command:C.command})}),n=await t.json();if(!t.ok)throw Error(n.error??e(`detail.toast.spawnFailed`));g.success(e(`detail.toast.jobRequeued`)),x(`/jobs/${n.jobId}`)}catch(e){g.error(e.message)}}if(L)return(0,z.jsx)(`div`,{className:`max-w-5xl mx-auto px-4 py-6`,children:(0,z.jsxs)(`div`,{className:`space-y-3`,children:[(0,z.jsx)(`div`,{className:`h-4 w-48 bg-muted/30 rounded animate-pulse`}),(0,z.jsx)(`div`,{className:`h-20 bg-muted/30 rounded-lg animate-pulse`}),(0,z.jsx)(`div`,{className:`h-64 bg-muted/30 rounded-lg animate-pulse`})]})});if(se||!C)return(0,z.jsxs)(`div`,{className:`max-w-5xl mx-auto px-4 py-6 flex flex-col items-center gap-3 mt-12`,children:[(0,z.jsx)(`p`,{className:`text-lg font-semibold`,children:e(`detail.notFound`)}),(0,z.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e(`detail.notFoundDescription`,{id:l})}),(0,z.jsx)(_,{asChild:!0,variant:`outline`,size:`sm`,children:(0,z.jsxs)(o,{to:`/`,children:[(0,z.jsx)(b,{className:`w-3.5 h-3.5 mr-1.5`}),e(`detail.backToDashboard`)]})})]});let $=me[C.status]??me.queued,Ce=C.status===`running`,we=C.status===`completed`||C.status===`failed`,Te=!!C.interactive,Ee=Te&&Ce,De=(C.tickets?.length??0)>0,Oe=F.length>1?{totalCostUsd:F.reduce((e,t)=>e+(t.total_cost_usd??0),0),totalTokensIn:F.reduce((e,t)=>e+(t.tokens_in??0),0),totalTokensOut:F.reduce((e,t)=>e+(t.tokens_out??0),0),totalTokensCacheRead:F.reduce((e,t)=>e+(t.tokens_cache_read??0),0),totalTokensCacheCreate:F.reduce((e,t)=>e+(t.tokens_cache_create??0),0),jobCount:F.length}:null;return(0,z.jsxs)(`div`,{"data-job-detail-surface":!0,className:`flex flex-col h-full max-w-5xl mx-auto w-full`,children:[(0,z.jsxs)(`div`,{className:`px-4 py-4 border-b border-border space-y-3`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-1 text-xs text-muted-foreground`,children:[(0,z.jsxs)(o,{to:`/`,className:`hover:text-foreground transition-colors flex items-center gap-1`,children:[(0,z.jsx)(b,{className:`w-3 h-3`}),e(`detail.breadcrumbDashboard`)]}),(0,z.jsx)(h,{className:`w-3 h-3`}),(0,z.jsx)(`span`,{className:`text-foreground font-mono`,children:e(`detail.breadcrumbJob`,{id:l?.slice(0,8)})})]}),De&&(0,z.jsx)(ue,{tickets:C.tickets??[],onTicketClick:S}),(0,z.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,z.jsxs)(`div`,{className:`space-y-1 min-w-0`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,z.jsxs)(i,{children:[(0,z.jsx)(t,{asChild:!0,children:(0,z.jsx)(`div`,{children:(0,z.jsx)(ee,{variant:$.variant,children:e($.labelKey)})})}),(0,z.jsx)(d,{children:e($.tooltipKey)})]}),(0,z.jsx)(`code`,{className:c(`font-mono text-foreground/90 truncate`,De?`text-xs text-muted-foreground`:`text-sm`),children:ie(C.command,m)})]}),(0,z.jsxs)(`div`,{className:`flex items-center gap-3 text-xs text-muted-foreground flex-wrap`,children:[(0,z.jsx)(`span`,{children:C.started_at?e(`detail.startedAgo`,{timeAgo:N(new Date(C.started_at),{addSuffix:!0,locale:y()})}):e(`detail.queuedWaiting`)}),C.model&&(0,z.jsx)(`span`,{className:`text-muted-foreground/40`,children:C.model})]})]}),(0,z.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[C.hasTelemetry&&(0,z.jsxs)(i,{children:[(0,z.jsx)(t,{asChild:!0,children:(0,z.jsxs)(_,{variant:`outline`,size:`sm`,className:`h-7`,onClick:xe,"aria-label":e(`detail.exportDiagnosticAria`),children:[(0,z.jsx)(n,{className:`w-3.5 h-3.5 mr-1.5`}),e(`detail.exportDiagnostic`)]})}),(0,z.jsx)(d,{children:e(`detail.exportDiagnosticTooltip`)})]}),we&&(0,z.jsxs)(i,{children:[(0,z.jsx)(t,{asChild:!0,children:(0,z.jsxs)(_,{variant:`outline`,size:`sm`,onClick:Se,className:`h-7`,children:[(0,z.jsx)(k,{className:`w-3.5 h-3.5 mr-1.5`}),e(`detail.reExecute`)]})}),(0,z.jsx)(d,{children:e(`detail.reExecuteTooltip`)})]}),Ee&&(0,z.jsxs)(i,{children:[(0,z.jsx)(t,{asChild:!0,children:(0,z.jsxs)(_,{variant:`outline`,size:`sm`,onClick:ye,disabled:K,className:`h-7 border-accent-success/40 text-accent-success hover:bg-accent-success/10`,children:[(0,z.jsx)(s,{className:`w-3.5 h-3.5 mr-1.5`}),e(K?`detail.finalizing`:`detail.finalizeJob`)]})}),(0,z.jsx)(d,{children:e(`detail.finalizeJobTooltip`)})]}),Ce&&(0,z.jsxs)(i,{children:[(0,z.jsx)(t,{asChild:!0,children:(0,z.jsx)(_,{variant:`outline`,size:`sm`,onClick:ve,className:`h-7 border-destructive/30 text-destructive hover:bg-destructive/10`,children:e(Te?`detail.cancelInteractive`:`detail.cancelJob`)})}),(0,z.jsx)(d,{children:e(`detail.cancelJobTooltip`)})]})]})]}),(0,z.jsx)(ae,{phases:M,phaseDefinitions:A})]}),(C.status===`running`||C.status===`completed`||C.status===`failed`)&&(0,z.jsx)(le,{job:C,events:T,defaultOpen:C.status===`completed`||C.status===`running`,pipelineTotals:Oe??void 0,phases:M,phaseDefinitions:A}),(0,z.jsx)(`div`,{className:`flex-1 overflow-hidden relative`,children:(0,z.jsx)(pe,{events:T})}),Ee&&(0,z.jsxs)(`div`,{className:`shrink-0 border-t border-border/40 bg-surface/40 px-3 py-2 space-y-2`,children:[(0,z.jsxs)(`div`,{className:`flex items-center justify-between text-[11px] text-muted-foreground`,children:[(0,z.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[H&&(0,z.jsx)(D,{className:`w-3 h-3 animate-spin`}),e(H?`detail.interactive.working`:`detail.interactive.ready`)]}),V&&(0,z.jsx)(`span`,{className:`tabular-nums`,children:e(`detail.interactive.liveTotals`,{turns:V.num_turns,cost:V.total_cost_usd.toFixed(4)})})]}),(0,z.jsxs)(`div`,{className:`flex items-end gap-2`,children:[(0,z.jsx)(`textarea`,{value:W,onChange:e=>G(e.target.value),onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),be())},rows:2,placeholder:e(`detail.interactive.placeholder`),"aria-label":e(`detail.interactive.placeholder`),className:`flex-1 resize-none rounded-md border border-border/50 bg-background px-2.5 py-1.5 text-sm focus:outline-none focus:ring-2 focus:ring-ring`}),(0,z.jsxs)(_,{size:`sm`,onClick:()=>void be(),disabled:de||!W.trim(),className:`h-9 shrink-0`,children:[(0,z.jsx)(ne,{className:`w-3.5 h-3.5 mr-1.5`}),e(`detail.interactive.send`)]})]})]})]})}export{Q as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as e}from"./chunk-BNv3lrIs.js";import{A as t,B as n,Cn as r,D as i,Dn as a,F as o,Ft as s,I as c,L as l,Mt as u,N as d,O as f,P as p,Pt as m,R as h,Sn as g,U as _,W as v,X as y,Xt as b,Yt as x,Zt as S,b as C,cn as w,ht as T,jn as E,ln as D,n as ee,q as te,qt as O,u as k,x as A,z as j}from"./index-B7vB20Jw.js";import{t as M}from"./ExportDropdown-C-o1Q4ef.js";import{t as ne}from"./format-command-D96da4fZ.js";var re=O(`git-compare-arrows`,[[`circle`,{cx:`5`,cy:`6`,r:`3`,key:`1qnov2`}],[`path`,{d:`M12 6h5a2 2 0 0 1 2 2v7`,key:`1yj91y`}],[`path`,{d:`m15 9-3-3 3-3`,key:`1lwv8l`}],[`circle`,{cx:`19`,cy:`18`,r:`3`,key:`1qljk2`}],[`path`,{d:`M12 18H7a2 2 0 0 1-2-2V9`,key:`16sdep`}],[`path`,{d:`m9 15 3 3-3 3`,key:`1m3kbl`}]]),N=e(E(),1),P=w();function F(e){if(e==null)return`—`;let t=Math.round(e/1e3);return t<60?`${t}s`:`${Math.floor(t/60)}m ${t%60}s`}function I(e){return e==null?`—`:e===0?`$0`:e<.01?`$${e.toFixed(4)}`:`$${e.toFixed(3)}`}function L(e){return e==null?`—`:e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}function R({label:e,a:t,b:n,highlight:r}){return(0,P.jsxs)(`div`,{className:`grid grid-cols-3 gap-2 py-2 border-b border-border/20 last:border-0 text-xs`,children:[(0,P.jsx)(`span`,{className:`text-muted-foreground`,children:e}),(0,P.jsx)(`span`,{className:`font-mono text-right ${r===`a`?`text-emerald-400 aurora-light:text-accent-success font-semibold`:``}`,children:t}),(0,P.jsx)(`span`,{className:`font-mono text-right ${r===`b`?`text-emerald-400 aurora-light:text-accent-success font-semibold`:``}`,children:n})]})}function z(e,t,n=!0){return e==null||t==null||e===t?null:n?e<t?`a`:`b`:e>t?`a`:`b`}function ie({jobIds:e,onClose:t}){let{t:i}=r(`jobs`),[a,o]=(0,N.useState)(null),[c,l]=(0,N.useState)(!0),[u,d]=(0,N.useState)(null),{panelRef:f,panelStyle:p,headerHandleProps:h,resizeHandles:g,isFloating:_,guardBackdrop:v}=n();(0,N.useEffect)(()=>{let t=new AbortController;return fetch(`${D()}/jobs/compare?jobIds=${e.join(`,`)}`,{signal:t.signal}).then(e=>{if(!e.ok)throw Error(`HTTP ${e.status}`);return e.json()}).then(e=>{o(e),l(!1)}).catch(e=>{e.name!==`AbortError`&&(d(e.message),l(!1))}),()=>t.abort()},[e]);function y(e,t){return(0,P.jsxs)(`div`,{className:`text-center space-y-1`,children:[(0,P.jsx)(`p`,{className:`text-[10px] text-muted-foreground font-medium uppercase tracking-wider`,children:i(`comparison.jobN`,{n:t+1})}),(0,P.jsx)(`code`,{className:`text-[10px] text-foreground/70 block truncate max-w-[160px] mx-auto`,children:e.command}),(0,P.jsxs)(`div`,{className:`flex items-center justify-center gap-1 text-[10px]`,children:[e.status===`completed`?(0,P.jsx)(s,{className:`w-3 h-3 text-emerald-400 aurora-light:text-accent-success`}):(0,P.jsx)(m,{className:`w-3 h-3 text-rose-400 aurora-light:text-destructive`}),(0,P.jsx)(`span`,{className:`capitalize text-muted-foreground`,children:i(`statusLabel.${e.status}`,{defaultValue:e.status})})]}),(0,P.jsx)(`p`,{className:`text-[10px] text-muted-foreground font-mono`,children:e.id.slice(0,8)})]})}return(0,P.jsxs)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm`,onClick:v(t),children:[(0,P.jsxs)(`div`,{ref:f,className:`w-full max-w-lg rounded-xl border border-border/30 bg-popover p-5 shadow-xl space-y-4 mx-4`,onClick:e=>e.stopPropagation(),style:p,children:[(0,P.jsxs)(`div`,{className:`flex items-center justify-between ${_?`cursor-grab active:cursor-grabbing`:``}`,...h,children:[(0,P.jsx)(`h2`,{className:`text-sm font-semibold`,children:i(`comparison.title`)}),(0,P.jsx)(`button`,{type:`button`,onClick:t,className:`text-muted-foreground hover:text-foreground transition-colors`,children:(0,P.jsx)(te,{className:`w-4 h-4`})})]}),c&&(0,P.jsx)(`div`,{className:`space-y-2`,children:[0,1,2,3].map(e=>(0,P.jsx)(`div`,{className:`h-8 bg-muted/20 rounded animate-pulse`},e))}),u&&(0,P.jsx)(`p`,{className:`text-xs text-red-400 aurora-light:text-destructive`,children:i(`comparison.loadFailed`,{error:u})}),a&&(()=>{let[e,t]=a.jobs,n=z(e.durationMs,t.durationMs,!0),r=z(e.totalCostUsd,t.totalCostUsd,!0),o=z(e.tokensOut==null?null:e.tokensOut,t.tokensOut==null?null:t.tokensOut,!0);return(0,P.jsxs)(`div`,{children:[(0,P.jsxs)(`div`,{className:`grid grid-cols-3 gap-2 pb-3 border-b border-border/30 mb-1`,children:[(0,P.jsx)(`div`,{}),y(e,0),y(t,1)]}),(0,P.jsx)(R,{label:i(`comparison.duration`),a:F(e.durationMs),b:F(t.durationMs),highlight:n}),(0,P.jsx)(R,{label:i(`comparison.cost`),a:I(e.totalCostUsd),b:I(t.totalCostUsd),highlight:r}),(0,P.jsx)(R,{label:i(`comparison.tokensOut`),a:L(e.tokensOut),b:L(t.tokensOut),highlight:o}),(0,P.jsx)(R,{label:i(`comparison.tokensIn`),a:L(e.tokensIn),b:L(t.tokensIn),highlight:null}),(0,P.jsx)(R,{label:i(`comparison.cacheRead`),a:L(e.tokensCacheRead),b:L(t.tokensCacheRead),highlight:null}),(0,P.jsx)(R,{label:i(`comparison.model`),a:e.model??`—`,b:t.model??`—`,highlight:null}),(0,P.jsx)(R,{label:i(`comparison.phasesDone`),a:e.phasesCompleted.length>0?e.phasesCompleted.join(`, `):`—`,b:t.phasesCompleted.length>0?t.phasesCompleted.join(`, `):`—`,highlight:null})]})})(),a&&(0,P.jsx)(`p`,{className:`text-[10px] text-muted-foreground/60 text-center`,children:i(`comparison.betterValueHint`)})]}),(0,P.jsx)(j,{handles:g})]})}var ae={running:{variant:`running`,labelKey:`statusLabel.running`,tooltipKey:`statusTooltip.running`},completed:{variant:`success`,labelKey:`statusLabel.done`,tooltipKey:`statusTooltip.completed`},failed:{variant:`failed`,labelKey:`statusLabel.failed`,tooltipKey:`statusTooltip.failed`},canceled:{variant:`canceled`,labelKey:`statusLabel.canceled`,tooltipKey:`statusTooltip.canceled`},queued:{variant:`queued`,labelKey:`statusLabel.queued`,tooltipKey:`statusTooltip.queuedToRun`},zombie_terminated:{variant:`failed`,labelKey:`statusLabel.zombie`,tooltipKey:`statusTooltip.zombie`},skipped:{variant:`warning`,labelKey:`statusLabel.skipped`,tooltipKey:`statusTooltip.skipped`}},oe=[`running`,`completed`,`failed`,`canceled`,`zombie_terminated`,`queued`,`skipped`],se={critical:{className:`bg-red-500/15 aurora-light:bg-destructive/10 text-red-400 aurora-light:text-destructive border-red-500/30 aurora-light:border-destructive/30`,labelKey:`recent.priority.critical`},high:{className:`bg-orange-500/15 aurora-light:bg-accent-warning/10 text-orange-400 aurora-light:text-accent-warning border-orange-500/30 aurora-light:border-accent-warning/30`,labelKey:`recent.priority.high`},normal:{className:``,labelKey:`recent.priority.normal`},low:{className:`bg-gray-500/15 aurora-light:bg-muted text-gray-400 aurora-light:text-muted-foreground border-gray-500/30 aurora-light:border-border`,labelKey:`recent.priority.low`}};function ce(e){return e==null||e===0?null:e<.01?`$${e.toFixed(4)}`:`$${e.toFixed(3)}`}function le(e,t){if(!t)return null;let n=new Date(t).getTime()-new Date(e).getTime();if(n<0)return null;let r=Math.round(n/1e3);if(r<60)return`${r}s`;let i=Math.floor(r/60),a=r%60;return i<60?`${i}m ${a}s`:`${Math.floor(i/60)}h ${i%60}m`}function ue(e){return e==null||e===0?null:e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}function de(e){try{return k(new Date(e),{addSuffix:!0,locale:S()})}catch{return e}}var B=10;function V({jobs:e,isLoading:s,onJobsCleared:m,onProposalClick:b,onProposalDelete:S}){let{t:C}=r(`jobs`),w=a(),{activeProjectId:E,projects:ee}=x(),te=ee.find(e=>e.id===E)?.provider,[O,k]=(0,N.useState)(null),[A,M]=(0,N.useState)(``),[F,I]=(0,N.useState)(``),[L,R]=(0,N.useState)(!1),[z,V]=(0,N.useState)(``),[H,U]=(0,N.useState)(``),[W,G]=(0,N.useState)(!1),[K,q]=(0,N.useState)(null),[J,fe]=(0,N.useState)(B),[Y,pe]=(0,N.useState)(!1),[X,Z]=(0,N.useState)([]),[me,Q]=(0,N.useState)(null),{panelRef:he,panelStyle:ge,headerHandleProps:_e,resizeHandles:ve,isFloating:ye,guardBackdrop:be}=n();(0,N.useEffect)(()=>{fe(B)},[e.length]);function xe(){pe(e=>!e),Z([])}function Se(e){Z(t=>{if(t.includes(e))return t.filter(t=>t!==e);if(t.length>=2)return t;let n=[...t,e];return n.length===2&&Q(n),n})}let $=e.filter(e=>!(O&&e.status!==O||A&&e.started_at<A||F&&e.started_at>`${F}T23:59:59`)),Ce=e.filter(e=>!(z&&e.started_at<z||H&&e.started_at>`${H}T23:59:59`)).length;async function we(e){G(!0);try{let t={};e===`range`&&(z&&(t.from=z),H&&(t.to=H));let n=await fetch(`${D()}/jobs`,{method:`DELETE`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)});if(n.ok){let e=await n.json();g.success(C(`recent.toast.cleared`,{count:e.deleted})),R(!1),V(``),U(``),m?.()}else g.error(C(`recent.toast.clearFailed`))}catch{g.error(C(`recent.toast.networkError`))}finally{G(!1)}}return s?(0,P.jsx)(`div`,{className:`rounded-lg border border-border/40 bg-card/50 p-4 space-y-1`,children:[0,1,2].map(e=>(0,P.jsx)(`div`,{className:`h-9 bg-muted/30 rounded-md animate-pulse`},e))}):e.length===0?(0,P.jsxs)(`div`,{className:`rounded-lg border border-dashed border-border/40 bg-card/50 p-8 text-center space-y-2`,children:[(0,P.jsx)(u,{className:`w-8 h-8 text-muted-foreground/30 mx-auto`}),(0,P.jsx)(`p`,{className:`text-sm font-medium text-muted-foreground`,children:C(`recent.emptyTitle`)}),(0,P.jsx)(`p`,{className:`text-xs text-muted-foreground/60`,children:C(`recent.emptyDescription`)})]}):(0,P.jsxs)(`div`,{className:`rounded-lg border border-border/40 bg-card/50 p-4 space-y-2`,children:[(0,P.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,P.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,P.jsx)(`button`,{type:`button`,onClick:()=>k(null),className:`px-2 py-0.5 rounded text-[10px] font-medium transition-colors ${O===null?`bg-accent text-foreground`:`text-muted-foreground hover:text-foreground hover:bg-accent/50`}`,children:C(`recent.filterAll`,{count:e.length})}),oe.map(t=>{let n=e.filter(e=>e.status===t).length;return n===0?null:(0,P.jsx)(`button`,{type:`button`,onClick:()=>k(O===t?null:t),className:`px-2 py-0.5 rounded text-[10px] font-medium capitalize transition-colors ${O===t?`bg-accent text-foreground`:`text-muted-foreground hover:text-foreground hover:bg-accent/50`}`,children:C(`recent.filterStatus`,{status:C(`statusName.${t}`),count:n})},t)})]}),(0,P.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,P.jsx)(`input`,{type:`date`,value:A,onChange:e=>M(e.target.value),className:`h-6 rounded border border-border bg-input px-1.5 text-[10px] text-foreground`,title:C(`recent.fromDate`)}),(0,P.jsx)(`input`,{type:`date`,value:F,onChange:e=>I(e.target.value),className:`h-6 rounded border border-border bg-input px-1.5 text-[10px] text-foreground`,title:C(`recent.toDate`)}),(A||F)&&(0,P.jsx)(`button`,{type:`button`,onClick:()=>{M(``),I(``)},className:`text-[10px] text-muted-foreground hover:text-foreground transition-colors`,children:C(`recent.clear`)}),(0,P.jsxs)(i,{children:[(0,P.jsx)(t,{asChild:!0,children:(0,P.jsx)(v,{variant:`ghost`,size:`sm`,className:`h-6 w-6 p-0 transition-colors ${Y?`text-foreground bg-accent`:`text-muted-foreground hover:text-foreground`}`,onClick:xe,children:(0,P.jsx)(re,{className:`w-3.5 h-3.5`})})}),(0,P.jsx)(f,{children:C(Y?`recent.exitCompareMode`:`recent.compareTwoJobs`)})]}),(0,P.jsxs)(i,{children:[(0,P.jsx)(t,{asChild:!0,children:(0,P.jsx)(v,{variant:`ghost`,size:`sm`,className:`h-6 w-6 p-0 text-muted-foreground hover:text-destructive`,onClick:()=>R(!0),children:(0,P.jsx)(y,{className:`w-3.5 h-3.5`})})}),(0,P.jsx)(f,{children:C(`recent.clearJobs`)})]})]})]}),Y&&(0,P.jsxs)(`div`,{className:`flex items-center justify-between rounded-md bg-accent/40 px-3 py-1.5 text-[10px] text-muted-foreground`,children:[(0,P.jsxs)(`span`,{children:[X.length===0&&C(`recent.selectTwoToCompare`),X.length===1&&C(`recent.selectOneMore`),X.length===2&&C(`recent.readyToCompare`)]}),X.length===2&&(0,P.jsx)(`button`,{type:`button`,className:`text-[10px] font-medium text-foreground hover:underline`,onClick:()=>Q(X),children:C(`recent.compareAction`)})]}),(0,P.jsxs)(`div`,{className:`flex items-center gap-3 px-3 py-1 text-[10px] font-medium text-muted-foreground uppercase tracking-wider`,children:[(0,P.jsx)(`span`,{className:`w-14`,children:C(`recent.colStatus`)}),(0,P.jsx)(`span`,{className:`flex-1 min-w-0`,children:C(`recent.colCommand`)}),(0,P.jsxs)(`div`,{className:`flex items-center gap-3 shrink-0`,children:[(0,P.jsx)(`span`,{className:`w-14 text-right`,children:C(`recent.colDuration`)}),(0,P.jsx)(`span`,{className:`w-12 text-right`,children:C(`recent.colTokens`)}),(0,P.jsx)(`span`,{className:`w-12 text-right`,children:C(`recent.colCost`)}),(0,P.jsx)(`span`,{className:`w-20 text-right`,children:C(`recent.colStarted`)})]})]}),(0,P.jsx)(`div`,{className:`space-y-0.5`,children:$.slice(0,J).map(e=>{let n=ae[e.status]??ae.queued,r=ce(e.total_cost_usd),a=le(e.started_at,e.finished_at),o=ue((e.tokens_in??0)+(e.tokens_out??0)+(e.tokens_cache_read??0)+(e.tokens_cache_create??0)||null),s=e.id.startsWith(`proposal:`),c=s?e.id.replace(`proposal:`,``):null,l=X.includes(e.id),u=Y&&!s&&X.length===2&&!l;return(0,P.jsxs)(`div`,{role:`button`,tabIndex:0,className:`flex items-center gap-3 px-3 py-2 rounded-md transition-colors cursor-pointer group ${l?`bg-accent/70 ring-1 ring-border`:u?`opacity-40 cursor-not-allowed`:`hover:bg-accent/50`}`,onClick:()=>{if(Y&&!s){Se(e.id);return}s&&c?b?.(c):w(`/jobs/${e.id}`)},children:[(0,P.jsxs)(i,{children:[(0,P.jsx)(t,{asChild:!0,children:(0,P.jsx)(`div`,{children:(0,P.jsx)(_,{variant:n.variant,children:C(n.labelKey)})})}),(0,P.jsx)(f,{children:C(n.tooltipKey)})]}),e.priority&&e.priority!==`normal`&&(0,P.jsx)(`span`,{className:`inline-flex items-center rounded px-1.5 py-0.5 text-[9px] font-medium border ${se[e.priority].className}`,children:C(se[e.priority].labelKey)}),e.profile_name&&(0,P.jsxs)(i,{children:[(0,P.jsx)(t,{asChild:!0,children:(0,P.jsx)(`span`,{className:`inline-flex items-center rounded px-1.5 py-0.5 text-[9px] font-medium border border-accent-primary/40 bg-accent-primary/10 text-accent-primary/90`,children:e.profile_name})}),(0,P.jsx)(f,{children:C(`recent.profileTooltip`,{name:e.profile_name})})]}),(0,P.jsxs)(`div`,{className:`flex items-center gap-1 flex-1 min-w-0`,children:[e.pipeline_id&&(0,P.jsxs)(i,{children:[(0,P.jsx)(t,{asChild:!0,children:(0,P.jsx)(T,{className:`w-3 h-3 text-accent-primary/60 shrink-0`})}),(0,P.jsxs)(f,{children:[C(`recent.pipelinePart`),e.depends_on_job_id&&` ${C(`recent.pipelineDependsOn`)}`,e.skip_reason&&` — ${e.skip_reason}`]})]}),(0,P.jsx)(`code`,{className:`text-xs text-foreground/80 truncate`,children:ne(e.command,te)})]}),(0,P.jsxs)(`div`,{className:`flex items-center gap-3 text-[10px] text-muted-foreground shrink-0`,children:[(0,P.jsx)(`span`,{className:`w-14 text-right`,children:a??`—`}),(0,P.jsx)(`span`,{className:`w-12 text-right`,children:o?`${o}`:`—`}),(0,P.jsx)(`span`,{className:`w-12 text-right`,children:r??`—`}),(0,P.jsx)(`span`,{className:`w-20 text-right`,children:de(e.started_at)}),s&&c&&(0,P.jsx)(`button`,{type:`button`,className:`w-4 h-4 md:opacity-0 md:group-hover:opacity-100 text-muted-foreground hover:text-destructive transition-all`,onClick:e=>{e.stopPropagation(),q(c)},title:C(`recent.deleteProposal`),children:(0,P.jsx)(y,{className:`w-3 h-3`})})]})]},e.id)})}),$.length>J&&(0,P.jsx)(`div`,{className:`pt-1 text-center`,children:(0,P.jsx)(`button`,{type:`button`,onClick:()=>fe(e=>e+B),className:`text-[10px] text-muted-foreground hover:text-foreground transition-colors px-3 py-1 rounded hover:bg-accent/50`,children:C(`recent.loadMore`,{count:$.length-J})})}),L&&(0,P.jsxs)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm`,onClick:be(()=>R(!1)),children:[(0,P.jsxs)(`div`,{ref:he,className:`w-80 rounded-xl border border-border/30 bg-popover p-4 shadow-lg space-y-4`,onClick:e=>e.stopPropagation(),style:ge,children:[(0,P.jsxs)(`div`,{..._e,className:ye?`cursor-grab active:cursor-grabbing`:void 0,children:[(0,P.jsx)(`h3`,{className:`text-sm font-semibold`,children:C(`recent.clearModal.title`)}),(0,P.jsx)(`p`,{className:`text-xs text-muted-foreground mt-0.5`,children:C(`recent.clearModal.jobsInHistory`,{count:e.length})})]}),(0,P.jsx)(v,{variant:`destructive`,size:`sm`,className:`w-full`,disabled:W,onClick:()=>we(`all`),children:C(`recent.clearModal.clearAll`,{count:e.length})}),(0,P.jsxs)(`div`,{className:`space-y-2`,children:[(0,P.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:C(`recent.clearModal.orByRange`)}),(0,P.jsxs)(`div`,{className:`flex gap-2`,children:[(0,P.jsx)(`input`,{type:`date`,value:z,onChange:e=>V(e.target.value),className:`flex-1 h-7 rounded-md border border-border bg-input px-2 text-xs text-foreground`,placeholder:C(`recent.clearModal.fromPlaceholder`)}),(0,P.jsx)(`input`,{type:`date`,value:H,onChange:e=>U(e.target.value),className:`flex-1 h-7 rounded-md border border-border bg-input px-2 text-xs text-foreground`,placeholder:C(`recent.clearModal.toPlaceholder`)})]}),(0,P.jsx)(v,{variant:`outline`,size:`sm`,className:`w-full`,disabled:W||!z&&!H,onClick:()=>we(`range`),children:z||H?C(`recent.clearModal.clearInRange`,{count:Ce}):C(`recent.clearModal.clearRange`)})]}),(0,P.jsx)(v,{variant:`ghost`,size:`sm`,className:`w-full`,onClick:()=>R(!1),children:C(`common:actions.cancel`)})]}),(0,P.jsx)(j,{handles:ve})]}),(0,P.jsx)(d,{open:K!==null,onOpenChange:e=>!e&&q(null),children:(0,P.jsxs)(p,{className:`max-w-sm`,children:[(0,P.jsxs)(l,{children:[(0,P.jsx)(h,{children:C(`recent.deleteProposalConfirm.title`)}),(0,P.jsx)(o,{children:C(`recent.deleteProposalConfirm.description`)})]}),(0,P.jsxs)(c,{children:[(0,P.jsx)(v,{variant:`ghost`,size:`sm`,onClick:()=>q(null),children:C(`common:actions.cancel`)}),(0,P.jsx)(v,{variant:`destructive`,size:`sm`,onClick:()=>{K&&S?.(K),q(null)},children:C(`common:actions.delete`)})]})]})}),me&&(0,P.jsx)(ie,{jobIds:me,onClose:()=>{Q(null),Z([]),pe(!1)}})]})}function H(){let{t:e}=r(`jobs`),{activeProjectId:t}=x(),{recentJobs:n}=ee(t),{data:i,isFirstLoad:a,refresh:o}=b({namespace:`jobs`,projectId:t,initialValue:n,fetcher:async()=>{let e=await fetch(`${D()}/jobs?limit=10`);return e.ok?(await e.json()).jobs:[]},pollInterval:1e4}),{data:s}=b({namespace:`proposals`,projectId:t,initialValue:[],fetcher:async()=>{let e=await fetch(`${D()}/propose?limit=10`);return e.ok?(await e.json()).proposals:[]},pollInterval:1e4}),u={input:`queued`,exploring:`running`,review:`running`,refining:`running`,creating_issue:`running`,created:`completed`,cancelled:`canceled`},f=s.map(e=>({id:`proposal:${e.id}`,command:`/specrails:propose-feature ${e.idea.length>60?e.idea.slice(0,57)+`...`:e.idea}`,started_at:e.created_at,status:u[e.status]??`queued`})),m=[...i,...f].sort((e,t)=>new Date(t.started_at).getTime()-new Date(e.started_at).getTime()),[y,S]=(0,N.useState)(null),w=(0,N.useCallback)(async e=>{try{let t=await fetch(`${D()}/propose/${e}`);if(!t.ok)return;S((await t.json()).proposal)}catch{}},[]),T=(0,N.useCallback)(async t=>{try{(await fetch(`${D()}/propose/${t}`,{method:`DELETE`})).ok&&(g.success(e(`page.proposalDeleted`)),o())}catch{}},[o,e]);return(0,P.jsxs)(`div`,{className:`max-w-4xl mx-auto px-4 py-6`,children:[(0,P.jsxs)(`div`,{className:`flex items-center justify-between mb-4`,children:[(0,P.jsx)(`h1`,{className:`text-sm font-semibold`,children:e(`page.title`)}),(0,P.jsx)(M,{baseUrl:`${D()}/jobs/export`,label:e(`page.exportJobs`)})]}),(0,P.jsx)(V,{jobs:m,isLoading:a,onJobsCleared:o,onProposalClick:w,onProposalDelete:T}),(0,P.jsx)(d,{open:y!==null,onOpenChange:e=>!e&&S(null),children:(0,P.jsx)(p,{className:`max-w-3xl glass-card`,children:y&&(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(l,{children:(0,P.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,P.jsx)(h,{className:`flex-1 min-w-0`,children:e(`page.proposal.title`)}),(0,P.jsx)(_,{variant:y.status===`created`?`success`:y.status===`cancelled`?`destructive`:`secondary`,children:y.status})]})}),(0,P.jsx)(`div`,{className:`text-xs text-muted-foreground bg-muted/20 rounded px-2 py-1 italic`,children:y.idea}),y.result_markdown?(0,P.jsx)(`div`,{className:`max-h-[400px] overflow-y-auto rounded-lg px-3 py-2 text-xs bg-muted/40`,children:(0,P.jsx)(`div`,{className:`prose prose-invert prose-xs max-w-none prose-p:my-1 prose-headings:mt-2 prose-headings:mb-1 prose-headings:text-sm prose-headings:font-semibold prose-ul:my-1 prose-ol:my-1 prose-li:my-0 prose-code:text-cyan-300 prose-code:text-[10px] prose-code:bg-muted/40 prose-code:px-1 prose-code:py-0.5 prose-code:rounded text-foreground/80`,children:(0,P.jsx)(A,{remarkPlugins:[C],children:y.result_markdown})})}):(0,P.jsx)(`p`,{className:`text-xs text-muted-foreground py-4 text-center`,children:e(`page.proposal.noContent`)}),y.issue_url&&(0,P.jsxs)(`div`,{className:`text-xs`,children:[e(`page.proposal.githubIssue`),` `,(0,P.jsx)(`a`,{href:y.issue_url,target:`_blank`,rel:`noopener noreferrer`,className:`text-accent-primary hover:underline`,children:y.issue_url})]}),(0,P.jsxs)(c,{children:[(0,P.jsx)(v,{variant:`destructive`,size:`sm`,onClick:()=>{T(y.id),S(null)},children:e(`common:actions.delete`)}),(0,P.jsx)(v,{variant:`ghost`,size:`sm`,onClick:()=>S(null),children:e(`common:actions.close`)})]})]})})})]})}export{H as default};
|