specrails-desktop 2.26.2 → 2.28.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/client/dist/assets/{ActivityFeedPage-bDe4VitF.js → ActivityFeedPage-DcMmDAP3.js} +1 -1
- package/client/dist/assets/AgentBrowserCapture-CZ3oc1UL.js +1 -0
- package/client/dist/assets/AgentIntegrationsModal-DkqooCFn.js +1 -0
- package/client/dist/assets/{AgentModeCodePane-Ci39DcOo.js → AgentModeCodePane-CM77ljte.js} +2 -2
- package/client/dist/assets/AgentModeJobsPane-DbZzogbi.js +1 -0
- package/client/dist/assets/AgentsPage-BZIml7eL.js +86 -0
- package/client/dist/assets/{AnalyticsPage-Da21wWWw.js → AnalyticsPage-B4qflNxi.js} +1 -1
- package/client/dist/assets/{BarChart-BiLTq3uC.js → BarChart-Ckstq9fl.js} +1 -1
- package/client/dist/assets/CodePage-DFZXLbI1.js +2 -0
- package/client/dist/assets/{DesktopAnalyticsPage-COkzgMmd.js → DesktopAnalyticsPage-DbgMa8OO.js} +1 -1
- package/client/dist/assets/DocsDialog-BQc9Kwev.js +11 -0
- package/client/dist/assets/DocsPage-OsV44ECy.js +11 -0
- package/client/dist/assets/{ExportDropdown-DDhJH-Jr.js → ExportDropdown-a43XHO3Y.js} +1 -1
- package/client/dist/assets/IntegrationsPage-C3E8hZhB.js +1 -0
- package/client/dist/assets/InteractiveJobComposer-zj8SrOAl.js +19 -0
- package/client/dist/assets/JobDetailModal-Cm6ZeVoh.js +1 -0
- package/client/dist/assets/JobDetailPage-DN67LsdX.js +1 -0
- package/client/dist/assets/JobsPage-DF9wKGbw.js +1 -0
- package/client/dist/assets/{LoopBuilderPage-DsLLrtHa.js → LoopBuilderPage-RJ6GGjli.js} +2 -2
- package/client/dist/assets/{LoopPreviewModal-C-fDEgnu.js → LoopPreviewModal-B2wmifF6.js} +1 -1
- package/client/dist/assets/LoopsPage-DdlvH-dJ.js +1 -0
- package/client/dist/assets/PluginsPage-9DI0a6jI.js +2 -0
- package/client/dist/assets/ProjectSettingsDialog-dgy5hqPd.js +1 -0
- package/client/dist/assets/{TemplatePreviewModal-DcHFbLA8.js → TemplatePreviewModal-CERf1IYB.js} +1 -1
- package/client/dist/assets/agent-BRJCESkc2.js +1 -0
- package/client/dist/assets/agent-BuYz6fJd.js +1 -0
- package/client/dist/assets/agent-CxnRzL6Z.js +1 -0
- package/client/dist/assets/agent-D4JAuEGN2.js +1 -0
- package/client/dist/assets/agent-DNQlI8EN.js +1 -0
- package/client/dist/assets/agent-DyzUH89R.js +1 -0
- package/client/dist/assets/agent-MaTxBlg5.js +1 -0
- package/client/dist/assets/agent-ostmMYNz2.js +1 -0
- package/client/dist/assets/{brain-BBNUUrUI.js → brain-BPbhM1Jx.js} +1 -1
- package/client/dist/assets/dashboard-5C2FOZQX.js +1 -0
- package/client/dist/assets/{dashboard-C6w0rICe.js → dashboard-B6iQ-IL_.js} +1 -1
- package/client/dist/assets/dashboard-BFfnCtq52.js +1 -0
- package/client/dist/assets/dashboard-BIC8KtRf2.js +1 -0
- package/client/dist/assets/dashboard-CEgg9NAr.js +1 -0
- package/client/dist/assets/dashboard-CiOyDh9L.js +1 -0
- package/client/dist/assets/dashboard-D6x5OnNj2.js +1 -0
- package/client/dist/assets/dashboard-DBuLfWo9.js +1 -0
- package/client/dist/assets/{dist-js-BxjTIvdT.js → dist-js-Byjcju1W.js} +1 -1
- package/client/dist/assets/{dist-js-DdP_Gl3p.js → dist-js-Dh-9lbLD.js} +1 -1
- package/client/dist/assets/index-89SuhD4Y.js +158 -0
- package/client/dist/assets/index-DOGzWJhO.css +2 -0
- package/client/dist/assets/integrations-By80EBkf.js +1 -0
- package/client/dist/assets/integrations-CAjq5tdW2.js +1 -0
- package/client/dist/assets/integrations-CG2dp3Kd.js +1 -0
- package/client/dist/assets/integrations-CP_aiV_8.js +1 -0
- package/client/dist/assets/integrations-CUNe3t9l2.js +1 -0
- package/client/dist/assets/integrations-CWjh5VRk.js +1 -0
- package/client/dist/assets/integrations-JOHSCvB3.js +1 -0
- package/client/dist/assets/integrations-RJfzXkPx2.js +1 -0
- package/client/dist/assets/{lib-BviHZ_gK.js → lib-yKyTNJ1c.js} +1 -1
- package/client/dist/assets/nav-B2_ToNqS.js +1 -0
- package/client/dist/assets/nav-BAMkVEId.js +1 -0
- package/client/dist/assets/nav-BTg8s-cD.js +1 -0
- package/client/dist/assets/nav-BY_4EWRv.js +1 -0
- package/client/dist/assets/nav-CVXtv0wX2.js +1 -0
- package/client/dist/assets/nav-D0Erv9ZJ2.js +1 -0
- package/client/dist/assets/nav-DUuw9VIU2.js +1 -0
- package/client/dist/assets/nav-S4HM94vW.js +1 -0
- package/client/dist/assets/settings-BYCMtxOz.js +1 -0
- package/client/dist/assets/{settings-BHdPchJP.js → settings-B_v3zgJf.js} +1 -1
- package/client/dist/assets/{settings-BeCczBFS2.js → settings-BemR_e3F.js} +1 -1
- package/client/dist/assets/{settings-D54_cgl12.js → settings-Bp24JHlv2.js} +1 -1
- package/client/dist/assets/{settings-C_nY14Yz.js → settings-BvIwQ3A1.js} +1 -1
- package/client/dist/assets/{settings-BlLi719f.js → settings-Bx2ObkTR2.js} +1 -1
- package/client/dist/assets/{settings-CaZ26a0S.js → settings-C_T0-j9d.js} +1 -1
- package/client/dist/assets/{settings-cn0tbve62.js → settings-DhaFKpcw2.js} +1 -1
- package/client/dist/assets/{upload-CRuuzzvp.js → upload-Qh1NE3xi.js} +1 -1
- package/client/dist/assets/{value-CIr5hDMt.js → value-BMPeyInx.js} +1 -1
- package/client/dist/index.html +29 -29
- package/package.json +1 -1
- package/server/dist/agent-chat-router.js +2 -0
- package/server/dist/agent-operator-prompt.js +17 -1
- package/server/dist/db.js +51 -2
- package/server/dist/dev-ports.js +35 -0
- package/server/dist/global-plugins-router.js +62 -0
- package/server/dist/headroom-manager.js +971 -0
- package/server/dist/headroom-routing.js +53 -0
- package/server/dist/index.js +9 -6
- package/server/dist/mcp/guide.js +3 -0
- package/server/dist/mcp/tools/catalog.js +2 -0
- package/server/dist/mcp/tools/env.js +72 -0
- package/server/dist/mcp/tools/jobs.js +110 -2
- package/server/dist/path-resolver.js +84 -18
- package/server/dist/project-env.js +30 -0
- package/server/dist/project-registry.js +4 -2
- package/server/dist/project-router-jobs.js +126 -0
- package/server/dist/project-router-settings.js +10 -1
- package/server/dist/queue-manager.js +9 -1
- package/server/dist/rail-isolated-launch.js +5 -4
- package/server/dist/rail-pr-decision.js +27 -17
- package/server/dist/rail-pr-store.js +36 -0
- package/server/dist/rails-router.js +7 -1
- package/server/dist/setup-manager.js +32 -29
- package/server/dist/setup-prerequisites.js +3 -1
- package/server/dist/transient-children.js +266 -9
- package/server/dist/util/cli-prompt.js +3 -0
- package/server/dist/workspace-resolution.js +3 -3
- package/server/dist/worktree-env-discovery.js +172 -0
- package/client/dist/assets/AgentBrowserCapture-DQyeEm2V.js +0 -1
- package/client/dist/assets/AgentModeJobsPane-C-g1WNVG.js +0 -1
- package/client/dist/assets/AgentsPage-BWgglK7V.js +0 -86
- package/client/dist/assets/CodePage-BUcAp7SC.js +0 -2
- package/client/dist/assets/DocsDialog-PZHMN18B.js +0 -11
- package/client/dist/assets/DocsPage-D3fChfkj.js +0 -11
- package/client/dist/assets/IntegrationsPage-F87uxxVH.js +0 -3
- package/client/dist/assets/InteractiveJobComposer-DqDCiCa0.js +0 -19
- package/client/dist/assets/JobDetailModal-BWJR60fi.js +0 -1
- package/client/dist/assets/JobDetailPage-CjWE_jyd.js +0 -1
- package/client/dist/assets/JobsPage-LmnXkyCa.js +0 -1
- package/client/dist/assets/LoopsPage-DDNO9h9T.js +0 -1
- package/client/dist/assets/ProjectSettingsDialog-CX854C8e.js +0 -1
- package/client/dist/assets/agent-BI6vr-To.js +0 -1
- package/client/dist/assets/agent-BUGXI3Ok2.js +0 -1
- package/client/dist/assets/agent-Bph_-xt7.js +0 -1
- package/client/dist/assets/agent-Bvy2Csyd.js +0 -1
- package/client/dist/assets/agent-Bwkyg2oX2.js +0 -1
- package/client/dist/assets/agent-CLCyDaZh.js +0 -1
- package/client/dist/assets/agent-Cqs14QMr2.js +0 -1
- package/client/dist/assets/agent-DJ0EBUuP.js +0 -1
- package/client/dist/assets/dashboard-BjjS1OrL.js +0 -1
- package/client/dist/assets/dashboard-Bk6oSk1H2.js +0 -1
- package/client/dist/assets/dashboard-BrH-GdOg2.js +0 -1
- package/client/dist/assets/dashboard-BurhUI8_.js +0 -1
- package/client/dist/assets/dashboard-CAUnfDQL2.js +0 -1
- package/client/dist/assets/dashboard-C_ljpeYO.js +0 -1
- package/client/dist/assets/dashboard-D6OqDdj6.js +0 -1
- package/client/dist/assets/index-C695aPdV.css +0 -2
- package/client/dist/assets/index-Dw1N2-ci.js +0 -156
- package/client/dist/assets/integrations-4KZnYECp.js +0 -1
- package/client/dist/assets/integrations-7W266oqF2.js +0 -1
- package/client/dist/assets/integrations-BNuauK3o.js +0 -1
- package/client/dist/assets/integrations-CHy8tnpV.js +0 -1
- package/client/dist/assets/integrations-Cl_wD5AI.js +0 -1
- package/client/dist/assets/integrations-CuWnMR5L.js +0 -1
- package/client/dist/assets/integrations-Cy8nZ_dv2.js +0 -1
- package/client/dist/assets/integrations-zMqY4VU12.js +0 -1
- package/client/dist/assets/nav-40HzpIFb.js +0 -1
- package/client/dist/assets/nav-8yPhBn00.js +0 -1
- package/client/dist/assets/nav-B6PkGfTk2.js +0 -1
- package/client/dist/assets/nav-BHqMLrS72.js +0 -1
- package/client/dist/assets/nav-CGy4yx3C.js +0 -1
- package/client/dist/assets/nav-CXEDcRdv2.js +0 -1
- package/client/dist/assets/nav-CzKzuwH8.js +0 -1
- package/client/dist/assets/nav-EI_OhEAo.js +0 -1
- package/client/dist/assets/settings-D9bDDe2O.js +0 -1
- /package/client/dist/assets/{activity-BZNfOdiS.js → activity-BZZlEG3a.js} +0 -0
- /package/client/dist/assets/{activity--iN4Ad2R2.js → activity-BbWiDfn-2.js} +0 -0
- /package/client/dist/assets/{activity-CIOLxGvh.js → activity-D3Ic-HTS.js} +0 -0
- /package/client/dist/assets/{activity-DtxrAUMo2.js → activity-DFbvNqhE2.js} +0 -0
- /package/client/dist/assets/{activity-D8vQJrpW.js → activity-Dbl71S-E.js} +0 -0
- /package/client/dist/assets/{activity-BuVo5sPB.js → activity-DtzRy92x.js} +0 -0
- /package/client/dist/assets/{activity-6hM_ZSg9.js → activity-DvECTYGt.js} +0 -0
- /package/client/dist/assets/{activity-D2r2h3SE2.js → activity-FleOlK0l2.js} +0 -0
- /package/client/dist/assets/{addspec-D-JLDsUV.js → addspec-BKrH2Ucz.js} +0 -0
- /package/client/dist/assets/{addspec-DfhDbg5c.js → addspec-B_LQMHW3.js} +0 -0
- /package/client/dist/assets/{addspec-bsNDdqRm2.js → addspec-Bw_YQwo62.js} +0 -0
- /package/client/dist/assets/{addspec-BMtLZLW62.js → addspec-CFxGvmJR2.js} +0 -0
- /package/client/dist/assets/{addspec-mgPOt5q02.js → addspec-CR8MB5Fr2.js} +0 -0
- /package/client/dist/assets/{addspec-CP0HRuxY.js → addspec-DaA-CbTt.js} +0 -0
- /package/client/dist/assets/{addspec-DxW6oPsk.js → addspec-DrXqP8ip.js} +0 -0
- /package/client/dist/assets/{addspec-CRuvWn8d.js → addspec-NBbcTbLc.js} +0 -0
- /package/client/dist/assets/{agents-BpoUaoW92.js → agents-B9pFSJQI2.js} +0 -0
- /package/client/dist/assets/{agents-78bTZGZh.js → agents-BHgn--3j.js} +0 -0
- /package/client/dist/assets/{agents-BUdEi3-N.js → agents-B_qGaB0F.js} +0 -0
- /package/client/dist/assets/{agents-Cev2oFfX.js → agents-CGDn_3kB.js} +0 -0
- /package/client/dist/assets/{agents-bvyRLczL.js → agents-CP8_ezYG.js} +0 -0
- /package/client/dist/assets/{agents-BLhWCmDS2.js → agents-CV-_xBvX2.js} +0 -0
- /package/client/dist/assets/{agents-CWo-KyAB.js → agents-HFCqQH0Z.js} +0 -0
- /package/client/dist/assets/{agents-DDtCJ5M02.js → agents-VsyFhGOS2.js} +0 -0
- /package/client/dist/assets/{agentstudio-BMQxc_bz.js → agentstudio-BEp7Sb46.js} +0 -0
- /package/client/dist/assets/{agentstudio-Dtq3dGYk.js → agentstudio-BOjG6tgJ.js} +0 -0
- /package/client/dist/assets/{agentstudio-C_Jq8Tl4.js → agentstudio-Br3WD7Xs.js} +0 -0
- /package/client/dist/assets/{agentstudio-sI27TpBu2.js → agentstudio-CuTt3ZGe2.js} +0 -0
- /package/client/dist/assets/{agentstudio-CWgXG5W52.js → agentstudio-D2A5peWV2.js} +0 -0
- /package/client/dist/assets/{agentstudio-CZm2rOzt.js → agentstudio-Dxe_94PK.js} +0 -0
- /package/client/dist/assets/{agentstudio-COZriimI2.js → agentstudio-RfZavULt2.js} +0 -0
- /package/client/dist/assets/{agentstudio-jKMTdT70.js → agentstudio-RsxnZtUA.js} +0 -0
- /package/client/dist/assets/{aiedit-igmw-ZoZ2.js → aiedit-26p5A_HY2.js} +0 -0
- /package/client/dist/assets/{aiedit-6CHdb_iv2.js → aiedit-CV520D4W2.js} +0 -0
- /package/client/dist/assets/{aiedit-pc5JDUq1.js → aiedit-CcugGPbS.js} +0 -0
- /package/client/dist/assets/{aiedit-eMN4eQPF.js → aiedit-D0Syl-mC.js} +0 -0
- /package/client/dist/assets/{aiedit-hknZlly82.js → aiedit-DnBzjlVz2.js} +0 -0
- /package/client/dist/assets/{aiedit-B03pD_Na.js → aiedit-DrIjSojo.js} +0 -0
- /package/client/dist/assets/{aiedit-DYtnZU9H.js → aiedit-DrfHQnlz.js} +0 -0
- /package/client/dist/assets/{aiedit-BtRqRxML.js → aiedit-a-Z-g5iC.js} +0 -0
- /package/client/dist/assets/{analytics-C5dpiS0o.js → analytics-4-eskbtX.js} +0 -0
- /package/client/dist/assets/{analytics-CR1TJqUi2.js → analytics-4HvXb0Vn2.js} +0 -0
- /package/client/dist/assets/{analytics-rmHuJv0V.js → analytics-Bd9rHGjV.js} +0 -0
- /package/client/dist/assets/{analytics-BWMUZ2Pq2.js → analytics-Bpe41fnX2.js} +0 -0
- /package/client/dist/assets/{analytics-Bj-SmKHa.js → analytics-CpSTNfui.js} +0 -0
- /package/client/dist/assets/{analytics-Ce-sPORu.js → analytics-CxDYcBl9.js} +0 -0
- /package/client/dist/assets/{analytics-CCprAqk3.js → analytics-DEe5BMz8.js} +0 -0
- /package/client/dist/assets/{analytics-DfNdXR0y2.js → analytics-DcOITHla2.js} +0 -0
- /package/client/dist/assets/{attachments-BjyMmrwE.js → attachments-CA2f3qL3.js} +0 -0
- /package/client/dist/assets/{attachments-DCZOL1RU.js → attachments-CHDbhKeH.js} +0 -0
- /package/client/dist/assets/{attachments-rNn1ekRy2.js → attachments-CKAY5aYG2.js} +0 -0
- /package/client/dist/assets/{attachments-BgBNSqQd.js → attachments-CgOQ9K-6.js} +0 -0
- /package/client/dist/assets/{attachments-DPCmkFZu2.js → attachments-D2jwJXQ42.js} +0 -0
- /package/client/dist/assets/{attachments-C9GTTJsx2.js → attachments-DlEQu56g2.js} +0 -0
- /package/client/dist/assets/{attachments-Ci6_42Kh.js → attachments-DvxQbBTC.js} +0 -0
- /package/client/dist/assets/{attachments-DL-bPy9E.js → attachments-jVdKzAXn.js} +0 -0
- /package/client/dist/assets/{auth-Cvsb7-Ek.js → auth-DpZq5p1e.js} +0 -0
- /package/client/dist/assets/{browser-Cvg-QHvd2.js → browser-BQFDxrRq.js} +0 -0
- /package/client/dist/assets/{browser-rWKj-RR_2.js → browser-BbJ_q_OT2.js} +0 -0
- /package/client/dist/assets/{browser-Cc0iDqUi.js → browser-C4VJ5CW12.js} +0 -0
- /package/client/dist/assets/{browser-BPkhILSJ.js → browser-Cl-FwPXs.js} +0 -0
- /package/client/dist/assets/{browser-CdS6O1Qb.js → browser-DM8G151q.js} +0 -0
- /package/client/dist/assets/{browser-FRv8P02E.js → browser-Do2jf8_N.js} +0 -0
- /package/client/dist/assets/{browser-BqLqJVVT.js → browser-JsiohNmW.js} +0 -0
- /package/client/dist/assets/{browser-BijVYG0Y2.js → browser-kA31eYhu2.js} +0 -0
- /package/client/dist/assets/{chat-VMflhzxn.js → chat-0dg5hOo_.js} +0 -0
- /package/client/dist/assets/{chat-DdwZjT8K2.js → chat-BMWD_Rx12.js} +0 -0
- /package/client/dist/assets/{chat-Bom6bqK3.js → chat-BalviUAD.js} +0 -0
- /package/client/dist/assets/{chat-DsbwJhus.js → chat-CJddjN3D2.js} +0 -0
- /package/client/dist/assets/{chat-Dnwg-NpQ.js → chat-D5xEtsf3.js} +0 -0
- /package/client/dist/assets/{chat-vylxqR0P2.js → chat-Ds8GvCnv.js} +0 -0
- /package/client/dist/assets/{chat-BgL3zv6x2.js → chat-SaG-ng1x2.js} +0 -0
- /package/client/dist/assets/{chat-Bh3NdgJs.js → chat-n43nZGvn.js} +0 -0
- /package/client/dist/assets/{code-thSEptMx.js → code-B62fClk-.js} +0 -0
- /package/client/dist/assets/{code-DzC1rMk12.js → code-Bit_z2Xd2.js} +0 -0
- /package/client/dist/assets/{code-BRcDlze52.js → code-BotxM43N2.js} +0 -0
- /package/client/dist/assets/{code-UPVvmAKM2.js → code-C9U6M5-e2.js} +0 -0
- /package/client/dist/assets/{code-BdMy3Ffq.js → code-CIPmDEd0.js} +0 -0
- /package/client/dist/assets/{code-DgeHz9CB.js → code-DUe1Bouz.js} +0 -0
- /package/client/dist/assets/{code-CwnBPPyA.js → code-F_KjccGf.js} +0 -0
- /package/client/dist/assets/{code-CeQ0FZpC.js → code-HDK4P6Rx.js} +0 -0
- /package/client/dist/assets/{commands-DkU0qliq.js → commands-BFQZc9AG.js} +0 -0
- /package/client/dist/assets/{commands-u-4eEHCN.js → commands-BMkC5-ki.js} +0 -0
- /package/client/dist/assets/{commands-CSDs9q_2.js → commands-BllkJauO.js} +0 -0
- /package/client/dist/assets/{commands-xHDDGfcP2.js → commands-CWX9WmDX2.js} +0 -0
- /package/client/dist/assets/{commands-C4Y3C-PF2.js → commands-CzFSoIiq2.js} +0 -0
- /package/client/dist/assets/{commands-CckaBWdV.js → commands-DCJ-R9E4.js} +0 -0
- /package/client/dist/assets/{commands-JWMfGDmr.js → commands-KBbhsnw8.js} +0 -0
- /package/client/dist/assets/{commands-RHOchN4n2.js → commands-cKTaLwwV2.js} +0 -0
- /package/client/dist/assets/{common-DmqBPwZG.js → common-BfQD173j.js} +0 -0
- /package/client/dist/assets/{common-DhWTkocg.js → common-CF8iGXrG.js} +0 -0
- /package/client/dist/assets/{common-Bwafujnc2.js → common-Cfmwcrl52.js} +0 -0
- /package/client/dist/assets/{common-C-vU-j-I.js → common-D2cimsul.js} +0 -0
- /package/client/dist/assets/{common-C5HKSbbz.js → common-DH7fjyL1.js} +0 -0
- /package/client/dist/assets/{common-CYaT2yHp.js → common-DXrmj6WD.js} +0 -0
- /package/client/dist/assets/{common-BM3LFLCE2.js → common-DZbXlmq72.js} +0 -0
- /package/client/dist/assets/{common-DiPTT7V_2.js → common-DtXmzX2o2.js} +0 -0
- /package/client/dist/assets/{explore-UvW1jEMa.js → explore-BEpIs343.js} +0 -0
- /package/client/dist/assets/{explore-CNBzrEPS.js → explore-BO_OinBD.js} +0 -0
- /package/client/dist/assets/{explore-C0k8HrkN.js → explore-Bhy7WWXv.js} +0 -0
- /package/client/dist/assets/{explore-B7fblXBb2.js → explore-CAc8Qzu32.js} +0 -0
- /package/client/dist/assets/{explore-D_mWBYCS2.js → explore-DCZL9gRN2.js} +0 -0
- /package/client/dist/assets/{explore-Dahc1lOx.js → explore-DW_YTkQh.js} +0 -0
- /package/client/dist/assets/{explore-BHtEpoNN2.js → explore-ELbrSZyQ2.js} +0 -0
- /package/client/dist/assets/{explore-BKVV5JSu.js → explore-_XyU5e7R.js} +0 -0
- /package/client/dist/assets/{format-command-CuWuRvka.js → format-command-Db1viey1.js} +0 -0
- /package/client/dist/assets/{jira-uNH1gETL2.js → jira-B5wszJ1-2.js} +0 -0
- /package/client/dist/assets/{jira-BHAKtc4B.js → jira-C5UjxHE4.js} +0 -0
- /package/client/dist/assets/{jira-D5efgwp_.js → jira-CQ7mrZde.js} +0 -0
- /package/client/dist/assets/{jira-bDs7Im2C.js → jira-DIRkZk9U.js} +0 -0
- /package/client/dist/assets/{jira-CPpgA-5z2.js → jira-DTYu3hJi2.js} +0 -0
- /package/client/dist/assets/{jira-B3613-gj.js → jira-DeIjwCK3.js} +0 -0
- /package/client/dist/assets/{jira-DS7ownDy.js → jira-DtZpokjJ.js} +0 -0
- /package/client/dist/assets/{jira-Be369RIR2.js → jira-ZdKb-50F2.js} +0 -0
- /package/client/dist/assets/{jobs-CE8qeIYj.js → jobs-BFIdeDTw.js} +0 -0
- /package/client/dist/assets/{jobs-BgQzB0Sx2.js → jobs-BJ-Gcao22.js} +0 -0
- /package/client/dist/assets/{jobs-1GV2-4zd2.js → jobs-DAGiPVIS2.js} +0 -0
- /package/client/dist/assets/{jobs-26F9gGcE.js → jobs-DAU8C_tZ.js} +0 -0
- /package/client/dist/assets/{jobs-BqWui9_f.js → jobs-Da0GaaSc.js} +0 -0
- /package/client/dist/assets/{jobs-D5sZzgLs.js → jobs-DrYmsKy5.js} +0 -0
- /package/client/dist/assets/{jobs-Wh7dn28q2.js → jobs-P3unxtxo2.js} +0 -0
- /package/client/dist/assets/{jobs-DzeuASRf.js → jobs-p360zdf1.js} +0 -0
- /package/client/dist/assets/{loops-CvOWsi5r.js → loops-Bi4ywYGn.js} +0 -0
- /package/client/dist/assets/{loops-BvqQ-bHR2.js → loops-BjK8lmoZ2.js} +0 -0
- /package/client/dist/assets/{loops-Brnx4Fji.js → loops-CO6q75W8.js} +0 -0
- /package/client/dist/assets/{loops-K5_HXfJa.js → loops-D3wdUkZV.js} +0 -0
- /package/client/dist/assets/{loops-D6D3XHjj.js → loops-DDs4KPu_.js} +0 -0
- /package/client/dist/assets/{loops-LIgO_-eM.js → loops-DKzYFcq6.js} +0 -0
- /package/client/dist/assets/{loops-DJNhp17p2.js → loops-Du-bNVpc2.js} +0 -0
- /package/client/dist/assets/{loops-vhJdbcz92.js → loops-DvGbSfxw2.js} +0 -0
- /package/client/dist/assets/{mcp-XJNRfxVp2.js → mcp-BG-OCJca2.js} +0 -0
- /package/client/dist/assets/{mcp-DtbxuH3V2.js → mcp-CbJ04oFS2.js} +0 -0
- /package/client/dist/assets/{mcp-sRmWE8WJ.js → mcp-CrWdq5db.js} +0 -0
- /package/client/dist/assets/{mcp-H-gnQUdN.js → mcp-Dd844F5_.js} +0 -0
- /package/client/dist/assets/{mcp-Dcl-XxkR.js → mcp-DfmzoT5t.js} +0 -0
- /package/client/dist/assets/{mcp-CjVKXAhD2.js → mcp-DyULurYS2.js} +0 -0
- /package/client/dist/assets/{mcp-CIH0pH1K.js → mcp-HwBbQDk0.js} +0 -0
- /package/client/dist/assets/{mcp-N1nzp8oL.js → mcp-zSJ2TsJj.js} +0 -0
- /package/client/dist/assets/{setup-BuQNKztt2.js → setup-1vN48B-m2.js} +0 -0
- /package/client/dist/assets/{setup-BwMovM9z2.js → setup-BmJ0Kx16.js} +0 -0
- /package/client/dist/assets/{setup-RiUHzq7E.js → setup-D2CmgAro.js} +0 -0
- /package/client/dist/assets/{setup-BXpw07r-.js → setup-DQWsu2TR.js} +0 -0
- /package/client/dist/assets/{setup-D84y3wx-.js → setup-JeBwoXoM.js} +0 -0
- /package/client/dist/assets/{setup-DU0ULX8q2.js → setup-T_ApeQDV2.js} +0 -0
- /package/client/dist/assets/{setup-BiduSX9d.js → setup-mXnzww4f.js} +0 -0
- /package/client/dist/assets/{setup-7J8TjG4O.js → setup-q0wRHUp1.js} +0 -0
- /package/client/dist/assets/{specs-CWtKcVDC.js → specs-BGRKhM8t.js} +0 -0
- /package/client/dist/assets/{specs-CBDvEYKv.js → specs-C6J2zrLM.js} +0 -0
- /package/client/dist/assets/{specs-D2clrt2c2.js → specs-CT8exGOy2.js} +0 -0
- /package/client/dist/assets/{specs-C9Sd7BhH2.js → specs-Ce5y2iFc2.js} +0 -0
- /package/client/dist/assets/{specs-CIPr9reA2.js → specs-DZDoZsDq.js} +0 -0
- /package/client/dist/assets/{specs-PozUNhqb.js → specs-DbtIzV8a.js} +0 -0
- /package/client/dist/assets/{specs-DTplt2XM.js → specs-GkiL-snY.js} +0 -0
- /package/client/dist/assets/{specs-CmEZY57v.js → specs-PGIOzMtc.js} +0 -0
- /package/client/dist/assets/{terminal-xGbCZJHg.js → terminal-BNSg2lR7.js} +0 -0
- /package/client/dist/assets/{terminal-De2Brd23.js → terminal-BTpE7iki.js} +0 -0
- /package/client/dist/assets/{terminal-DFPNRLKp.js → terminal-CFt56A5f.js} +0 -0
- /package/client/dist/assets/{terminal-BRm03iFA2.js → terminal-Cvabyzm42.js} +0 -0
- /package/client/dist/assets/{terminal-DxQWCqSD2.js → terminal-D0z12_sJ2.js} +0 -0
- /package/client/dist/assets/{terminal-Z7KsDM_n.js → terminal-DDk_bTw0.js} +0 -0
- /package/client/dist/assets/{terminal-cqfd3EDV.js → terminal-DEyt0prF.js} +0 -0
- /package/client/dist/assets/{terminal-WSAvHXoU.js → terminal-a6Uq8B0p.js} +0 -0
- /package/client/dist/assets/{tickets-CkfbISuK.js → tickets-BHv3ewvq.js} +0 -0
- /package/client/dist/assets/{tickets-C3b8cHhd2.js → tickets-BIxU86j12.js} +0 -0
- /package/client/dist/assets/{tickets-SuX_HkK4.js → tickets-C2BhwzwR.js} +0 -0
- /package/client/dist/assets/{tickets-DTHo9c3C.js → tickets-D1IeX2EW.js} +0 -0
- /package/client/dist/assets/{tickets-BoXom7l8.js → tickets-DZut8Ryt.js} +0 -0
- /package/client/dist/assets/{tickets-CWYFvx1W2.js → tickets-LfK6LzKl2.js} +0 -0
- /package/client/dist/assets/{tickets-CFXnJsYF.js → tickets-dQfsc7Ph.js} +0 -0
- /package/client/dist/assets/{tickets-B7zT4IRf.js → tickets-sVun0I6v.js} +0 -0
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/editor.main-C9J2ikJK.js","assets/chunk-BNv3lrIs.js","assets/preload-helper-DSXbuxSR.js","assets/editor.api2-C3B0tp2x.js","assets/editor-Br_kD0ds.css","assets/workers-U0UXyLUf.js","assets/monaco.contribution-Desq7oq4.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{a as e}from"./chunk-BNv3lrIs.js";import{t}from"./preload-helper-DSXbuxSR.js";import{Bn as n,Dn as r,En as i,Gn as a,Jn as o,M as s,Nt as c,Rn as l,Tn as u,Vt as d,X as f,Yn as p,Z as m,_ as h,at as g,b as _,cn as v,ct as y,dn as b,fn as x,gn as S,it as C,j as w,ln as T,lt as E,mn as D,nt as O,on as k,pn as A,qn as j,ut as M,wt as N,zn as P}from"./index-89SuhD4Y.js";var F=l(`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`}]]),I=e(p(),1),L=e(o(),1);function R(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 z(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 ee(e,t){if(e===void 0)throw Error(`Unexpected undefined${t?`: ${t}`:``}`);return e}var te=(e,t)=>Math.abs(e-t)<1.01,ne=(e,t,n)=>{let r;return function(...i){e.clearTimeout(r),r=e.setTimeout(()=>t.apply(this,i),n)}},B,V=()=>{if(B!==void 0)return B;if(typeof navigator>`u`)return B=!1;if(/iP(hone|od|ad)/.test(navigator.userAgent))return B=!0;let e=navigator.maxTouchPoints;return B=navigator.platform===`MacIntel`&&e!==void 0&&e>0},H=e=>{let{offsetWidth:t,offsetHeight:n}=e;return{width:t,height:n}},U=e=>e,W=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},re=(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(H(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(H(n))};e.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(r):r()});return a.observe(n,{box:`border-box`}),()=>{a.unobserve(n)}},G={passive:!0},K=typeof window>`u`?!0:`onscrollend`in window,q=(e,t,n)=>{let r=e.scrollElement;if(!r)return;let i=e.targetWindow;if(!i)return;let a=e.options.useScrollendEvent&&K,o=0,s=a?null:ne(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,G),a&&r.addEventListener(`scrollend`,u,G),()=>{r.removeEventListener(`scroll`,l),a&&r.removeEventListener(`scrollend`,u)}},ie=(e,t)=>q(e,t,t=>{let{horizontal:n,isRtl:r}=e.options;return n?t.scrollLeft*(r&&-1||1):t.scrollTop}),J=(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`]},ae=(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})},oe=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:U,rangeExtractor:W,onChange:()=>{},measureElement:J,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=z(()=>(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,!(!V()||this.targetWindow==null)&&(this._iosJustTouchEnded=!0,this._iosTouchEndTimerId=this.targetWindow.setTimeout(()=>{this._iosJustTouchEnded=!1,this._iosTouchEndTimerId=null,this._flushIosDeferredIfReady()},150))};e.addEventListener(`touchstart`,t,G),e.addEventListener(`touchend`,n,G),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=z(()=>[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=z(()=>[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=R(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=z(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(e,t,n,r)=>this.range=e.length>0&&t>0?se({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=z(()=>{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))&&(V()&&(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=z(()=>[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 ee(t[Y(0,t.length-1,r?e=>n[e*2]:e=>ee(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&&te(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()}},Y=(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 se({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=Y(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 ce=typeof document<`u`?I.useLayoutEffect:I.useEffect;function le({useFlushSync:e=!0,...t}){let n=I.useReducer(e=>e+1,0)[1],r={...t,onChange:(r,i)=>{var a;e&&i?(0,L.flushSync)(n):n(),(a=t.onChange)==null||a.call(t,r,i)}},[i]=I.useState(()=>new oe(r));return i.setOptions(r),ce(()=>i._didMount(),[]),ce(()=>i._willUpdate()),i}function ue(e){return le({observeElementRect:re,observeElementOffset:ie,scrollToFn:ae,...e})}var X=E(),Z=e=>`specrails-desktop:code-tree-filter:${e}`,de=e=>`specrails-desktop:code-tree-collapsed:${e}`;function fe(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:a,filterTicketId:o}){let{t:s}=n(`code`),{activeProjectId:c}=C(),{openTicketDetail:l}=_(),{registerHandler:u,unregisterHandler:d}=y(),[f,p]=(0,I.useState)(()=>{if(!c)return`touched-by-ai`;try{let e=localStorage.getItem(Z(c));if(e===`all`||e===`touched-by-ai`)return e}catch{}return`touched-by-ai`});(0,I.useEffect)(()=>{if(c)try{localStorage.setItem(Z(c),f)}catch{}},[f,c]);let[m,h]=(0,I.useState)(()=>{if(!c)return new Set;try{let e=localStorage.getItem(de(c));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,I.useEffect)(()=>{if(c)try{localStorage.setItem(de(c),JSON.stringify([...m]))}catch{}},[m,c]);let x=(0,I.useCallback)(e=>{h(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),S=(0,I.useCallback)(()=>{h(new Set)},[]),{data:w,refresh:E,isFirstLoad:D}=g({namespace:`code-tree:${f}:${f===`touched-by-ai`?`${a??`all-jobs`}:${o??`all-specs`}`:`all`}`,projectId:c,initialValue:[],fetcher:(0,I.useCallback)(async()=>{let e=[],t=null;for(let n=0;n<100;n+=1){let n=new URLSearchParams({withProvenance:`1`,filter:f});f===`touched-by-ai`&&a&&n.set(`jobId`,a),f===`touched-by-ai`&&typeof o==`number`&&n.set(`ticketId`,String(o)),t&&n.set(`cursor`,t);let r=await fetch(`${M()}/code/tree?${n.toString()}`);if(!r.ok)break;let i=await r.json().catch(()=>({}));if(Array.isArray(i.entries)&&e.push(...i.entries),!i.nextCursor)break;t=i.nextCursor}return e},[f,a,o])}),A=(0,I.useRef)(c);(0,I.useEffect)(()=>{A.current=c},[c]),(0,I.useEffect)(()=>{if(!c)return;let e=`code-tree-${c}`;return u(e,e=>{let t=e;t.projectId===A.current&&t.type===`file.provenance_updated`&&E()}),()=>d(e)},[c,u,d,E]);let j=(0,I.useRef)(null),N=(0,I.useMemo)(()=>(w??[]).filter(e=>!ge(e.path,m)),[w,m]),P=(0,I.useCallback)(()=>{h(new Set((w??[]).filter(e=>e.kind===`dir`).map(e=>e.path)))},[w]),F=ue({count:N.length,getScrollElement:()=>j.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()=>{}}}),L=N.length===0,R=(0,I.useMemo)(()=>(w??[]).filter(e=>e.kind===`file`).length,[w]);return(0,X.jsxs)(`div`,{className:`flex flex-col h-full`,"data-testid":`file-tree`,children:[(0,X.jsxs)(`div`,{className:`px-2 py-2 border-b border-border text-xs space-y-2`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,X.jsx)(`button`,{type:`button`,onClick:()=>p(`touched-by-ai`),className:O(`px-2 py-1 rounded-md transition-colors`,f===`touched-by-ai`?`bg-accent-primary/20 text-accent-primary`:`text-muted-foreground hover:text-foreground hover:bg-muted/50`),"aria-pressed":f===`touched-by-ai`,children:s(a?`tree.jobFiles`:o?`tree.specFiles`:`tree.touchedByAi`)}),(0,X.jsx)(`button`,{type:`button`,onClick:()=>p(`all`),className:O(`px-2 py-1 rounded-md transition-colors`,f===`all`?`bg-accent-primary/20 text-accent-primary`:`text-muted-foreground hover:text-foreground hover:bg-muted/50`),"aria-pressed":f===`all`,children:s(`tree.allFiles`)}),(0,X.jsx)(`div`,{className:`flex-1`}),(0,X.jsx)(`button`,{type:`button`,onClick:P,title:s(`tree.collapseAll`),className:`px-1.5 py-1 rounded-md text-muted-foreground hover:text-foreground hover:bg-muted/50`,"aria-label":s(`tree.collapseAll`),children:(0,X.jsx)(i,{className:`w-3.5 h-3.5`})}),(0,X.jsx)(`button`,{type:`button`,onClick:S,title:s(`tree.expandAll`),className:`px-1.5 py-1 rounded-md text-muted-foreground hover:text-foreground hover:bg-muted/50`,"aria-label":s(`tree.expandAll`),children:(0,X.jsx)(r,{className:`w-3.5 h-3.5`})})]}),f===`touched-by-ai`&&R>0&&(0,X.jsx)(`div`,{className:`flex items-center justify-between gap-2 text-[11px] text-muted-foreground`,children:(0,X.jsx)(`span`,{children:s(`tree.touchedCount`,{count:R})})})]}),L&&D?(0,X.jsx)(`div`,{className:`flex-1 flex items-center justify-center px-4 text-center`,"data-testid":`file-tree-loading`,children:(0,X.jsx)(`p`,{className:`text-xs text-muted-foreground animate-pulse`,children:s(`tree.loadingFiles`)})}):L&&f===`touched-by-ai`?(0,X.jsxs)(`div`,{className:`flex-1 flex flex-col items-center justify-center px-4 text-center gap-3`,children:[(0,X.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:s(`tree.emptyTouched`)}),(0,X.jsx)(`button`,{type:`button`,onClick:()=>p(`all`),className:`text-xs px-3 py-1.5 rounded-md bg-accent-primary/20 text-accent-primary hover:bg-accent-primary/30`,children:s(`tree.showAllFiles`)})]}):L?(0,X.jsx)(`div`,{className:`flex-1 flex items-center justify-center text-xs text-muted-foreground px-4 text-center`,children:s(`tree.noFiles`)}):(0,X.jsx)(`div`,{ref:j,className:`flex-1 overflow-auto`,"data-testid":`file-tree-scroller`,children:(0,X.jsx)(`div`,{style:{height:F.getTotalSize(),position:`relative`,width:`100%`},children:F.getVirtualItems().map(n=>{let a=N[n.index],o=fe(a.path)*12,c=a.kind===`file`&&a.path===t,u=a.provenance?.createdByTicketId,d=a.provenance?.modifiedByTicketIds??[],f=a.provenance?.latest??null,p=me(f?.jobId),h=he(f?.kind),g=a.kind===`dir`,_=g&&m.has(a.path),y=a.provenance?.touchedFileCount??0;return(0,X.jsxs)(`div`,{style:{position:`absolute`,top:0,left:0,transform:`translateY(${n.start}px)`,height:n.size,width:`100%`},className:O(`flex items-center gap-2 px-2 text-xs cursor-pointer hover:bg-muted/50`,c&&`bg-muted text-foreground`),onClick:()=>{g?x(a.path):e(a.path)},role:`button`,tabIndex:0,"aria-expanded":g?!_:void 0,"data-testid":`file-tree-row-${a.path}`,children:[(0,X.jsxs)(`span`,{style:{paddingLeft:o},className:`flex items-center gap-1 min-w-0 flex-1`,children:[g?(0,X.jsxs)(X.Fragment,{children:[_?(0,X.jsx)(i,{className:`w-3 h-3 text-muted-foreground flex-shrink-0`}):(0,X.jsx)(r,{className:`w-3 h-3 text-muted-foreground flex-shrink-0`}),_?(0,X.jsx)(v,{className:`w-3.5 h-3.5 text-accent-info flex-shrink-0`}):(0,X.jsx)(T,{className:`w-3.5 h-3.5 text-accent-info flex-shrink-0`})]}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`span`,{className:`w-3 flex-shrink-0`}),(0,X.jsx)(b,{className:`w-3.5 h-3.5 text-muted-foreground flex-shrink-0`})]}),(0,X.jsx)(`span`,{className:`truncate ml-0.5`,children:pe(a.path)})]}),(0,X.jsxs)(`span`,{className:`flex items-center gap-1 flex-shrink-0`,children:[g&&y>0&&(0,X.jsx)(`span`,{className:`text-[10px] px-1.5 py-0.5 rounded bg-muted/60 text-muted-foreground`,title:s(`tree.folderTouched`,{count:y}),children:y}),!g&&h&&(0,X.jsx)(`span`,{className:O(`text-[10px] px-1.5 py-0.5 rounded`,f?.kind===`created`&&`bg-accent-success/15 text-accent-success`,f?.kind===`modified`&&`bg-accent-info/15 text-accent-info`,f?.kind===`deleted`&&`bg-destructive/15 text-destructive`),title:f?.kind===`created`?s(`tree.latestTitleCreated`):f?.kind===`deleted`?s(`tree.latestTitleDeleted`):s(`tree.latestTitleModified`),children:s(`action.${h}`)}),!g&&p&&(0,X.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:s(`tree.jobTitle`,{jobId:f?.jobId??``}),children:[(0,X.jsx)(k,{className:`h-3 w-3`}),p]}),!g&&typeof u==`number`&&(0,X.jsxs)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),l(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:s(`tree.createdBySpec`,{id:u}),children:[`#`,u]}),!g&&d.slice(0,2).map(e=>(0,X.jsxs)(`button`,{type:`button`,onClick:t=>{t.stopPropagation(),l(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:s(`tree.modifiedBySpec`,{id:e}),children:[`#`,e]},e))]})]},a.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 Q(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=Q(r.background),a=Q(r.foreground),o=Q(r.brightBlack),s=Q(r.magenta),c=Q(r.yellow),l=Q(r.cyan),u=Q(r.blue),d=Q(r.green),f=Q(r.brightBlack),p=Q(r.brightCyan),m=Q(r.red),h=Q(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":Q(r.cursor),"editor.selectionBackground":h,"editor.inactiveSelectionBackground":h,"editor.lineHighlightBackground":Q(r.black),"editor.lineHighlightBorder":Q(r.black),"editorGutter.background":i,"editorWhitespace.foreground":o,"editorIndentGuide.background1":Q(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:r,readOnly:i,onChange:a}){let{t:o}=n(`code`),s=h(),c=(0,I.useRef)(null),l=(0,I.useRef)(null),u=(0,I.useRef)(null),[d,f]=(0,I.useState)(!1),p=(0,I.useRef)(e),m=(0,I.useRef)(r),g=(0,I.useRef)(s),_=(0,I.useRef)(i),v=(0,I.useRef)(a);return(0,I.useEffect)(()=>{p.current=e},[e]),(0,I.useEffect)(()=>{m.current=r},[r]),(0,I.useEffect)(()=>{g.current=s},[s]),(0,I.useEffect)(()=>{_.current=i},[i]),(0,I.useEffect)(()=>{v.current=a},[a]),(0,I.useEffect)(()=>{let e=!1;return De(),t(()=>import(`./editor.main-C9J2ikJK.js`).then(t=>{if(e||!c.current)return;u.current=t;let n=Ee(t,g.current),r=t.editor.create(c.current,{value:p.current,language:m.current,readOnly:_.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,I.useEffect)(()=>{let t=l.current;t&&t.getValue?.()!==e&&t.setValue?.(e)},[e]),(0,I.useEffect)(()=>{l.current?.updateOptions?.({readOnly:i})},[i]),(0,I.useEffect)(()=>{let e=u.current,t=l.current;if(!e||!t)return;let n=t.getModel?.();n&&e.editor.setModelLanguage(n,r)},[r]),(0,I.useEffect)(()=>{let e=u.current;if(!e)return;let t=Ee(e,s);e.editor.setTheme(t)},[s]),d?(0,X.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,X.jsx)(`span`,{children:o(`monaco.loadFailed`)}),(0,X.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,X.jsx)(`div`,{ref:c,className:`w-full h-full`,"data-testid":`monaco-host`})}var ke=(0,I.lazy)(async()=>({default:Oe}));function Ae({content:e,language:t,readOnly:r=!0,onChange:i}){let{t:a}=n(`code`);return(0,X.jsx)(I.Suspense,{fallback:(0,X.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,X.jsx)(ke,{content:e,language:t,readOnly:r,onChange:i})})}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:r,regenerating:i,generateDisabledReason:a,onCollapse:o}){let{t:s,i18n:c}=n(`code`),{openTicketDetail:l}=_();if(!t)return(0,X.jsx)(`div`,{className:`border-b border-border px-4 py-3 bg-surface`,"data-testid":`summary-header-empty`,children:(0,X.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,X.jsxs)(`div`,{className:`flex flex-col gap-0.5 min-w-0`,children:[(0,X.jsx)(`span`,{className:`text-xs text-muted-foreground truncate`,children:e}),(0,X.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:a?s(`summary.unavailable`,{reason:a}):s(`summary.empty`)})]}),o&&(0,X.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,X.jsx)(u,{className:`h-3.5 w-3.5`}),s(`summary.hide`)]})]})});let d=je(t.generatedAt,c.language),f=t.triggeredBy?.ticketId,p=t.triggeredBy?.modifiedTicketIds??[];return(0,X.jsx)(`div`,{className:`border-b border-border px-4 py-3 bg-surface`,"data-testid":`summary-header`,children:(0,X.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,X.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,X.jsx)(`span`,{className:`text-xs text-muted-foreground truncate`,children:e}),r&&(0,X.jsx)(`span`,{className:O(`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`)}),i&&(0,X.jsx)(`span`,{className:`w-1.5 h-1.5 rounded-full bg-accent-primary animate-pulse`,"aria-hidden":!0})]}),(0,X.jsx)(`p`,{className:`text-sm text-foreground mt-1`,children:t.summary}),(0,X.jsxs)(`div`,{className:`flex items-center gap-2 mt-2 flex-wrap`,children:[typeof f==`number`&&(0,X.jsxs)(`button`,{type:`button`,onClick:()=>l(f),className:`text-[10px] px-1.5 py-0.5 rounded bg-accent-success/20 text-accent-success`,children:[`#`,f]}),p.map(e=>(0,X.jsxs)(`button`,{type:`button`,onClick:()=>l(e),className:`text-[10px] px-1.5 py-0.5 rounded bg-accent-info/15 text-accent-info`,children:[`#`,e]},e)),d&&(0,X.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:d})]})]}),o&&(0,X.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,X.jsx)(u,{className:`h-3.5 w-3.5`}),s(`summary.hide`)]})]})})}function Ne({content:e}){return(0,X.jsx)(s,{remarkPlugins:[w],children:e})}var Pe={done:`bg-accent-success/15 text-accent-success`,in_progress:`bg-accent-info/15 text-accent-info`,on_review:`bg-accent-warning/15 text-accent-warning`,todo:`bg-muted/60 text-muted-foreground`,draft:`bg-accent-secondary/15 text-accent-secondary`};function Fe(e){return e===`created`?A:e===`deleted`?D:x}function Ie({relPath:e,height:t,onOpenTicket:r,onFilterJob:i}){let{t:a}=n(`code`),{activeProjectId:o}=C(),{registerHandler:s,unregisterHandler:c}=y(),[l,u]=(0,I.useState)(null),[d,f]=(0,I.useState)(!1),[p,m]=(0,I.useState)({}),h=(0,I.useRef)(o);(0,I.useEffect)(()=>{h.current=o},[o]);let g=(0,I.useRef)(e);(0,I.useEffect)(()=>{g.current=e},[e]);let _=(0,I.useRef)(0),v=(0,I.useCallback)(async()=>{let t=++_.current;try{let n=await fetch(`${M()}/code/file/story?path=${encodeURIComponent(e)}`);if(t!==_.current)return;if(!n.ok){u([]),f(!0);return}let r=await n.json();if(t!==_.current)return;u(Array.isArray(r.story)?r.story:[]),f(!1)}catch{t===_.current&&(u([]),f(!0))}},[e,o]);(0,I.useEffect)(()=>{u(null),m({}),v()},[v]),(0,I.useEffect)(()=>{if(!o)return;let e=`code-story-${o}`;return s(e,e=>{let t=e;t.projectId===h.current&&t.path===g.current&&(t.type===`file.story_updated`||t.type===`file.provenance_updated`)&&v()}),()=>c(e)},[o,s,c,v]);let b=(0,I.useCallback)(async(t,n)=>{m(e=>({...e,[t.provenanceId]:`busy`}));try{let r=await fetch(`${M()}/code/file/story/explain?path=${encodeURIComponent(e)}`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({provenanceId:t.provenanceId,overrideBudget:n})}),i=await r.json().catch(()=>({}));if(i.skipped===`budget`){m(e=>({...e,[t.provenanceId]:`budget`}));return}if(!r.ok||!i.ok){P.error(a(`story.explainFailed`)),m(e=>{let n={...e};return delete n[t.provenanceId],n});return}await v(),m(e=>{let n={...e};return delete n[t.provenanceId],n})}catch{P.error(a(`story.explainFailed`)),m(e=>{let n={...e};return delete n[t.provenanceId],n})}},[v,e,a]);return(0,X.jsx)(`div`,{className:`shrink-0 border-t border-border bg-card/40 px-4 py-3 overflow-hidden`,style:{height:t},"data-testid":`construction-story`,children:(0,X.jsx)(`div`,{className:`h-full overflow-auto`,children:l===null?(0,X.jsx)(`div`,{className:`text-[11px] text-muted-foreground animate-pulse py-2`,children:a(`story.loading`)}):d?(0,X.jsx)(`div`,{className:`text-[11px] text-muted-foreground py-2`,"data-testid":`story-failed`,children:a(`story.loadFailed`)}):l.length===0?(0,X.jsx)(`div`,{className:`text-[11px] text-muted-foreground py-2`,"data-testid":`story-empty`,children:a(`story.empty`)}):(0,X.jsx)(`ol`,{className:`relative ml-1.5 border-l border-border/60 space-y-3 py-1`,children:l.map(e=>(0,X.jsx)(Le,{entry:e,state:p[e.provenanceId],onOpenTicket:r,onFilterJob:i,onExplain:t=>{b(e,t)}},e.provenanceId))})})})}function Le({entry:e,state:t,onOpenTicket:r,onFilterJob:i,onExplain:a}){let{t:o}=n(`code`),s=Fe(e.kind),l=e.ticket?.status??null,u=e.ticket?.title?`#${e.ticket.id} · ${e.ticket.title}`:e.ticketId==null?null:o(`story.spec`,{ticketId:e.ticketId}),d=e.ticketId==null?`${e.kind}NoSpec`:e.kind;return(0,X.jsxs)(`li`,{className:`relative pl-4`,"data-testid":`story-card`,children:[(0,X.jsx)(`span`,{"aria-hidden":!0,className:`absolute -left-[5px] top-2 h-2.5 w-2.5 rounded-full border-2 border-background ${e.kind===`created`?`bg-accent-success`:e.kind===`deleted`?`bg-destructive`:`bg-accent-info`}`}),(0,X.jsxs)(`article`,{className:`rounded-lg border border-border/60 bg-card/60 px-3 py-2.5 backdrop-blur-sm transition-colors hover:border-border`,children:[(0,X.jsxs)(`header`,{className:`flex flex-wrap items-center gap-2`,children:[(0,X.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-xs text-muted-foreground`,children:[(0,X.jsx)(s,{className:`h-3.5 w-3.5 shrink-0`}),o(`story.kindLabel.${e.kind}`)]}),u!=null&&e.ticketId!=null&&(0,X.jsx)(`button`,{type:`button`,onClick:()=>r(e.ticketId),className:`min-w-0 max-w-full truncate rounded bg-accent-primary/15 px-1.5 py-0.5 text-left text-[11px] font-medium text-accent-primary hover:bg-accent-primary/25`,title:o(`story.openSpec`,{ticketId:e.ticketId}),children:u}),u==null&&(0,X.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,children:o(`story.unknownSpec`)}),l&&(0,X.jsx)(`span`,{className:`rounded px-1.5 py-0.5 text-[10px] ${Pe[l]??`bg-muted/60 text-muted-foreground`}`,"data-testid":`story-status-pill`,children:l}),(0,X.jsxs)(`span`,{className:`ml-auto inline-flex items-center gap-2`,children:[e.addedLines!=null&&e.addedLines>0&&(0,X.jsxs)(`span`,{className:`font-mono text-[10px] text-accent-success`,title:o(`story.linesAdded`),children:[`+`,e.addedLines]}),e.removedLines!=null&&e.removedLines>0&&(0,X.jsxs)(`span`,{className:`font-mono text-[10px] text-destructive`,title:o(`story.linesRemoved`),children:[`−`,e.removedLines]}),(0,X.jsx)(`time`,{className:`text-[10px] text-muted-foreground`,dateTime:new Date(e.at).toISOString(),children:new Date(e.at).toLocaleString()})]})]}),(0,X.jsx)(`div`,{className:`mt-1.5`,children:e.summary?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`p`,{className:`text-sm leading-relaxed text-foreground/90`,"data-testid":`story-contribution`,children:e.summary}),e.summaryModel&&(0,X.jsx)(`p`,{className:`mt-1 text-[10px] text-muted-foreground/80`,children:o(`story.explainedBy`,{model:e.summaryModel})})]}):(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,X.jsx)(`p`,{className:`text-xs text-muted-foreground`,"data-testid":`story-fallback`,children:o(`story.fallback.${d}`)}),t===`budget`?(0,X.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,X.jsx)(`span`,{className:`text-[10px] text-accent-warning`,children:o(`story.budgetReached`)}),(0,X.jsx)(`button`,{type:`button`,onClick:()=>a(!0),className:`rounded bg-accent-warning/15 px-1.5 py-0.5 text-[10px] text-accent-warning hover:bg-accent-warning/25`,children:o(`story.generateAnyway`)})]}):(0,X.jsxs)(`button`,{type:`button`,onClick:()=>a(!1),disabled:t===`busy`,className:`inline-flex items-center gap-1 rounded bg-accent-primary/10 px-1.5 py-0.5 text-[10px] text-accent-primary hover:bg-accent-primary/20 disabled:opacity-60`,"data-testid":`story-explain`,children:[(0,X.jsx)(c,{className:t===`busy`?`h-3 w-3 animate-pulse`:`h-3 w-3`}),o(t===`busy`?`story.explaining`:`story.explain`)]})]})}),e.jobId&&i&&(0,X.jsx)(`footer`,{className:`mt-1.5`,children:(0,X.jsx)(`button`,{type:`button`,onClick:()=>i(e.jobId),className:`font-mono text-[10px] text-muted-foreground hover:text-foreground`,title:o(`history.filterByJob`,{jobId:e.jobId}),children:e.jobId.length>12?e.jobId.slice(0,12):e.jobId})})]})]})}function Re(e,t){return t===`markdown`||t===`md`?!0:/\.(md|mdx|markdown)$/i.test(e)}var ze=180,Be=120,Ve=240;function He(e){return e?`specrails-desktop:code-summary-collapsed:${e}`:null}function Ue(e){return e?`specrails-desktop:code-history-height:${e}`:null}function We(e){return e?`specrails-desktop:code-history-collapsed:${e}`:null}function Ge(e){return e?`specrails-desktop:code-history-mode:${e}`:null}function Ke(e){let t=Ge(e);if(!t)return`story`;try{return localStorage.getItem(t)===`log`?`log`:`story`}catch{return`story`}}function qe(e,t){let n=Ge(e);if(n)try{localStorage.setItem(n,t)}catch{}}function Je(e){let t=Ue(e);if(!t)return ze;try{let e=localStorage.getItem(t),n=e?Number(e):NaN;return Number.isFinite(n)&&n>0?n:ze}catch{return ze}}function Ye(e,t){let n=Ue(e);if(n)try{localStorage.setItem(n,String(Math.round(t)))}catch{}}function Xe(e){let t=He(e);if(!t)return!1;try{return localStorage.getItem(t)===`true`}catch{return!1}}function Ze(e,t){let n=He(e);if(n)try{localStorage.setItem(n,t?`true`:`false`)}catch{}}function Qe(e){let t=We(e);if(!t)return!1;try{return localStorage.getItem(t)===`true`}catch{return!1}}function $e(e,t){let n=We(e);if(n)try{localStorage.setItem(n,t?`true`:`false`)}catch{}}function et(e,t){let n=Math.max(Be,t-Ve);return Math.min(Math.max(e,Be),n)}function tt({relPath:e,onFilterJob:t,onSummaryActionChange:i,onCopyPathActionChange:a}){let{t:o}=n(`code`),{activeProjectId:s}=C(),{openTicketDetail:c}=_(),{registerHandler:l,unregisterHandler:d}=y(),p=m({allowMove:!1}),h=(0,I.useRef)(null),[g,v]=(0,I.useState)(null),[b,x]=(0,I.useState)(!0),[S,w]=(0,I.useState)(!1),[T,E]=(0,I.useState)(!1),[D,O]=(0,I.useState)(()=>Xe(s)),[k,A]=(0,I.useState)(()=>Je(s)),[j,N]=(0,I.useState)(()=>Qe(s)),[F,L]=(0,I.useState)(()=>Ke(s)),R=(0,I.useRef)(s);(0,I.useEffect)(()=>{R.current=s},[s]);let z=(0,I.useRef)(e);(0,I.useEffect)(()=>{z.current=e},[e]),(0,I.useEffect)(()=>{let e=h.current?.clientHeight||window.innerHeight;O(Xe(s)),A(et(Je(s),e)),N(Qe(s)),L(Ke(s))},[s]);let ee=(0,I.useCallback)(e=>{let t=e.clientY,n=k,r=h.current?.clientHeight||window.innerHeight,i=e.currentTarget;try{i.setPointerCapture(e.pointerId)}catch{}function a(e){A(et(n+(t-e.clientY),r))}function o(){window.removeEventListener(`pointermove`,a),window.removeEventListener(`pointerup`,o),window.removeEventListener(`pointercancel`,o),A(e=>{let t=et(e,r);return Ye(s,t),t})}window.addEventListener(`pointermove`,a),window.addEventListener(`pointerup`,o),window.addEventListener(`pointercancel`,o)},[s,k]),te=(0,I.useCallback)(()=>{let e=et(ze,h.current?.clientHeight||window.innerHeight);A(e),Ye(s,e)},[s]),ne=(0,I.useCallback)(()=>{O(e=>{let t=!e;return Ze(s,t),t})},[s]),B=(0,I.useCallback)(()=>{N(e=>{let t=!e;return $e(s,t),t})},[s]),V=(0,I.useCallback)(e=>{L(e),qe(s,e)},[s]);(0,I.useEffect)(()=>{w(!1),E(!1),q(`preview`),J(!1)},[e]);let H=(0,I.useRef)(0),U=(0,I.useCallback)(async()=>{let t=++H.current;x(!0);try{let n=await fetch(`${M()}/code/file?path=${encodeURIComponent(e)}`);if(t!==H.current)return;if(!n.ok){v(null);return}let r=await n.json();if(t!==H.current)return;v(r)}catch{t===H.current&&v(null)}finally{t===H.current&&x(!1)}},[e,s]);(0,I.useEffect)(()=>{U()},[U]),(0,I.useEffect)(()=>{if(!s)return;let e=`code-file-${s}`;return l(e,e=>{let t=e;t.projectId===R.current&&(t.type===`file.summary_updated`&&t.path===z.current?(w(!1),U()):t.type===`file.summary_failed`&&t.path===z.current?(P.error(t.reason??o(`summary.generationFailed`)),w(!1)):t.type===`file.summary_skipped`&&t.path===z.current&&(t.reason&&P(o(`summary.skipped`,{reason:t.reason})),w(!1)))}),()=>d(e)},[s,l,d,U,o]);let W=(0,I.useCallback)(async t=>{w(!0);try{let n=await fetch(`${M()}/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){w(!1);let e=typeof r.skipped==`string`?r.skipped:null;P.error(e?o(`summary.skipped`,{reason:e}):o(`summary.generationFailed`));return}if(r.skipped===`budget`){w(!1),E(!0);return}if(r.skipped){w(!1),P(o(`summary.skipped`,{reason:r.skipped}));return}await U(),w(!1)}catch{w(!1),P.error(o(`summary.generationFailed`))}},[U,e,o]),re=(0,I.useCallback)(async()=>{let t=g?.absolutePath??e;try{await navigator.clipboard?.writeText(t),P.success(o(`viewer.pathCopied`))}catch{P.error(o(`viewer.copyPathFailed`))}},[g,e,o]),G=(0,I.useMemo)(()=>Re(e,g?.language),[e,g?.language]),[K,q]=(0,I.useState)(`preview`),[ie,J]=(0,I.useState)(!1),[ae,oe]=(0,I.useState)(``),[Y,se]=(0,I.useState)(!1),ce=g?.content!==void 0&&!g.binary&&!g.tooLarge&&g.reason!==`not-found`,le=(0,I.useCallback)(()=>{oe(g?.content??``),q(`raw`),J(!0)},[g]),ue=(0,I.useCallback)(async()=>{se(!0);try{let t=await fetch(`${M()}/code/file`,{method:`PUT`,headers:{"content-type":`application/json`},body:JSON.stringify({path:e,content:ae})});if(!t.ok){let e=await t.json().catch(()=>({}));P.error(e.error??o(`viewer.saveFailed`));return}P.success(o(`viewer.saved`)),J(!1),U()}catch{P.error(o(`viewer.saveFailed`))}finally{se(!1)}},[e,ae,o,U]),Z=g?.summary??null,de=!!g?.summaryStale,fe=g?.provenance??[],pe=g?.reason===`not-found`,me=pe?o(`summary.reason.missing`):g?.binary?o(`summary.reason.binary`):g?.tooLarge?o(`summary.reason.tooLarge`):null;return(0,I.useEffect)(()=>{if(i){if(b&&!g){i(null);return}return i({hasSummary:!!Z,regenerating:S,disabledReason:me,onClick:()=>W(!1)}),()=>i(null)}},[g,W,b,i,S,Z,me]),(0,I.useEffect)(()=>{if(a){if(b&&!g){a(null);return}return a({onClick:re}),()=>a(null)}},[re,g,b,a]),b&&!g?(0,X.jsx)(`div`,{className:`flex-1 flex items-center justify-center text-sm text-muted-foreground animate-pulse`,children:o(`viewer.loadingFile`)}):(0,X.jsxs)(`div`,{ref:h,className:`flex flex-col h-full`,"data-testid":`file-viewer`,children:[D?(0,X.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,X.jsx)(`span`,{className:`truncate text-xs text-muted-foreground`,children:e}),(0,X.jsxs)(`button`,{type:`button`,onClick:ne,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,X.jsx)(r,{className:`h-3.5 w-3.5`}),o(`viewer.showSummary`)]})]}):(0,X.jsx)(Me,{path:e,summary:Z,stale:de,regenerating:S,generateDisabledReason:me,onCollapse:ne}),(0,X.jsxs)(`div`,{className:`px-4 py-1 border-b border-border flex items-center justify-between gap-3`,children:[(0,X.jsx)(`div`,{className:`flex items-center gap-2 min-w-0`,children:G&&g?.content!==void 0&&!g.binary&&!g.tooLarge&&(0,X.jsxs)(`div`,{className:`flex items-center gap-1 text-[11px]`,role:`group`,"aria-label":o(`viewer.markdownViewMode`),children:[(0,X.jsx)(`button`,{type:`button`,onClick:()=>q(`preview`),"aria-pressed":K===`preview`,className:K===`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,X.jsx)(`button`,{type:`button`,onClick:()=>q(`raw`),"aria-pressed":K===`raw`,className:K===`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,X.jsxs)(`div`,{className:`flex items-center gap-1 text-[11px] shrink-0`,children:[ce&&!ie&&(0,X.jsx)(`button`,{type:`button`,onClick:le,className:`px-2 py-1 rounded-md text-muted-foreground hover:text-foreground hover:bg-muted/50`,children:o(`viewer.edit`)}),ie&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`button`,{type:`button`,onClick:()=>J(!1),disabled:Y,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,X.jsx)(`button`,{type:`button`,onClick:ue,disabled:Y,className:`px-2 py-1 rounded-md bg-accent-primary/20 text-accent-primary hover:bg-accent-primary/30 disabled:opacity-50`,children:o(Y?`viewer.saving`:`viewer.save`)})]})]})]}),(0,X.jsx)(`div`,{className:`flex-1 overflow-hidden`,children:pe?(0,X.jsx)(`div`,{className:`h-full flex items-center justify-center text-sm text-muted-foreground`,"data-testid":`file-missing`,children:o(`viewer.missingFile`)}):g?.binary?(0,X.jsx)(`div`,{className:`h-full flex items-center justify-center text-sm text-muted-foreground`,"data-testid":`file-binary`,children:o(`viewer.binaryFile`)}):g?.tooLarge?(0,X.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((g.sizeBytes??0)/1024/1024)})}):g?.content===void 0?(0,X.jsx)(`div`,{className:`h-full flex items-center justify-center text-sm text-muted-foreground`,children:o(`viewer.noContent`)}):ie?(0,X.jsx)(Ae,{content:ae,language:g.language??`plaintext`,readOnly:!1,onChange:oe}):G&&K===`preview`?(0,X.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,X.jsx)(Ne,{content:g.content})}):(0,X.jsx)(Ae,{content:g.content,language:g.language??`plaintext`})}),fe.length>0&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`div`,{role:`separator`,"aria-orientation":`horizontal`,"aria-label":o(`history.resize`),onPointerDown:j?void 0:ee,onDoubleClick:j?void 0:te,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,X.jsx)(`span`,{className:`text-[11px] font-medium uppercase tracking-wider text-muted-foreground`,children:o(F===`story`?`story.title`:`history.title`,{count:fe.length})}),(0,X.jsxs)(`span`,{className:`flex items-center gap-1`,children:[!j&&(0,X.jsxs)(`span`,{className:`flex items-center gap-0.5 rounded-md bg-muted/40 p-0.5`,role:`group`,"aria-label":o(`story.viewMode`),onPointerDown:e=>e.stopPropagation(),children:[(0,X.jsx)(`button`,{type:`button`,onClick:()=>V(`story`),"aria-pressed":F===`story`,className:F===`story`?`rounded px-2 py-0.5 text-[10px] bg-accent-primary/20 text-accent-primary`:`rounded px-2 py-0.5 text-[10px] text-muted-foreground hover:text-foreground`,children:o(`story.modeStory`)}),(0,X.jsx)(`button`,{type:`button`,onClick:()=>V(`log`),"aria-pressed":F===`log`,className:F===`log`?`rounded px-2 py-0.5 text-[10px] bg-accent-primary/20 text-accent-primary`:`rounded px-2 py-0.5 text-[10px] text-muted-foreground hover:text-foreground`,children:o(`story.modeLog`)})]}),(0,X.jsxs)(`button`,{type:`button`,onPointerDown:e=>e.stopPropagation(),onClick:B,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,X.jsx)(u,{className:`h-3.5 w-3.5`}):(0,X.jsx)(r,{className:`h-3.5 w-3.5`}),o(j?`history.show`:`history.hide`)]})]})]}),!j&&(F===`story`?(0,X.jsx)(Ie,{relPath:e,height:k,onOpenTicket:c,onFilterJob:t}):(0,X.jsx)(nt,{rows:fe,onOpenTicket:c,onFilterJob:t,height:k}))]}),T&&(0,X.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(()=>E(!1)),children:[(0,X.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,X.jsx)(`p`,{className:`text-sm text-foreground`,children:o(`viewer.budgetPrompt`)}),(0,X.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,X.jsx)(`button`,{type:`button`,onClick:()=>E(!1),className:`text-xs px-3 py-1.5 rounded-md text-muted-foreground hover:text-foreground`,children:o(`common:actions.cancel`)}),(0,X.jsx)(`button`,{type:`button`,onClick:()=>{E(!1),W(!0)},className:`text-xs px-3 py-1.5 rounded-md bg-accent-primary text-white`,children:o(`common:actions.confirm`)})]})]}),(0,X.jsx)(f,{handles:p.resizeHandles})]})]})}function nt({rows:e,onOpenTicket:t,onFilterJob:r,height:i}){let{t:a}=n(`code`),[o,s]=(0,I.useState)(null),[c,l]=(0,I.useState)({});if(e.length===0)return null;async function u(e,t){if(o===t){s(null);return}if(s(t),!(!e.jobId||c[t])){l(e=>({...e,[t]:`loading`}));try{let n=new URLSearchParams({jobId:e.jobId,path:e.path}),r=await fetch(`${M()}/code/diff?${n.toString()}`);if(r.status===404){l(e=>({...e,[t]:`missing`}));return}if(!r.ok)throw Error(`diff failed`);let i=await r.json();l(e=>({...e,[t]:{patch:i.patch??``,truncated:i.truncated===!0}}))}catch{l(e=>({...e,[t]:`missing`}))}}}return(0,X.jsx)(`div`,{className:`shrink-0 border-t border-border bg-card/40 px-4 py-3 overflow-hidden`,style:{height:i},"data-testid":`file-provenance-timeline`,children:(0,X.jsx)(`div`,{className:`h-full overflow-auto space-y-1`,children:e.map((e,n)=>{let i=e.kind===`created`?A:e.kind===`deleted`?D:x,s=e.jobId?e.jobId.length>12?e.jobId.slice(0,12):e.jobId:a(`history.unknownJob`),l=`${e.jobId??`job`}:${e.path}:${e.at}:${n}`,d=c[l];return(0,X.jsxs)(`div`,{className:`rounded-md hover:bg-muted/40`,children:[(0,X.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,X.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 min-w-0`,children:[(0,X.jsx)(i,{className:`h-3.5 w-3.5 text-muted-foreground shrink-0`}),(0,X.jsx)(`span`,{className:`capitalize`,children:a(`kind.${e.kind}`)})]}),(0,X.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 min-w-0 text-muted-foreground`,children:[(0,X.jsx)(k,{className:`h-3.5 w-3.5 shrink-0`}),e.jobId&&r?(0,X.jsx)(`button`,{type:`button`,onClick:()=>r(e.jobId),className:`font-mono truncate hover:text-foreground`,title:a(`history.filterByJob`,{jobId:e.jobId}),children:s}):(0,X.jsx)(`span`,{className:`font-mono truncate`,title:e.jobId??void 0,children:s}),e.jobId&&(0,X.jsx)(`button`,{type:`button`,onClick:()=>u(e,l),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,X.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,X.jsx)(`time`,{className:`text-[11px] text-muted-foreground`,dateTime:new Date(e.at).toISOString(),children:new Date(e.at).toLocaleString()})]}),o===l&&(0,X.jsx)(`div`,{className:`px-2 pb-2`,children:d===`loading`?(0,X.jsx)(`div`,{className:`rounded-md bg-muted/35 px-2 py-2 text-[11px] text-muted-foreground`,children:a(`history.loadingDiff`)}):d===`missing`||!d?(0,X.jsx)(`div`,{className:`rounded-md bg-muted/35 px-2 py-2 text-[11px] text-muted-foreground`,children:a(`history.diffUnavailable`)}):(0,X.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:[d.patch,d.truncated?`\n${a(`history.diffTruncated`)}`:``]})})]},l)})})})}var rt=320,it=240,at=520;function ot(e){return e?`specrails-desktop:code-tree-width:${e}`:null}function st(e){let t=ot(e);if(!t)return rt;try{let e=localStorage.getItem(t),n=e?Number(e):NaN;return Number.isFinite(n)&&n>0?n:rt}catch{return rt}}function ct(e,t){let n=ot(e);if(n)try{localStorage.setItem(n,String(Math.round(t)))}catch{}}function $(e,t){let n=Math.max(it,t-at);return Math.min(Math.max(e,it),n)}function lt({embedded:e=!1,initialPath:t=null,onSelectedPathChange:r}={}){let{t:i}=n(`code`),{activeProjectId:o}=C(),[s]=j(),c=a(),l=(0,I.useRef)(null),[u,d]=(0,I.useState)(e?t:s.get(`path`)),f=(0,I.useCallback)(e=>{d(e),r?.(e)},[r]),[p,m]=(0,I.useState)(null),[h,g]=(0,I.useState)(null),[_,v]=(0,I.useState)(()=>st(o)),[y,b]=(0,I.useState)(null),[x,S]=(0,I.useState)(null),w=e?y:s.get(`jobId`),T=(0,I.useMemo)(()=>{if(e)return x;let t=s.get(`ticketId`);if(!t)return null;let n=Number(t);return Number.isInteger(n)&&n>0?n:null},[e,x,s]),[E,D]=(0,I.useState)(T==null?``:String(T));(0,I.useEffect)(()=>{if(e)return;let t=s.get(`path`);t!==u&&d(t)},[s,e]),(0,I.useEffect)(()=>{D(T==null?``:String(T))},[T]),(0,I.useEffect)(()=>{let e=l.current?.clientWidth||window.innerWidth;v($(st(o),e))},[o]),(0,I.useEffect)(()=>{let e=l.current;if(!e||typeof ResizeObserver>`u`)return;let t=new ResizeObserver(e=>{let t=e[0]?.contentRect.width;typeof t==`number`&&v(e=>$(e,t))});return t.observe(e),()=>t.disconnect()},[]);let O=(0,I.useCallback)(e=>{let t=e.clientX,n=_,r=l.current?.clientWidth||window.innerWidth,i=e.currentTarget;try{i.setPointerCapture(e.pointerId)}catch{}function a(e){v($(n+(e.clientX-t),r))}function s(){window.removeEventListener(`pointermove`,a),window.removeEventListener(`pointerup`,s),window.removeEventListener(`pointercancel`,s),v(e=>{let t=$(e,r);return ct(o,t),t})}window.addEventListener(`pointermove`,a),window.addEventListener(`pointerup`,s),window.addEventListener(`pointercancel`,s)},[o,_]),k=(0,I.useCallback)(()=>{let e=$(rt,l.current?.clientWidth||window.innerWidth);v(e),ct(o,e)},[o]),A=(0,I.useCallback)(t=>{if(f(t),e)return;let n=new URLSearchParams(s);n.set(`path`,t),c({pathname:`/code`,search:`?${n.toString()}`},{replace:!0})},[e,c,s,f]),M=(0,I.useCallback)(t=>{if(e){b(t),S(null);return}let n=new URLSearchParams(s);n.set(`jobId`,t),n.delete(`ticketId`),c({pathname:`/code`,search:`?${n.toString()}`},{replace:!0})},[e,c,s]),N=(0,I.useCallback)(()=>{if(e){b(null),S(null);return}let t=new URLSearchParams(s);t.delete(`jobId`),t.delete(`ticketId`),c({pathname:`/code`,search:t.toString()?`?${t.toString()}`:``},{replace:!0})},[e,c,s]),P=(0,I.useCallback)(t=>{let n=Number(t.trim());if(!Number.isInteger(n)||n<=0){N();return}if(e){S(n),b(null);return}let r=new URLSearchParams(s);r.set(`ticketId`,String(n)),r.delete(`jobId`),c({pathname:`/code`,search:`?${r.toString()}`},{replace:!0})},[N,e,c,s]);return(0,X.jsxs)(`div`,{ref:l,className:`flex h-full w-full`,"data-testid":`code-page`,children:[(0,X.jsx)(`aside`,{className:`overflow-hidden flex flex-col shrink-0`,style:{width:_},children:(0,X.jsx)(_e,{onOpenFile:A,selectedPath:u,filterJobId:w,filterTicketId:T},o??`no-project`)}),(0,X.jsx)(`div`,{role:`separator`,"aria-orientation":`vertical`,"aria-label":i(`page.resizeFileTree`),onPointerDown:O,onDoubleClick:k,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:i(`resizer.hint`),"data-testid":`code-tree-resizer`}),(0,X.jsxs)(`main`,{className:`flex-1 overflow-hidden flex flex-col`,children:[(0,X.jsx)(ut,{jobId:w,ticketId:T,ticketInput:E,onTicketInputChange:D,onApplyTicket:P,onClear:N,summaryAction:p,copyPathAction:h}),(w||T)&&(0,X.jsx)(dt,{jobId:w,ticketId:T,onOpenFile:A}),u?(0,X.jsx)(tt,{relPath:u,onFilterJob:M,onSummaryActionChange:m,onCopyPathActionChange:g}):(0,X.jsx)(`div`,{className:`h-full flex items-center justify-center text-sm text-muted-foreground`,children:i(`page.selectFile`)})]})]})}function ut({jobId:e,ticketId:t,ticketInput:r,onTicketInputChange:i,onApplyTicket:a,onClear:o,summaryAction:s,copyPathAction:c}){let{t:l}=n(`code`),u=t?`spec`:e?`job-context`:`all`;return(0,X.jsx)(`div`,{className:`border-b border-border bg-background/80 px-4 py-2`,"data-testid":`code-provenance-toolbar`,children:(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,X.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-xs font-medium text-muted-foreground`,children:[(0,X.jsx)(F,{className:`h-3.5 w-3.5`}),l(`toolbar.scope`)]}),(0,X.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,X.jsxs)(`div`,{className:`flex items-center gap-1 rounded-md border border-border/70 bg-card/40 px-1 py-1`,children:[(0,X.jsx)(`button`,{type:`button`,onClick:()=>a(r),"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,X.jsx)(`input`,{value:r,onChange:e=>i(e.target.value),onKeyDown:e=>{e.key===`Enter`&&a(r)},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,X.jsx)(`div`,{className:`flex-1`}),c&&(0,X.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,X.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,X.jsx)(d,{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,X.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,X.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,X.jsx)(N,{className:`h-3.5 w-3.5`}),l(`toolbar.clear`)]})]})})}function dt({jobId:e,ticketId:t,onOpenFile:r}){let{t:i}=n(`code`),[a,o]=(0,I.useState)(null);(0,I.useEffect)(()=>{let n=!1,r=new URLSearchParams;return e&&r.set(`jobId`,e),t&&r.set(`ticketId`,String(t)),fetch(`${M()}/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,I.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,X.jsx)(`section`,{className:`border-b border-border bg-card/35 px-4 py-3`,"data-testid":`provenance-result-panel`,children:(0,X.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,X.jsxs)(`div`,{className:`min-w-0`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,X.jsx)(`h2`,{className:`text-sm font-semibold truncate`,children:e?i(`provenancePanel.jobTitle`,{jobId:e}):i(`provenancePanel.specTitle`,{ticketId:t})}),(0,X.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,children:i(`provenancePanel.touchedFiles`,{count:c})})]}),(0,X.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-2`,children:[(0,X.jsx)(ft,{label:i(`action.added`),rows:s.created,icon:`created`,onOpenFile:r}),(0,X.jsx)(ft,{label:i(`action.changed`),rows:s.modified,icon:`modified`,onOpenFile:r}),(0,X.jsx)(ft,{label:i(`action.deleted`),rows:s.deleted,icon:`deleted`,onOpenFile:r})]})]}),(0,X.jsx)(`div`,{className:`flex items-center gap-1 shrink-0`,children:e&&(0,X.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,X.jsx)(S,{className:`h-3.5 w-3.5`}),i(`provenancePanel.log`)]})})]})})}function ft({label:e,rows:t,icon:n,onOpenFile:r}){return(0,X.jsxs)(`details`,{className:`group min-w-[180px] max-w-[320px]`,children:[(0,X.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,X.jsx)(n===`created`?A:n===`deleted`?D:x,{className:`h-3.5 w-3.5 text-muted-foreground`}),(0,X.jsx)(`span`,{children:e}),(0,X.jsx)(`span`,{className:`text-muted-foreground`,children:t.length})]}),t.length>0&&(0,X.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,X.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{lt as default};
|
package/client/dist/assets/{DesktopAnalyticsPage-COkzgMmd.js → DesktopAnalyticsPage-DbgMa8OO.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e}from"./chunk-BNv3lrIs.js";import{t}from"./clsx-CNmW0Nip.js";import{Cn as n,Ct as r,Kn as i,Rn as a,Sn as o,bn as s,g as c,gn as l,rt as u,x as d}from"./index-Dw1N2-ci.js";import{$ as f,A as p,B as m,E as h,F as g,H as _,K as v,L as y,N as b,O as x,P as S,Q as C,R as w,S as T,T as ee,U as E,W as D,X as O,Y as te,Z as k,_ as ne,_t as A,a as re,c as ie,d as ae,dt as j,et as M,ft as oe,g as se,gt as ce,h as le,ht as ue,i as de,it as N,j as fe,k as pe,l as P,lt as F,mt as me,n as he,nt as I,o as ge,pt as L,q as R,r as z,rt as B,s as _e,t as ve,u as ye,ut as V,v as be,w as H,z as xe}from"./BarChart-BiLTq3uC.js";var Se=l(`trending-up`,[[`path`,{d:`M16 7h6v6`,key:`box55l`}],[`path`,{d:`m22 7-8.5 8.5-5-5L2 17`,key:`1t1m79`}]]),U=e(i());function W(){return W=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},W.apply(null,arguments)}var G=e=>{var{cx:n,cy:r,r:i,className:a}=e,o=t(`recharts-dot`,a);return j(n)&&j(r)&&j(i)?U.createElement(`circle`,W({},ce(e),N(e),{className:o,cx:n,cy:r,r:i})):null},Ce=[`points`];function K(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 q(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?K(Object(n),!0).forEach(function(t){we(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):K(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function we(e,t,n){return(t=Te(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Te(e){var t=Ee(e,`string`);return typeof t==`symbol`?t:t+``}function Ee(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)}function J(){return J=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},J.apply(null,arguments)}function De(e,t){if(e==null)return{};var n,r,i=Oe(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 Oe(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 ke(e){var{option:n,dotProps:r,className:i}=e;if((0,U.isValidElement)(n))return(0,U.cloneElement)(n,r);if(typeof n==`function`)return n(r);var a=t(i,typeof n==`boolean`?``:n.className),o=r??{},{points:s}=o,c=De(o,Ce);return U.createElement(G,J({},c,{className:a}))}function Ae(e,t){return e==null?!1:t?!0:e.length===1}function je(e){var{points:t,dot:n,className:r,dotClassName:i,dataKey:a,baseProps:o,needClip:s,clipPathId:c,zIndex:l=y.scatter}=e;if(!Ae(t,n))return null;var u=H(n),d=ue(n),f=t.map((e,r)=>{var s=q(q(q({r:3},o),d),{},{index:r,cx:e.x??void 0,cy:e.y??void 0,dataKey:a,value:e.value,payload:e.payload,points:t});return U.createElement(ke,{key:`dot-${r}`,option:n,dotProps:s,className:i})}),m={};return s&&c!=null&&(m.clipPath=`url(#clipPath-${u?``:`dots-`}${c})`),U.createElement(p,{zIndex:l},U.createElement(L,J({className:r},m),f))}function Me(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 Y(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?Me(Object(n),!0).forEach(function(t){Ne(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Me(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Ne(e,t,n){return(t=Pe(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Pe(e){var t=Fe(e,`string`);return typeof t==`symbol`?t:t+``}function Fe(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 Ie=e=>{var{point:t,childIndex:n,mainColor:r,activeDot:i,dataKey:a,clipPath:o}=e;if(i===!1||t.x==null||t.y==null)return null;var s=Y(Y(Y({},{index:n,dataKey:a,cx:t.x,cy:t.y,r:4,fill:r??`none`,strokeWidth:2,stroke:`#fff`,payload:t.payload,value:t.value}),A(i)),N(i)),c=(0,U.isValidElement)(i)?(0,U.cloneElement)(i,s):typeof i==`function`?i(s):U.createElement(G,s);return U.createElement(L,{className:`recharts-active-dot`,clipPath:o},c)};function Le(e){var{points:t,mainColor:n,activeDot:r,itemDataKey:i,clipPath:a,zIndex:o=y.activeDot}=e,s=I(fe),c=ye();if(t==null||c==null)return null;var l=t.find(e=>c.includes(e.payload));return V(l)?null:U.createElement(p,{zIndex:o},U.createElement(Ie,{point:l,childIndex:Number(s),mainColor:n,dataKey:i,activeDot:r,clipPath:a}))}var Re=(e,t,n,r)=>b(e,`xAxis`,t,r),ze=(e,t,n,r)=>S(e,`xAxis`,t,r),Be=(e,t,n,r)=>b(e,`yAxis`,n,r),Ve=(e,t,n,r)=>S(e,`yAxis`,n,r),He=M([E,Re,Be,ze,Ve],(e,t,n,r,i)=>f(e,`xAxis`)?te(t,r,!1):te(n,i,!1)),Ue=(e,t,n,r,i)=>i;function We(e){return e.type===`line`}var Ge=M([E,Re,Be,ze,Ve,M([g,Ue],(e,t)=>e.filter(We).find(e=>e.id===t)),He,w],(e,t,n,r,i,a,o,s)=>{var{chartData:c,dataStartIndex:l,dataEndIndex:u}=s;if(!(a==null||t==null||n==null||r==null||i==null||r.length===0||i.length===0||o==null||e!==`horizontal`&&e!==`vertical`)){var{dataKey:d,data:f}=a,p=f!=null&&f.length>0?f:c?.slice(l,u+1);if(p!=null)return gt({layout:e,xAxis:t,yAxis:n,xAxisTicks:r,yAxisTicks:i,dataKey:d,bandSize:o,displayedData:p})}});function Ke(e){var t=A(e),n=3,r=2;if(t!=null){var{r:i,strokeWidth:a}=t,o=Number(i),s=Number(a);return(Number.isNaN(o)||o<0)&&(o=n),(Number.isNaN(s)||s<0)&&(s=r),{r:o,strokeWidth:s}}return{r:n,strokeWidth:r}}var qe=[`id`],Je=[`type`,`layout`,`connectNulls`,`needClip`,`shape`],Ye=[`activeDot`,`animateNewValues`,`animationBegin`,`animationDuration`,`animationEasing`,`connectNulls`,`dot`,`hide`,`isAnimationActive`,`label`,`legendType`,`xAxisId`,`yAxisId`,`id`];function X(){return X=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},X.apply(null,arguments)}function Xe(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 Z(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?Xe(Object(n),!0).forEach(function(t){Ze(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Xe(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Ze(e,t,n){return(t=Qe(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Qe(e){var t=$e(e,`string`);return typeof t==`symbol`?t:t+``}function $e(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)}function Q(e,t){if(e==null)return{};var n,r,i=et(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 et(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}var tt=e=>{var{dataKey:t,name:n,stroke:r,legendType:i,hide:a}=e;return[{inactive:a,dataKey:t,type:i,color:r,value:k(n,t),payload:e}]},nt=U.memo(e=>{var{dataKey:t,data:n,stroke:r,strokeWidth:i,fill:a,name:o,hide:s,unit:c,tooltipType:l,id:u}=e,d={dataDefinedOnItem:n,getPosition:oe,settings:{stroke:r,strokeWidth:i,fill:a,dataKey:t,nameKey:void 0,name:k(o,t),hide:s,type:l,color:r,unit:c,graphicalItemId:u}};return U.createElement(be,{tooltipEntrySettings:d})}),rt=(e,t)=>`${t}px ${e}px`;function it(e,t){for(var n=e.length%2==0?e:[...e,0],r=[],i=0;i<t;++i)r.push(...n);return r}var at=(e,t,n)=>{var r=n.reduce((e,t)=>e+t,0);if(!r)return rt(t,e);for(var i=Math.floor(e/r),a=e%r,o=[],s=0,c=0;s<n.length;c+=(l=n[s])??0,++s){var l,u=n[s];if(u!=null&&c+u>a){o=[...n.slice(0,s),a-c];break}}var d=o.length%2==0?[0,t]:[t];return[...it(n,i),...o,...d].map(e=>`${e}px`).join(`, `)};function ot(e){var{clipPathId:t,points:n,props:r}=e,{dot:i,dataKey:a,needClip:o}=r,{id:s}=r,c=ce(Q(r,qe));return U.createElement(je,{points:n,dot:i,className:`recharts-line-dots`,dotClassName:`recharts-line-dot`,dataKey:a,baseProps:c,needClip:o,clipPathId:t})}function st(e){var{showLabels:t,children:n,points:r}=e,i=(0,U.useMemo)(()=>r?.map(e=>{var t={x:e.x??0,y:e.y??0,width:0,lowerWidth:0,upperWidth:0,height:0};return Z(Z({},t),{},{value:e.value,payload:e.payload,viewBox:t,parentViewBox:void 0,fill:void 0})}),[r]);return U.createElement(ee,{value:t?i:void 0},n)}function ct(e){var{clipPathId:t,pathRef:n,points:r,strokeDasharray:i,props:a}=e,{type:o,layout:s,connectNulls:c,needClip:l,shape:u}=a,d=Z(Z({},me(Q(a,Je))),{},{fill:`none`,className:`recharts-line-curve`,clipPath:l?`url(#clipPath-${t})`:void 0,points:r,type:o,layout:s,connectNulls:c,strokeDasharray:i??a.strokeDasharray});return U.createElement(U.Fragment,null,r?.length>1&&U.createElement(T,X({shapeType:`curve`,option:u},d,{pathRef:n})),U.createElement(ot,{points:r,clipPathId:t,props:a}))}function lt(e){try{return e&&e.getTotalLength&&e.getTotalLength()||0}catch{return 0}}function ut(e){var{clipPathId:t,props:n,pathRef:r,previousPointsRef:i,longestAnimatedLengthRef:a}=e,{points:o,strokeDasharray:s,isAnimationActive:c,animationBegin:l,animationDuration:u,animationEasing:d,animateNewValues:f,width:p,height:g,onAnimationEnd:_,onAnimationStart:v}=n,y=i.current,b=xe(o,`recharts-line-`),x=(0,U.useRef)(b),[S,C]=(0,U.useState)(!1),w=!S,T=(0,U.useCallback)(()=>{typeof _==`function`&&_(),C(!1)},[_]),ee=(0,U.useCallback)(()=>{typeof v==`function`&&v(),C(!0)},[v]),E=lt(r.current),D=(0,U.useRef)(0);x.current!==b&&(D.current=a.current,x.current=b);var O=D.current;return U.createElement(st,{points:o,showLabels:w},n.children,U.createElement(m,{animationId:b,begin:l,duration:u,isActive:c,easing:d,onAnimationEnd:T,onAnimationStart:ee,key:b},e=>{var l=F(O,E+O,e),u=Math.min(l,E),d=c?s?at(u,E,`${s}`.split(/[,\s]+/gim).map(e=>parseFloat(e))):rt(E,u):s==null?void 0:String(s);if(e>0&&E>0&&(i.current=o,a.current=Math.max(a.current,u)),y){var m=y.length/o.length,h=e===1?o:o.map((t,n)=>{var r=Math.floor(n*m);if(y[r]){var i=y[r];return Z(Z({},t),{},{x:F(i.x,t.x,e),y:F(i.y,t.y,e)})}return f?Z(Z({},t),{},{x:F(p*2,t.x,e),y:F(g/2,t.y,e)}):Z(Z({},t),{},{x:t.x,y:t.y})});return i.current=h,U.createElement(ct,{props:n,points:h,clipPathId:t,pathRef:r,strokeDasharray:d})}return U.createElement(ct,{props:n,points:o,clipPathId:t,pathRef:r,strokeDasharray:d})}),U.createElement(h,{label:n.label}))}function dt(e){var{clipPathId:t,props:n}=e,r=(0,U.useRef)(null),i=(0,U.useRef)(0),a=(0,U.useRef)(null);return U.createElement(ut,{props:n,clipPathId:t,previousPointsRef:r,longestAnimatedLengthRef:i,pathRef:a})}var ft=(e,t)=>({x:e.x??void 0,y:e.y??void 0,value:e.value,errorVal:C(e.payload,t)}),pt=class extends U.Component{render(){var{hide:e,dot:n,points:r,className:i,xAxisId:a,yAxisId:o,top:s,left:c,width:l,height:u,id:d,needClip:f,zIndex:m}=this.props;if(e)return null;var h=t(`recharts-line`,i),g=d,{r:_,strokeWidth:v}=Ke(n),y=H(n),b=_*2+v,x=f?`url(#clipPath-${y?``:`dots-`}${g})`:void 0;return U.createElement(p,{zIndex:m},U.createElement(L,{className:h},f&&U.createElement(`defs`,null,U.createElement(ge,{clipPathId:g,xAxisId:a,yAxisId:o}),!y&&U.createElement(`clipPath`,{id:`clipPath-dots-${g}`},U.createElement(`rect`,{x:c-b/2,y:s-b/2,width:l+b,height:u+b}))),U.createElement(ie,{xAxisId:a,yAxisId:o,data:r,dataPointFormatter:ft,errorBarOffset:0},U.createElement(dt,{props:this.props,clipPathId:g}))),U.createElement(Le,{activeDot:this.props.activeDot,points:r,mainColor:this.props.stroke,itemDataKey:this.props.dataKey,clipPath:x}))}},mt={activeDot:!0,animateNewValues:!0,animationBegin:0,animationDuration:1500,animationEasing:`ease`,connectNulls:!1,dot:!0,fill:`#fff`,hide:!1,isAnimationActive:`auto`,label:!1,legendType:`line`,stroke:`#3182bd`,strokeWidth:1,xAxisId:0,yAxisId:0,zIndex:y.line,type:`linear`};function ht(e){var t=B(e,mt),{activeDot:n,animateNewValues:r,animationBegin:i,animationDuration:a,animationEasing:o,connectNulls:s,dot:c,hide:l,isAnimationActive:u,label:d,legendType:f,xAxisId:p,yAxisId:m,id:h}=t,g=Q(t,Ye),{needClip:_}=_e(p,m),v=ae(),y=D(),b=R(),x=I(e=>Ge(e,p,m,b,h));if(y!==`horizontal`&&y!==`vertical`||x==null||v==null)return null;var{height:S,width:C,x:w,y:T}=v;return U.createElement(pt,X({},g,{id:h,connectNulls:s,dot:c,activeDot:n,animateNewValues:r,animationBegin:i,animationDuration:a,animationEasing:o,isAnimationActive:u,hide:l,label:d,legendType:f,xAxisId:p,yAxisId:m,points:x,layout:y,height:S,width:C,left:w,top:T,needClip:_}))}function gt(e){var{layout:t,xAxis:n,yAxis:r,xAxisTicks:i,yAxisTicks:a,dataKey:o,bandSize:s,displayedData:c}=e;return c.map((e,c)=>{var l=C(e,o);if(t===`horizontal`)return{x:O({axis:n,ticks:i,bandSize:s,entry:e,index:c}),y:(V(l)?null:r.scale.map(l))??null,value:l,payload:e};var u=V(l)?null:n.scale.map(l),d=O({axis:r,ticks:a,bandSize:s,entry:e,index:c});return u==null||d==null?null:{x:u,y:d,value:l,payload:e}}).filter(Boolean)}function _t(e){var t=B(e,mt),n=R();return U.createElement(se,{id:t.id,type:`line`},e=>U.createElement(U.Fragment,null,U.createElement(ne,{legendPayload:tt(t)}),U.createElement(nt,{dataKey:t.dataKey,data:t.data,stroke:t.stroke,strokeWidth:t.strokeWidth,fill:t.fill,name:t.name,hide:t.hide,unit:t.unit,tooltipType:t.tooltipType,id:e}),U.createElement(le,{type:`line`,id:e,data:t.data,xAxisId:t.xAxisId,yAxisId:t.yAxisId,zAxisId:0,dataKey:t.dataKey,hide:t.hide,isPanorama:n}),U.createElement(ht,X({},t,{id:e}))))}var vt=U.memo(_t,_);vt.displayName=`Line`;var yt=[`axis`],bt=(0,U.forwardRef)((e,t)=>U.createElement(he,{chartName:`LineChart`,defaultTooltipEventType:`axis`,validateTooltipEventTypes:yt,tooltipPayloadSearcher:pe,categoricalChartProps:e,ref:t})),$=n(),xt=[{value:`7d`,labelKey:`periods.d7`},{value:`30d`,labelKey:`periods.d30`},{value:`90d`,labelKey:`periods.d90`},{value:`all`,labelKey:`periods.all`},{value:`custom`,labelKey:`periods.custom`}];function St({period:e,from:t,to:n,onChange:r}){let{t:i}=a(`analytics`);function o(e){e===`custom`?r(`custom`,t,n):r(e)}function s(e){r(`custom`,e,n)}function c(e){r(`custom`,t,e)}return(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,$.jsx)(`div`,{className:`flex items-center gap-1`,children:xt.map(t=>(0,$.jsx)(`button`,{onClick:()=>o(t.value),className:u(`h-7 px-3 rounded-md text-xs font-medium transition-colors`,e===t.value?`bg-primary text-primary-foreground`:`text-muted-foreground hover:text-foreground hover:bg-accent`),children:i(t.labelKey)},t.value))}),e===`custom`&&(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`input`,{type:`date`,value:t,onChange:e=>s(e.target.value),"aria-label":i(`periods.startDate`),className:`h-7 px-2 rounded-md text-xs bg-card border border-border text-foreground focus:outline-none focus:ring-1 focus:ring-primary`}),(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:i(`periods.to`)}),(0,$.jsx)(`input`,{type:`date`,value:n,onChange:e=>c(e.target.value),"aria-label":i(`periods.endDate`),className:`h-7 px-2 rounded-md text-xs bg-card border border-border text-foreground focus:outline-none focus:ring-1 focus:ring-primary`})]})]})}function Ct({kpi:e,windowLabel:t}){let{t:n}=a(`analytics`),r=e.estimatedCostUsd??0,i=e.estimatedCostToday??0,o=e.includesEstimated??r>0,s=r>0,c=i>0;return(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(`div`,{className:`grid grid-cols-2 lg:grid-cols-4 gap-3`,children:[{key:`totalCost`,label:n(`desktop.totalCost`),value:`${s?`~`:``}$${e.totalCostUsd.toFixed(4)}`,sub:n(`desktop.costToday`,{value:`${c?`~`:``}$${e.costToday.toFixed(4)}`}),estimated:s,window:t},{key:`totalJobs`,label:n(`desktop.totalJobs`),value:e.totalJobs.toLocaleString(),sub:n(`desktop.jobsToday`,{n:e.jobsToday}),estimated:!1},{key:`successRate`,label:n(`desktop.successRate`),value:`${(e.successRate*100).toFixed(1)}%`,sub:n(`desktop.acrossAllProjects`),estimated:!1},{key:`avgCostPerJob`,label:n(`desktop.avgCostPerJob`),value:e.totalJobs>0?`${s?`~`:``}$${(e.totalCostUsd/e.totalJobs).toFixed(5)}`:`—`,sub:n(`desktop.periodAverage`),estimated:s&&e.totalJobs>0}].map(e=>(0,$.jsxs)(`div`,{className:`rounded-lg border border-border/40 bg-card/50 p-4`,"data-estimated":e.estimated?`true`:void 0,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-1 mb-1`,children:[(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e.label}),`window`in e&&e.window&&(0,$.jsx)(`span`,{"data-testid":`kpi-window-label`,className:`text-[10px] text-muted-foreground/70 whitespace-nowrap`,children:e.window})]}),(0,$.jsx)(`p`,{className:`text-xl font-semibold font-mono`,children:e.value}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground mt-1`,children:e.sub})]},e.key))}),o&&(0,$.jsx)(`p`,{"data-testid":`kpi-estimated-footnote`,className:`text-[10px] text-muted-foreground/70 italic`,title:n(`desktop.includesEstimatedTooltip`,{amount:`$${r.toFixed(4)}`}),children:n(`desktop.includesEstimated`,{amount:`$${r.toFixed(4)}`})})]})}function wt({data:e}){let{t}=a(`analytics`),n=c(),r=e.length>0&&e.some(e=>e.costUsd>0),i=Math.max(1,Math.floor(e.length/7)),o=e.filter((e,t)=>t%i===0).map(e=>e.date),l=new Map(e.map(e=>[e.date,e.estimatedCostUsd??0])),u=e.some(e=>(e.estimatedCostUsd??0)>0);return(0,$.jsxs)(`div`,{className:`rounded-lg border border-border/40 bg-card/50 p-4`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between mb-3`,children:[(0,$.jsx)(`h3`,{className:`text-sm font-medium`,children:t(`desktop.costOverTime`)}),u&&(0,$.jsx)(`span`,{"data-testid":`timeline-estimated-note`,className:`text-[10px] text-muted-foreground/70 italic`,title:t(`desktop.timelineEstimatedTooltip`),children:t(`desktop.includesEstimatedShort`)})]}),r?(0,$.jsx)(v,{width:`100%`,height:200,children:(0,$.jsxs)(bt,{data:e,margin:{top:4,right:8,left:0,bottom:0},children:[(0,$.jsx)(P,{strokeDasharray:`3 3`,stroke:`var(--color-border)`}),(0,$.jsx)(de,{dataKey:`date`,ticks:o,tickFormatter:e=>{try{return d(new Date(e),`MMM d`,{locale:s()})}catch{return e}},tick:{fontSize:10,fill:`var(--color-muted-foreground)`},axisLine:!1,tickLine:!1}),(0,$.jsx)(z,{tickFormatter:e=>`$${e.toFixed(2)}`,tick:{fontSize:10,fill:`var(--color-muted-foreground)`},axisLine:!1,tickLine:!1,width:55}),(0,$.jsx)(x,{content:({active:e,payload:t,label:n})=>{if(!e||!t?.length)return null;let r=(l.get(n)??0)>0;return(0,$.jsxs)(`div`,{className:`bg-popover border border-border/30 rounded-lg p-2 text-xs shadow-lg`,children:[(0,$.jsx)(`p`,{className:`text-muted-foreground mb-1`,children:n}),(0,$.jsxs)(`p`,{className:`font-medium`,children:[r?`~`:``,`$`,t[0].value.toFixed(4)]})]})}}),(0,$.jsx)(vt,{type:`monotone`,dataKey:`costUsd`,stroke:n.chart[0],strokeWidth:2,dot:!1,activeDot:{r:3,fill:n.chart[0]}})]})}):(0,$.jsx)(`div`,{className:`h-[200px] flex items-center justify-center text-xs text-muted-foreground`,children:t(`desktop.noCostData`)})]})}function Tt({projects:e}){let{t}=a(`analytics`),n=c();if(e.length===0)return(0,$.jsxs)(`div`,{className:`rounded-lg border border-border/40 bg-card/50 p-4`,children:[(0,$.jsx)(`h3`,{className:`text-sm font-medium mb-3`,children:t(`desktop.projectComparison`)}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:t(`desktop.noProjects`)})]});let r=Math.max(...e.map(e=>e.totalCostUsd),1e-4);return(0,$.jsxs)(`div`,{className:`rounded-lg border border-border/40 bg-card/50 p-4`,children:[(0,$.jsx)(`h3`,{className:`text-sm font-medium mb-4`,children:t(`desktop.projectComparison`)}),(0,$.jsx)(`div`,{className:`space-y-3`,children:e.map((e,i)=>{let a=e.estimatedCostUsd??0,o=a>0;return(0,$.jsxs)(`div`,{className:`space-y-1`,"data-estimated":o?`true`:void 0,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between text-xs`,children:[(0,$.jsxs)(`span`,{className:`font-medium truncate max-w-[160px] flex items-center gap-1`,title:e.projectName,children:[e.projectName,o&&(0,$.jsx)(`span`,{"data-testid":`project-estimated-badge`,className:`text-[9px] uppercase tracking-wide text-muted-foreground/70 not-italic border border-border/40 rounded px-1`,title:t(`desktop.projectEstimatedTooltip`,{amount:`$${a.toFixed(4)}`}),children:t(`desktop.estimatedBadge`)})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-4 text-muted-foreground`,children:[(0,$.jsx)(`span`,{children:t(`desktop.jobsCount`,{count:e.totalJobs})}),(0,$.jsx)(`span`,{children:t(`desktop.successPct`,{pct:(e.successRate*100).toFixed(0)})}),(0,$.jsxs)(`span`,{className:`font-mono text-foreground`,children:[o?`~`:``,`$`,e.totalCostUsd.toFixed(4)]})]})]}),(0,$.jsx)(`div`,{className:`h-1.5 rounded-full bg-border/30 overflow-hidden`,children:(0,$.jsx)(`div`,{className:`h-full rounded-full transition-all duration-500`,style:{width:`${e.totalCostUsd/r*100}%`,backgroundColor:n.chart[i%n.chart.length]}})})]},e.projectId)})})]})}function Et({projects:e}){let{t}=a(`analytics`),n=c();if(e.length===0)return null;let r=e.map(e=>({name:e.projectName.slice(0,12),costUsd:e.totalCostUsd}));return(0,$.jsxs)(`div`,{className:`rounded-lg border border-border/40 bg-card/50 p-4`,children:[(0,$.jsx)(`h3`,{className:`text-sm font-medium mb-3`,children:t(`desktop.costByProject`)}),(0,$.jsx)(v,{width:`100%`,height:180,children:(0,$.jsxs)(ve,{data:r,margin:{top:4,right:8,left:0,bottom:0},children:[(0,$.jsx)(P,{strokeDasharray:`3 3`,stroke:`var(--color-border)`}),(0,$.jsx)(de,{dataKey:`name`,tick:{fontSize:10,fill:`var(--color-muted-foreground)`},axisLine:!1,tickLine:!1}),(0,$.jsx)(z,{tickFormatter:e=>`$${e.toFixed(2)}`,tick:{fontSize:10,fill:`var(--color-muted-foreground)`},axisLine:!1,tickLine:!1,width:55}),(0,$.jsx)(x,{content:({active:e,payload:t,label:n})=>e&&t?.length?(0,$.jsxs)(`div`,{className:`bg-popover border border-border/30 rounded-lg p-2 text-xs shadow-lg`,children:[(0,$.jsx)(`p`,{className:`text-muted-foreground mb-1`,children:n}),(0,$.jsxs)(`p`,{className:`font-medium`,children:[`$`,t[0].value.toFixed(4)]})]}):null}),(0,$.jsx)(re,{dataKey:`costUsd`,fill:n.chart[1],radius:[3,3,0,0]})]})})]})}function Dt(){let{t:e}=a(`analytics`),[t,n]=(0,U.useState)(`7d`),[i,s]=(0,U.useState)(``),[c,l]=(0,U.useState)(``),[u,d]=(0,U.useState)(null),[f,p]=(0,U.useState)(!0),[m,h]=(0,U.useState)(null),{registerHandler:g,unregisterHandler:_}=o(),v=(0,U.useCallback)(e=>{let n=e;(n.type===`spending.invalidated`||n.type===`rail.job_completed`)&&y(t,i,c)},[t,i,c]);(0,U.useEffect)(()=>(g(`desktop-analytics`,v),()=>_(`desktop-analytics`)),[v,g,_]);async function y(e,t,n){p(!0),h(null);try{let r=new URLSearchParams({period:e});e===`custom`&&t&&n&&(r.set(`from`,t),r.set(`to`,n));let i=await fetch(`/api/analytics?${r}`);if(!i.ok)throw Error(`HTTP ${i.status}`);d(await i.json())}catch(e){h(e.message)}finally{p(!1)}}(0,U.useEffect)(()=>{y(t,i,c)},[t,i,c]);function b(e,t,r){n(e),t!==void 0&&s(t),r!==void 0&&l(r)}return(0,$.jsx)(`div`,{className:`flex flex-col h-full overflow-auto bg-background`,children:(0,$.jsxs)(`div`,{className:`p-4 space-y-4`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(Se,{className:`w-4 h-4 text-muted-foreground`}),(0,$.jsx)(`h1`,{className:`text-sm font-semibold`,children:e(`desktop.title`)}),u&&(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:u.period.label})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-3 mr-8`,children:[(0,$.jsx)(St,{period:t,from:i,to:c,onChange:b}),(0,$.jsx)(`button`,{onClick:()=>y(t,i,c),disabled:f,className:`flex items-center gap-1.5 h-7 px-2 rounded-md text-xs text-muted-foreground hover:text-foreground hover:bg-accent transition-colors disabled:opacity-50`,"aria-label":e(`desktop.refreshAria`),children:(0,$.jsx)(r,{className:`w-3 h-3 ${f?`animate-spin`:``}`})})]})]}),m&&(0,$.jsx)(`div`,{className:`rounded-lg border border-red-400/30 aurora-light:border-destructive/30 bg-red-400/10 aurora-light:bg-destructive/10 p-3 text-xs text-red-400 aurora-light:text-destructive`,children:e(`desktop.failedToLoad`,{error:m})}),f&&!u&&(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.jsx)(`div`,{className:`grid grid-cols-2 lg:grid-cols-4 gap-3`,children:Array.from({length:4}).map((e,t)=>(0,$.jsx)(`div`,{className:`h-20 rounded-lg border border-border/40 bg-card/50 animate-pulse`},t))}),(0,$.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-3`,children:Array.from({length:2}).map((e,t)=>(0,$.jsx)(`div`,{className:`h-[220px] rounded-lg border border-border/40 bg-card/50 animate-pulse`},t))})]}),u&&(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.jsx)(Ct,{kpi:u.kpi,windowLabel:t===`custom`?u.period.label:e(`windowLabels.${t}`)}),(0,$.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-3`,children:[(0,$.jsx)(wt,{data:u.costTimeline}),(0,$.jsx)(Et,{projects:u.projectBreakdown})]}),(0,$.jsx)(Tt,{projects:u.projectBreakdown})]})]})})}export{Dt as default};
|
|
1
|
+
import{a as e}from"./chunk-BNv3lrIs.js";import{t}from"./clsx-CNmW0Nip.js";import{Bn as n,Rn as r,S as i,Wt as a,Yn as o,_ as s,ct as c,lt as l,nt as u,ot as d}from"./index-89SuhD4Y.js";import{$ as f,A as p,B as m,E as h,F as g,H as _,K as v,L as y,N as b,O as x,P as S,Q as C,R as w,S as T,T as ee,U as E,W as D,X as O,Y as te,Z as k,_ as ne,_t as A,a as re,c as ie,d as ae,dt as j,et as M,ft as oe,g as se,gt as ce,h as le,ht as ue,i as de,it as N,j as fe,k as pe,l as P,lt as F,mt as me,n as he,nt as I,o as ge,pt as L,q as R,r as z,rt as B,s as _e,t as ve,u as ye,ut as V,v as be,w as H,z as xe}from"./BarChart-Ckstq9fl.js";var Se=r(`trending-up`,[[`path`,{d:`M16 7h6v6`,key:`box55l`}],[`path`,{d:`m22 7-8.5 8.5-5-5L2 17`,key:`1t1m79`}]]),U=e(o());function W(){return W=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},W.apply(null,arguments)}var G=e=>{var{cx:n,cy:r,r:i,className:a}=e,o=t(`recharts-dot`,a);return j(n)&&j(r)&&j(i)?U.createElement(`circle`,W({},ce(e),N(e),{className:o,cx:n,cy:r,r:i})):null},Ce=[`points`];function K(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 q(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?K(Object(n),!0).forEach(function(t){we(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):K(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function we(e,t,n){return(t=Te(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Te(e){var t=Ee(e,`string`);return typeof t==`symbol`?t:t+``}function Ee(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)}function J(){return J=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},J.apply(null,arguments)}function De(e,t){if(e==null)return{};var n,r,i=Oe(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 Oe(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 ke(e){var{option:n,dotProps:r,className:i}=e;if((0,U.isValidElement)(n))return(0,U.cloneElement)(n,r);if(typeof n==`function`)return n(r);var a=t(i,typeof n==`boolean`?``:n.className),o=r??{},{points:s}=o,c=De(o,Ce);return U.createElement(G,J({},c,{className:a}))}function Ae(e,t){return e==null?!1:t?!0:e.length===1}function je(e){var{points:t,dot:n,className:r,dotClassName:i,dataKey:a,baseProps:o,needClip:s,clipPathId:c,zIndex:l=y.scatter}=e;if(!Ae(t,n))return null;var u=H(n),d=ue(n),f=t.map((e,r)=>{var s=q(q(q({r:3},o),d),{},{index:r,cx:e.x??void 0,cy:e.y??void 0,dataKey:a,value:e.value,payload:e.payload,points:t});return U.createElement(ke,{key:`dot-${r}`,option:n,dotProps:s,className:i})}),m={};return s&&c!=null&&(m.clipPath=`url(#clipPath-${u?``:`dots-`}${c})`),U.createElement(p,{zIndex:l},U.createElement(L,J({className:r},m),f))}function Me(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 Y(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?Me(Object(n),!0).forEach(function(t){Ne(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Me(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Ne(e,t,n){return(t=Pe(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Pe(e){var t=Fe(e,`string`);return typeof t==`symbol`?t:t+``}function Fe(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 Ie=e=>{var{point:t,childIndex:n,mainColor:r,activeDot:i,dataKey:a,clipPath:o}=e;if(i===!1||t.x==null||t.y==null)return null;var s=Y(Y(Y({},{index:n,dataKey:a,cx:t.x,cy:t.y,r:4,fill:r??`none`,strokeWidth:2,stroke:`#fff`,payload:t.payload,value:t.value}),A(i)),N(i)),c=(0,U.isValidElement)(i)?(0,U.cloneElement)(i,s):typeof i==`function`?i(s):U.createElement(G,s);return U.createElement(L,{className:`recharts-active-dot`,clipPath:o},c)};function Le(e){var{points:t,mainColor:n,activeDot:r,itemDataKey:i,clipPath:a,zIndex:o=y.activeDot}=e,s=I(fe),c=ye();if(t==null||c==null)return null;var l=t.find(e=>c.includes(e.payload));return V(l)?null:U.createElement(p,{zIndex:o},U.createElement(Ie,{point:l,childIndex:Number(s),mainColor:n,dataKey:i,activeDot:r,clipPath:a}))}var Re=(e,t,n,r)=>b(e,`xAxis`,t,r),ze=(e,t,n,r)=>S(e,`xAxis`,t,r),Be=(e,t,n,r)=>b(e,`yAxis`,n,r),Ve=(e,t,n,r)=>S(e,`yAxis`,n,r),He=M([E,Re,Be,ze,Ve],(e,t,n,r,i)=>f(e,`xAxis`)?te(t,r,!1):te(n,i,!1)),Ue=(e,t,n,r,i)=>i;function We(e){return e.type===`line`}var Ge=M([E,Re,Be,ze,Ve,M([g,Ue],(e,t)=>e.filter(We).find(e=>e.id===t)),He,w],(e,t,n,r,i,a,o,s)=>{var{chartData:c,dataStartIndex:l,dataEndIndex:u}=s;if(!(a==null||t==null||n==null||r==null||i==null||r.length===0||i.length===0||o==null||e!==`horizontal`&&e!==`vertical`)){var{dataKey:d,data:f}=a,p=f!=null&&f.length>0?f:c?.slice(l,u+1);if(p!=null)return gt({layout:e,xAxis:t,yAxis:n,xAxisTicks:r,yAxisTicks:i,dataKey:d,bandSize:o,displayedData:p})}});function Ke(e){var t=A(e),n=3,r=2;if(t!=null){var{r:i,strokeWidth:a}=t,o=Number(i),s=Number(a);return(Number.isNaN(o)||o<0)&&(o=n),(Number.isNaN(s)||s<0)&&(s=r),{r:o,strokeWidth:s}}return{r:n,strokeWidth:r}}var qe=[`id`],Je=[`type`,`layout`,`connectNulls`,`needClip`,`shape`],Ye=[`activeDot`,`animateNewValues`,`animationBegin`,`animationDuration`,`animationEasing`,`connectNulls`,`dot`,`hide`,`isAnimationActive`,`label`,`legendType`,`xAxisId`,`yAxisId`,`id`];function X(){return X=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},X.apply(null,arguments)}function Xe(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 Z(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?Xe(Object(n),!0).forEach(function(t){Ze(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Xe(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Ze(e,t,n){return(t=Qe(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Qe(e){var t=$e(e,`string`);return typeof t==`symbol`?t:t+``}function $e(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)}function Q(e,t){if(e==null)return{};var n,r,i=et(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 et(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}var tt=e=>{var{dataKey:t,name:n,stroke:r,legendType:i,hide:a}=e;return[{inactive:a,dataKey:t,type:i,color:r,value:k(n,t),payload:e}]},nt=U.memo(e=>{var{dataKey:t,data:n,stroke:r,strokeWidth:i,fill:a,name:o,hide:s,unit:c,tooltipType:l,id:u}=e,d={dataDefinedOnItem:n,getPosition:oe,settings:{stroke:r,strokeWidth:i,fill:a,dataKey:t,nameKey:void 0,name:k(o,t),hide:s,type:l,color:r,unit:c,graphicalItemId:u}};return U.createElement(be,{tooltipEntrySettings:d})}),rt=(e,t)=>`${t}px ${e}px`;function it(e,t){for(var n=e.length%2==0?e:[...e,0],r=[],i=0;i<t;++i)r.push(...n);return r}var at=(e,t,n)=>{var r=n.reduce((e,t)=>e+t,0);if(!r)return rt(t,e);for(var i=Math.floor(e/r),a=e%r,o=[],s=0,c=0;s<n.length;c+=(l=n[s])??0,++s){var l,u=n[s];if(u!=null&&c+u>a){o=[...n.slice(0,s),a-c];break}}var d=o.length%2==0?[0,t]:[t];return[...it(n,i),...o,...d].map(e=>`${e}px`).join(`, `)};function ot(e){var{clipPathId:t,points:n,props:r}=e,{dot:i,dataKey:a,needClip:o}=r,{id:s}=r,c=ce(Q(r,qe));return U.createElement(je,{points:n,dot:i,className:`recharts-line-dots`,dotClassName:`recharts-line-dot`,dataKey:a,baseProps:c,needClip:o,clipPathId:t})}function st(e){var{showLabels:t,children:n,points:r}=e,i=(0,U.useMemo)(()=>r?.map(e=>{var t={x:e.x??0,y:e.y??0,width:0,lowerWidth:0,upperWidth:0,height:0};return Z(Z({},t),{},{value:e.value,payload:e.payload,viewBox:t,parentViewBox:void 0,fill:void 0})}),[r]);return U.createElement(ee,{value:t?i:void 0},n)}function ct(e){var{clipPathId:t,pathRef:n,points:r,strokeDasharray:i,props:a}=e,{type:o,layout:s,connectNulls:c,needClip:l,shape:u}=a,d=Z(Z({},me(Q(a,Je))),{},{fill:`none`,className:`recharts-line-curve`,clipPath:l?`url(#clipPath-${t})`:void 0,points:r,type:o,layout:s,connectNulls:c,strokeDasharray:i??a.strokeDasharray});return U.createElement(U.Fragment,null,r?.length>1&&U.createElement(T,X({shapeType:`curve`,option:u},d,{pathRef:n})),U.createElement(ot,{points:r,clipPathId:t,props:a}))}function lt(e){try{return e&&e.getTotalLength&&e.getTotalLength()||0}catch{return 0}}function ut(e){var{clipPathId:t,props:n,pathRef:r,previousPointsRef:i,longestAnimatedLengthRef:a}=e,{points:o,strokeDasharray:s,isAnimationActive:c,animationBegin:l,animationDuration:u,animationEasing:d,animateNewValues:f,width:p,height:g,onAnimationEnd:_,onAnimationStart:v}=n,y=i.current,b=xe(o,`recharts-line-`),x=(0,U.useRef)(b),[S,C]=(0,U.useState)(!1),w=!S,T=(0,U.useCallback)(()=>{typeof _==`function`&&_(),C(!1)},[_]),ee=(0,U.useCallback)(()=>{typeof v==`function`&&v(),C(!0)},[v]),E=lt(r.current),D=(0,U.useRef)(0);x.current!==b&&(D.current=a.current,x.current=b);var O=D.current;return U.createElement(st,{points:o,showLabels:w},n.children,U.createElement(m,{animationId:b,begin:l,duration:u,isActive:c,easing:d,onAnimationEnd:T,onAnimationStart:ee,key:b},e=>{var l=F(O,E+O,e),u=Math.min(l,E),d=c?s?at(u,E,`${s}`.split(/[,\s]+/gim).map(e=>parseFloat(e))):rt(E,u):s==null?void 0:String(s);if(e>0&&E>0&&(i.current=o,a.current=Math.max(a.current,u)),y){var m=y.length/o.length,h=e===1?o:o.map((t,n)=>{var r=Math.floor(n*m);if(y[r]){var i=y[r];return Z(Z({},t),{},{x:F(i.x,t.x,e),y:F(i.y,t.y,e)})}return f?Z(Z({},t),{},{x:F(p*2,t.x,e),y:F(g/2,t.y,e)}):Z(Z({},t),{},{x:t.x,y:t.y})});return i.current=h,U.createElement(ct,{props:n,points:h,clipPathId:t,pathRef:r,strokeDasharray:d})}return U.createElement(ct,{props:n,points:o,clipPathId:t,pathRef:r,strokeDasharray:d})}),U.createElement(h,{label:n.label}))}function dt(e){var{clipPathId:t,props:n}=e,r=(0,U.useRef)(null),i=(0,U.useRef)(0),a=(0,U.useRef)(null);return U.createElement(ut,{props:n,clipPathId:t,previousPointsRef:r,longestAnimatedLengthRef:i,pathRef:a})}var ft=(e,t)=>({x:e.x??void 0,y:e.y??void 0,value:e.value,errorVal:C(e.payload,t)}),pt=class extends U.Component{render(){var{hide:e,dot:n,points:r,className:i,xAxisId:a,yAxisId:o,top:s,left:c,width:l,height:u,id:d,needClip:f,zIndex:m}=this.props;if(e)return null;var h=t(`recharts-line`,i),g=d,{r:_,strokeWidth:v}=Ke(n),y=H(n),b=_*2+v,x=f?`url(#clipPath-${y?``:`dots-`}${g})`:void 0;return U.createElement(p,{zIndex:m},U.createElement(L,{className:h},f&&U.createElement(`defs`,null,U.createElement(ge,{clipPathId:g,xAxisId:a,yAxisId:o}),!y&&U.createElement(`clipPath`,{id:`clipPath-dots-${g}`},U.createElement(`rect`,{x:c-b/2,y:s-b/2,width:l+b,height:u+b}))),U.createElement(ie,{xAxisId:a,yAxisId:o,data:r,dataPointFormatter:ft,errorBarOffset:0},U.createElement(dt,{props:this.props,clipPathId:g}))),U.createElement(Le,{activeDot:this.props.activeDot,points:r,mainColor:this.props.stroke,itemDataKey:this.props.dataKey,clipPath:x}))}},mt={activeDot:!0,animateNewValues:!0,animationBegin:0,animationDuration:1500,animationEasing:`ease`,connectNulls:!1,dot:!0,fill:`#fff`,hide:!1,isAnimationActive:`auto`,label:!1,legendType:`line`,stroke:`#3182bd`,strokeWidth:1,xAxisId:0,yAxisId:0,zIndex:y.line,type:`linear`};function ht(e){var t=B(e,mt),{activeDot:n,animateNewValues:r,animationBegin:i,animationDuration:a,animationEasing:o,connectNulls:s,dot:c,hide:l,isAnimationActive:u,label:d,legendType:f,xAxisId:p,yAxisId:m,id:h}=t,g=Q(t,Ye),{needClip:_}=_e(p,m),v=ae(),y=D(),b=R(),x=I(e=>Ge(e,p,m,b,h));if(y!==`horizontal`&&y!==`vertical`||x==null||v==null)return null;var{height:S,width:C,x:w,y:T}=v;return U.createElement(pt,X({},g,{id:h,connectNulls:s,dot:c,activeDot:n,animateNewValues:r,animationBegin:i,animationDuration:a,animationEasing:o,isAnimationActive:u,hide:l,label:d,legendType:f,xAxisId:p,yAxisId:m,points:x,layout:y,height:S,width:C,left:w,top:T,needClip:_}))}function gt(e){var{layout:t,xAxis:n,yAxis:r,xAxisTicks:i,yAxisTicks:a,dataKey:o,bandSize:s,displayedData:c}=e;return c.map((e,c)=>{var l=C(e,o);if(t===`horizontal`)return{x:O({axis:n,ticks:i,bandSize:s,entry:e,index:c}),y:(V(l)?null:r.scale.map(l))??null,value:l,payload:e};var u=V(l)?null:n.scale.map(l),d=O({axis:r,ticks:a,bandSize:s,entry:e,index:c});return u==null||d==null?null:{x:u,y:d,value:l,payload:e}}).filter(Boolean)}function _t(e){var t=B(e,mt),n=R();return U.createElement(se,{id:t.id,type:`line`},e=>U.createElement(U.Fragment,null,U.createElement(ne,{legendPayload:tt(t)}),U.createElement(nt,{dataKey:t.dataKey,data:t.data,stroke:t.stroke,strokeWidth:t.strokeWidth,fill:t.fill,name:t.name,hide:t.hide,unit:t.unit,tooltipType:t.tooltipType,id:e}),U.createElement(le,{type:`line`,id:e,data:t.data,xAxisId:t.xAxisId,yAxisId:t.yAxisId,zAxisId:0,dataKey:t.dataKey,hide:t.hide,isPanorama:n}),U.createElement(ht,X({},t,{id:e}))))}var vt=U.memo(_t,_);vt.displayName=`Line`;var yt=[`axis`],bt=(0,U.forwardRef)((e,t)=>U.createElement(he,{chartName:`LineChart`,defaultTooltipEventType:`axis`,validateTooltipEventTypes:yt,tooltipPayloadSearcher:pe,categoricalChartProps:e,ref:t})),$=l(),xt=[{value:`7d`,labelKey:`periods.d7`},{value:`30d`,labelKey:`periods.d30`},{value:`90d`,labelKey:`periods.d90`},{value:`all`,labelKey:`periods.all`},{value:`custom`,labelKey:`periods.custom`}];function St({period:e,from:t,to:r,onChange:i}){let{t:a}=n(`analytics`);function o(e){e===`custom`?i(`custom`,t,r):i(e)}function s(e){i(`custom`,e,r)}function c(e){i(`custom`,t,e)}return(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,$.jsx)(`div`,{className:`flex items-center gap-1`,children:xt.map(t=>(0,$.jsx)(`button`,{onClick:()=>o(t.value),className:u(`h-7 px-3 rounded-md text-xs font-medium transition-colors`,e===t.value?`bg-primary text-primary-foreground`:`text-muted-foreground hover:text-foreground hover:bg-accent`),children:a(t.labelKey)},t.value))}),e===`custom`&&(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`input`,{type:`date`,value:t,onChange:e=>s(e.target.value),"aria-label":a(`periods.startDate`),className:`h-7 px-2 rounded-md text-xs bg-card border border-border text-foreground focus:outline-none focus:ring-1 focus:ring-primary`}),(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:a(`periods.to`)}),(0,$.jsx)(`input`,{type:`date`,value:r,onChange:e=>c(e.target.value),"aria-label":a(`periods.endDate`),className:`h-7 px-2 rounded-md text-xs bg-card border border-border text-foreground focus:outline-none focus:ring-1 focus:ring-primary`})]})]})}function Ct({kpi:e,windowLabel:t}){let{t:r}=n(`analytics`),i=e.estimatedCostUsd??0,a=e.estimatedCostToday??0,o=e.includesEstimated??i>0,s=i>0,c=a>0;return(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(`div`,{className:`grid grid-cols-2 lg:grid-cols-4 gap-3`,children:[{key:`totalCost`,label:r(`desktop.totalCost`),value:`${s?`~`:``}$${e.totalCostUsd.toFixed(4)}`,sub:r(`desktop.costToday`,{value:`${c?`~`:``}$${e.costToday.toFixed(4)}`}),estimated:s,window:t},{key:`totalJobs`,label:r(`desktop.totalJobs`),value:e.totalJobs.toLocaleString(),sub:r(`desktop.jobsToday`,{n:e.jobsToday}),estimated:!1},{key:`successRate`,label:r(`desktop.successRate`),value:`${(e.successRate*100).toFixed(1)}%`,sub:r(`desktop.acrossAllProjects`),estimated:!1},{key:`avgCostPerJob`,label:r(`desktop.avgCostPerJob`),value:e.totalJobs>0?`${s?`~`:``}$${(e.totalCostUsd/e.totalJobs).toFixed(5)}`:`—`,sub:r(`desktop.periodAverage`),estimated:s&&e.totalJobs>0}].map(e=>(0,$.jsxs)(`div`,{className:`rounded-lg border border-border/40 bg-card/50 p-4`,"data-estimated":e.estimated?`true`:void 0,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-1 mb-1`,children:[(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e.label}),`window`in e&&e.window&&(0,$.jsx)(`span`,{"data-testid":`kpi-window-label`,className:`text-[10px] text-muted-foreground/70 whitespace-nowrap`,children:e.window})]}),(0,$.jsx)(`p`,{className:`text-xl font-semibold font-mono`,children:e.value}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground mt-1`,children:e.sub})]},e.key))}),o&&(0,$.jsx)(`p`,{"data-testid":`kpi-estimated-footnote`,className:`text-[10px] text-muted-foreground/70 italic`,title:r(`desktop.includesEstimatedTooltip`,{amount:`$${i.toFixed(4)}`}),children:r(`desktop.includesEstimated`,{amount:`$${i.toFixed(4)}`})})]})}function wt({data:e}){let{t}=n(`analytics`),r=s(),a=e.length>0&&e.some(e=>e.costUsd>0),o=Math.max(1,Math.floor(e.length/7)),c=e.filter((e,t)=>t%o===0).map(e=>e.date),l=new Map(e.map(e=>[e.date,e.estimatedCostUsd??0])),u=e.some(e=>(e.estimatedCostUsd??0)>0);return(0,$.jsxs)(`div`,{className:`rounded-lg border border-border/40 bg-card/50 p-4`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between mb-3`,children:[(0,$.jsx)(`h3`,{className:`text-sm font-medium`,children:t(`desktop.costOverTime`)}),u&&(0,$.jsx)(`span`,{"data-testid":`timeline-estimated-note`,className:`text-[10px] text-muted-foreground/70 italic`,title:t(`desktop.timelineEstimatedTooltip`),children:t(`desktop.includesEstimatedShort`)})]}),a?(0,$.jsx)(v,{width:`100%`,height:200,children:(0,$.jsxs)(bt,{data:e,margin:{top:4,right:8,left:0,bottom:0},children:[(0,$.jsx)(P,{strokeDasharray:`3 3`,stroke:`var(--color-border)`}),(0,$.jsx)(de,{dataKey:`date`,ticks:c,tickFormatter:e=>{try{return i(new Date(e),`MMM d`,{locale:d()})}catch{return e}},tick:{fontSize:10,fill:`var(--color-muted-foreground)`},axisLine:!1,tickLine:!1}),(0,$.jsx)(z,{tickFormatter:e=>`$${e.toFixed(2)}`,tick:{fontSize:10,fill:`var(--color-muted-foreground)`},axisLine:!1,tickLine:!1,width:55}),(0,$.jsx)(x,{content:({active:e,payload:t,label:n})=>{if(!e||!t?.length)return null;let r=(l.get(n)??0)>0;return(0,$.jsxs)(`div`,{className:`bg-popover border border-border/30 rounded-lg p-2 text-xs shadow-lg`,children:[(0,$.jsx)(`p`,{className:`text-muted-foreground mb-1`,children:n}),(0,$.jsxs)(`p`,{className:`font-medium`,children:[r?`~`:``,`$`,t[0].value.toFixed(4)]})]})}}),(0,$.jsx)(vt,{type:`monotone`,dataKey:`costUsd`,stroke:r.chart[0],strokeWidth:2,dot:!1,activeDot:{r:3,fill:r.chart[0]}})]})}):(0,$.jsx)(`div`,{className:`h-[200px] flex items-center justify-center text-xs text-muted-foreground`,children:t(`desktop.noCostData`)})]})}function Tt({projects:e}){let{t}=n(`analytics`),r=s();if(e.length===0)return(0,$.jsxs)(`div`,{className:`rounded-lg border border-border/40 bg-card/50 p-4`,children:[(0,$.jsx)(`h3`,{className:`text-sm font-medium mb-3`,children:t(`desktop.projectComparison`)}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:t(`desktop.noProjects`)})]});let i=Math.max(...e.map(e=>e.totalCostUsd),1e-4);return(0,$.jsxs)(`div`,{className:`rounded-lg border border-border/40 bg-card/50 p-4`,children:[(0,$.jsx)(`h3`,{className:`text-sm font-medium mb-4`,children:t(`desktop.projectComparison`)}),(0,$.jsx)(`div`,{className:`space-y-3`,children:e.map((e,n)=>{let a=e.estimatedCostUsd??0,o=a>0;return(0,$.jsxs)(`div`,{className:`space-y-1`,"data-estimated":o?`true`:void 0,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between text-xs`,children:[(0,$.jsxs)(`span`,{className:`font-medium truncate max-w-[160px] flex items-center gap-1`,title:e.projectName,children:[e.projectName,o&&(0,$.jsx)(`span`,{"data-testid":`project-estimated-badge`,className:`text-[9px] uppercase tracking-wide text-muted-foreground/70 not-italic border border-border/40 rounded px-1`,title:t(`desktop.projectEstimatedTooltip`,{amount:`$${a.toFixed(4)}`}),children:t(`desktop.estimatedBadge`)})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-4 text-muted-foreground`,children:[(0,$.jsx)(`span`,{children:t(`desktop.jobsCount`,{count:e.totalJobs})}),(0,$.jsx)(`span`,{children:t(`desktop.successPct`,{pct:(e.successRate*100).toFixed(0)})}),(0,$.jsxs)(`span`,{className:`font-mono text-foreground`,children:[o?`~`:``,`$`,e.totalCostUsd.toFixed(4)]})]})]}),(0,$.jsx)(`div`,{className:`h-1.5 rounded-full bg-border/30 overflow-hidden`,children:(0,$.jsx)(`div`,{className:`h-full rounded-full transition-all duration-500`,style:{width:`${e.totalCostUsd/i*100}%`,backgroundColor:r.chart[n%r.chart.length]}})})]},e.projectId)})})]})}function Et({projects:e}){let{t}=n(`analytics`),r=s();if(e.length===0)return null;let i=e.map(e=>({name:e.projectName.slice(0,12),costUsd:e.totalCostUsd}));return(0,$.jsxs)(`div`,{className:`rounded-lg border border-border/40 bg-card/50 p-4`,children:[(0,$.jsx)(`h3`,{className:`text-sm font-medium mb-3`,children:t(`desktop.costByProject`)}),(0,$.jsx)(v,{width:`100%`,height:180,children:(0,$.jsxs)(ve,{data:i,margin:{top:4,right:8,left:0,bottom:0},children:[(0,$.jsx)(P,{strokeDasharray:`3 3`,stroke:`var(--color-border)`}),(0,$.jsx)(de,{dataKey:`name`,tick:{fontSize:10,fill:`var(--color-muted-foreground)`},axisLine:!1,tickLine:!1}),(0,$.jsx)(z,{tickFormatter:e=>`$${e.toFixed(2)}`,tick:{fontSize:10,fill:`var(--color-muted-foreground)`},axisLine:!1,tickLine:!1,width:55}),(0,$.jsx)(x,{content:({active:e,payload:t,label:n})=>e&&t?.length?(0,$.jsxs)(`div`,{className:`bg-popover border border-border/30 rounded-lg p-2 text-xs shadow-lg`,children:[(0,$.jsx)(`p`,{className:`text-muted-foreground mb-1`,children:n}),(0,$.jsxs)(`p`,{className:`font-medium`,children:[`$`,t[0].value.toFixed(4)]})]}):null}),(0,$.jsx)(re,{dataKey:`costUsd`,fill:r.chart[1],radius:[3,3,0,0]})]})})]})}function Dt(){let{t:e}=n(`analytics`),[t,r]=(0,U.useState)(`7d`),[i,o]=(0,U.useState)(``),[s,l]=(0,U.useState)(``),[u,d]=(0,U.useState)(null),[f,p]=(0,U.useState)(!0),[m,h]=(0,U.useState)(null),{registerHandler:g,unregisterHandler:_}=c(),v=(0,U.useCallback)(e=>{let n=e;(n.type===`spending.invalidated`||n.type===`rail.job_completed`)&&y(t,i,s)},[t,i,s]);(0,U.useEffect)(()=>(g(`desktop-analytics`,v),()=>_(`desktop-analytics`)),[v,g,_]);async function y(e,t,n){p(!0),h(null);try{let r=new URLSearchParams({period:e});e===`custom`&&t&&n&&(r.set(`from`,t),r.set(`to`,n));let i=await fetch(`/api/analytics?${r}`);if(!i.ok)throw Error(`HTTP ${i.status}`);d(await i.json())}catch(e){h(e.message)}finally{p(!1)}}(0,U.useEffect)(()=>{y(t,i,s)},[t,i,s]);function b(e,t,n){r(e),t!==void 0&&o(t),n!==void 0&&l(n)}return(0,$.jsx)(`div`,{className:`flex flex-col h-full overflow-auto bg-background`,children:(0,$.jsxs)(`div`,{className:`p-4 space-y-4`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(Se,{className:`w-4 h-4 text-muted-foreground`}),(0,$.jsx)(`h1`,{className:`text-sm font-semibold`,children:e(`desktop.title`)}),u&&(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:u.period.label})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-3 mr-8`,children:[(0,$.jsx)(St,{period:t,from:i,to:s,onChange:b}),(0,$.jsx)(`button`,{onClick:()=>y(t,i,s),disabled:f,className:`flex items-center gap-1.5 h-7 px-2 rounded-md text-xs text-muted-foreground hover:text-foreground hover:bg-accent transition-colors disabled:opacity-50`,"aria-label":e(`desktop.refreshAria`),children:(0,$.jsx)(a,{className:`w-3 h-3 ${f?`animate-spin`:``}`})})]})]}),m&&(0,$.jsx)(`div`,{className:`rounded-lg border border-red-400/30 aurora-light:border-destructive/30 bg-red-400/10 aurora-light:bg-destructive/10 p-3 text-xs text-red-400 aurora-light:text-destructive`,children:e(`desktop.failedToLoad`,{error:m})}),f&&!u&&(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.jsx)(`div`,{className:`grid grid-cols-2 lg:grid-cols-4 gap-3`,children:Array.from({length:4}).map((e,t)=>(0,$.jsx)(`div`,{className:`h-20 rounded-lg border border-border/40 bg-card/50 animate-pulse`},t))}),(0,$.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-3`,children:Array.from({length:2}).map((e,t)=>(0,$.jsx)(`div`,{className:`h-[220px] rounded-lg border border-border/40 bg-card/50 animate-pulse`},t))})]}),u&&(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.jsx)(Ct,{kpi:u.kpi,windowLabel:t===`custom`?u.period.label:e(`windowLabels.${t}`)}),(0,$.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-3`,children:[(0,$.jsx)(wt,{data:u.costTimeline}),(0,$.jsx)(Et,{projects:u.projectBreakdown})]}),(0,$.jsx)(Tt,{projects:u.projectBreakdown})]})]})})}export{Dt as default};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import{a as e}from"./chunk-BNv3lrIs.js";import{Bn as t,En as n,G as r,J as i,K as a,M as o,W as s,Y as c,Yn as l,en as u,fn as d,j as f,jn as p,lt as m,nt as h}from"./index-89SuhD4Y.js";import{t as g}from"./lib-yKyTNJ1c.js";import{t as _}from"./atom-one-dark-BMDPFwRZ.js";var v=e(l(),1),y=m();function b({categories:e,activeCategory:n,activeSlug:r,onSelect:i,onHome:a}){let{t:o}=t(`integrations`);return(0,y.jsxs)(`nav`,{className:`w-48 shrink-0 space-y-4 overflow-y-auto border-r border-border pr-2`,children:[(0,y.jsxs)(`button`,{onClick:a,className:h(`flex w-full items-center gap-2 rounded-lg px-2.5 py-1.5 text-left text-xs transition-colors`,!n&&!r?`bg-accent-primary/15 font-medium text-foreground`:`text-muted-foreground hover:bg-muted/40 hover:text-foreground`),children:[(0,y.jsx)(p,{className:`w-3.5 h-3.5 shrink-0`}),(0,y.jsx)(`span`,{className:`truncate`,children:o(`docs.title`)})]}),e.map(e=>(0,y.jsxs)(`div`,{className:`space-y-0.5`,children:[(0,y.jsxs)(`div`,{className:`px-2.5 mb-1 flex items-center justify-between`,children:[(0,y.jsx)(`span`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wider`,children:e.name}),e.docs.length>0&&(0,y.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,y.jsx)(`p`,{className:`px-2.5 text-xs text-muted-foreground italic`,children:o(`docs.sidebarEmpty`)}):(0,y.jsx)(`ul`,{className:`space-y-0.5`,children:e.docs.map(t=>{let a=n===e.slug&&r===t.slug;return(0,y.jsx)(`li`,{children:(0,y.jsxs)(`button`,{onClick:()=>i(e.slug,t.slug),title:t.title,className:h(`flex w-full items-center gap-2 rounded-lg px-2.5 py-1.5 text-left text-xs transition-colors`,a?`bg-accent-primary/15 font-medium text-foreground`:`text-muted-foreground hover:bg-muted/40 hover:text-foreground`),children:[(0,y.jsx)(d,{className:`w-3.5 h-3.5 shrink-0`}),(0,y.jsx)(`span`,{className:`truncate`,children:t.title})]})},t.slug)})})]},e.slug))]})}function x({categories:e,onSelect:r}){let{t:i}=t(`integrations`),a=e.reduce((e,t)=>e+t.docs.length,0),o=e.filter(e=>e.docs.length>0).length;return(0,y.jsxs)(`div`,{className:`max-w-2xl mx-auto py-2 px-1 space-y-5`,children:[(0,y.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:a===0?i(`docs.indexEmpty`):i(`docs.summary`,{documents:i(`docs.documentCount`,{count:a}),categories:i(`docs.categoryCount`,{count:o})})}),e.map(e=>(0,y.jsxs)(`div`,{className:`space-y-2`,children:[(0,y.jsx)(`h2`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wider`,children:e.name}),e.docs.length===0?(0,y.jsx)(`p`,{className:`text-xs text-muted-foreground italic pl-2`,children:i(`docs.categoryEmpty`)}):(0,y.jsx)(`ul`,{className:`space-y-2`,children:e.docs.map(t=>(0,y.jsx)(`li`,{children:(0,y.jsxs)(`button`,{onClick:()=>r(e.slug,t.slug),className:`w-full flex items-center gap-3 p-2.5 rounded-md border border-border text-left transition-colors hover:bg-muted/40 group`,children:[(0,y.jsx)(d,{className:`w-3.5 h-3.5 text-muted-foreground flex-shrink-0`}),(0,y.jsx)(`span`,{className:`text-xs font-medium text-foreground truncate`,children:t.title}),(0,y.jsx)(n,{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 S=(0,v.memo)(function({content:e,currentCategory:t,onNavigateDoc:n}){return(0,y.jsx)(o,{remarkPlugins:[f],rehypePlugins:[g],components:{a({href:e,children:r,...i}){return(0,y.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=_(e,t);i&&n(i.category,i.slug)},...i,children:r})}},children:e})});function C({category:e,slug:n,lang:r,onNotFound:i,onNavigate:a,scrollContainerRef:o}){let{t:s}=t(`integrations`),[c,l]=(0,v.useState)(null),[d,f]=(0,v.useState)(null),p=(0,v.useRef)(0);return(0,v.useEffect)(()=>{let t=++p.current;f(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===p.current&&e&&(l(e),o.current&&(o.current.scrollTop=0))}).catch(e=>{t===p.current&&f(e instanceof Error?e.message:s(`docs.loadError`))})},[e,n,r,i,o]),!c&&!d?(0,y.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,y.jsx)(u,{className:`w-4 h-4 animate-spin text-muted-foreground`})}):d&&!c?(0,y.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,y.jsx)(`p`,{className:`text-sm text-destructive`,children:d})}):c?(0,y.jsx)(`article`,{className:`max-w-2xl mx-auto py-2 px-1`,children:(0,y.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,y.jsx)(S,{content:c.content,currentCategory:c.category,onNavigateDoc:a})})}):null}function w({open:e,onClose:n}){let{t:o,i18n:l}=t(`integrations`),d=l.language||`en`,[f,m]=(0,v.useState)(null),[h,g]=(0,v.useState)(!0),[_,S]=(0,v.useState)(),[w,T]=(0,v.useState)(),E=(0,v.useRef)(null);(0,v.useEffect)(()=>{e&&(g(!0),fetch(`/api/docs?lang=${encodeURIComponent(d)}`).then(e=>e.json()).then(e=>m(e)).catch(()=>m({categories:[]})).finally(()=>g(!1)))},[e,d]);let D=(0,v.useCallback)((e,t)=>{S(e),T(t)},[]),O=(0,v.useCallback)(()=>{S(void 0),T(void 0)},[]),k=!!(_&&w);return(0,y.jsx)(s,{open:e,onOpenChange:e=>{e||n()},children:(0,y.jsxs)(r,{movableResizable:!0,className:`flex max-w-5xl w-[92vw] h-[82vh] flex-col overflow-hidden`,children:[(0,y.jsxs)(i,{children:[(0,y.jsxs)(c,{className:`flex items-center gap-2`,children:[(0,y.jsx)(p,{className:`w-4 h-4`}),o(`docs.title`)]}),(0,y.jsx)(a,{children:o(`docs.dialogDescription`)})]}),(0,y.jsxs)(`div`,{className:`flex min-h-0 flex-1 gap-5 py-2`,children:[h?(0,y.jsx)(`div`,{className:`w-48 shrink-0 border-r border-border flex items-center justify-center`,children:(0,y.jsx)(u,{className:`w-3.5 h-3.5 animate-spin text-muted-foreground`})}):(0,y.jsx)(b,{categories:f?.categories??[],activeCategory:_,activeSlug:w,onSelect:D,onHome:O}),(0,y.jsx)(`main`,{ref:E,className:`min-w-0 flex-1 overflow-y-auto pr-1`,children:k&&_&&w?(0,y.jsx)(C,{category:_,slug:w,lang:d,onNotFound:O,onNavigate:D,scrollContainerRef:E}):f&&(0,y.jsx)(x,{categories:f.categories,onSelect:D})})]})]})})}var T=(0,v.memo)(w);export{T as default};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import{a as e}from"./chunk-BNv3lrIs.js";import{Bn as t,En as n,Gn as r,Kn as i,M as a,Un as o,Yn as s,en as c,fn as l,j as u,jn as d,lt as f,nt as p}from"./index-89SuhD4Y.js";import{t as m}from"./lib-yKyTNJ1c.js";import{t as h}from"./atom-one-dark-BMDPFwRZ.js";var g=e(s(),1),_=f();function v({categories:e,activeCategory:n,activeSlug:r}){let{t:i}=t(`integrations`);return(0,_.jsxs)(`nav`,{className:`w-56 flex-shrink-0 border-r border-border overflow-y-auto py-4 px-3 space-y-4`,children:[(0,_.jsxs)(o,{to:`/docs`,className:p(`flex w-full items-center gap-2 rounded-lg px-2.5 py-1.5 text-left text-xs transition-colors`,!n&&!r?`bg-accent-primary/15 font-medium text-foreground`:`text-muted-foreground hover:bg-muted/40 hover:text-foreground`),children:[(0,_.jsx)(d,{className:`w-3.5 h-3.5 shrink-0`}),(0,_.jsx)(`span`,{className:`truncate`,children:i(`docs.title`)})]}),e.map(e=>(0,_.jsxs)(`div`,{className:`space-y-0.5`,children:[(0,_.jsxs)(`div`,{className:`px-2.5 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.5 text-xs text-muted-foreground italic`,children:i(`docs.sidebarEmpty`)}):(0,_.jsx)(`ul`,{className:`space-y-0.5`,children:e.docs.map(t=>{let i=n===e.slug&&r===t.slug;return(0,_.jsx)(`li`,{children:(0,_.jsxs)(o,{to:`/docs/${e.slug}/${t.slug}`,title:t.title,className:p(`flex w-full items-center gap-2 rounded-lg px-2.5 py-1.5 text-left text-xs transition-colors`,i?`bg-accent-primary/15 font-medium text-foreground`:`text-muted-foreground hover:bg-muted/40 hover:text-foreground`),children:[(0,_.jsx)(l,{className:`w-3.5 h-3.5 shrink-0`}),(0,_.jsx)(`span`,{className:`truncate`,children:t.title})]})},t.slug)})})]},e.slug))]})}function y({categories:e}){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,_.jsxs)(`div`,{className:`max-w-2xl mx-auto py-8 px-6 space-y-5`,children:[(0,_.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,_.jsxs)(`h1`,{className:`flex items-center gap-2 text-lg font-semibold`,children:[(0,_.jsx)(d,{className:`w-4 h-4`}),r(`docs.title`)]}),(0,_.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})})})]}),e.map(e=>(0,_.jsxs)(`div`,{className:`space-y-2`,children:[(0,_.jsx)(`h2`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wider`,children:e.name}),e.docs.length===0?(0,_.jsx)(`p`,{className:`text-xs text-muted-foreground italic pl-2`,children:r(`docs.categoryEmpty`)}):(0,_.jsx)(`ul`,{className:`space-y-2`,children:e.docs.map(t=>(0,_.jsx)(`li`,{children:(0,_.jsxs)(o,{to:`/docs/${e.slug}/${t.slug}`,className:`flex items-center gap-3 p-2.5 rounded-md border border-border transition-colors hover:bg-muted/40 group`,children:[(0,_.jsx)(l,{className:`w-3.5 h-3.5 text-muted-foreground flex-shrink-0`}),(0,_.jsx)(`span`,{className:`text-xs font-medium text-foreground truncate`,children:t.title}),(0,_.jsx)(n,{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)(a,{remarkPlugins:[u],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:n,lang:i,scrollContainerRef:a}){let{t:o}=t(`integrations`),[s,l]=(0,g.useState)(null),[u,d]=(0,g.useState)(null),f=(0,g.useRef)(0),p=r();return(0,g.useEffect)(()=>{let t=++f.current;d(null),fetch(`/api/docs/${e}/${n}?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===f.current&&e&&(l(e),a.current&&(a.current.scrollTop=0))}).catch(e=>{t===f.current&&d(e instanceof Error?e.message:o(`docs.loadError`))})},[e,n,i,p,a]),!s&&!u?(0,_.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,_.jsx)(c,{className:`w-4 h-4 animate-spin text-muted-foreground`})}):u&&!s?(0,_.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,_.jsx)(`p`,{className:`text-sm text-destructive`,children:u})}):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}=i(),{i18n:r}=t(`integrations`),a=r.language||`en`,[o,s]=(0,g.useState)(null),[l,u]=(0,g.useState)(!0),d=(0,g.useRef)(null);(0,g.useEffect)(()=>{fetch(`/api/docs?lang=${encodeURIComponent(a)}`).then(e=>e.json()).then(e=>s(e)).catch(()=>s({categories:[]})).finally(()=>u(!1))},[a]);let f=!!(e&&n);return(0,_.jsxs)(`div`,{className:`flex h-full overflow-hidden`,children:[l?(0,_.jsx)(`div`,{className:`w-56 flex-shrink-0 border-r border-border flex items-center justify-center`,children:(0,_.jsx)(c,{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:d,className:`flex-1 overflow-y-auto`,children:f&&e&&n?(0,_.jsx)(x,{category:e,slug:n,lang:a,scrollContainerRef:d}):o&&(0,_.jsx)(y,{categories:o.categories})})]})}export{S as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e}from"./chunk-BNv3lrIs.js";import{
|
|
1
|
+
import{a as e}from"./chunk-BNv3lrIs.js";import{Bn as t,Yn as n,_n as r,lt as i,zn as a}from"./index-89SuhD4Y.js";var o=e(n(),1),s=i(),c=[{labelKey:`export.summaryCsv`,format:`csv`,mode:`summary`},{labelKey:`export.rawCsv`,format:`csv`,mode:`raw`},{labelKey:`export.summaryJson`,format:`json`,mode:`summary`},{labelKey:`export.rawJson`,format:`json`,mode:`raw`}];function l(e){if(!e)return null;let t=e.match(/filename="?([^"]+)"?/);return t?t[1]:null}function u({baseUrl:e,params:n,label:i,disabled:u}){let{t:d}=t(`analytics`),[f,p]=(0,o.useState)(!1),[m,h]=(0,o.useState)(!1),g=(0,o.useRef)(null);(0,o.useEffect)(()=>{if(!f)return;function e(e){g.current&&!g.current.contains(e.target)&&p(!1)}return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[f]);let _=(0,o.useCallback)(t=>`${e}?${new URLSearchParams({format:t.format,mode:t.mode,...n}).toString()}`,[e,n]),v=(0,o.useCallback)(async e=>{p(!1),h(!0);try{let t=await fetch(_(e));if(!t.ok)throw Error(`HTTP ${t.status}`);let n=await t.blob(),r=URL.createObjectURL(n),i=document.createElement(`a`);i.href=r;let a=l(t.headers.get(`Content-Disposition`)),o=`analytics-${e.mode}.${e.format}`;i.download=a??o,document.body.appendChild(i),i.click(),i.remove(),URL.revokeObjectURL(r)}catch(e){console.warn(`[ExportDropdown] download failed:`,e),a.error(d(`export.failed`))}finally{h(!1)}},[_,d]);return(0,s.jsxs)(`div`,{ref:g,className:`relative`,children:[(0,s.jsxs)(`button`,{type:`button`,"aria-haspopup":`true`,"aria-expanded":f,disabled:m||u,onClick:()=>p(e=>!e),title:u?d(`export.noData`):void 0,className:`flex items-center gap-1.5 h-7 px-2.5 rounded-md text-xs font-medium border border-border/60 bg-card/50 text-muted-foreground hover:text-foreground hover:bg-accent/60 transition-colors disabled:opacity-50 disabled:pointer-events-none`,children:[(0,s.jsx)(r,{className:`w-3 h-3`}),m?d(`export.downloading`):i??d(`common:actions.export`)]}),f&&(0,s.jsx)(`div`,{role:`menu`,className:`absolute right-0 z-50 mt-1 min-w-[180px] rounded-md border border-border/60 bg-popover shadow-md text-xs overflow-hidden`,children:c.map(e=>(0,s.jsxs)(`button`,{role:`menuitem`,type:`button`,onClick:()=>v(e),className:`flex w-full items-center gap-2 px-3 py-2 text-left text-foreground hover:bg-accent/60 transition-colors`,children:[(0,s.jsx)(r,{className:`w-3 h-3 shrink-0`}),(0,s.jsx)(`span`,{className:`flex-1`,children:d(e.labelKey)}),e.mode===`raw`&&(0,s.jsx)(`span`,{className:`text-[9px] text-muted-foreground`,children:`≤10k`})]},`${e.format}-${e.mode}`))})]})}export{u as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{Wn as e,lt as t}from"./index-89SuhD4Y.js";var n=t();function r(){return(0,n.jsx)(e,{to:`/plugins`,replace:!0})}export{r as default};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import{a as e}from"./chunk-BNv3lrIs.js";import{t}from"./brain-BPbhM1Jx.js";import{a as n}from"./auth-DpZq5p1e.js";import{B as r,Bn as i,Cn as a,Dn as o,En as s,M as c,On as l,Pn as u,Rn as d,Rt as f,Sn as p,U as m,Ut as h,V as g,Vt as _,Yn as v,a as y,ct as b,en as x,g as S,i as C,it as w,j as T,jt as E,kt as D,lt as O,nn as k,nt as A,o as j,qt as M,r as N,sn as P,st as F,tt as I,un as L,ut as R,vn as z,w as B,wt as V,xn as H,zn as U,zt as ee}from"./index-89SuhD4Y.js";import{t as te}from"./lib-yKyTNJ1c.js";var ne=d(`chevrons-down-up`,[[`path`,{d:`m7 20 5-5 5 5`,key:`13a0gw`}],[`path`,{d:`m7 4 5 5 5-5`,key:`1kwcof`}]]),re=d(`chevrons-up-down`,[[`path`,{d:`m7 15 5 5 5-5`,key:`1hf1tw`}],[`path`,{d:`m7 9 5-5 5 5`,key:`sgt6xg`}]]),ie=d(`hourglass`,[[`path`,{d:`M5 22h14`,key:`ehvnwv`}],[`path`,{d:`M5 2h14`,key:`pdyrp9`}],[`path`,{d:`M17 22v-4.172a2 2 0 0 0-.586-1.414L12 12l-4.414 4.414A2 2 0 0 0 7 17.828V22`,key:`1d314k`}],[`path`,{d:`M7 2v4.172a2 2 0 0 0 .586 1.414L12 12l4.414-4.414A2 2 0 0 0 17 6.172V2`,key:`1vvvr6`}]]);function ae(e){return e.command.startsWith(`loop:`)?`loop-run`:e.interactive?`interactive`:`job`}var oe=15e3;function se(e){if(typeof AbortSignal<`u`&&typeof AbortSignal.timeout==`function`)return AbortSignal.timeout(e)}async function ce(e){let{projectId:t,jobId:r,timeoutMs:i=oe}=e,a=t?`${n}/api/projects/${t}`:R(),o;try{o=await fetch(`${a}/jobs/${r}`,{method:`DELETE`,signal:se(i)})}catch(e){let t=e;return{ok:!1,error:t?.name===`TimeoutError`||t?.name===`AbortError`?`Request timed out after ${Math.round(i/1e3)}s`:t?.message||String(e),httpStatus:null}}if(o.ok){let e=`canceled`;try{let t=await o.json();t&&typeof t.status==`string`&&(e=t.status)}catch{}return{ok:!0,status:e}}let s=typeof o.status==`number`?o.status:null,c=s==null?``:` (HTTP ${s})`,l=``;try{typeof o.text==`function`?l=await o.text():typeof o.json==`function`&&(l=JSON.stringify(await o.json()))}catch{}let u=l.slice(0,200).trim();try{let e=JSON.parse(l);e&&typeof e.error==`string`&&e.error&&(u=e.error)}catch{}let d=typeof o.statusText==`string`?o.statusText:``;return{ok:!1,error:u?`${u}${c}`:`HTTP ${s??`?`}${d?` ${d}`:``}`,httpStatus:s}}var W=O();function le({phases:e,phaseDefinitions:t}){return t.length===0?null:(0,W.jsx)(`div`,{className:`flex items-center`,children:t.map((n,i)=>{let a=e[n.key]??`idle`,o=i<t.length-1?e[t[i+1].key]??`idle`:null;return(0,W.jsxs)(`div`,{className:`flex items-center`,children:[(0,W.jsxs)(r,{children:[(0,W.jsx)(m,{asChild:!0,children:(0,W.jsxs)(`div`,{className:`flex flex-col items-center gap-1.5 cursor-default px-4`,children:[(0,W.jsx)(ue,{state:a}),(0,W.jsx)(`span`,{className:A(`text-xs font-medium transition-colors`,a===`running`?`text-blue-400 aurora-light:text-accent-info`:a===`done`?`text-emerald-400 aurora-light:text-accent-success`:a===`error`?`text-red-400 aurora-light:text-destructive`:`text-muted-foreground/40`),children:n.label})]})}),(0,W.jsxs)(g,{side:`bottom`,className:`max-w-[200px]`,children:[(0,W.jsx)(`p`,{className:`font-medium`,children:n.label}),(0,W.jsx)(`p`,{className:`text-muted-foreground mt-0.5`,children:n.description})]})]}),o!==null&&(0,W.jsx)(`div`,{className:A(`h-px w-12 -mt-5 shrink-0 transition-all duration-300`,o===`done`||a===`done`?`bg-emerald-500/30 aurora-light:bg-accent-success/40`:o===`running`?`bg-blue-400/40 aurora-light:bg-accent-info/40`:`bg-border/30`)})]},n.key)})})}function ue({state:e}){return(0,W.jsxs)(`div`,{className:A(`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,W.jsx)(x,{className:`w-6 h-6 text-blue-400 aurora-light:text-accent-info animate-spin`}),e===`done`&&(0,W.jsx)(a,{className:`w-6 h-6 text-emerald-400 aurora-light:text-accent-success`}),e===`error`&&(0,W.jsx)(p,{className:`w-6 h-6 text-red-400 aurora-light:text-destructive`}),e===`idle`&&(0,W.jsx)(H,{className:`w-6 h-6 text-muted-foreground/20`})]})}var G=e(v(),1);function de(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))}var fe=new Set;function K({ticketId:e,onOpen:t,children:n}){let{t:r}=i(`agent`),a=r(`refs.openTicket`,{id:e});return(0,W.jsx)(`button`,{type:`button`,"data-testid":`log-ticket-ref`,onClick:n=>{n.stopPropagation(),t(e)},title:a,"aria-label":a,className:`inline cursor-pointer p-0 align-baseline text-accent-primary/90 underline decoration-accent-primary/50 decoration-dotted underline-offset-2 transition-colors hover:text-accent-primary hover:decoration-solid`,children:n})}function pe(e){if(!e.includes(`#`))return null;let t=y(e,fe);return t.some(e=>e.kind===`ticket`)?t:null}function me(e,t){let n=pe(e);return n?n.map((e,n)=>e.kind===`ticket`?(0,W.jsx)(K,{ticketId:e.ticketId,onOpen:t,children:e.label},n):(0,W.jsx)(G.Fragment,{children:e.kind===`text`?e.text:e.label},n)):e}var he=new Set([`code`,`inlineCode`,`link`,`linkReference`,`image`,`imageReference`,`definition`,`html`]);function ge(e){return e.kind===`ticket`?{type:`link`,url:N({kind:`ticket`,ticketId:e.ticketId}),children:[{type:`text`,value:e.label}]}:{type:`text`,value:e.kind===`text`?e.text:e.label}}function _e(e){let t=e.children;if(t)for(let e=t.length-1;e>=0;e--){let n=t[e];if(!he.has(n.type))if(n.type===`text`&&typeof n.value==`string`){let r=y(n.value,fe);r.some(e=>e.kind===`ticket`)&&t.splice(e,1,...r.map(ge))}else _e(n)}}function ve(){return e=>_e(e)}function ye(e){let{activeProjectId:t}=w(),{openRef:n}=j(),r=e??t??void 0;return(0,G.useMemo)(()=>r?e=>{n(r,{kind:`ticket`,ticketId:e})}:void 0,[r,n])}function be(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}:de(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(F.t(`jobs:logViewer.turns`,{count:t.num_turns})),{id:n,content:`▸ ${F.t(`jobs:logViewer.completed`)}${i.length?` — ${i.join(` · `)}`:``}`,type:`result`,timestamp:r}}catch{return null}return null}function xe(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 Se(e){let t=[];for(let n of e){let e=t.length>0?t[t.length-1]:null;n.type===`assistant`&&e?.type===`assistant`?e.content+=`
|
|
2
|
+
`+n.content:t.push({...n})}return t}function Ce(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 we({events:e,isLoading:t,projectId:n}){let{t:r,i18n:a}=i(`jobs`),[s,c]=(0,G.useState)(``),[l,u]=(0,G.useState)(!0),[d,f]=(0,G.useState)(new Set),p=(0,G.useRef)(null),m=(0,G.useRef)(null),h=ye(n),{processedLines:g,groups:_,totalLines:v}=(0,G.useMemo)(()=>{let t=xe(Se(e.map((e,t)=>be(e,t)).filter(e=>e!==null)));return{processedLines:t,groups:Ce(t),totalLines:t.length}},[e,a.language]),y=(0,G.useMemo)(()=>{if(!s)return v;let e=s.toLowerCase();return g.filter(t=>t.content.toLowerCase().includes(e)).length},[s,g,v]),b=(0,G.useCallback)(()=>{let e=m.current;e&&(e.scrollTop=e.scrollHeight)},[]);(0,G.useEffect)(()=>{l&&b()},[e.length,l,b]);function x(){let e=m.current;e&&u(e.scrollHeight-e.scrollTop-e.clientHeight<50)}function C(e){f(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})}return t?(0,W.jsx)(`div`,{className:`flex-1 flex items-center justify-center`,children:(0,W.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:r(`logViewer.loading`)})}):v===0?(0,W.jsx)(`div`,{className:`flex-1 flex items-center justify-center`,children:(0,W.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:r(`logViewer.empty`)})}):(0,W.jsxs)(`div`,{className:`flex flex-col h-full`,children:[(0,W.jsxs)(`div`,{className:`px-4 py-2 border-b border-border flex items-center gap-2`,children:[(0,W.jsxs)(`div`,{className:`relative flex-1 max-w-xs`,children:[(0,W.jsx)(ee,{className:`absolute left-2.5 top-1/2 -translate-y-1/2 w-3 h-3 text-muted-foreground`}),(0,W.jsx)(S,{placeholder:r(`logViewer.filterPlaceholder`),value:s,onChange:e=>c(e.target.value),className:`pl-7 h-7`})]}),(0,W.jsx)(I,{variant:`ghost`,size:`sm`,className:`h-7 px-2 text-muted-foreground/50 hover:text-foreground`,onClick:()=>{let e=g.map(e=>e.content).join(`
|
|
3
|
+
`);navigator.clipboard.writeText(e).then(()=>{U.success(r(`logViewer.copySuccess`))}).catch(()=>{U.error(r(`logViewer.copyFailed`))})},children:(0,W.jsx)(z,{className:`w-3.5 h-3.5`})}),(0,W.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:r(`logViewer.lineCount`,{filtered:y,total:v})})]}),(0,W.jsxs)(`div`,{ref:m,className:`flex-1 overflow-y-auto p-2 text-xs relative`,onScroll:x,children:[_.map(e=>(0,W.jsx)(Te,{group:e,filter:s,collapsed:d.has(e.key),onToggle:()=>C(e.key),onOpenTicket:h},e.key)),(0,W.jsx)(`div`,{ref:p})]}),!l&&(0,W.jsxs)(I,{size:`sm`,variant:`secondary`,onClick:()=>{u(!0),b()},className:`absolute bottom-16 right-6 h-7 gap-1 shadow-lg`,children:[(0,W.jsx)(o,{className:`w-3 h-3`}),r(`logViewer.jumpToBottom`)]})]})}var Te=(0,G.memo)(function({group:e,filter:t,collapsed:n,onToggle:r,onOpenTicket:a}){let{t:o}=i(`jobs`),c=t?e.lines.filter(e=>e.content.toLowerCase().includes(t.toLowerCase())):e.lines;if(e.header===null)return c.length===0?null:(0,W.jsx)(`div`,{children:c.map((e,t)=>(0,W.jsx)(q,{line:e,even:t%2==0,onOpenTicket:a},e.id))});let l=e.header.content;return(0,W.jsxs)(`div`,{className:`mt-3 rounded-md overflow-hidden border border-border/20`,children:[(0,W.jsxs)(`button`,{type:`button`,onClick:r,className:A(`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,W.jsx)(s,{className:A(`w-3 h-3 text-primary/60 shrink-0 transition-transform duration-150`,!n&&`rotate-90`)}),(0,W.jsx)(`span`,{className:`flex-1 text-[12px] font-semibold text-foreground leading-none`,children:l}),e.header.timestamp&&(0,W.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,W.jsx)(`span`,{className:`text-[10px] text-muted-foreground/40 shrink-0`,children:o(`logViewer.phaseLines`,{count:e.lines.length})})]}),!n&&(0,W.jsx)(`div`,{className:`bg-muted/5`,children:c.length===0?(0,W.jsx)(`p`,{className:`px-4 py-2 text-[10px] text-muted-foreground/40 italic`,children:o(t?`logViewer.noMatchingLines`:`logViewer.noOutput`)}):c.map((e,t)=>(0,W.jsx)(q,{line:e,even:t%2==0,onOpenTicket:a},e.id))})]})}),Ee=[te],De=[T],Oe=[T,ve],q=(0,G.memo)(function({line:e,even:t,onOpenTicket:n}){let r=e.type===`assistant`,i=e.type===`diff-add`,a=e.type===`diff-remove`,o=e.type===`diff-meta`,s=e.type===`diff-hunk`,l=i||a||o||s,u=n!=null&&(e.type===`plain`||e.type===`log`),d=(0,G.useMemo)(()=>u&&n?me(e.content,n):e.content,[u,n,e.content]),f=r&&n?Oe:De,p=(0,G.useMemo)(()=>n?{a:({href:e,children:t})=>{let r=C(e);return r?.kind===`ticket`?(0,W.jsx)(K,{ticketId:r.ticketId,onOpen:n,children:t}):(0,W.jsx)(`a`,{href:e,children:t})}}:void 0,[n]);return(0,W.jsxs)(`div`,{className:A(`flex items-start gap-2 group px-2 py-0.5 rounded-sm`,!l&&(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`,i&&`bg-emerald-500/8 aurora-light:bg-accent-success/10 border-l-2 border-emerald-500/50 aurora-light:border-accent-success/50`,a&&`bg-red-500/8 aurora-light:bg-destructive/10 border-l-2 border-red-500/50 aurora-light:border-destructive/50`,o&&`bg-accent-primary/5 border-l-2 border-accent-primary/30`,s&&`bg-accent-info/5 border-l-2 border-accent-info/30`),children:[e.timestamp&&(0,W.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})}),r?(0,W.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,W.jsx)(c,{remarkPlugins:f,rehypePlugins:Ee,components:p,children:e.content})}):(0,W.jsx)(`span`,{className:A(`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`,i&&`text-emerald-400 aurora-light:text-accent-success`,a&&`text-red-400 aurora-light:text-destructive`,o&&`text-accent-primary/80`,s&&`text-accent-info/80`),children:d})]})});function J(e){try{let t=JSON.parse(e);if(t&&typeof t==`object`&&!Array.isArray(t))return t}catch{}return null}var ke=/^\s*━+\s*Step\s+\d+\s*·/,Ae=/\s*\(iteration\s+\d+\)\s*$/i;function Y(e){return e.replace(/^[\s\uFE0F\p{Extended_Pictographic}]+/u,``).trim()||e.trim()}function X(e){let t=Y(e.title);return e.iteration==null?t:t.replace(Ae,``)}function je(e){return e.meta.nodeId??`${e.meta.kind}::${Y(e.meta.title).replace(Ae,``)}`}function Me(e){let t=null,n=0,r=[[]],i=[];for(let a=0;a<e.length;a++){let o=e[a];if(o.event_type===`loop_graph`){let e=J(o.payload);e&&e.graph&&typeof e.graph==`object`&&!Array.isArray(e.graph)&&(t={graph:e.graph,loopId:typeof e.loopId==`string`?e.loopId:void 0,loopName:typeof e.loopName==`string`?e.loopName:void 0,provider:typeof e.provider==`string`?e.provider:void 0,model:typeof e.model==`string`?e.model:void 0,iterationLimit:typeof e.iterationLimit==`number`?e.iterationLimit:void 0});continue}if(o.event_type===`loop_step`){let e=J(o.payload);if(!e||typeof e.index!=`number`)continue;let t=typeof e.iteration==`number`?e.iteration:null;t!=null&&t>n&&(n=t),i.push({meta:{index:e.index,kind:typeof e.kind==`string`?e.kind:`ai-step`,title:typeof e.title==`string`?e.title:``,nodeId:typeof e.nodeId==`string`?e.nodeId:null,iteration:t,template:typeof e.template==`string`&&e.template?e.template:void 0,command:typeof e.command==`string`&&e.command?e.command:void 0},end:null,lastActivity:null}),r.push([]);continue}if(o.event_type===`loop_step_end`){let e=J(o.payload);if(!e||typeof e.index!=`number`)continue;for(let t=i.length-1;t>=0;t--)if(i[t].meta.index===e.index){i[t].end={index:e.index,nodeId:typeof e.nodeId==`string`?e.nodeId:null,status:e.status===`failed`?`failed`:`ok`,exitCode:typeof e.exitCode==`number`?e.exitCode:null,durationMs:typeof e.durationMs==`number`?e.durationMs:null,decision:e.decision===`continue`||e.decision===`stop`?e.decision:void 0};break}continue}let s=i.length>0,c=be(o,a);if(c&&!(s&&ke.test(c.content))&&r[r.length-1].push(c),s){let e=B(o);e.step&&e.actionKey&&(i[i.length-1].lastActivity={actionKey:e.actionKey,actionArg:e.actionArg})}}let a=e=>xe(Se(e)),o=a(r[0]),s=i.map((e,t)=>({key:`step-${t}-${e.meta.index}`,meta:e.meta,lines:a(r[t+1]),end:e.end,lastActivity:e.lastActivity})),c=o.length+s.reduce((e,t)=>e+t.lines.length,0);return{graphMeta:t,setup:o,segments:s,maxIteration:n,totalLines:c}}function Ne(e,t){return e.end?e.end.status:t.isLast?t.jobSettled?`interrupted`:`running`:`unknown`}function Pe(e){return e===`continue`?0:e===`stop`?2:1}function Fe(e){let t=new Map(e.nodes.map(e=>[e.id,e])),n=new Set,r=[],i=a=>{if(n.has(a))return;let o=t.get(a);if(!o)return;n.add(a),r.push(o);let s=e.edges.filter(e=>e.source===a).slice().sort((e,t)=>Pe(e.branch)-Pe(t.branch));for(let e of s)i(e.target)},a=e.nodes.find(e=>e.type===`start`);a&&i(a.id);for(let t of e.nodes)i(t.id);return r}function Z(e){let t=e.data?.label;return typeof t==`string`&&t.trim()?t.trim():null}function Ie(e,t){let n=e.segments.length-1,r=new Map,i=new Map;e.segments.forEach((e,t)=>{let n=je(e);r.set(n,{seg:e,idx:t}),e.meta.kind===`decider`&&e.end?.decision&&i.set(n,e.end.decision)});let a=e=>{let r=Ne(e.seg,{isLast:e.idx===n,jobSettled:t.jobSettled});return r===`unknown`?`ok`:r};if(e.graphMeta)return Fe(e.graphMeta.graph).map(e=>{if(e.type===`start`)return{key:e.id,kind:`start`,label:Z(e),state:`ok`,latestSegmentKey:null};if(e.type===`end`)return{key:e.id,kind:`end`,label:Z(e),state:t.jobSettled?t.jobFailed?`failed`:`ok`:`pending`,latestSegmentKey:null};let n=r.get(e.id);return n?{key:e.id,kind:e.type,label:Z(e)??X(n.seg.meta),state:a(n),decision:e.type===`decider`?i.get(e.id):void 0,latestSegmentKey:n.seg.key}:{key:e.id,kind:e.type,label:Z(e),state:`pending`,latestSegmentKey:null}});let o=[],s=new Map;return e.segments.forEach((e,t)=>{let n=je(e),r={seg:e,idx:t},c=s.get(n),l=e.meta.kind===`decider`?i.get(n):void 0;if(c!=null){let t=o[c];t.state=a(r),t.decision=l,t.latestSegmentKey=e.key}else s.set(n,o.length),o.push({key:n,kind:e.meta.kind,label:X(e.meta)||null,state:a(r),decision:l,latestSegmentKey:e.key})}),o}function Le(e){if(!Number.isFinite(e)||e<0)return`—`;if(e<1e3)return`${Math.round(e)}ms`;let t=e/1e3;if(t<60)return`${t.toFixed(1)}s`;let n=Math.floor(t/60),r=Math.round(t%60);return n<60?`${n}m ${r}s`:`${Math.floor(n/60)}h ${n%60}m`}var Re={start:M,"ai-step":t,shell:D,decider:P,condition:P,end:L},ze=E,Be={start:`text-accent-success`,"ai-step":`text-accent-primary`,shell:`text-accent-warning`,decider:`text-accent-highlight`,condition:`text-accent-info`,end:`text-accent-secondary`},Ve={start:`border-accent-success/60`,"ai-step":`border-accent-primary/60`,shell:`border-accent-warning/60`,decider:`border-accent-highlight/60`,condition:`border-accent-info/60`,end:`border-accent-secondary/60`};function He(e){return Re[e]??ze}function Ue({chips:e,iteration:t,onChipClick:n,variant:r}){let{t:a}=i(`jobs`);return e.length===0&&!t?null:(0,W.jsxs)(`div`,{"data-testid":`loop-overview-strip`,role:`list`,"aria-label":a(`loopExplorer.stepMapAria`),className:A(`flex items-center gap-1 overflow-x-auto border-b border-border/30 bg-surface/20`,r===`glass`?`px-3 py-1.5`:`px-4 py-2`),children:[e.map((e,t)=>{let r=He(e.kind),i=Be[e.kind]??`text-foreground`,o=Ve[e.kind]??`border-border/40`,c=e.label??a(`loops:builder.nodes.${e.kind}`,{defaultValue:e.kind}),d=e.latestSegmentKey!=null;return(0,W.jsxs)(G.Fragment,{children:[t>0&&(0,W.jsx)(s,{className:`w-3 h-3 text-muted-foreground/30 shrink-0`}),(0,W.jsxs)(`button`,{type:`button`,role:`listitem`,"data-testid":`loop-node-chip`,"data-state":e.state,"data-kind":e.kind,"data-decision":e.decision,"aria-label":`${c} — ${e.state}`,disabled:!d,onClick:()=>e.latestSegmentKey&&n(e.latestSegmentKey),className:A(`relative flex items-center gap-1.5 shrink-0 rounded-full border bg-surface/40 px-2.5 py-1 text-[11px] transition-colors`,o,e.state===`pending`&&`opacity-45 border-border/40`,e.state===`interrupted`&&`border-dashed border-accent-warning/50`,d?`cursor-pointer hover:bg-surface/70`:`cursor-default`),children:[e.state===`running`&&(0,W.jsx)(`span`,{"aria-hidden":!0,className:`absolute -inset-px rounded-full ring-2 ring-accent-primary/50 motion-safe:animate-pulse pointer-events-none`}),(0,W.jsx)(r,{className:A(`w-3 h-3 shrink-0`,i)}),(0,W.jsx)(`span`,{className:A(`max-w-[120px] truncate font-medium text-foreground/90`,e.state===`running`&&`title-shimmer`),children:c}),e.state===`ok`&&(0,W.jsx)(l,{className:`w-3 h-3 text-accent-success shrink-0`}),e.state===`failed`&&(0,W.jsx)(V,{className:`w-3 h-3 text-destructive shrink-0`}),e.decision===`continue`&&(0,W.jsx)(_,{className:`w-3 h-3 text-accent-highlight shrink-0`}),e.decision===`stop`&&(0,W.jsx)(u,{className:`w-3 h-3 text-accent-success shrink-0`})]})]},e.key)}),t&&(0,W.jsxs)(`span`,{"data-testid":`loop-iteration-chip`,className:`ml-auto flex items-center gap-1.5 shrink-0 rounded-full border border-accent-highlight/40 bg-accent-highlight/10 px-2.5 py-1 text-[10px] font-medium text-accent-highlight tabular-nums`,children:[(0,W.jsx)(h,{className:`w-3 h-3`}),t.limit==null?a(`loopExplorer.iterationBadge`,{count:t.current}):a(`loopExplorer.iteration`,{current:t.current,limit:t.limit})]})]})}var We=(0,G.memo)(Ue);function Ge({className:e}){return(0,W.jsxs)(`span`,{className:A(`relative flex h-2 w-2 shrink-0`,e),children:[(0,W.jsx)(`span`,{className:`motion-safe:animate-ping absolute inline-flex h-full w-full rounded-full bg-accent-primary opacity-60`}),(0,W.jsx)(`span`,{className:`relative inline-flex rounded-full h-2 w-2 bg-accent-primary`})]})}function Ke(e,t){if(!t)return e;let n=t.toLowerCase();return e.filter(e=>e.content.toLowerCase().includes(n))}function qe(e,t,n,r){return e.length===0?(0,W.jsx)(`p`,{className:`px-4 py-2 text-[10px] text-muted-foreground/40 italic`,children:n(t?`logViewer.noMatchingLines`:`logViewer.noOutput`)}):e.map((e,t)=>(0,W.jsx)(q,{line:e,even:t%2==0,onOpenTicket:r},e.id))}function Je({label:e,value:t,copyLabel:n}){let[r,i]=(0,G.useState)(!1),a=async()=>{try{await navigator.clipboard.writeText(t),i(!0),window.setTimeout(()=>i(!1),1500)}catch{}};return(0,W.jsxs)(`div`,{className:`min-w-0`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,W.jsx)(`span`,{className:`text-[9px] font-semibold uppercase tracking-wider text-muted-foreground/50`,children:e}),(0,W.jsx)(`button`,{type:`button`,onClick:()=>void a(),"aria-label":`${n} — ${e}`,title:n,className:`p-0.5 text-muted-foreground/40 hover:text-foreground transition-colors cursor-pointer`,children:r?(0,W.jsx)(l,{className:`w-2.5 h-2.5 text-accent-success`}):(0,W.jsx)(z,{className:`w-2.5 h-2.5`})})]}),(0,W.jsx)(`pre`,{className:`mt-0.5 text-[10px] font-mono leading-relaxed text-foreground/75 whitespace-pre-wrap break-words`,children:t})]})}function Ye({segment:e,status:t,collapsed:n,filter:r,onToggle:a,onCopy:o,setRef:c,onOpenTicket:u}){let{t:d}=i(`jobs`),{meta:f,lines:p,end:m,lastActivity:h}=e,g=He(f.kind),_=Be[f.kind]??`text-foreground`,v=Ke(p,r),y=t===`running`,b=!!(f.template||f.command),[x,S]=(0,G.useState)(!1);return(0,W.jsxs)(`div`,{ref:t=>c(e.key,t),"data-testid":`loop-step-section`,"data-status":t,"data-step-index":f.index,className:A(`mt-3 rounded-md overflow-hidden border animate-in fade-in duration-200`,t===`running`&&`border-accent-primary/40`,t===`failed`&&`border-destructive/30`,t===`interrupted`&&`border-dashed border-accent-warning/40`,(t===`ok`||t===`unknown`)&&`border-border/20`),children:[(0,W.jsxs)(`div`,{className:A(`flex items-stretch bg-primary/5 border-b`,t===`failed`?`border-destructive/20`:`border-primary/20`),children:[(0,W.jsxs)(`button`,{type:`button`,onClick:()=>a(e.key),className:`flex items-center gap-2 flex-1 min-w-0 text-left px-3 py-2 hover:bg-primary/10 transition-colors duration-150 cursor-pointer`,children:[(0,W.jsx)(s,{className:A(`w-3 h-3 text-primary/60 shrink-0 transition-transform duration-150`,!n&&`rotate-90`)}),(0,W.jsx)(`span`,{className:`text-[10px] font-mono tabular-nums text-muted-foreground/60 shrink-0 w-5 text-right`,children:f.index}),(0,W.jsx)(g,{className:A(`w-3.5 h-3.5 shrink-0`,_)}),(0,W.jsx)(`span`,{className:`text-[12px] font-semibold text-foreground leading-none truncate`,children:X(f)}),f.iteration!=null&&f.iteration>=1&&(0,W.jsx)(`span`,{className:`shrink-0 rounded-full bg-muted/60 px-1.5 py-0.5 text-[9px] font-medium text-muted-foreground tabular-nums`,children:d(`loopExplorer.iterationBadge`,{count:f.iteration})}),y&&(0,W.jsxs)(`span`,{className:`flex items-center gap-1.5 min-w-0 shrink-0 max-w-[40%]`,children:[(0,W.jsx)(Ge,{}),h&&(0,W.jsx)(`span`,{className:`title-shimmer text-[10px] truncate`,children:d(`statusPanel.activity.${h.actionKey}`,{arg:h.actionArg??``})})]}),t===`ok`&&(0,W.jsx)(l,{className:`w-3.5 h-3.5 text-accent-success shrink-0`}),t===`failed`&&(0,W.jsx)(V,{className:`w-3.5 h-3.5 text-destructive shrink-0`}),t===`interrupted`&&(0,W.jsx)(`span`,{className:`shrink-0 rounded border border-dashed border-accent-warning/50 px-1.5 py-0.5 text-[9px] font-medium uppercase tracking-wide text-accent-warning`,children:d(`loopExplorer.interrupted`)}),(0,W.jsx)(`span`,{className:`flex-1`}),m?.durationMs!=null&&(0,W.jsx)(`span`,{className:`text-[10px] text-muted-foreground/50 font-mono tabular-nums shrink-0`,children:Le(m.durationMs)}),t===`failed`&&m?.exitCode!=null&&m.exitCode!==0&&(0,W.jsx)(`span`,{className:`text-[10px] text-destructive/70 font-mono shrink-0`,children:d(`activeJob.exitCode`,{code:m.exitCode})}),(0,W.jsx)(`span`,{className:`text-[10px] text-muted-foreground/40 shrink-0`,children:d(`logViewer.phaseLines`,{count:p.length})})]}),b&&(0,W.jsx)(`button`,{type:`button`,onClick:()=>S(e=>!e),"aria-label":d(`loopExplorer.stepDetail`),"aria-expanded":x,title:d(`loopExplorer.stepDetail`),className:A(`px-2 flex items-center transition-colors cursor-pointer`,x?`text-foreground bg-primary/10`:`text-muted-foreground/40 hover:text-foreground hover:bg-primary/10`),children:(0,W.jsx)(k,{className:`w-3 h-3`})}),(0,W.jsx)(`button`,{type:`button`,onClick:()=>o(e.key),"aria-label":d(`loopExplorer.copyStep`),title:d(`loopExplorer.copyStep`),className:`px-2.5 flex items-center text-muted-foreground/40 hover:text-foreground hover:bg-primary/10 transition-colors cursor-pointer`,children:(0,W.jsx)(z,{className:`w-3 h-3`})})]}),x&&b&&(0,W.jsxs)(`div`,{"data-testid":`loop-step-detail`,className:A(`px-4 py-2.5 space-y-2.5 bg-muted/10 border-b animate-in fade-in duration-150`,t===`failed`?`border-destructive/20`:`border-primary/10`),children:[f.template&&(0,W.jsx)(Je,{label:d(`loopExplorer.stepDetailTemplate`),value:f.template,copyLabel:d(`loopExplorer.copyCommand`)}),f.command&&(0,W.jsx)(Je,{label:d(`loopExplorer.stepDetailCommand`),value:f.command,copyLabel:d(`loopExplorer.copyCommand`)})]}),!n&&(0,W.jsx)(`div`,{className:`bg-muted/5`,children:qe(v,r,d,u)})]})}var Xe=(0,G.memo)(Ye,(e,t)=>e.segment.key===t.segment.key&&e.segment.lines.length===t.segment.lines.length&&e.segment.lines[e.segment.lines.length-1]?.content===t.segment.lines[t.segment.lines.length-1]?.content&&e.segment.meta.template===t.segment.meta.template&&e.segment.meta.command===t.segment.meta.command&&e.segment.end?.status===t.segment.end?.status&&e.segment.end?.durationMs===t.segment.end?.durationMs&&e.segment.end?.decision===t.segment.end?.decision&&e.segment.end?.exitCode===t.segment.end?.exitCode&&e.segment.lastActivity?.actionKey===t.segment.lastActivity?.actionKey&&e.segment.lastActivity?.actionArg===t.segment.lastActivity?.actionArg&&e.status===t.status&&e.collapsed===t.collapsed&&e.filter===t.filter&&e.onOpenTicket===t.onOpenTicket),Q=`__setup__`;function Ze({lines:e,collapsed:t,filter:n,onToggle:r,setRef:a,onOpenTicket:o}){let{t:c}=i(`jobs`),l=Ke(e,n);return(0,W.jsxs)(`div`,{ref:e=>a(Q,e),"data-testid":`loop-setup-section`,className:`rounded-md overflow-hidden border border-border/20`,children:[(0,W.jsxs)(`button`,{type:`button`,onClick:()=>r(Q),className:`flex items-center gap-2 w-full text-left px-3 py-2 bg-muted/10 border-b border-border/20 hover:bg-muted/20 transition-colors duration-150 cursor-pointer`,children:[(0,W.jsx)(s,{className:A(`w-3 h-3 text-muted-foreground/60 shrink-0 transition-transform duration-150`,!t&&`rotate-90`)}),(0,W.jsx)(M,{className:`w-3.5 h-3.5 text-accent-success/70 shrink-0`}),(0,W.jsx)(`span`,{className:`text-[11px] font-semibold text-muted-foreground leading-none uppercase tracking-wide`,children:c(`loopExplorer.setup`)}),(0,W.jsx)(`span`,{className:`flex-1`}),(0,W.jsx)(`span`,{className:`text-[10px] text-muted-foreground/40 shrink-0`,children:c(`logViewer.phaseLines`,{count:e.length})})]}),!t&&(0,W.jsx)(`div`,{className:`bg-muted/5`,children:qe(l,n,c,o)})]})}var Qe=(0,G.memo)(Ze,(e,t)=>e.lines.length===t.lines.length&&e.lines[e.lines.length-1]?.content===t.lines[t.lines.length-1]?.content&&e.collapsed===t.collapsed&&e.filter===t.filter&&e.onOpenTicket===t.onOpenTicket);function $(){return(0,W.jsxs)(`span`,{className:`relative flex h-1.5 w-1.5 shrink-0`,children:[(0,W.jsx)(`span`,{className:`motion-safe:animate-ping absolute inline-flex h-full w-full rounded-full bg-accent-primary opacity-60`}),(0,W.jsx)(`span`,{className:`relative inline-flex rounded-full h-1.5 w-1.5 bg-accent-primary`})]})}function $e({events:e,jobStatus:t,isLoading:n,variant:r=`page`,projectId:a}){let{t:o,i18n:s}=i(`jobs`),[c,l]=(0,G.useState)(``),[u,d]=(0,G.useState)(`follow`),[f,p]=(0,G.useState)(new Set),m=(0,G.useRef)(null),h=(0,G.useRef)(new Map),g=ye(a),_=(0,G.useMemo)(()=>Me(e),[e,s.language]),v=t!=null&&t!==`running`&&t!==`queued`,y=t===`running`,b=(0,G.useMemo)(()=>_.segments.map((e,t)=>Ne(e,{isLast:t===_.segments.length-1,jobSettled:v})),[_,v]),x=(0,G.useMemo)(()=>{let e=_.segments.map(e=>e.key);return _.setup.length>0&&e.push(Q),e},[_]),C=_.segments.length>0?_.segments[_.segments.length-1].key:Q,w=(0,G.useMemo)(()=>c?new Set(x):u===`follow`?new Set([C]):f,[c,u,C,f,x]),T=(0,G.useRef)(w);T.current=w;let E=(0,G.useRef)(_);E.current=_;let D=(0,G.useCallback)(e=>{let t=new Set(T.current);e?.(t),p(t),d(`manual`)},[]),O=(0,G.useCallback)(e=>{D(t=>{t.has(e)?t.delete(e):t.add(e)})},[D]),k=(0,G.useCallback)(e=>{D(t=>t.add(e)),requestAnimationFrame(()=>{h.current.get(e)?.scrollIntoView?.({behavior:`smooth`,block:`start`})})},[D]),j=(0,G.useCallback)(()=>{let e=m.current;e&&(e.scrollTop=e.scrollHeight)},[]),M=(0,G.useCallback)(()=>{d(`follow`),requestAnimationFrame(j)},[j]),N=(0,G.useCallback)(()=>{p(new Set(x)),d(`manual`)},[x]),P=(0,G.useCallback)(()=>{p(new Set),d(`manual`)},[]);(0,G.useEffect)(()=>{u===`follow`&&!c&&j()},[_.totalLines,_.segments.length,u,c,j]);let F=(0,G.useCallback)(()=>{let e=m.current;!e||u!==`follow`||e.scrollHeight-e.scrollTop-e.clientHeight>80&&D()},[u,D]),L=(0,G.useCallback)((e,t)=>{t?h.current.set(e,t):h.current.delete(e)},[]),R=(0,G.useCallback)(e=>{let t=E.current.segments.find(t=>t.key===e),n=e===`__setup__`?E.current.setup.map(e=>e.content).join(`
|
|
17
|
+
`):(t?.lines??[]).map(e=>e.content).join(`
|
|
18
|
+
`);navigator.clipboard.writeText(n).then(()=>U.success(o(`loopExplorer.copied`))).catch(()=>U.error(o(`logViewer.copyFailed`)))},[o]),B=(0,G.useCallback)(()=>{let e=E.current,t=e.setup.map(e=>e.content);for(let n of e.segments){t.push(`── Step ${n.meta.index} · ${Y(n.meta.title)} ──`);for(let e of n.lines)t.push(e.content)}navigator.clipboard.writeText(t.join(`
|
|
19
|
+
`)).then(()=>U.success(o(`logViewer.copySuccess`))).catch(()=>U.error(o(`logViewer.copyFailed`)))},[o]),V=(0,G.useMemo)(()=>Ie(_,{jobSettled:v,jobFailed:t===`failed`}),[_,v,t]),H=_.graphMeta?.iterationLimit??_.graphMeta?.graph.config.maxIterations??null,te=_.maxIteration>0?{current:_.maxIteration,limit:H}:null,ie=(0,G.useMemo)(()=>{if(!c)return _.totalLines;let e=c.toLowerCase(),t=_.setup.filter(t=>t.content.toLowerCase().includes(e)).length;for(let n of _.segments)t+=n.lines.filter(t=>t.content.toLowerCase().includes(e)).length;return t},[c,_]),ae=_.segments[_.segments.length-1],oe=y&&(_.segments.length===0||ae?.end!=null);return n?(0,W.jsx)(`div`,{className:`flex-1 flex items-center justify-center h-full`,children:(0,W.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:o(`logViewer.loading`)})}):_.totalLines===0&&_.segments.length===0?(0,W.jsx)(`div`,{"data-testid":`loop-step-explorer`,className:`flex-1 flex items-center justify-center h-full`,children:(0,W.jsxs)(`p`,{className:`text-xs text-muted-foreground flex items-center gap-2`,children:[y&&(0,W.jsx)($,{}),o(y?`loopExplorer.waiting`:`logViewer.empty`)]})}):(0,W.jsxs)(`div`,{"data-testid":`loop-step-explorer`,className:`relative flex flex-col h-full`,children:[(0,W.jsxs)(`div`,{className:A(`border-b border-border flex items-center gap-2`,r===`glass`?`px-3 py-1.5`:`px-4 py-2`),children:[(0,W.jsxs)(`div`,{className:`relative flex-1 max-w-xs`,children:[(0,W.jsx)(ee,{className:`absolute left-2.5 top-1/2 -translate-y-1/2 w-3 h-3 text-muted-foreground`}),(0,W.jsx)(S,{placeholder:o(`logViewer.filterPlaceholder`),value:c,onChange:e=>l(e.target.value),className:`pl-7 h-7`})]}),(0,W.jsx)(I,{variant:`ghost`,size:`sm`,className:`h-7 px-2 text-muted-foreground/50 hover:text-foreground`,onClick:N,"aria-label":o(`loopExplorer.expandAll`),title:o(`loopExplorer.expandAll`),children:(0,W.jsx)(re,{className:`w-3.5 h-3.5`})}),(0,W.jsx)(I,{variant:`ghost`,size:`sm`,className:`h-7 px-2 text-muted-foreground/50 hover:text-foreground`,onClick:P,"aria-label":o(`loopExplorer.collapseAll`),title:o(`loopExplorer.collapseAll`),children:(0,W.jsx)(ne,{className:`w-3.5 h-3.5`})}),u===`follow`&&y&&(0,W.jsxs)(`span`,{className:`flex items-center gap-1.5 text-[10px] text-accent-primary shrink-0`,children:[(0,W.jsx)($,{}),o(`loopExplorer.follow`)]}),(0,W.jsx)(`span`,{className:`flex-1`}),(0,W.jsx)(I,{variant:`ghost`,size:`sm`,className:`h-7 px-2 text-muted-foreground/50 hover:text-foreground`,onClick:B,"aria-label":o(`logViewer.copySuccess`),children:(0,W.jsx)(z,{className:`w-3.5 h-3.5`})}),(0,W.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:o(`logViewer.lineCount`,{filtered:ie,total:_.totalLines})})]}),(0,W.jsx)(We,{chips:V,iteration:te,onChipClick:k,variant:r}),(0,W.jsxs)(`div`,{ref:m,onScroll:F,className:`flex-1 overflow-y-auto p-2 text-xs`,children:[_.setup.length>0&&(0,W.jsx)(Qe,{lines:_.setup,collapsed:!w.has(`__setup__`),filter:c,onToggle:O,setRef:L,onOpenTicket:g}),_.segments.map((e,t)=>(0,W.jsx)(Xe,{segment:e,status:b[t],collapsed:!w.has(e.key),filter:c,onToggle:O,onCopy:R,setRef:L,onOpenTicket:g},e.key)),oe&&(0,W.jsxs)(`div`,{"data-testid":`loop-waiting-row`,className:`mt-3 flex items-center gap-2 px-3 py-2 text-[11px] text-muted-foreground/70 italic`,children:[(0,W.jsx)($,{}),o(`loopExplorer.waiting`)]})]}),u===`manual`&&y&&!c&&(0,W.jsxs)(`button`,{type:`button`,"data-testid":`resume-follow-pill`,onClick:M,className:`absolute bottom-4 left-1/2 -translate-x-1/2 z-10 flex items-center gap-1.5 rounded-full glass-card border border-accent-primary/30 px-3 py-1.5 text-[11px] font-medium text-foreground shadow-lg hover:border-accent-primary/60 transition-colors cursor-pointer animate-in fade-in slide-in-from-bottom-2 duration-200`,children:[(0,W.jsx)($,{}),o(`loopExplorer.resumeFollow`)]})]})}function et(e,t){switch(t.type){case`turn-user`:return{...e,streaming:!0,accepting:!0,queued:t.queued?e.queued+1:e.queued};case`turn-done`:{let n=Math.max(0,e.queued-1);return{...e,totals:t.totals,queued:n,streaming:e.queued>0}}case`finalized`:return{...e,streaming:!1,finalizing:!1,accepting:!1,queued:0,totals:t.totals??e.totals};case`accepting`:return t.accepting?{...e,accepting:!0}:{...e,accepting:!1,streaming:!1,queued:0};case`finalize-request`:return{...e,finalizing:!0};case`finalize-reject`:return{...e,finalizing:!1};case`blocked`:return{...e,accepting:!1,streaming:!1};default:return e}}function tt(){try{return b()}catch{return null}}function nt({jobId:e,projectId:t,settleMode:o,initialAcceptingTurns:s,kind:c=`job`,variant:l=`page`,onFinalized:u}){let{t:d}=i(`jobs`),p=o??`finalize`,h=()=>t?`${n}/api/projects/${t}`:R(),[_,v]=(0,G.useReducer)(et,{streaming:!1,queued:0,totals:null,accepting:s??!0,finalizing:!1}),[y,b]=(0,G.useState)(``),[S,C]=(0,G.useState)(!1),w=(0,G.useRef)(null);(0,G.useEffect)(()=>{s!==void 0&&v({type:`accepting`,accepting:s})},[s]);let T=(0,G.useRef)(u);T.current=u;let E=tt(),D=(0,G.useId)();(0,G.useEffect)(()=>{if(!E)return;let t=`interactive-composer-${e}-${D}`;return E.registerHandler(t,t=>{let n=t;n.jobId===e&&(n.type===`job.turn_user`?v({type:`turn-user`,queued:!!n.queued}):n.type===`job.turn_done`?v({type:`turn-done`,totals:n.totals}):n.type===`job.finalized`?(v({type:`finalized`,totals:n.totals??null}),T.current?.()):n.type===`job.interactive`&&v({type:`accepting`,accepting:!!n.acceptingTurns}))}),()=>E.unregisterHandler(t)},[E,e,D]);let O=c===`loop-step`&&!_.accepting;async function k(){let t=y.trim();if(!(!t||S||O)){C(!0);try{let n=await fetch(`${h()}/jobs/${e}/messages`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({text:t})});if(n.ok)b(``),requestAnimationFrame(()=>w.current?.focus());else if(n.status===409&&c===`loop-step`)v({type:`blocked`});else{let e=await n.json().catch(()=>({}));U.error(d(`detail.toast.sendFailed`),{description:e.error})}}catch{U.error(d(`detail.toast.networkError`))}finally{C(!1)}}}async function j(){if(!_.finalizing){v({type:`finalize-request`});try{let t=await fetch(`${h()}/jobs/${e}/finalize`,{method:`POST`});if(t.ok)U.success(d(p===`finalize`?`detail.toast.finalizeScheduled`:c===`loop-step`?`detail.toast.wrapUpStepScheduled`:`detail.toast.wrapUpScheduled`));else if(t.status===409&&c===`loop-step`)v({type:`blocked`}),v({type:`finalize-reject`});else{let e=await t.json().catch(()=>({}));U.error(d(`detail.toast.finalizeFailed`),{description:e.error}),v({type:`finalize-reject`})}}catch{U.error(d(`detail.toast.networkError`)),v({type:`finalize-reject`})}}}let M=S||O||!y.trim(),N=d(`detail.interactive.working`);return(0,W.jsxs)(`div`,{"data-testid":`interactive-job-composer`,className:A(`shrink-0 border-t px-3 py-2 space-y-1.5`,`motion-safe:animate-in motion-safe:fade-in motion-safe:slide-in-from-bottom-2 motion-safe:duration-300`,l===`glass`?`border-border/30 bg-surface/30`:`border-border/40 bg-surface/40`),children:[(0,W.jsxs)(`div`,{className:`flex items-center justify-between gap-3 text-[11px] text-muted-foreground`,children:[(0,W.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[O?(0,W.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,W.jsx)(ie,{className:`h-3 w-3 motion-safe:animate-pulse`}),d(`detail.interactive.waitingForStepShort`)]}):_.streaming?(0,W.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,W.jsx)(x,{className:`h-3 w-3 animate-spin text-accent-primary`}),(0,W.jsxs)(`span`,{className:`relative`,children:[N,(0,W.jsx)(`span`,{"aria-hidden":!0,className:`title-shimmer pointer-events-none absolute inset-0`,children:N})]})]}):(0,W.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,W.jsx)(`span`,{className:`h-1.5 w-1.5 rounded-full bg-accent-success motion-safe:animate-pulse`}),d(`detail.interactive.ready`)]}),_.queued>0&&(0,W.jsx)(`span`,{className:`rounded-full border border-accent-info/30 bg-accent-info/10 px-1.5 py-px text-[10px] tabular-nums text-accent-info motion-safe:animate-in motion-safe:fade-in`,children:d(`detail.interactive.queued`,{count:_.queued})})]}),(0,W.jsxs)(`span`,{className:`flex shrink-0 items-center gap-3`,children:[_.totals&&(0,W.jsx)(`span`,{className:`tabular-nums`,children:d(`detail.interactive.liveTotals`,{turns:_.totals.num_turns,cost:_.totals.total_cost_usd.toFixed(4)})}),p===`finalize`?(0,W.jsxs)(r,{children:[(0,W.jsx)(m,{asChild:!0,children:(0,W.jsxs)(I,{variant:`outline`,size:`sm`,onClick:()=>void j(),disabled:_.finalizing,className:`h-7 border-accent-success/40 text-accent-success hover:bg-accent-success/10`,children:[(0,W.jsx)(a,{className:`mr-1.5 h-3.5 w-3.5`}),_.finalizing?d(`detail.finalizing`):d(`detail.finalizeJob`)]})}),(0,W.jsx)(g,{children:d(`detail.finalizeJobTooltip`)})]}):(0,W.jsxs)(r,{children:[(0,W.jsx)(m,{asChild:!0,children:(0,W.jsx)(`button`,{type:`button`,onClick:()=>void j(),disabled:_.finalizing||O,className:A(`text-[11px] underline-offset-2 transition-colors`,O?`cursor-not-allowed text-muted-foreground/40`:`text-muted-foreground hover:text-accent-success hover:underline`),children:_.finalizing?d(`detail.interactive.wrappingUp`):d(c===`loop-step`?`detail.interactive.wrapUpStep`:`detail.interactive.wrapUp`)})}),(0,W.jsx)(g,{children:d(c===`loop-step`?`detail.interactive.wrapUpStepTooltip`:`detail.interactive.wrapUpTooltip`)})]})]})]}),p===`auto`&&(0,W.jsx)(`p`,{className:`text-[11px] leading-snug text-muted-foreground/60`,children:d(O?`detail.interactive.waitingForStep`:`detail.interactive.autoHint`)}),(0,W.jsxs)(`div`,{className:`flex items-end gap-2`,children:[(0,W.jsx)(`textarea`,{ref:w,value:y,onChange:e=>b(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(!e.shiftKey||e.metaKey||e.ctrlKey)&&(e.preventDefault(),k())},rows:2,placeholder:d(O?`detail.interactive.waitingForStepShort`:`detail.interactive.placeholder`),"aria-label":d(`detail.interactive.placeholder`),disabled:O,className:A(`flex-1 resize-none rounded-md border border-border/50 bg-background px-2.5 py-1.5 text-sm transition-opacity focus:outline-none focus:ring-2 focus:ring-ring`,O&&`opacity-60`)}),(0,W.jsxs)(r,{children:[(0,W.jsx)(m,{asChild:!0,children:(0,W.jsx)(`span`,{className:`shrink-0`,children:(0,W.jsxs)(I,{size:`sm`,onClick:()=>void k(),disabled:M,className:`h-9`,children:[(0,W.jsx)(f,{className:`mr-1.5 h-3.5 w-3.5`}),d(`detail.interactive.send`)]})})}),M&&!S&&(0,W.jsx)(g,{children:d(O?`detail.interactive.sendDisabledWaiting`:`detail.interactive.sendDisabledEmpty`)})]})]})]})}export{ce as a,le as i,$e as n,ae as o,we as r,nt as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as e}from"./chunk-BNv3lrIs.js";import{a as t,i as n,n as r,o as i,r as a,t as o}from"./InteractiveJobComposer-zj8SrOAl.js";import{a as s,n as c}from"./auth-DpZq5p1e.js";import{B as l,Bn as u,H as d,Jn as f,L as p,U as ee,V as m,X as h,Yn as g,Z as _,en as v,et as y,lt as b,ot as x,tt as S,ut as C,wt as w,x as T,zn as E}from"./index-89SuhD4Y.js";var te=e(f(),1),D=e(g(),1),O=[1e3,2e3,4e3,8e3,16e3];function k(e,t){let[n,r]=(0,D.useState)(`connecting`),i=(0,D.useRef)(null),a=(0,D.useRef)(0),o=(0,D.useRef)(null),s=(0,D.useRef)(t);s.current=t;let l=(0,D.useCallback)(()=>{let t=c(),n=t?new WebSocket(e,[`specrails-desktop`,t]):new WebSocket(e);i.current=n,r(`connecting`),n.onopen=()=>{a.current=0,r(`connected`)},n.onmessage=e=>{try{let t=JSON.parse(e.data);s.current(t)}catch{}},n.onclose=()=>{i.current=null;let e=a.current;if(e>=O.length){r(`disconnected`);return}let t=O[e];a.current+=1,o.current=setTimeout(l,t)}},[e]);return(0,D.useEffect)(()=>(l(),()=>{o.current&&clearTimeout(o.current);let e=i.current;e&&(e.onopen=null,e.onmessage=null,e.onclose=null,e.onerror=null,e.close()),i.current=null}),[l]),{connectionStatus:n}}var A=b();function ne(e,t){let n=new Date(t).getTime()-new Date(e).getTime();if(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`}var j={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`},zombie_terminated:{variant:`failed`,labelKey:`statusLabel.zombie`,tooltipKey:`statusTooltip.zombie`}};function M({jobId:e,onClose:c,projectId:f}){let{t:g}=u(`jobs`),b=(0,D.useCallback)(()=>f?`${s}/api/projects/${f}`:C(),[f]),[O,M]=(0,D.useState)(null),[N,P]=(0,D.useState)([]),[F,I]=(0,D.useState)([]),[L,R]=(0,D.useState)({}),[z,B]=(0,D.useState)(!0),[V,H]=(0,D.useState)(!1),[U,W]=(0,D.useState)(!1),[G,K]=(0,D.useState)(!1);(0,D.useEffect)(()=>{async function t(){try{let t=await fetch(`${b()}/jobs/${e}`);if(t.status===404){H(!0);return}if(!t.ok)throw Error(`Failed to fetch job`);let n=await t.json();if(M(n.job),P(n.events),n.phaseDefinitions){I(n.phaseDefinitions);let e={};for(let t of n.phaseDefinitions)e[t.key]=`idle`;R(e)}}catch{H(!0)}finally{B(!1)}}t()},[e,b]);let q=(0,D.useCallback)(()=>{fetch(`${b()}/jobs/${e}`).then(e=>e.ok?e.json():null).then(e=>{e?.job&&M(e.job)}).catch(()=>{})},[e,b]),J=(0,D.useRef)([]),Y=(0,D.useRef)(null),X=(0,D.useCallback)(()=>{Y.current=null;let e=J.current;e.length!==0&&(J.current=[],P(t=>{let n=[...t,...e];return n.length>1e4?n.slice(n.length-8e3):n}))},[]);(0,D.useEffect)(()=>()=>{Y.current&&cancelAnimationFrame(Y.current)},[]),k(p,(0,D.useCallback)(t=>{let n=t;if(n.type===`event`&&n.jobId===e){let t={id:Date.now(),job_id:e,seq:0,event_type:n.event_type,source:n.source,payload:n.payload,timestamp:n.timestamp};J.current.push(t),Y.current||=requestAnimationFrame(X)}else if(n.type===`log`&&n.processId===e){let t={id:Date.now(),job_id:e,seq:0,event_type:`log`,source:n.source,payload:JSON.stringify({line:n.line}),timestamp:n.timestamp};J.current.push(t),Y.current||=requestAnimationFrame(X)}else if(n.type===`job.finalized`&&n.jobId===e)q();else if(n.type===`phase`){let e=n.phase,t=n.state;R(n=>({...n,[e]:t}))}else if(n.type===`queue`){let t=n.jobs?.find(t=>t.id===e);t&&O&&M(e=>e&&{...e,status:t.status})}},[e,O,X,q])),(0,D.useEffect)(()=>{function e(e){if(e.key===`Escape`){if(U){W(!1);return}c()}}return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[c,U]);let Z=O?i(O):`job`,Q=Z===`loop-run`;async function re(){K(!0);try{let n=await t({projectId:f??null,jobId:e,kind:Z});n.ok?(E.success(g(Q?`modal.toast.stopSignalSent`:`modal.toast.cancelSignalSent`),{description:g(Q?`modal.toast.stopSignalSentDescription`:`modal.toast.cancelSignalSentDescription`)}),q()):E.error(g(`modal.toast.cancelFailed`),{description:n.error})}finally{K(!1)}}let $=O?j[O.status]??j.queued:j.queued,ie=O?.status===`running`,{panelRef:ae,panelStyle:oe,headerHandleProps:se,resizeHandles:ce,isFloating:le,guardBackdrop:ue}=_();return(0,te.createPortal)((0,A.jsx)(d,{delayDuration:400,children:(0,A.jsxs)(`div`,{className:`fixed inset-0 z-[65] flex items-stretch justify-center`,children:[(0,A.jsx)(`div`,{className:`absolute inset-0 bg-black/50 backdrop-blur-sm`,onClick:ue(c)}),(0,A.jsxs)(`div`,{ref:ae,className:`relative w-full m-3 rounded-xl glass-card border border-border/30 flex flex-col animate-in fade-in zoom-in-95 duration-200 overflow-hidden`,style:oe,children:[(0,A.jsxs)(`div`,{...se,className:`flex items-center justify-between px-4 py-3 border-b border-border/30${le?` cursor-grab active:cursor-grabbing`:``}`,children:[(0,A.jsxs)(`div`,{className:`flex items-center gap-3 min-w-0`,children:[O&&(0,A.jsxs)(A.Fragment,{children:[(0,A.jsxs)(l,{children:[(0,A.jsx)(ee,{asChild:!0,children:(0,A.jsx)(`div`,{children:(0,A.jsx)(y,{variant:$.variant,children:g($.labelKey)})})}),(0,A.jsx)(m,{children:g($.tooltipKey)})]}),(0,A.jsx)(`code`,{className:`text-xs font-mono text-foreground/80 truncate`,children:O.command}),(0,A.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:T(new Date(O.started_at),{addSuffix:!0,locale:x()})}),O.total_cost_usd!=null&&O.total_cost_usd>0&&(0,A.jsxs)(`span`,{className:`text-[10px] text-muted-foreground`,children:[`$`,O.total_cost_usd.toFixed(4)]}),O.finished_at&&(0,A.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:ne(O.started_at,O.finished_at)})]}),z&&(0,A.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:g(`common:states.loading`)})]}),(0,A.jsxs)(`div`,{className:`flex items-center gap-1 shrink-0`,children:[F.length>0&&(0,A.jsx)(`div`,{className:`mr-3`,children:(0,A.jsx)(n,{phases:L,phaseDefinitions:F})}),ie&&(0,A.jsxs)(S,{variant:`ghost`,size:`sm`,onClick:()=>W(!0),disabled:G,className:`h-7 text-destructive hover:text-destructive hover:bg-destructive/10`,children:[G&&(0,A.jsx)(v,{className:`w-3.5 h-3.5 mr-1.5 animate-spin`,"aria-hidden":!0}),g(Q?`dashboard:railControls.stop`:Z===`interactive`?`common:actions.discard`:`common:actions.cancel`)]}),(0,A.jsx)(`button`,{onClick:c,className:`h-7 w-7 flex items-center justify-center rounded-md text-muted-foreground hover:text-foreground hover:bg-surface/50 transition-colors cursor-pointer`,children:(0,A.jsx)(w,{className:`w-4 h-4`})})]})]}),(0,A.jsx)(`div`,{className:`flex-1 overflow-hidden relative`,children:V?(0,A.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,A.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:g(`modal.notFound`)})}):O?.command.startsWith(`loop:`)?(0,A.jsx)(r,{events:N,jobStatus:O.status,isLoading:z,variant:`glass`,projectId:f}):(0,A.jsx)(a,{events:N,isLoading:z,projectId:f})}),!!O?.interactive&&O.status===`running`&&(0,A.jsx)(o,{jobId:e,projectId:f,settleMode:O.interactiveSettleMode,initialAcceptingTurns:O.interactiveAcceptingTurns,kind:O.command.startsWith(`loop:`)?`loop-step`:`job`,variant:`glass`,onFinalized:q})]}),(0,A.jsx)(h,{handles:ce}),U&&(0,A.jsxs)(`div`,{"data-testid":`job-cancel-confirm`,className:`absolute inset-0 z-10 flex items-center justify-center p-4`,children:[(0,A.jsx)(`div`,{className:`absolute inset-0 bg-black/60 backdrop-blur-sm`,onClick:()=>W(!1)}),(0,A.jsxs)(`div`,{className:`relative w-full max-w-sm rounded-xl glass-card border border-border/30 p-5 shadow-xl animate-in fade-in zoom-in-95 duration-150`,children:[(0,A.jsx)(`h3`,{className:`text-base font-semibold text-foreground`,children:g(Q?`modal.stopRunConfirmTitle`:`modal.cancelConfirmTitle`)}),(0,A.jsx)(`p`,{className:`mt-1.5 text-sm text-muted-foreground`,children:g(Q?`modal.stopRunConfirmDescription`:`modal.cancelConfirmDescription`)}),(0,A.jsxs)(`div`,{className:`mt-4 flex justify-end gap-2`,children:[(0,A.jsx)(S,{variant:`ghost`,size:`sm`,onClick:()=>W(!1),children:g(`modal.keepRunning`)}),(0,A.jsx)(S,{variant:`destructive`,size:`sm`,onClick:()=>{W(!1),re()},children:g(Q?`modal.stopRun`:Z===`interactive`?`common:actions.discard`:`modal.cancelJob`)})]})]})]})]})}),document.body)}export{M as JobDetailModal};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as e}from"./chunk-BNv3lrIs.js";import{a as t,i as n,n as r,r as i,t as a}from"./InteractiveJobComposer-zj8SrOAl.js";import{B as o,Bn as s,C as c,Cn as l,Dn as u,En as d,Gn as ee,Ht as f,Kn as p,Sn as te,Tn as m,U as h,Un as g,V as _,Yn as v,_n as y,b,ct as x,en as S,et as C,it as ne,lt as w,nt as T,ot as E,rn as D,tt as O,ut as k,w as A,x as j,yn as M,zn as N}from"./index-89SuhD4Y.js";import{t as P}from"./format-command-Db1viey1.js";var F=e(v(),1),I=w();function L(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 R(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 z={steps:0,actionKey:``,actionArg:``,lastSeenIdx:0};function B(e,t){if(t.type===`reset`)return z;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 V({job:e,events:t,defaultOpen:n=!0,pipelineTotals:r,phases:i,phaseDefinitions:a}){let{t:o}=s(`jobs`),[d,ee]=(0,F.useState)(n),f=(0,F.useMemo)(()=>R(t),[t]),p=e.status===`running`,m=e.status===`completed`,[h,g]=(0,F.useState)(()=>Date.now());(0,F.useEffect)(()=>{if(!p)return;let e=window.setInterval(()=>g(Date.now()),1e3);return()=>window.clearInterval(e)},[p]);let[_,v]=(0,F.useReducer)(B,z),y=(0,F.useRef)(e.id);(0,F.useEffect)(()=>{y.current!==e.id&&(y.current=e.id,v({type:`reset`})),v({type:`consume`,events:t})},[e.id,t]);let[b,x]=(0,F.useState)(!0);(0,F.useEffect)(()=>{if(!p)return;x(!0);let e=window.setTimeout(()=>x(!1),8e3);return()=>window.clearTimeout(e)},[p,e.id]);let C=e.finished_at?L(e.started_at,e.finished_at):p?L(e.started_at,h):`—`,ne=!!e.total_cost_usd_estimated,w=e.total_cost_usd==null?null:`${ne?`~`:``}$${e.total_cost_usd.toFixed(4)}`,E=e.num_turns==null?null:String(e.num_turns),D=e.tokens_in==null?null:(e.tokens_in??0)+(e.tokens_out??0)+(e.tokens_cache_read??0)+(e.tokens_cache_create??0),O=D==null?null:`${(D/1e3).toFixed(1)}k`,k=(0,F.useMemo)(()=>!i||!a?null:a.find(e=>i[e.key]===`running`)?.label??null,[i,a]),A=p&&_.steps===0?`connecting`:_.actionKey||`thinking`,j=c.has(A)&&_.actionArg!==``,M=c.has(A)&&!j?`working`:A,N=j?o(`statusPanel.activity.${M}`,{arg:_.actionArg}):o(`statusPanel.activity.${M}`),P=k??(p&&_.steps===0?o(`statusPanel.activity.starting`):null),V=_.steps>0?o(`statusPanel.steps`,{count:_.steps}):null,G=o(p?`statusPanel.inProgress`:m?`statusPanel.completed`:`statusPanel.failed`),re=p?`border-accent-info/20 bg-accent-info/5`:m?`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`,K=p?S:m?l:te,q=p?`w-4 h-4 text-accent-info shrink-0 animate-spin`:m?`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,I.jsxs)(`div`,{className:T(`mx-4 my-2 rounded-xl border transition-colors duration-500`,re),children:[(0,I.jsxs)(`button`,{type:`button`,onClick:()=>ee(!d),className:`w-full flex items-center gap-3 px-4 py-3`,children:[(0,I.jsx)(K,{className:q,"aria-hidden":`true`}),(0,I.jsx)(`span`,{className:`text-sm font-semibold flex-1 text-left`,children:G}),(0,I.jsxs)(`div`,{className:`flex items-center gap-3 text-[11px] text-muted-foreground`,children:[(0,I.jsx)(`span`,{className:`tabular-nums`,children:C}),p?V&&(0,I.jsx)(`span`,{className:`tabular-nums`,children:V}):(0,I.jsxs)(I.Fragment,{children:[w&&(0,I.jsx)(`span`,{className:`tabular-nums text-yellow-400 aurora-light:text-accent-warning`,children:w}),f.length>0&&(0,I.jsx)(`span`,{children:o(`statusPanel.filesCount`,{count:f.length})})]})]}),(0,I.jsx)(u,{className:T(`w-4 h-4 text-muted-foreground/40 transition-transform duration-150 shrink-0`,d&&`rotate-180`)})]}),d&&(0,I.jsx)(`div`,{className:`px-4 pb-4 space-y-3 border-t border-border/20`,children:p?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`p`,{className:`pt-3 text-[10px] text-muted-foreground/50 uppercase tracking-wider`,children:o(`statusPanel.zoneInProgress`)}),(0,I.jsxs)(`div`,{className:`flex flex-col sm:flex-row gap-3 sm:items-stretch`,children:[(0,I.jsxs)(`div`,{className:`bg-muted/20 rounded-lg px-3 py-2 sm:w-44 shrink-0`,children:[(0,I.jsxs)(`p`,{className:`flex items-center gap-1.5 text-[10px] text-muted-foreground/50 uppercase tracking-wider`,children:[o(`statusPanel.duration`),(0,I.jsx)(`span`,{className:`inline-block w-1.5 h-1.5 rounded-full bg-accent-info animate-pulse`,title:o(`statusPanel.liveTooltip`),"aria-label":o(`statusPanel.liveTooltip`)})]}),(0,I.jsx)(`p`,{className:`text-sm font-semibold tabular-nums mt-0.5 text-accent-info`,children:C})]}),(0,I.jsxs)(`div`,{className:`flex-1 flex items-center gap-2 bg-muted/10 rounded-lg px-3 py-2 min-w-0`,children:[(0,I.jsx)(S,{className:`w-3.5 h-3.5 text-accent-info shrink-0 animate-spin`,"aria-hidden":`true`}),P&&(0,I.jsx)(`span`,{className:`text-[11px] font-medium px-1.5 py-0.5 rounded bg-accent-info/15 text-accent-info shrink-0`,children:P}),(0,I.jsx)(`span`,{className:`text-xs text-muted-foreground truncate flex-1 min-w-0`,children:N}),V&&(0,I.jsxs)(`span`,{className:`text-[11px] text-muted-foreground/60 tabular-nums shrink-0`,children:[`· `,V]})]})]}),b&&(0,I.jsx)(`p`,{className:`text-[11px] text-muted-foreground/40 leading-snug`,children:o(`statusPanel.explainer`)}),(0,I.jsx)(`p`,{className:`pt-1 text-[10px] text-muted-foreground/50 uppercase tracking-wider border-t border-accent-info/10 mt-1`,children:o(`statusPanel.zoneFinalPending`)}),(0,I.jsxs)(`div`,{className:`grid grid-cols-3 gap-2`,children:[(0,I.jsx)(W,{label:o(`statusPanel.cost`),caption:o(`statusPanel.pendingCaption`),tooltip:o(`statusPanel.costTooltip`)}),(0,I.jsx)(W,{label:o(`statusPanel.turns`),caption:o(`statusPanel.pendingCaption`),tooltip:o(`statusPanel.pendingTooltip`)}),(0,I.jsx)(W,{label:o(`statusPanel.tokens`),caption:o(`statusPanel.pendingCaption`),tooltip:o(`statusPanel.pendingTooltip`)})]})]}):(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`p`,{className:`pt-3 text-[10px] text-muted-foreground/50 uppercase tracking-wider`,children:o(`statusPanel.zoneFinal`)}),(0,I.jsxs)(`div`,{className:`grid grid-cols-2 sm:grid-cols-4 gap-2`,children:[(0,I.jsx)(H,{label:o(`statusPanel.duration`),value:C}),(0,I.jsx)(U,{label:o(`statusPanel.cost`),value:w,valueClass:`text-yellow-400 aurora-light:text-accent-warning`,naCaption:o(`statusPanel.notAvailable`)}),(0,I.jsx)(U,{label:o(`statusPanel.turns`),value:E,naCaption:o(`statusPanel.notAvailable`)}),(0,I.jsx)(U,{label:o(`statusPanel.tokens`),value:O,naCaption:o(`statusPanel.notAvailable`)})]}),r&&(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`p`,{className:`text-[10px] text-muted-foreground/50 uppercase tracking-wider mb-1.5`,children:o(`statusPanel.pipelineTotal`,{count:r.jobCount})}),(0,I.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,I.jsx)(H,{label:o(`statusPanel.totalCost`),value:`${r.costEstimated?`~`:``}${r.hasNullCost?`≥`:``}$${r.totalCostUsd.toFixed(4)}`,valueClass:`text-yellow-400 aurora-light:text-accent-warning`}),(0,I.jsx)(H,{label:o(`statusPanel.totalTokens`),value:`${((r.totalTokensIn+r.totalTokensOut+r.totalTokensCacheRead+r.totalTokensCacheCreate)/1e3).toFixed(1)}k`})]}),r.hasNullCost&&(0,I.jsx)(`p`,{"data-testid":`pipeline-partial-hint`,className:`text-[10px] text-muted-foreground/70 mt-1.5`,title:o(`statusPanel.pipelinePartialTooltip`),children:o(`statusPanel.pipelinePartial`,{count:r.nullCostCount??0})})]}),f.length>0&&(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`p`,{className:`text-[10px] text-muted-foreground/50 uppercase tracking-wider mb-1.5`,children:o(`statusPanel.filesModified`)}),(0,I.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:f.map(e=>(0,I.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,I.jsxs)(`div`,{className:`bg-muted/20 rounded-lg px-3 py-2`,children:[(0,I.jsx)(`p`,{className:`text-[10px] text-muted-foreground/50 uppercase tracking-wider`,children:e}),(0,I.jsx)(`p`,{className:T(`text-sm font-semibold tabular-nums mt-0.5`,n),children:t})]})}function U({label:e,value:t,valueClass:n,naCaption:r}){return(0,I.jsxs)(`div`,{className:`bg-muted/20 rounded-lg px-3 py-2`,children:[(0,I.jsx)(`p`,{className:`text-[10px] text-muted-foreground/50 uppercase tracking-wider`,children:e}),(0,I.jsx)(`p`,{className:T(`text-sm font-semibold tabular-nums mt-0.5`,t==null?`text-muted-foreground`:n),children:t??`—`}),t==null&&(0,I.jsx)(`p`,{className:`text-[10px] text-muted-foreground/30 mt-0.5`,children:r})]})}function W({label:e,caption:t,tooltip:n}){return(0,I.jsxs)(`div`,{className:`bg-muted/20 rounded-lg px-3 py-2 ring-1 ring-accent-info/10`,title:n,children:[(0,I.jsxs)(`p`,{className:`flex items-center gap-1 text-[10px] text-muted-foreground/50 uppercase tracking-wider`,children:[e,(0,I.jsx)(M,{className:`w-2.5 h-2.5 text-muted-foreground/30`,"aria-hidden":`true`})]}),(0,I.jsx)(`p`,{className:`text-sm font-semibold tabular-nums mt-0.5 text-muted-foreground/40`,children:`—`}),(0,I.jsx)(`p`,{className:`text-[10px] text-muted-foreground/30 mt-0.5`,children:t})]})}var G=4;function re({tickets:e,onTicketClick:t}){let{t:n}=s(`jobs`),[r,i]=(0,F.useState)(!1);if(e.length===0)return null;let a=e.length>=G&&!r?e.slice(0,1):e,o=e.length-a.length;return(0,I.jsxs)(`div`,{className:`rounded-xl border border-border/40 bg-card/40 px-4 py-3 space-y-1.5`,children:[a.map(e=>(0,I.jsx)(K,{ticket:e,onClick:()=>t(e.id)},e.id)),o>0&&(0,I.jsxs)(`button`,{type:`button`,onClick:()=>i(!0),className:`flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground transition-colors`,children:[n(`ticketHeader.showMore`,{count:o}),(0,I.jsx)(u,{className:`w-3 h-3`})]}),r&&e.length>=G&&(0,I.jsxs)(`button`,{type:`button`,onClick:()=>i(!1),className:`flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground transition-colors`,children:[n(`ticketHeader.showLess`),(0,I.jsx)(m,{className:`w-3 h-3`})]})]})}function K({ticket:e,onClick:t}){let{t:n}=s(`jobs`),r=e.title==null,i=`inline-flex items-center px-1.5 py-0.5 rounded-md text-[11px] font-mono tabular-nums shrink-0`;return r?(0,I.jsx)(`div`,{className:`flex items-center gap-2 min-w-0`,children:(0,I.jsx)(`span`,{className:T(i,`text-muted-foreground bg-muted/20 select-none`),title:n(`ticketHeader.deletedTooltip`),children:n(`ticketHeader.deletedTicket`,{id:e.id})})}):(0,I.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,I.jsxs)(`span`,{className:T(i,`text-accent-primary bg-accent-primary/10 group-hover:bg-accent-primary/20 transition-colors`),children:[`#`,e.id]}),(0,I.jsx)(`span`,{className:`text-lg font-semibold text-foreground truncate group-hover:text-accent-primary transition-colors`,children:e.title})]})}var q={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 J(){let{t:e}=s(`jobs`),{id:c}=p(),{activeProjectId:l,projects:u}=ne(),te=u.find(e=>e.id===l)?.provider,m=ee(),{openTicketDetail:v}=b(),[S,w]=(0,F.useState)(null),[A,M]=(0,F.useState)([]),[L,R]=(0,F.useState)([]),[z,B]=(0,F.useState)({}),[H,U]=(0,F.useState)([]),[W,G]=(0,F.useState)(!0),[K,J]=(0,F.useState)(!1);(0,F.useEffect)(()=>{if(!c)return;let e=new AbortController;w(null),M([]),R([]),B({}),G(!0),J(!1);async function t(){try{let t=await fetch(`${k()}/jobs/${c}`,{signal:e.signal});if(t.status===404){J(!0);return}if(!t.ok)throw Error(`Failed to fetch job`);let n=await t.json();w(n.job),M(n.events)}catch(e){if(e.name===`AbortError`)return;J(!0)}finally{e.signal.aborted||G(!1)}}return t(),()=>e.abort()},[c,l]),(0,F.useEffect)(()=>{if(!S?.pipeline_id){U([]);return}let e=S.pipeline_id;fetch(`${k()}/pipelines/${e}`).then(e=>e.ok?e.json():null).then(e=>{e?.jobs&&U(e.jobs)}).catch(()=>{})},[S?.pipeline_id,S?.status]);let Y=(0,F.useRef)(l);Y.current=l;let ie=(0,F.useRef)(null);ie.current=S?.status??null;let X=(0,F.useRef)([]),Z=(0,F.useRef)(null),ae=(0,F.useCallback)(()=>{Z.current=null;let e=X.current;e.length!==0&&(X.current=[],M(t=>{let n=[...t,...e];return n.length>1e4?n.slice(n.length-8e3):n}))},[]),Q=(0,F.useCallback)(e=>{let t=X.current;t.push(e),t.length>1e4&&(X.current=t.slice(-8e3)),Z.current||=requestAnimationFrame(ae)},[ae]);(0,F.useEffect)(()=>()=>{Z.current&&cancelAnimationFrame(Z.current)},[]);let oe=(0,F.useCallback)(e=>{let t=e;if(!(Y.current&&t.projectId&&t.projectId!==Y.current)){if(t.type===`init`){let e=t.phaseDefinitions??[];R(e);let n={};for(let r of e)n[r.key]=t.phases?.[r.key]??`idle`;B(n)}else if(t.type===`event`&&t.jobId===c)Q({id:Date.now(),job_id:c??``,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===c)Q({id:Date.now(),job_id:c??``,seq:0,event_type:`log`,source:t.source,payload:JSON.stringify({line:t.line}),timestamp:t.timestamp});else if(t.type===`job.finalized`&&t.jobId===c)fetch(`${k()}/jobs/${c}`).then(e=>e.json()).then(e=>w(e.job)).catch(()=>{});else if(t.type===`phase`){let e=t.phase,n=t.state;B(t=>({...t,[e]:n}))}else if(t.type===`queue`){let e=t.jobs?.find(e=>e.id===c);if(e){let t=e.status,n=ie.current;w(e=>e&&{...e,status:t}),(t===`completed`||t===`failed`||t===`canceled`||t===`running`&&n!==`running`)&&fetch(`${k()}/jobs/${c}`).then(e=>e.json()).then(e=>w(e.job)).catch(()=>{})}}}},[c,Q]),{registerHandler:se,unregisterHandler:ce}=x();(0,F.useEffect)(()=>(se(`job-detail-${c}`,oe),()=>ce(`job-detail-${c}`)),[c,oe,se,ce]),(0,F.useEffect)(()=>{if(!c||!S||S.status!==`running`||S.hasTelemetry)return;let e=setInterval(()=>{fetch(`${k()}/jobs/${c}`).then(e=>e.ok?e.json():null).then(e=>{e?.job?.hasTelemetry&&w(e=>e&&{...e,hasTelemetry:!0})}).catch(()=>{})},8e3);return()=>clearInterval(e)},[c,S?.status,S?.hasTelemetry]);async function le(){if(!c)return;let n=await t({projectId:null,jobId:c});n.ok?n.status===`deleted`?(N.success(e(`detail.toast.jobDeleted`)),m(`/jobs`)):N.success(e(`detail.toast.cancelSignalSent`),{description:e(`detail.toast.cancelSignalSentDescription`)}):n.httpStatus===null?N.error(e(`detail.toast.networkError`)):N.error(e(`detail.toast.failed`),{description:n.error})}async function ue(){if(S)try{let t=await fetch(`${k()}/jobs/${S.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-${S.id}-${i}.zip`,document.body.appendChild(a),a.click(),a.remove(),URL.revokeObjectURL(r)}catch(t){N.error(e(`detail.toast.exportFailed`),{description:t.message})}}async function de(){if(S)try{let t=await fetch(`${k()}/spawn`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({command:S.command})}),n=await t.json();if(!t.ok)throw Error(n.error??e(`detail.toast.spawnFailed`));N.success(e(`detail.toast.jobRequeued`)),m(`/jobs/${n.jobId}`)}catch(e){N.error(e.message)}}if(W)return(0,I.jsx)(`div`,{className:`max-w-5xl mx-auto px-4 py-6`,children:(0,I.jsxs)(`div`,{className:`space-y-3`,children:[(0,I.jsx)(`div`,{className:`h-4 w-48 bg-muted/30 rounded animate-pulse`}),(0,I.jsx)(`div`,{className:`h-20 bg-muted/30 rounded-lg animate-pulse`}),(0,I.jsx)(`div`,{className:`h-64 bg-muted/30 rounded-lg animate-pulse`})]})});if(K||!S)return(0,I.jsxs)(`div`,{className:`max-w-5xl mx-auto px-4 py-6 flex flex-col items-center gap-3 mt-12`,children:[(0,I.jsx)(`p`,{className:`text-lg font-semibold`,children:e(`detail.notFound`)}),(0,I.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e(`detail.notFoundDescription`,{id:c})}),(0,I.jsx)(O,{asChild:!0,variant:`outline`,size:`sm`,children:(0,I.jsxs)(g,{to:`/`,children:[(0,I.jsx)(D,{className:`w-3.5 h-3.5 mr-1.5`}),e(`detail.backToDashboard`)]})})]});let $=q[S.status]??q.queued,fe=S.status===`running`,pe=S.status===`completed`||S.status===`failed`,me=!!S.interactive,he=me&&fe,ge=(S.tickets?.length??0)>0,_e=S.command.startsWith(`loop:`),ve=H.length>1?{totalCostUsd:H.reduce((e,t)=>e+(t.total_cost_usd??0),0),hasNullCost:H.some(e=>e.total_cost_usd==null),costEstimated:H.some(e=>!!e.total_cost_usd_estimated),nullCostCount:H.filter(e=>e.total_cost_usd==null).length,totalTokensIn:H.reduce((e,t)=>e+(t.tokens_in??0),0),totalTokensOut:H.reduce((e,t)=>e+(t.tokens_out??0),0),totalTokensCacheRead:H.reduce((e,t)=>e+(t.tokens_cache_read??0),0),totalTokensCacheCreate:H.reduce((e,t)=>e+(t.tokens_cache_create??0),0),jobCount:H.length}:null;return(0,I.jsxs)(`div`,{"data-job-detail-surface":!0,className:`flex flex-col h-full max-w-5xl mx-auto w-full`,children:[(0,I.jsxs)(`div`,{className:`px-4 py-4 border-b border-border space-y-3`,children:[(0,I.jsxs)(`div`,{className:`flex items-center gap-1 text-xs text-muted-foreground`,children:[(0,I.jsxs)(g,{to:`/`,className:`hover:text-foreground transition-colors flex items-center gap-1`,children:[(0,I.jsx)(D,{className:`w-3 h-3`}),e(`detail.breadcrumbDashboard`)]}),(0,I.jsx)(d,{className:`w-3 h-3`}),(0,I.jsx)(`span`,{className:`text-foreground font-mono`,children:e(`detail.breadcrumbJob`,{id:c?.slice(0,8)})})]}),ge&&(0,I.jsx)(re,{tickets:S.tickets??[],onTicketClick:v}),(0,I.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,I.jsxs)(`div`,{className:`space-y-1 min-w-0`,children:[(0,I.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,I.jsxs)(o,{children:[(0,I.jsx)(h,{asChild:!0,children:(0,I.jsx)(`div`,{children:(0,I.jsx)(C,{variant:$.variant,children:e($.labelKey)})})}),(0,I.jsx)(_,{children:e($.tooltipKey)})]}),(0,I.jsx)(`code`,{className:T(`font-mono text-foreground/90 truncate`,ge?`text-xs text-muted-foreground`:`text-sm`),children:P(S.command,te)})]}),(0,I.jsxs)(`div`,{className:`flex items-center gap-3 text-xs text-muted-foreground flex-wrap`,children:[(0,I.jsx)(`span`,{children:S.started_at?e(`detail.startedAgo`,{timeAgo:j(new Date(S.started_at),{addSuffix:!0,locale:E()})}):e(`detail.queuedWaiting`)}),S.model&&(0,I.jsx)(`span`,{className:`text-muted-foreground/40`,children:S.model})]})]}),(0,I.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[S.hasTelemetry&&(0,I.jsxs)(o,{children:[(0,I.jsx)(h,{asChild:!0,children:(0,I.jsxs)(O,{variant:`outline`,size:`sm`,className:`h-7`,onClick:ue,"aria-label":e(`detail.exportDiagnosticAria`),children:[(0,I.jsx)(y,{className:`w-3.5 h-3.5 mr-1.5`}),e(`detail.exportDiagnostic`)]})}),(0,I.jsx)(_,{children:e(`detail.exportDiagnosticTooltip`)})]}),pe&&(0,I.jsxs)(o,{children:[(0,I.jsx)(h,{asChild:!0,children:(0,I.jsxs)(O,{variant:`outline`,size:`sm`,onClick:de,className:`h-7`,children:[(0,I.jsx)(f,{className:`w-3.5 h-3.5 mr-1.5`}),e(`detail.reExecute`)]})}),(0,I.jsx)(_,{children:e(`detail.reExecuteTooltip`)})]}),fe&&(0,I.jsxs)(o,{children:[(0,I.jsx)(h,{asChild:!0,children:(0,I.jsx)(O,{variant:`outline`,size:`sm`,onClick:le,className:`h-7 border-destructive/30 text-destructive hover:bg-destructive/10`,children:e(me?`detail.cancelInteractive`:`detail.cancelJob`)})}),(0,I.jsx)(_,{children:e(`detail.cancelJobTooltip`)})]})]})]}),(0,I.jsx)(n,{phases:z,phaseDefinitions:L})]}),(S.status===`running`||S.status===`completed`||S.status===`failed`)&&(0,I.jsx)(V,{job:S,events:A,defaultOpen:S.status===`completed`||S.status===`running`,pipelineTotals:ve??void 0,phases:z,phaseDefinitions:L}),(0,I.jsx)(`div`,{className:`flex-1 overflow-hidden relative`,children:_e?(0,I.jsx)(r,{events:A,jobStatus:S.status,variant:`page`}):(0,I.jsx)(i,{events:A})}),he&&(0,I.jsx)(a,{jobId:S.id,settleMode:S.interactiveSettleMode,initialAcceptingTurns:S.interactiveAcceptingTurns,kind:S.command.startsWith(`loop:`)?`loop-step`:`job`,variant:`page`})]})}export{J as default};
|