specrails-desktop 2.26.2 → 2.27.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-BlkNVXCv.js} +1 -1
- package/client/dist/assets/AgentBrowserCapture-76Ri2QR1.js +1 -0
- package/client/dist/assets/AgentIntegrationsModal-D9hVgaBR.js +1 -0
- package/client/dist/assets/{AgentModeCodePane-Ci39DcOo.js → AgentModeCodePane-BUR_QxqR.js} +2 -2
- package/client/dist/assets/AgentModeJobsPane-CnRXelns.js +1 -0
- package/client/dist/assets/AgentsPage-DEt9vpzh.js +86 -0
- package/client/dist/assets/{AnalyticsPage-Da21wWWw.js → AnalyticsPage-C_eT3I3i.js} +1 -1
- package/client/dist/assets/{BarChart-BiLTq3uC.js → BarChart-DuzYxiJ6.js} +1 -1
- package/client/dist/assets/CodePage-72-FLBNw.js +2 -0
- package/client/dist/assets/{DesktopAnalyticsPage-COkzgMmd.js → DesktopAnalyticsPage-BSeBkF2n.js} +1 -1
- package/client/dist/assets/{DocsDialog-PZHMN18B.js → DocsDialog-CGzqDyN3.js} +2 -2
- package/client/dist/assets/DocsPage-BB3VGFM9.js +11 -0
- package/client/dist/assets/{ExportDropdown-DDhJH-Jr.js → ExportDropdown-IehskH-7.js} +1 -1
- package/client/dist/assets/IntegrationsPage-X8bLyuDk.js +3 -0
- package/client/dist/assets/InteractiveJobComposer-D1HUALME.js +19 -0
- package/client/dist/assets/JobDetailModal-CMg6aKSO.js +1 -0
- package/client/dist/assets/JobDetailPage-Bg01rzeu.js +1 -0
- package/client/dist/assets/JobsPage-Cwkm9yYc.js +1 -0
- package/client/dist/assets/{LoopBuilderPage-DsLLrtHa.js → LoopBuilderPage-4uPNN8Xn.js} +2 -2
- package/client/dist/assets/{LoopPreviewModal-C-fDEgnu.js → LoopPreviewModal-BNUQ9iL8.js} +1 -1
- package/client/dist/assets/LoopsPage-DLXESZxq.js +1 -0
- package/client/dist/assets/ProjectSettingsDialog-DP6hAug-.js +1 -0
- package/client/dist/assets/{TemplatePreviewModal-DcHFbLA8.js → TemplatePreviewModal-C6mndL8D.js} +1 -1
- package/client/dist/assets/{agent-Bwkyg2oX2.js → agent-B0Rg_eLw2.js} +1 -1
- package/client/dist/assets/{agent-DJ0EBUuP.js → agent-B8f79myL.js} +1 -1
- package/client/dist/assets/{agent-Bph_-xt7.js → agent-BCH7a3z-.js} +1 -1
- package/client/dist/assets/{agent-BI6vr-To.js → agent-BELAd4RF.js} +1 -1
- package/client/dist/assets/{agent-Cqs14QMr2.js → agent-BrCnHlvX2.js} +1 -1
- package/client/dist/assets/{agent-BUGXI3Ok2.js → agent-CrcIj6WE2.js} +1 -1
- package/client/dist/assets/{agent-CLCyDaZh.js → agent-CtwLUmjl.js} +1 -1
- package/client/dist/assets/{agent-Bvy2Csyd.js → agent-xG4qLg4R.js} +1 -1
- package/client/dist/assets/{brain-BBNUUrUI.js → brain-Dia32foa.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-BawQCyrV.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/{dist-js-DdP_Gl3p.js → dist-js-DN7Pxudf.js} +1 -1
- package/client/dist/assets/{dist-js-BxjTIvdT.js → dist-js-D_4k5prK.js} +1 -1
- package/client/dist/assets/index-BbVOi-dY.js +158 -0
- package/client/dist/assets/{index-C695aPdV.css → index-o3Q2Lii5.css} +1 -1
- package/client/dist/assets/{lib-BviHZ_gK.js → lib-BxSZPd0W.js} +1 -1
- package/client/dist/assets/settings-BFv6UbKV.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-4u055Eea.js} +1 -1
- package/client/dist/assets/{value-CIr5hDMt.js → value-C3Qe3VXm.js} +1 -1
- package/client/dist/index.html +5 -5
- package/package.json +1 -1
- package/server/dist/agent-operator-prompt.js +10 -1
- package/server/dist/db.js +51 -2
- package/server/dist/dev-ports.js +35 -0
- package/server/dist/index.js +2 -6
- 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 +66 -1
- package/server/dist/path-resolver.js +74 -15
- package/server/dist/project-env.js +30 -0
- package/server/dist/project-registry.js +4 -2
- package/server/dist/project-router-jobs.js +76 -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/transient-children.js +126 -8
- 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/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/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-Dw1N2-ci.js +0 -156
- 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-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-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-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-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-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-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-DL-bPy9E.js → attachments-jVdKzAXn.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-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-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-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-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-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/{format-command-CuWuRvka.js → format-command-Db1viey1.js} +0 -0
- /package/client/dist/assets/{integrations-BNuauK3o.js → integrations-BQNkrfr7.js} +0 -0
- /package/client/dist/assets/{integrations-Cl_wD5AI.js → integrations-BdN2f6bP.js} +0 -0
- /package/client/dist/assets/{integrations-CHy8tnpV.js → integrations-BrIUJmVf.js} +0 -0
- /package/client/dist/assets/{integrations-Cy8nZ_dv2.js → integrations-Cyp7cSYv2.js} +0 -0
- /package/client/dist/assets/{integrations-4KZnYECp.js → integrations-DDR3OHdq.js} +0 -0
- /package/client/dist/assets/{integrations-7W266oqF2.js → integrations-DVxi8b0j2.js} +0 -0
- /package/client/dist/assets/{integrations-zMqY4VU12.js → integrations-RuNEX3La2.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-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-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-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-N1nzp8oL.js → mcp-zSJ2TsJj.js} +0 -0
- /package/client/dist/assets/{nav-EI_OhEAo.js → nav-BFCUtHUQ2.js} +0 -0
- /package/client/dist/assets/{nav-CGy4yx3C.js → nav-BouzorQ5.js} +0 -0
- /package/client/dist/assets/{nav-40HzpIFb.js → nav-Bpr-K0tD.js} +0 -0
- /package/client/dist/assets/{nav-B6PkGfTk2.js → nav-CpFrRDXd2.js} +0 -0
- /package/client/dist/assets/{nav-CXEDcRdv2.js → nav-Dkv4Vlr_2.js} +0 -0
- /package/client/dist/assets/{nav-8yPhBn00.js → nav-GG6azCbh.js} +0 -0
- /package/client/dist/assets/{nav-BHqMLrS72.js → nav-prHkMqcr.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-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/{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-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-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{$ as n,Cn as r,Gn as i,Jt as a,Kn as o,Kt as s,M as c,Q as l,Rn as u,Tn as d,Un as f,Ut as p,Vt as m,Wt as h,Xt as g,_,_n as v,an as y,b,bn as x,ht as S,it as C,j as w,on as T,ot as E,qn as D,qt as O,sn as k,wn as A,xt as j,yn as M,zn as N}from"./index-BbVOi-dY.js";var ee=v(`file`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}]]),P=v(`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`}]]),F=e(D(),1),I=e(o(),1);function L(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 R(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 te(e,t){if(e===void 0)throw Error(`Unexpected undefined${t?`: ${t}`:``}`);return e}var ne=(e,t)=>Math.abs(e-t)<1.01,re=(e,t,n)=>{let r;return function(...i){e.clearTimeout(r),r=e.setTimeout(()=>t.apply(this,i),n)}},z,ie=()=>{if(z!==void 0)return z;if(typeof navigator>`u`)return z=!1;if(/iP(hone|od|ad)/.test(navigator.userAgent))return z=!0;let e=navigator.maxTouchPoints;return z=navigator.platform===`MacIntel`&&e!==void 0&&e>0},B=e=>{let{offsetWidth:t,offsetHeight:n}=e;return{width:t,height:n}},V=e=>e,H=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},ae=(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(B(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(B(n))};e.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(r):r()});return a.observe(n,{box:`border-box`}),()=>{a.unobserve(n)}},U={passive:!0},W=typeof window>`u`?!0:`onscrollend`in window,G=(e,t,n)=>{let r=e.scrollElement;if(!r)return;let i=e.targetWindow;if(!i)return;let a=e.options.useScrollendEvent&&W,o=0,s=a?null:re(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,U),a&&r.addEventListener(`scrollend`,u,U),()=>{r.removeEventListener(`scroll`,l),a&&r.removeEventListener(`scrollend`,u)}},oe=(e,t)=>G(e,t,t=>{let{horizontal:n,isRtl:r}=e.options;return n?t.scrollLeft*(r&&-1||1):t.scrollTop}),K=(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`]},q=(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})},se=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:V,rangeExtractor:H,onChange:()=>{},measureElement:K,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=R(()=>(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,!(!ie()||this.targetWindow==null)&&(this._iosJustTouchEnded=!0,this._iosTouchEndTimerId=this.targetWindow.setTimeout(()=>{this._iosJustTouchEnded=!1,this._iosTouchEndTimerId=null,this._flushIosDeferredIfReady()},150))};e.addEventListener(`touchstart`,t,U),e.addEventListener(`touchend`,n,U),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=R(()=>[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=R(()=>[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=L(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=R(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(e,t,n,r)=>this.range=e.length>0&&t>0?ce({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=R(()=>{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))&&(ie()&&(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=R(()=>[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 te(t[J(0,t.length-1,r?e=>n[e*2]:e=>te(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&&ne(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()}},J=(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 ce({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=J(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 le=typeof document<`u`?F.useLayoutEffect:F.useEffect;function ue({useFlushSync:e=!0,...t}){let n=F.useReducer(e=>e+1,0)[1],r={...t,onChange:(r,i)=>{var a;e&&i?(0,I.flushSync)(n):n(),(a=t.onChange)==null||a.call(t,r,i)}},[i]=F.useState(()=>new se(r));return i.setOptions(r),le(()=>i._didMount(),[]),le(()=>i._willUpdate()),i}function de(e){return ue({observeElementRect:ae,observeElementOffset:oe,scrollToFn:q,...e})}var Y=A(),X=e=>`specrails-desktop:code-tree-filter:${e}`,fe=e=>`specrails-desktop:code-tree-collapsed:${e}`;function pe(e){return e.split(`/`).length-1}function me(e){let t=e.lastIndexOf(`/`);return t>=0?e.slice(t+1):e}function he(e){return e?e.length>10?e.slice(0,10):e:null}function ge(e){return e===`created`?`added`:e===`modified`?`changed`:e===`deleted`?`deleted`:null}function _e(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 ve({onOpenFile:e,selectedPath:t,filterJobId:n,filterTicketId:i}){let{t:a}=N(`code`),{activeProjectId:o}=M(),{openTicketDetail:s}=b(),{registerHandler:c,unregisterHandler:l}=r(),[u,f]=(0,F.useState)(()=>{if(!o)return`touched-by-ai`;try{let e=localStorage.getItem(X(o));if(e===`all`||e===`touched-by-ai`)return e}catch{}return`touched-by-ai`});(0,F.useEffect)(()=>{if(o)try{localStorage.setItem(X(o),u)}catch{}},[u,o]);let[g,_]=(0,F.useState)(()=>{if(!o)return new Set;try{let e=localStorage.getItem(fe(o));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,F.useEffect)(()=>{if(o)try{localStorage.setItem(fe(o),JSON.stringify([...g]))}catch{}},[g,o]);let v=(0,F.useCallback)(e=>{_(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),y=(0,F.useCallback)(()=>{_(new Set)},[]),{data:S,refresh:w,isFirstLoad:E}=x({namespace:`code-tree:${u}:${u===`touched-by-ai`?`${n??`all-jobs`}:${i??`all-specs`}`:`all`}`,projectId:o,initialValue:[],fetcher:(0,F.useCallback)(async()=>{let e=[],t=null;for(let r=0;r<100;r+=1){let r=new URLSearchParams({withProvenance:`1`,filter:u});u===`touched-by-ai`&&n&&r.set(`jobId`,n),u===`touched-by-ai`&&typeof i==`number`&&r.set(`ticketId`,String(i)),t&&r.set(`cursor`,t);let a=await fetch(`${d()}/code/tree?${r.toString()}`);if(!a.ok)break;let o=await a.json().catch(()=>({}));if(Array.isArray(o.entries)&&e.push(...o.entries),!o.nextCursor)break;t=o.nextCursor}return e},[u,n,i])}),D=(0,F.useRef)(o);(0,F.useEffect)(()=>{D.current=o},[o]),(0,F.useEffect)(()=>{if(!o)return;let e=`code-tree-${o}`;return c(e,e=>{let t=e;t.projectId===D.current&&t.type===`file.provenance_updated`&&w()}),()=>l(e)},[o,c,l,w]);let O=(0,F.useRef)(null),A=(0,F.useMemo)(()=>(S??[]).filter(e=>!_e(e.path,g)),[S,g]),j=(0,F.useCallback)(()=>{_(new Set((S??[]).filter(e=>e.kind===`dir`).map(e=>e.path)))},[S]),P=de({count:A.length,getScrollElement:()=>O.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()=>{}}}),I=A.length===0,L=(0,F.useMemo)(()=>(S??[]).filter(e=>e.kind===`file`).length,[S]);return(0,Y.jsxs)(`div`,{className:`flex flex-col h-full`,"data-testid":`file-tree`,children:[(0,Y.jsxs)(`div`,{className:`px-2 py-2 border-b border-border text-xs space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,Y.jsx)(`button`,{type:`button`,onClick:()=>f(`touched-by-ai`),className:C(`px-2 py-1 rounded-md transition-colors`,u===`touched-by-ai`?`bg-accent-primary/20 text-accent-primary`:`text-muted-foreground hover:text-foreground hover:bg-muted/50`),"aria-pressed":u===`touched-by-ai`,children:a(n?`tree.jobFiles`:i?`tree.specFiles`:`tree.touchedByAi`)}),(0,Y.jsx)(`button`,{type:`button`,onClick:()=>f(`all`),className:C(`px-2 py-1 rounded-md transition-colors`,u===`all`?`bg-accent-primary/20 text-accent-primary`:`text-muted-foreground hover:text-foreground hover:bg-muted/50`),"aria-pressed":u===`all`,children:a(`tree.allFiles`)}),(0,Y.jsx)(`div`,{className:`flex-1`}),(0,Y.jsx)(`button`,{type:`button`,onClick:j,title:a(`tree.collapseAll`),className:`px-1.5 py-1 rounded-md text-muted-foreground hover:text-foreground hover:bg-muted/50`,"aria-label":a(`tree.collapseAll`),children:(0,Y.jsx)(T,{className:`w-3.5 h-3.5`})}),(0,Y.jsx)(`button`,{type:`button`,onClick:y,title:a(`tree.expandAll`),className:`px-1.5 py-1 rounded-md text-muted-foreground hover:text-foreground hover:bg-muted/50`,"aria-label":a(`tree.expandAll`),children:(0,Y.jsx)(k,{className:`w-3.5 h-3.5`})})]}),u===`touched-by-ai`&&L>0&&(0,Y.jsx)(`div`,{className:`flex items-center justify-between gap-2 text-[11px] text-muted-foreground`,children:(0,Y.jsx)(`span`,{children:a(`tree.touchedCount`,{count:L})})})]}),I&&E?(0,Y.jsx)(`div`,{className:`flex-1 flex items-center justify-center px-4 text-center`,"data-testid":`file-tree-loading`,children:(0,Y.jsx)(`p`,{className:`text-xs text-muted-foreground animate-pulse`,children:a(`tree.loadingFiles`)})}):I&&u===`touched-by-ai`?(0,Y.jsxs)(`div`,{className:`flex-1 flex flex-col items-center justify-center px-4 text-center gap-3`,children:[(0,Y.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:a(`tree.emptyTouched`)}),(0,Y.jsx)(`button`,{type:`button`,onClick:()=>f(`all`),className:`text-xs px-3 py-1.5 rounded-md bg-accent-primary/20 text-accent-primary hover:bg-accent-primary/30`,children:a(`tree.showAllFiles`)})]}):I?(0,Y.jsx)(`div`,{className:`flex-1 flex items-center justify-center text-xs text-muted-foreground px-4 text-center`,children:a(`tree.noFiles`)}):(0,Y.jsx)(`div`,{ref:O,className:`flex-1 overflow-auto`,"data-testid":`file-tree-scroller`,children:(0,Y.jsx)(`div`,{style:{height:P.getTotalSize(),position:`relative`,width:`100%`},children:P.getVirtualItems().map(n=>{let r=A[n.index],i=pe(r.path)*12,o=r.kind===`file`&&r.path===t,c=r.provenance?.createdByTicketId,l=r.provenance?.modifiedByTicketIds??[],u=r.provenance?.latest??null,d=he(u?.jobId),f=ge(u?.kind),_=r.kind===`dir`,y=_&&g.has(r.path),b=r.provenance?.touchedFileCount??0;return(0,Y.jsxs)(`div`,{style:{position:`absolute`,top:0,left:0,transform:`translateY(${n.start}px)`,height:n.size,width:`100%`},className:C(`flex items-center gap-2 px-2 text-xs cursor-pointer hover:bg-muted/50`,o&&`bg-muted text-foreground`),onClick:()=>{_?v(r.path):e(r.path)},role:`button`,tabIndex:0,"aria-expanded":_?!y:void 0,"data-testid":`file-tree-row-${r.path}`,children:[(0,Y.jsxs)(`span`,{style:{paddingLeft:i},className:`flex items-center gap-1 min-w-0 flex-1`,children:[_?(0,Y.jsxs)(Y.Fragment,{children:[y?(0,Y.jsx)(T,{className:`w-3 h-3 text-muted-foreground flex-shrink-0`}):(0,Y.jsx)(k,{className:`w-3 h-3 text-muted-foreground flex-shrink-0`}),y?(0,Y.jsx)(p,{className:`w-3.5 h-3.5 text-accent-info flex-shrink-0`}):(0,Y.jsx)(h,{className:`w-3.5 h-3.5 text-accent-info flex-shrink-0`})]}):(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`span`,{className:`w-3 flex-shrink-0`}),(0,Y.jsx)(ee,{className:`w-3.5 h-3.5 text-muted-foreground flex-shrink-0`})]}),(0,Y.jsx)(`span`,{className:`truncate ml-0.5`,children:me(r.path)})]}),(0,Y.jsxs)(`span`,{className:`flex items-center gap-1 flex-shrink-0`,children:[_&&b>0&&(0,Y.jsx)(`span`,{className:`text-[10px] px-1.5 py-0.5 rounded bg-muted/60 text-muted-foreground`,title:a(`tree.folderTouched`,{count:b}),children:b}),!_&&f&&(0,Y.jsx)(`span`,{className:C(`text-[10px] px-1.5 py-0.5 rounded`,u?.kind===`created`&&`bg-accent-success/15 text-accent-success`,u?.kind===`modified`&&`bg-accent-info/15 text-accent-info`,u?.kind===`deleted`&&`bg-destructive/15 text-destructive`),title:u?.kind===`created`?a(`tree.latestTitleCreated`):u?.kind===`deleted`?a(`tree.latestTitleDeleted`):a(`tree.latestTitleModified`),children:a(`action.${f}`)}),!_&&d&&(0,Y.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:a(`tree.jobTitle`,{jobId:u?.jobId??``}),children:[(0,Y.jsx)(m,{className:`h-3 w-3`}),d]}),!_&&typeof c==`number`&&(0,Y.jsxs)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),s(c)},className:`text-[10px] px-1.5 py-0.5 rounded bg-accent-success/20 text-accent-success`,"data-testid":`provenance-chip-created-${c}`,title:a(`tree.createdBySpec`,{id:c}),children:[`#`,c]}),!_&&l.slice(0,2).map(e=>(0,Y.jsxs)(`button`,{type:`button`,onClick:t=>{t.stopPropagation(),s(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:a(`tree.modifiedBySpec`,{id:e}),children:[`#`,e]},e))]})]},r.path)})})})]})}function ye(e){return new Worker(`/assets/editor.worker-Bd9IXS8d.js`,{name:e?.name})}function be(e){return new Worker(`/assets/json.worker-DzV-CpCQ.js`,{name:e?.name})}function xe(e){return new Worker(`/assets/css.worker-Wv5dxAWO.js`,{name:e?.name})}function Se(e){return new Worker(`/assets/html.worker-CQP8QQsS.js`,{name:e?.name})}function Ce(e){return new Worker(`/assets/ts.worker-METxwbDZ.js`,{name:e?.name})}var we=!1;function Te(e){let t=e.trim().match(/^hsl\(\s*([-\d.]+)[\s,]+([\d.]+)%[\s,]+([\d.]+)%\s*\)$/i);return t?[parseFloat(t[1]),parseFloat(t[2]),parseFloat(t[3])]:null}function Z(e,t=`#1e1e1e`){if(e.startsWith(`#`))return e;let n=Te(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 Ee(e){return`specrails-${e}`}function De(e,t){let n=Ee(t.id),r=t.xterm,i=Z(r.background),a=Z(r.foreground),o=Z(r.brightBlack),s=Z(r.magenta),c=Z(r.yellow),l=Z(r.cyan),u=Z(r.blue),d=Z(r.green),f=Z(r.brightBlack),p=Z(r.brightCyan),m=Z(r.red),h=Z(r.selectionBackground);return e.editor.defineTheme(n,{base:t.scheme===`light`?`vs`:`vs-dark`,inherit:!0,rules:[{token:``,foreground:a.slice(1)},{token:`comment`,foreground:f.slice(1),fontStyle:`italic`},{token:`keyword`,foreground:s.slice(1)},{token:`string`,foreground:c.slice(1)},{token:`number`,foreground:l.slice(1)},{token:`constant`,foreground:p.slice(1)},{token:`constant.numeric`,foreground:l.slice(1)},{token:`type`,foreground:d.slice(1)},{token:`type.identifier`,foreground:d.slice(1)},{token:`identifier`,foreground:a.slice(1)},{token:`function`,foreground:u.slice(1)},{token:`tag`,foreground:m.slice(1)},{token:`attribute.name`,foreground:p.slice(1)},{token:`attribute.value`,foreground:c.slice(1)},{token:`delimiter`,foreground:o.slice(1)},{token:`operator`,foreground:o.slice(1)}],colors:{"editor.background":i,"editor.foreground":a,"editorLineNumber.foreground":o,"editorLineNumber.activeForeground":a,"editorCursor.foreground":Z(r.cursor),"editor.selectionBackground":h,"editor.inactiveSelectionBackground":h,"editor.lineHighlightBackground":Z(r.black),"editor.lineHighlightBorder":Z(r.black),"editorGutter.background":i,"editorWhitespace.foreground":o,"editorIndentGuide.background1":Z(r.black),"editorIndentGuide.activeBackground1":o,"scrollbarSlider.background":`${o}55`,"scrollbarSlider.hoverBackground":`${o}88`,"scrollbarSlider.activeBackground":`${o}bb`,"minimap.background":i}}),n}function Oe(){we||=(self.MonacoEnvironment={getWorker(e,t){switch(t){case`json`:return new be;case`css`:case`scss`:case`less`:return new xe;case`html`:case`handlebars`:case`razor`:return new Se;case`typescript`:case`javascript`:return new Ce;default:return new ye}}},!0)}function ke({content:e,language:n,readOnly:r,onChange:i}){let{t:a}=N(`code`),o=_(),s=(0,F.useRef)(null),c=(0,F.useRef)(null),l=(0,F.useRef)(null),[u,d]=(0,F.useState)(!1),f=(0,F.useRef)(e),p=(0,F.useRef)(n),m=(0,F.useRef)(o),h=(0,F.useRef)(r),g=(0,F.useRef)(i);return(0,F.useEffect)(()=>{f.current=e},[e]),(0,F.useEffect)(()=>{p.current=n},[n]),(0,F.useEffect)(()=>{m.current=o},[o]),(0,F.useEffect)(()=>{h.current=r},[r]),(0,F.useEffect)(()=>{g.current=i},[i]),(0,F.useEffect)(()=>{let e=!1;return Oe(),t(()=>import(`./editor.main-C9J2ikJK.js`).then(t=>{if(e||!s.current)return;l.current=t;let n=De(t,m.current),r=t.editor.create(s.current,{value:f.current,language:p.current,readOnly:h.current,theme:n,minimap:{enabled:!1},lineNumbers:`on`,scrollBeyondLastLine:!1,automaticLayout:!0,fontSize:13});r.onDidChangeModelContent(()=>{g.current?.(r.getValue())}),c.current=r}),__vite__mapDeps([0,1,2,3,4,5,6])).catch(()=>{e||d(!0)}),()=>{e=!0,c.current?.dispose?.(),c.current=null}},[]),(0,F.useEffect)(()=>{let t=c.current;t&&t.getValue?.()!==e&&t.setValue?.(e)},[e]),(0,F.useEffect)(()=>{c.current?.updateOptions?.({readOnly:r})},[r]),(0,F.useEffect)(()=>{let e=l.current,t=c.current;if(!e||!t)return;let r=t.getModel?.();r&&e.editor.setModelLanguage(r,n)},[n]),(0,F.useEffect)(()=>{let e=l.current;if(!e)return;let t=De(e,o);e.editor.setTheme(t)},[o]),u?(0,Y.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,Y.jsx)(`span`,{children:a(`monaco.loadFailed`)}),(0,Y.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:a(`monaco.reload`)})]}):(0,Y.jsx)(`div`,{ref:s,className:`w-full h-full`,"data-testid":`monaco-host`})}var Ae=(0,F.lazy)(async()=>({default:ke}));function je({content:e,language:t,readOnly:n=!0,onChange:r}){let{t:i}=N(`code`);return(0,Y.jsx)(F.Suspense,{fallback:(0,Y.jsx)(`div`,{className:`w-full h-full flex items-center justify-center text-sm text-muted-foreground animate-pulse`,children:i(`monaco.loadingEditor`)}),children:(0,Y.jsx)(Ae,{content:e,language:t,readOnly:n,onChange:r})})}function Me(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 Ne({path:e,summary:t,stale:n,regenerating:r,generateDisabledReason:i,onCollapse:a}){let{t:o,i18n:s}=N(`code`),{openTicketDetail:c}=b();if(!t)return(0,Y.jsx)(`div`,{className:`border-b border-border px-4 py-3 bg-surface`,"data-testid":`summary-header-empty`,children:(0,Y.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,Y.jsxs)(`div`,{className:`flex flex-col gap-0.5 min-w-0`,children:[(0,Y.jsx)(`span`,{className:`text-xs text-muted-foreground truncate`,children:e}),(0,Y.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:i?o(`summary.unavailable`,{reason:i}):o(`summary.empty`)})]}),a&&(0,Y.jsxs)(`button`,{type:`button`,onClick:a,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,Y.jsx)(y,{className:`h-3.5 w-3.5`}),o(`summary.hide`)]})]})});let l=Me(t.generatedAt,s.language),u=t.triggeredBy?.ticketId,d=t.triggeredBy?.modifiedTicketIds??[];return(0,Y.jsx)(`div`,{className:`border-b border-border px-4 py-3 bg-surface`,"data-testid":`summary-header`,children:(0,Y.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,Y.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,Y.jsx)(`span`,{className:`text-xs text-muted-foreground truncate`,children:e}),n&&(0,Y.jsx)(`span`,{className:C(`text-[10px] px-1.5 py-0.5 rounded bg-accent-warning/20 text-accent-warning font-medium`),"data-testid":`summary-stale-badge`,children:o(`summary.stale`)}),r&&(0,Y.jsx)(`span`,{className:`w-1.5 h-1.5 rounded-full bg-accent-primary animate-pulse`,"aria-hidden":!0})]}),(0,Y.jsx)(`p`,{className:`text-sm text-foreground mt-1`,children:t.summary}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 mt-2 flex-wrap`,children:[typeof u==`number`&&(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>c(u),className:`text-[10px] px-1.5 py-0.5 rounded bg-accent-success/20 text-accent-success`,children:[`#`,u]}),d.map(e=>(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>c(e),className:`text-[10px] px-1.5 py-0.5 rounded bg-accent-info/15 text-accent-info`,children:[`#`,e]},e)),l&&(0,Y.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:l})]})]}),a&&(0,Y.jsxs)(`button`,{type:`button`,onClick:a,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,Y.jsx)(y,{className:`h-3.5 w-3.5`}),o(`summary.hide`)]})]})})}function Pe({content:e}){return(0,Y.jsx)(c,{remarkPlugins:[w],children:e})}var Fe={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 Ie(e){return e===`created`?O:e===`deleted`?a:s}function Le({relPath:e,height:t,onOpenTicket:n,onFilterJob:i}){let{t:a}=N(`code`),{activeProjectId:o}=M(),{registerHandler:s,unregisterHandler:c}=r(),[l,f]=(0,F.useState)(null),[p,m]=(0,F.useState)(!1),[h,g]=(0,F.useState)({}),_=(0,F.useRef)(o);(0,F.useEffect)(()=>{_.current=o},[o]);let v=(0,F.useRef)(e);(0,F.useEffect)(()=>{v.current=e},[e]);let y=(0,F.useRef)(0),b=(0,F.useCallback)(async()=>{let t=++y.current;try{let n=await fetch(`${d()}/code/file/story?path=${encodeURIComponent(e)}`);if(t!==y.current)return;if(!n.ok){f([]),m(!0);return}let r=await n.json();if(t!==y.current)return;f(Array.isArray(r.story)?r.story:[]),m(!1)}catch{t===y.current&&(f([]),m(!0))}},[e,o]);(0,F.useEffect)(()=>{f(null),g({}),b()},[b]),(0,F.useEffect)(()=>{if(!o)return;let e=`code-story-${o}`;return s(e,e=>{let t=e;t.projectId===_.current&&t.path===v.current&&(t.type===`file.story_updated`||t.type===`file.provenance_updated`)&&b()}),()=>c(e)},[o,s,c,b]);let x=(0,F.useCallback)(async(t,n)=>{g(e=>({...e,[t.provenanceId]:`busy`}));try{let r=await fetch(`${d()}/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`){g(e=>({...e,[t.provenanceId]:`budget`}));return}if(!r.ok||!i.ok){u.error(a(`story.explainFailed`)),g(e=>{let n={...e};return delete n[t.provenanceId],n});return}await b(),g(e=>{let n={...e};return delete n[t.provenanceId],n})}catch{u.error(a(`story.explainFailed`)),g(e=>{let n={...e};return delete n[t.provenanceId],n})}},[b,e,a]);return(0,Y.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,Y.jsx)(`div`,{className:`h-full overflow-auto`,children:l===null?(0,Y.jsx)(`div`,{className:`text-[11px] text-muted-foreground animate-pulse py-2`,children:a(`story.loading`)}):p?(0,Y.jsx)(`div`,{className:`text-[11px] text-muted-foreground py-2`,"data-testid":`story-failed`,children:a(`story.loadFailed`)}):l.length===0?(0,Y.jsx)(`div`,{className:`text-[11px] text-muted-foreground py-2`,"data-testid":`story-empty`,children:a(`story.empty`)}):(0,Y.jsx)(`ol`,{className:`relative ml-1.5 border-l border-border/60 space-y-3 py-1`,children:l.map(e=>(0,Y.jsx)(Re,{entry:e,state:h[e.provenanceId],onOpenTicket:n,onFilterJob:i,onExplain:t=>{x(e,t)}},e.provenanceId))})})})}function Re({entry:e,state:t,onOpenTicket:n,onFilterJob:r,onExplain:i}){let{t:a}=N(`code`),o=Ie(e.kind),s=e.ticket?.status??null,c=e.ticket?.title?`#${e.ticket.id} · ${e.ticket.title}`:e.ticketId==null?null:a(`story.spec`,{ticketId:e.ticketId}),l=e.ticketId==null?`${e.kind}NoSpec`:e.kind;return(0,Y.jsxs)(`li`,{className:`relative pl-4`,"data-testid":`story-card`,children:[(0,Y.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,Y.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,Y.jsxs)(`header`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Y.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-xs text-muted-foreground`,children:[(0,Y.jsx)(o,{className:`h-3.5 w-3.5 shrink-0`}),a(`story.kindLabel.${e.kind}`)]}),c!=null&&e.ticketId!=null&&(0,Y.jsx)(`button`,{type:`button`,onClick:()=>n(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:a(`story.openSpec`,{ticketId:e.ticketId}),children:c}),c==null&&(0,Y.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,children:a(`story.unknownSpec`)}),s&&(0,Y.jsx)(`span`,{className:`rounded px-1.5 py-0.5 text-[10px] ${Fe[s]??`bg-muted/60 text-muted-foreground`}`,"data-testid":`story-status-pill`,children:s}),(0,Y.jsxs)(`span`,{className:`ml-auto inline-flex items-center gap-2`,children:[e.addedLines!=null&&e.addedLines>0&&(0,Y.jsxs)(`span`,{className:`font-mono text-[10px] text-accent-success`,title:a(`story.linesAdded`),children:[`+`,e.addedLines]}),e.removedLines!=null&&e.removedLines>0&&(0,Y.jsxs)(`span`,{className:`font-mono text-[10px] text-destructive`,title:a(`story.linesRemoved`),children:[`−`,e.removedLines]}),(0,Y.jsx)(`time`,{className:`text-[10px] text-muted-foreground`,dateTime:new Date(e.at).toISOString(),children:new Date(e.at).toLocaleString()})]})]}),(0,Y.jsx)(`div`,{className:`mt-1.5`,children:e.summary?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`p`,{className:`text-sm leading-relaxed text-foreground/90`,"data-testid":`story-contribution`,children:e.summary}),e.summaryModel&&(0,Y.jsx)(`p`,{className:`mt-1 text-[10px] text-muted-foreground/80`,children:a(`story.explainedBy`,{model:e.summaryModel})})]}):(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Y.jsx)(`p`,{className:`text-xs text-muted-foreground`,"data-testid":`story-fallback`,children:a(`story.fallback.${l}`)}),t===`budget`?(0,Y.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,Y.jsx)(`span`,{className:`text-[10px] text-accent-warning`,children:a(`story.budgetReached`)}),(0,Y.jsx)(`button`,{type:`button`,onClick:()=>i(!0),className:`rounded bg-accent-warning/15 px-1.5 py-0.5 text-[10px] text-accent-warning hover:bg-accent-warning/25`,children:a(`story.generateAnyway`)})]}):(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>i(!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,Y.jsx)(S,{className:t===`busy`?`h-3 w-3 animate-pulse`:`h-3 w-3`}),a(t===`busy`?`story.explaining`:`story.explain`)]})]})}),e.jobId&&r&&(0,Y.jsx)(`footer`,{className:`mt-1.5`,children:(0,Y.jsx)(`button`,{type:`button`,onClick:()=>r(e.jobId),className:`font-mono text-[10px] text-muted-foreground hover:text-foreground`,title:a(`history.filterByJob`,{jobId:e.jobId}),children:e.jobId.length>12?e.jobId.slice(0,12):e.jobId})})]})]})}function ze(e,t){return t===`markdown`||t===`md`?!0:/\.(md|mdx|markdown)$/i.test(e)}var Q=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 Q;try{let e=localStorage.getItem(t),n=e?Number(e):NaN;return Number.isFinite(n)&&n>0?n:Q}catch{return Q}}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}=M(),{openTicketDetail:c}=b(),{registerHandler:f,unregisterHandler:p}=r(),m=n({allowMove:!1}),h=(0,F.useRef)(null),[g,_]=(0,F.useState)(null),[v,x]=(0,F.useState)(!0),[S,C]=(0,F.useState)(!1),[w,T]=(0,F.useState)(!1),[E,D]=(0,F.useState)(()=>Xe(s)),[O,A]=(0,F.useState)(()=>Je(s)),[j,ee]=(0,F.useState)(()=>Qe(s)),[P,I]=(0,F.useState)(()=>Ke(s)),L=(0,F.useRef)(s);(0,F.useEffect)(()=>{L.current=s},[s]);let R=(0,F.useRef)(e);(0,F.useEffect)(()=>{R.current=e},[e]),(0,F.useEffect)(()=>{let e=h.current?.clientHeight||window.innerHeight;D(Xe(s)),A(et(Je(s),e)),ee(Qe(s)),I(Ke(s))},[s]);let te=(0,F.useCallback)(e=>{let t=e.clientY,n=O,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,O]),ne=(0,F.useCallback)(()=>{let e=et(Q,h.current?.clientHeight||window.innerHeight);A(e),Ye(s,e)},[s]),re=(0,F.useCallback)(()=>{D(e=>{let t=!e;return Ze(s,t),t})},[s]),z=(0,F.useCallback)(()=>{ee(e=>{let t=!e;return $e(s,t),t})},[s]),ie=(0,F.useCallback)(e=>{I(e),qe(s,e)},[s]);(0,F.useEffect)(()=>{C(!1),T(!1),G(`preview`),K(!1)},[e]);let B=(0,F.useRef)(0),V=(0,F.useCallback)(async()=>{let t=++B.current;x(!0);try{let n=await fetch(`${d()}/code/file?path=${encodeURIComponent(e)}`);if(t!==B.current)return;if(!n.ok){_(null);return}let r=await n.json();if(t!==B.current)return;_(r)}catch{t===B.current&&_(null)}finally{t===B.current&&x(!1)}},[e,s]);(0,F.useEffect)(()=>{V()},[V]),(0,F.useEffect)(()=>{if(!s)return;let e=`code-file-${s}`;return f(e,e=>{let t=e;t.projectId===L.current&&(t.type===`file.summary_updated`&&t.path===R.current?(C(!1),V()):t.type===`file.summary_failed`&&t.path===R.current?(u.error(t.reason??o(`summary.generationFailed`)),C(!1)):t.type===`file.summary_skipped`&&t.path===R.current&&(t.reason&&u(o(`summary.skipped`,{reason:t.reason})),C(!1)))}),()=>p(e)},[s,f,p,V,o]);let H=(0,F.useCallback)(async t=>{C(!0);try{let n=await fetch(`${d()}/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){C(!1);let e=typeof r.skipped==`string`?r.skipped:null;u.error(e?o(`summary.skipped`,{reason:e}):o(`summary.generationFailed`));return}if(r.skipped===`budget`){C(!1),T(!0);return}if(r.skipped){C(!1),u(o(`summary.skipped`,{reason:r.skipped}));return}await V(),C(!1)}catch{C(!1),u.error(o(`summary.generationFailed`))}},[V,e,o]),ae=(0,F.useCallback)(async()=>{let t=g?.absolutePath??e;try{await navigator.clipboard?.writeText(t),u.success(o(`viewer.pathCopied`))}catch{u.error(o(`viewer.copyPathFailed`))}},[g,e,o]),U=(0,F.useMemo)(()=>ze(e,g?.language),[e,g?.language]),[W,G]=(0,F.useState)(`preview`),[oe,K]=(0,F.useState)(!1),[q,se]=(0,F.useState)(``),[J,ce]=(0,F.useState)(!1),le=g?.content!==void 0&&!g.binary&&!g.tooLarge&&g.reason!==`not-found`,ue=(0,F.useCallback)(()=>{se(g?.content??``),G(`raw`),K(!0)},[g]),de=(0,F.useCallback)(async()=>{ce(!0);try{let t=await fetch(`${d()}/code/file`,{method:`PUT`,headers:{"content-type":`application/json`},body:JSON.stringify({path:e,content:q})});if(!t.ok){let e=await t.json().catch(()=>({}));u.error(e.error??o(`viewer.saveFailed`));return}u.success(o(`viewer.saved`)),K(!1),V()}catch{u.error(o(`viewer.saveFailed`))}finally{ce(!1)}},[e,q,o,V]),X=g?.summary??null,fe=!!g?.summaryStale,pe=g?.provenance??[],me=g?.reason===`not-found`,he=me?o(`summary.reason.missing`):g?.binary?o(`summary.reason.binary`):g?.tooLarge?o(`summary.reason.tooLarge`):null;return(0,F.useEffect)(()=>{if(i){if(v&&!g){i(null);return}return i({hasSummary:!!X,regenerating:S,disabledReason:he,onClick:()=>H(!1)}),()=>i(null)}},[g,H,v,i,S,X,he]),(0,F.useEffect)(()=>{if(a){if(v&&!g){a(null);return}return a({onClick:ae}),()=>a(null)}},[ae,g,v,a]),v&&!g?(0,Y.jsx)(`div`,{className:`flex-1 flex items-center justify-center text-sm text-muted-foreground animate-pulse`,children:o(`viewer.loadingFile`)}):(0,Y.jsxs)(`div`,{ref:h,className:`flex flex-col h-full`,"data-testid":`file-viewer`,children:[E?(0,Y.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,Y.jsx)(`span`,{className:`truncate text-xs text-muted-foreground`,children:e}),(0,Y.jsxs)(`button`,{type:`button`,onClick:re,className:`inline-flex items-center gap-1 rounded-md px-2 py-1 text-[11px] text-muted-foreground hover:bg-muted/50 hover:text-foreground`,children:[(0,Y.jsx)(k,{className:`h-3.5 w-3.5`}),o(`viewer.showSummary`)]})]}):(0,Y.jsx)(Ne,{path:e,summary:X,stale:fe,regenerating:S,generateDisabledReason:he,onCollapse:re}),(0,Y.jsxs)(`div`,{className:`px-4 py-1 border-b border-border flex items-center justify-between gap-3`,children:[(0,Y.jsx)(`div`,{className:`flex items-center gap-2 min-w-0`,children:U&&g?.content!==void 0&&!g.binary&&!g.tooLarge&&(0,Y.jsxs)(`div`,{className:`flex items-center gap-1 text-[11px]`,role:`group`,"aria-label":o(`viewer.markdownViewMode`),children:[(0,Y.jsx)(`button`,{type:`button`,onClick:()=>G(`preview`),"aria-pressed":W===`preview`,className:W===`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,Y.jsx)(`button`,{type:`button`,onClick:()=>G(`raw`),"aria-pressed":W===`raw`,className:W===`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,Y.jsxs)(`div`,{className:`flex items-center gap-1 text-[11px] shrink-0`,children:[le&&!oe&&(0,Y.jsx)(`button`,{type:`button`,onClick:ue,className:`px-2 py-1 rounded-md text-muted-foreground hover:text-foreground hover:bg-muted/50`,children:o(`viewer.edit`)}),oe&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`button`,{type:`button`,onClick:()=>K(!1),disabled:J,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,Y.jsx)(`button`,{type:`button`,onClick:de,disabled:J,className:`px-2 py-1 rounded-md bg-accent-primary/20 text-accent-primary hover:bg-accent-primary/30 disabled:opacity-50`,children:o(J?`viewer.saving`:`viewer.save`)})]})]})]}),(0,Y.jsx)(`div`,{className:`flex-1 overflow-hidden`,children:me?(0,Y.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,Y.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,Y.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,Y.jsx)(`div`,{className:`h-full flex items-center justify-center text-sm text-muted-foreground`,children:o(`viewer.noContent`)}):oe?(0,Y.jsx)(je,{content:q,language:g.language??`plaintext`,readOnly:!1,onChange:se}):U&&W===`preview`?(0,Y.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,Y.jsx)(Pe,{content:g.content})}):(0,Y.jsx)(je,{content:g.content,language:g.language??`plaintext`})}),pe.length>0&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`div`,{role:`separator`,"aria-orientation":`horizontal`,"aria-label":o(`history.resize`),onPointerDown:j?void 0:te,onDoubleClick:j?void 0:ne,className:j?`flex h-8 shrink-0 items-center justify-between border-t border-border bg-card/35 px-4`:`flex h-8 shrink-0 cursor-row-resize items-center justify-between border-y border-border/40 bg-card/35 px-4 hover:bg-accent-primary/10`,title:j?void 0:o(`resizer.hint`),"data-testid":`code-history-resizer`,children:[(0,Y.jsx)(`span`,{className:`text-[11px] font-medium uppercase tracking-wider text-muted-foreground`,children:o(P===`story`?`story.title`:`history.title`,{count:pe.length})}),(0,Y.jsxs)(`span`,{className:`flex items-center gap-1`,children:[!j&&(0,Y.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,Y.jsx)(`button`,{type:`button`,onClick:()=>ie(`story`),"aria-pressed":P===`story`,className:P===`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,Y.jsx)(`button`,{type:`button`,onClick:()=>ie(`log`),"aria-pressed":P===`log`,className:P===`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,Y.jsxs)(`button`,{type:`button`,onPointerDown:e=>e.stopPropagation(),onClick:z,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,Y.jsx)(y,{className:`h-3.5 w-3.5`}):(0,Y.jsx)(k,{className:`h-3.5 w-3.5`}),o(j?`history.show`:`history.hide`)]})]})]}),!j&&(P===`story`?(0,Y.jsx)(Le,{relPath:e,height:O,onOpenTicket:c,onFilterJob:t}):(0,Y.jsx)(nt,{rows:pe,onOpenTicket:c,onFilterJob:t,height:O}))]}),w&&(0,Y.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:m.guardBackdrop(()=>T(!1)),children:[(0,Y.jsxs)(`div`,{ref:m.panelRef,onClick:e=>e.stopPropagation(),className:`bg-card border border-border rounded-lg p-4 w-80 flex flex-col gap-3`,style:m.panelStyle,children:[(0,Y.jsx)(`p`,{className:`text-sm text-foreground`,children:o(`viewer.budgetPrompt`)}),(0,Y.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,Y.jsx)(`button`,{type:`button`,onClick:()=>T(!1),className:`text-xs px-3 py-1.5 rounded-md text-muted-foreground hover:text-foreground`,children:o(`common:actions.cancel`)}),(0,Y.jsx)(`button`,{type:`button`,onClick:()=>{T(!1),H(!0)},className:`text-xs px-3 py-1.5 rounded-md bg-accent-primary text-white`,children:o(`common:actions.confirm`)})]})]}),(0,Y.jsx)(l,{handles:m.resizeHandles})]})]})}function nt({rows:e,onOpenTicket:t,onFilterJob:n,height:r}){let{t:i}=N(`code`),[o,c]=(0,F.useState)(null),[l,u]=(0,F.useState)({});if(e.length===0)return null;async function f(e,t){if(o===t){c(null);return}if(c(t),!(!e.jobId||l[t])){u(e=>({...e,[t]:`loading`}));try{let n=new URLSearchParams({jobId:e.jobId,path:e.path}),r=await fetch(`${d()}/code/diff?${n.toString()}`);if(r.status===404){u(e=>({...e,[t]:`missing`}));return}if(!r.ok)throw Error(`diff failed`);let i=await r.json();u(e=>({...e,[t]:{patch:i.patch??``,truncated:i.truncated===!0}}))}catch{u(e=>({...e,[t]:`missing`}))}}}return(0,Y.jsx)(`div`,{className:`shrink-0 border-t border-border bg-card/40 px-4 py-3 overflow-hidden`,style:{height:r},"data-testid":`file-provenance-timeline`,children:(0,Y.jsx)(`div`,{className:`h-full overflow-auto space-y-1`,children:e.map((e,r)=>{let c=e.kind===`created`?O:e.kind===`deleted`?a:s,u=e.jobId?e.jobId.length>12?e.jobId.slice(0,12):e.jobId:i(`history.unknownJob`),d=`${e.jobId??`job`}:${e.path}:${e.at}:${r}`,p=l[d];return(0,Y.jsxs)(`div`,{className:`rounded-md hover:bg-muted/40`,children:[(0,Y.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,Y.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 min-w-0`,children:[(0,Y.jsx)(c,{className:`h-3.5 w-3.5 text-muted-foreground shrink-0`}),(0,Y.jsx)(`span`,{className:`capitalize`,children:i(`kind.${e.kind}`)})]}),(0,Y.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 min-w-0 text-muted-foreground`,children:[(0,Y.jsx)(m,{className:`h-3.5 w-3.5 shrink-0`}),e.jobId&&n?(0,Y.jsx)(`button`,{type:`button`,onClick:()=>n(e.jobId),className:`font-mono truncate hover:text-foreground`,title:i(`history.filterByJob`,{jobId:e.jobId}),children:u}):(0,Y.jsx)(`span`,{className:`font-mono truncate`,title:e.jobId??void 0,children:u}),e.jobId&&(0,Y.jsx)(`button`,{type:`button`,onClick:()=>f(e,d),className:`shrink-0 rounded bg-muted/60 px-1.5 py-0.5 text-[10px] text-muted-foreground hover:bg-muted hover:text-foreground`,children:i(`history.diff`)}),typeof e.ticketId==`number`&&(0,Y.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:i(`history.openSpec`,{ticketId:e.ticketId}),children:i(`history.specChip`,{ticketId:e.ticketId})})]}),(0,Y.jsx)(`time`,{className:`text-[11px] text-muted-foreground`,dateTime:new Date(e.at).toISOString(),children:new Date(e.at).toLocaleString()})]}),o===d&&(0,Y.jsx)(`div`,{className:`px-2 pb-2`,children:p===`loading`?(0,Y.jsx)(`div`,{className:`rounded-md bg-muted/35 px-2 py-2 text-[11px] text-muted-foreground`,children:i(`history.loadingDiff`)}):p===`missing`||!p?(0,Y.jsx)(`div`,{className:`rounded-md bg-muted/35 px-2 py-2 text-[11px] text-muted-foreground`,children:i(`history.diffUnavailable`)}):(0,Y.jsxs)(`pre`,{className:`max-h-72 overflow-auto rounded-md bg-muted/50 px-2 py-2 font-mono text-[11px] leading-relaxed text-foreground/85`,children:[p.patch,p.truncated?`\n${i(`history.diffTruncated`)}`:``]})})]},d)})})})}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:n}={}){let{t:r}=N(`code`),{activeProjectId:a}=M(),[o]=i(),s=f(),c=(0,F.useRef)(null),[l,u]=(0,F.useState)(e?t:o.get(`path`)),d=(0,F.useCallback)(e=>{u(e),n?.(e)},[n]),[p,m]=(0,F.useState)(null),[h,g]=(0,F.useState)(null),[_,v]=(0,F.useState)(()=>st(a)),[y,b]=(0,F.useState)(null),[x,S]=(0,F.useState)(null),C=e?y:o.get(`jobId`),w=(0,F.useMemo)(()=>{if(e)return x;let t=o.get(`ticketId`);if(!t)return null;let n=Number(t);return Number.isInteger(n)&&n>0?n:null},[e,x,o]),[T,E]=(0,F.useState)(w==null?``:String(w));(0,F.useEffect)(()=>{if(e)return;let t=o.get(`path`);t!==l&&u(t)},[o,e]),(0,F.useEffect)(()=>{E(w==null?``:String(w))},[w]),(0,F.useEffect)(()=>{let e=c.current?.clientWidth||window.innerWidth;v($(st(a),e))},[a]),(0,F.useEffect)(()=>{let e=c.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 D=(0,F.useCallback)(e=>{let t=e.clientX,n=_,r=c.current?.clientWidth||window.innerWidth,i=e.currentTarget;try{i.setPointerCapture(e.pointerId)}catch{}function o(e){v($(n+(e.clientX-t),r))}function s(){window.removeEventListener(`pointermove`,o),window.removeEventListener(`pointerup`,s),window.removeEventListener(`pointercancel`,s),v(e=>{let t=$(e,r);return ct(a,t),t})}window.addEventListener(`pointermove`,o),window.addEventListener(`pointerup`,s),window.addEventListener(`pointercancel`,s)},[a,_]),O=(0,F.useCallback)(()=>{let e=$(rt,c.current?.clientWidth||window.innerWidth);v(e),ct(a,e)},[a]),k=(0,F.useCallback)(t=>{if(d(t),e)return;let n=new URLSearchParams(o);n.set(`path`,t),s({pathname:`/code`,search:`?${n.toString()}`},{replace:!0})},[e,s,o,d]),A=(0,F.useCallback)(t=>{if(e){b(t),S(null);return}let n=new URLSearchParams(o);n.set(`jobId`,t),n.delete(`ticketId`),s({pathname:`/code`,search:`?${n.toString()}`},{replace:!0})},[e,s,o]),j=(0,F.useCallback)(()=>{if(e){b(null),S(null);return}let t=new URLSearchParams(o);t.delete(`jobId`),t.delete(`ticketId`),s({pathname:`/code`,search:t.toString()?`?${t.toString()}`:``},{replace:!0})},[e,s,o]),ee=(0,F.useCallback)(t=>{let n=Number(t.trim());if(!Number.isInteger(n)||n<=0){j();return}if(e){S(n),b(null);return}let r=new URLSearchParams(o);r.set(`ticketId`,String(n)),r.delete(`jobId`),s({pathname:`/code`,search:`?${r.toString()}`},{replace:!0})},[j,e,s,o]);return(0,Y.jsxs)(`div`,{ref:c,className:`flex h-full w-full`,"data-testid":`code-page`,children:[(0,Y.jsx)(`aside`,{className:`overflow-hidden flex flex-col shrink-0`,style:{width:_},children:(0,Y.jsx)(ve,{onOpenFile:k,selectedPath:l,filterJobId:C,filterTicketId:w},a??`no-project`)}),(0,Y.jsx)(`div`,{role:`separator`,"aria-orientation":`vertical`,"aria-label":r(`page.resizeFileTree`),onPointerDown:D,onDoubleClick:O,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:r(`resizer.hint`),"data-testid":`code-tree-resizer`}),(0,Y.jsxs)(`main`,{className:`flex-1 overflow-hidden flex flex-col`,children:[(0,Y.jsx)(ut,{jobId:C,ticketId:w,ticketInput:T,onTicketInputChange:E,onApplyTicket:ee,onClear:j,summaryAction:p,copyPathAction:h}),(C||w)&&(0,Y.jsx)(dt,{jobId:C,ticketId:w,onOpenFile:k}),l?(0,Y.jsx)(tt,{relPath:l,onFilterJob:A,onSummaryActionChange:m,onCopyPathActionChange:g}):(0,Y.jsx)(`div`,{className:`h-full flex items-center justify-center text-sm text-muted-foreground`,children:r(`page.selectFile`)})]})]})}function ut({jobId:e,ticketId:t,ticketInput:n,onTicketInputChange:r,onApplyTicket:i,onClear:a,summaryAction:o,copyPathAction:s}){let{t:c}=N(`code`),l=t?`spec`:e?`job-context`:`all`;return(0,Y.jsx)(`div`,{className:`border-b border-border bg-background/80 px-4 py-2`,"data-testid":`code-provenance-toolbar`,children:(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Y.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-xs font-medium text-muted-foreground`,children:[(0,Y.jsx)(P,{className:`h-3.5 w-3.5`}),c(`toolbar.scope`)]}),(0,Y.jsx)(`button`,{type:`button`,onClick:a,"aria-pressed":l===`all`,className:l===`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:c(`toolbar.allAi`)}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-1 rounded-md border border-border/70 bg-card/40 px-1 py-1`,children:[(0,Y.jsx)(`button`,{type:`button`,onClick:()=>i(n),"aria-pressed":l===`spec`,className:l===`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:c(`toolbar.spec`)}),(0,Y.jsx)(`input`,{value:n,onChange:e=>r(e.target.value),onKeyDown:e=>{e.key===`Enter`&&i(n)},placeholder:c(`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,Y.jsx)(`div`,{className:`flex-1`}),s&&(0,Y.jsx)(`button`,{type:`button`,onClick:s.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:c(`toolbar.copyFilePath`)}),o&&(0,Y.jsxs)(`button`,{type:`button`,onClick:o.onClick,disabled:o.regenerating||!!o.disabledReason,"aria-label":o.hasSummary?c(`toolbar.regenerateSummary`):c(`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:o.disabledReason?c(`toolbar.summaryUnavailable`,{reason:o.disabledReason}):void 0,children:[(0,Y.jsx)(j,{className:o.regenerating?`h-3.5 w-3.5 animate-spin`:`h-3.5 w-3.5`}),o.hasSummary?o.regenerating?c(`toolbar.regenerating`):c(`toolbar.regenerateSummary`):o.regenerating?c(`toolbar.generating`):c(`toolbar.generateSummary`)]}),l===`job-context`&&(0,Y.jsx)(`span`,{className:`rounded-md bg-accent-info/15 px-2 py-1 text-xs text-accent-info`,children:c(`toolbar.jobContext`)}),(e||t)&&(0,Y.jsxs)(`button`,{type:`button`,onClick:a,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,Y.jsx)(E,{className:`h-3.5 w-3.5`}),c(`toolbar.clear`)]})]})})}function dt({jobId:e,ticketId:t,onOpenFile:n}){let{t:r}=N(`code`),[i,a]=(0,F.useState)(null);(0,F.useEffect)(()=>{let n=!1,r=new URLSearchParams;return e&&r.set(`jobId`,e),t&&r.set(`ticketId`,String(t)),fetch(`${d()}/code/provenance?${r.toString()}`).then(e=>e.ok?e.json():[]).then(e=>{n||a(Array.isArray(e)?e:[])}).catch(()=>{n||a([])}),()=>{n=!0}},[e,t]);let o=(0,F.useMemo)(()=>{let e=i??[];return{created:e.filter(e=>e.kind===`created`),modified:e.filter(e=>e.kind===`modified`),deleted:e.filter(e=>e.kind===`deleted`)}},[i]),s=i?.length??0;return(0,Y.jsx)(`section`,{className:`border-b border-border bg-card/35 px-4 py-3`,"data-testid":`provenance-result-panel`,children:(0,Y.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,Y.jsxs)(`div`,{className:`min-w-0`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(`h2`,{className:`text-sm font-semibold truncate`,children:e?r(`provenancePanel.jobTitle`,{jobId:e}):r(`provenancePanel.specTitle`,{ticketId:t})}),(0,Y.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,children:r(`provenancePanel.touchedFiles`,{count:s})})]}),(0,Y.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-2`,children:[(0,Y.jsx)(ft,{label:r(`action.added`),rows:o.created,icon:`created`,onOpenFile:n}),(0,Y.jsx)(ft,{label:r(`action.changed`),rows:o.modified,icon:`modified`,onOpenFile:n}),(0,Y.jsx)(ft,{label:r(`action.deleted`),rows:o.deleted,icon:`deleted`,onOpenFile:n})]})]}),(0,Y.jsx)(`div`,{className:`flex items-center gap-1 shrink-0`,children:e&&(0,Y.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,Y.jsx)(g,{className:`h-3.5 w-3.5`}),r(`provenancePanel.log`)]})})]})})}function ft({label:e,rows:t,icon:n,onOpenFile:r}){return(0,Y.jsxs)(`details`,{className:`group min-w-[180px] max-w-[320px]`,children:[(0,Y.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,Y.jsx)(n===`created`?O:n===`deleted`?a:s,{className:`h-3.5 w-3.5 text-muted-foreground`}),(0,Y.jsx)(`span`,{children:e}),(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:t.length})]}),t.length>0&&(0,Y.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,Y.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-BSeBkF2n.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{Cn as n,S as r,_ as i,_n as a,it as o,qn as s,wn as c,wt as l,xn as u,zn as d}from"./index-BbVOi-dY.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-DuzYxiJ6.js";var Se=a(`trending-up`,[[`path`,{d:`M16 7h6v6`,key:`box55l`}],[`path`,{d:`m22 7-8.5 8.5-5-5L2 17`,key:`1t1m79`}]]),U=e(s());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})),$=c(),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}=d(`analytics`);function a(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:()=>a(t.value),className:o(`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}=d(`analytics`),r=e.estimatedCostUsd??0,i=e.estimatedCostToday??0,a=e.includesEstimated??r>0,o=r>0,s=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:`${o?`~`:``}$${e.totalCostUsd.toFixed(4)}`,sub:n(`desktop.costToday`,{value:`${s?`~`:``}$${e.costToday.toFixed(4)}`}),estimated:o,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?`${o?`~`:``}$${(e.totalCostUsd/e.totalJobs).toFixed(5)}`:`—`,sub:n(`desktop.periodAverage`),estimated:o&&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))}),a&&(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}=d(`analytics`),n=i(),a=e.length>0&&e.some(e=>e.costUsd>0),o=Math.max(1,Math.floor(e.length/7)),s=e.filter((e,t)=>t%o===0).map(e=>e.date),c=new Map(e.map(e=>[e.date,e.estimatedCostUsd??0])),l=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`)}),l&&(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:s,tickFormatter:e=>{try{return r(new Date(e),`MMM d`,{locale:u()})}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=(c.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}=d(`analytics`),n=i();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}=d(`analytics`),n=i();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}=d(`analytics`),[t,r]=(0,U.useState)(`7d`),[i,a]=(0,U.useState)(``),[o,s]=(0,U.useState)(``),[c,u]=(0,U.useState)(null),[f,p]=(0,U.useState)(!0),[m,h]=(0,U.useState)(null),{registerHandler:g,unregisterHandler:_}=n(),v=(0,U.useCallback)(e=>{let n=e;(n.type===`spending.invalidated`||n.type===`rail.job_completed`)&&y(t,i,o)},[t,i,o]);(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}`);u(await i.json())}catch(e){h(e.message)}finally{p(!1)}}(0,U.useEffect)(()=>{y(t,i,o)},[t,i,o]);function b(e,t,n){r(e),t!==void 0&&a(t),n!==void 0&&s(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`)}),c&&(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:c.period.label})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-3 mr-8`,children:[(0,$.jsx)(St,{period:t,from:i,to:o,onChange:b}),(0,$.jsx)(`button`,{onClick:()=>y(t,i,o),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)(l,{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&&!c&&(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))})]}),c&&(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.jsx)(Ct,{kpi:c.kpi,windowLabel:t===`custom`?c.period.label:e(`windowLabels.${t}`)}),(0,$.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-3`,children:[(0,$.jsx)(wt,{data:c.costTimeline}),(0,$.jsx)(Et,{projects:c.projectBreakdown})]}),(0,$.jsx)(Tt,{projects:c.projectBreakdown})]})]})})}export{Dt as default};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as e}from"./chunk-BNv3lrIs.js";import{
|
|
1
|
+
import{a as e}from"./chunk-BNv3lrIs.js";import{Ft as t,J as n,K as r,Kt as i,M as a,X as o,Z as s,it as c,j as l,on as u,q as d,qn as f,un as p,wn as m,zn as h}from"./index-BbVOi-dY.js";import{t as g}from"./lib-BxSZPd0W.js";import{t as _}from"./atom-one-dark-BMDPFwRZ.js";var v=e(f(),1),y=m();function b({categories:e,activeCategory:t,activeSlug:n,onSelect:r,onHome:a}){let{t:o}=h(`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:c(`flex w-full items-center gap-2 rounded-lg px-2.5 py-1.5 text-left text-xs transition-colors`,!t&&!n?`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(a=>{let o=t===e.slug&&n===a.slug;return(0,y.jsx)(`li`,{children:(0,y.jsxs)(`button`,{onClick:()=>r(e.slug,a.slug),title:a.title,className:c(`flex w-full items-center gap-2 rounded-lg px-2.5 py-1.5 text-left text-xs transition-colors`,o?`bg-accent-primary/15 font-medium text-foreground`:`text-muted-foreground hover:bg-muted/40 hover:text-foreground`),children:[(0,y.jsx)(i,{className:`w-3.5 h-3.5 shrink-0`}),(0,y.jsx)(`span`,{className:`truncate`,children:a.title})]})},a.slug)})})]},e.slug))]})}function x({categories:e,onSelect:t}){let{t:n}=h(`integrations`),r=e.reduce((e,t)=>e+t.docs.length,0),a=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:r===0?n(`docs.indexEmpty`):n(`docs.summary`,{documents:n(`docs.documentCount`,{count:r}),categories:n(`docs.categoryCount`,{count:a})})}),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:n(`docs.categoryEmpty`)}):(0,y.jsx)(`ul`,{className:`space-y-2`,children:e.docs.map(n=>(0,y.jsx)(`li`,{children:(0,y.jsxs)(`button`,{onClick:()=>t(e.slug,n.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)(i,{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:n.title}),(0,y.jsx)(u,{className:`w-3 h-3 text-muted-foreground ml-auto md:opacity-0 md:group-hover:opacity-100 transition-opacity`})]})},n.slug))})]},e.slug))]})}var S=(0,v.memo)(function({content:e,currentCategory:t,onNavigateDoc:n}){return(0,y.jsx)(a,{remarkPlugins:[l],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}=h(`integrations`),[c,l]=(0,v.useState)(null),[u,d]=(0,v.useState)(null),f=(0,v.useRef)(0);return(0,v.useEffect)(()=>{let t=++f.current;d(null),fetch(`/api/docs/${e}/${n}?lang=${encodeURIComponent(r)}`).then(async e=>{if(e.status===404){i();return}if(!e.ok)throw Error(`HTTP ${e.status}`);return e.json()}).then(e=>{t===f.current&&e&&(l(e),o.current&&(o.current.scrollTop=0))}).catch(e=>{t===f.current&&d(e instanceof Error?e.message:s(`docs.loadError`))})},[e,n,r,i,o]),!c&&!u?(0,y.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,y.jsx)(t,{className:`w-4 h-4 animate-spin text-muted-foreground`})}):u&&!c?(0,y.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,y.jsx)(`p`,{className:`text-sm text-destructive`,children:u})}):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
2
|
prose-headings:text-foreground prose-headings:font-bold
|
|
3
3
|
prose-p:text-foreground/90
|
|
4
4
|
prose-a:text-accent-primary prose-a:no-underline hover:prose-a:underline
|
|
@@ -8,4 +8,4 @@ import{a as e}from"./chunk-BNv3lrIs.js";import{A as t,Cn as n,G as r,Gt as i,K a
|
|
|
8
8
|
prose-blockquote:border-l-accent-primary prose-blockquote:text-muted-foreground
|
|
9
9
|
prose-hr:border-border
|
|
10
10
|
prose-th:text-foreground prose-td:text-foreground/90
|
|
11
|
-
prose-li:text-foreground/90`,children:(0,y.jsx)(S,{content:
|
|
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:i}){let{t:a,i18n:c}=h(`integrations`),l=c.language||`en`,[u,f]=(0,v.useState)(null),[m,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(l)}`).then(e=>e.json()).then(e=>f(e)).catch(()=>f({categories:[]})).finally(()=>g(!1)))},[e,l]);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)(r,{open:e,onOpenChange:e=>{e||i()},children:(0,y.jsxs)(d,{movableResizable:!0,className:`flex max-w-5xl w-[92vw] h-[82vh] flex-col overflow-hidden`,children:[(0,y.jsxs)(o,{children:[(0,y.jsxs)(s,{className:`flex items-center gap-2`,children:[(0,y.jsx)(p,{className:`w-4 h-4`}),a(`docs.title`)]}),(0,y.jsx)(n,{children:a(`docs.dialogDescription`)})]}),(0,y.jsxs)(`div`,{className:`flex min-h-0 flex-1 gap-5 py-2`,children:[m?(0,y.jsx)(`div`,{className:`w-48 shrink-0 border-r border-border flex items-center justify-center`,children:(0,y.jsx)(t,{className:`w-3.5 h-3.5 animate-spin text-muted-foreground`})}):(0,y.jsx)(b,{categories:u?.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:l,onNotFound:O,onNavigate:D,scrollContainerRef:E}):u&&(0,y.jsx)(x,{categories:u.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{Ft as t,Hn as n,Kt as r,M as i,Un as a,Wn as o,it as s,j as c,on as l,qn as u,un as d,wn as f,zn as p}from"./index-BbVOi-dY.js";import{t as m}from"./lib-BxSZPd0W.js";import{t as h}from"./atom-one-dark-BMDPFwRZ.js";var g=e(u(),1),_=f();function v({categories:e,activeCategory:t,activeSlug:i}){let{t:a}=p(`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)(n,{to:`/docs`,className:s(`flex w-full items-center gap-2 rounded-lg px-2.5 py-1.5 text-left text-xs transition-colors`,!t&&!i?`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:a(`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:a(`docs.sidebarEmpty`)}):(0,_.jsx)(`ul`,{className:`space-y-0.5`,children:e.docs.map(a=>{let o=t===e.slug&&i===a.slug;return(0,_.jsx)(`li`,{children:(0,_.jsxs)(n,{to:`/docs/${e.slug}/${a.slug}`,title:a.title,className:s(`flex w-full items-center gap-2 rounded-lg px-2.5 py-1.5 text-left text-xs transition-colors`,o?`bg-accent-primary/15 font-medium text-foreground`:`text-muted-foreground hover:bg-muted/40 hover:text-foreground`),children:[(0,_.jsx)(r,{className:`w-3.5 h-3.5 shrink-0`}),(0,_.jsx)(`span`,{className:`truncate`,children:a.title})]})},a.slug)})})]},e.slug))]})}function y({categories:e}){let{t}=p(`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`}),t(`docs.title`)]}),(0,_.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:i===0?t(`docs.indexEmpty`):t(`docs.summary`,{documents:t(`docs.documentCount`,{count:i}),categories:t(`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:t(`docs.categoryEmpty`)}):(0,_.jsx)(`ul`,{className:`space-y-2`,children:e.docs.map(t=>(0,_.jsx)(`li`,{children:(0,_.jsxs)(n,{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)(r,{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)(l,{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)(i,{remarkPlugins:[c],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:r,scrollContainerRef:i}){let{t:o}=p(`integrations`),[s,c]=(0,g.useState)(null),[l,u]=(0,g.useState)(null),d=(0,g.useRef)(0),f=a();return(0,g.useEffect)(()=>{let t=++d.current;u(null),fetch(`/api/docs/${e}/${n}?lang=${encodeURIComponent(r)}`).then(async e=>{if(e.status===404){f(`/docs`,{replace:!0});return}if(!e.ok)throw Error(`HTTP ${e.status}`);return e.json()}).then(e=>{t===d.current&&e&&(c(e),i.current&&(i.current.scrollTop=0))}).catch(e=>{t===d.current&&u(e instanceof Error?e.message:o(`docs.loadError`))})},[e,n,r,f,i]),!s&&!l?(0,_.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,_.jsx)(t,{className:`w-4 h-4 animate-spin text-muted-foreground`})}):l&&!s?(0,_.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,_.jsx)(`p`,{className:`text-sm text-destructive`,children:l})}):s?(0,_.jsx)(`article`,{className:`max-w-2xl mx-auto py-8 px-6`,children:(0,_.jsx)(`div`,{className:`prose prose-sm max-w-none
|
|
2
|
+
prose-headings:text-foreground prose-headings:font-bold
|
|
3
|
+
prose-p:text-foreground/90
|
|
4
|
+
prose-a:text-accent-primary prose-a:no-underline hover:prose-a:underline
|
|
5
|
+
prose-strong:text-foreground
|
|
6
|
+
prose-code:text-accent-info prose-code:bg-card prose-code:px-1 prose-code:py-0.5 prose-code:rounded prose-code:text-xs
|
|
7
|
+
prose-pre:bg-card prose-pre:border prose-pre:border-border prose-pre:rounded-md prose-pre:p-0 prose-pre:overflow-x-auto
|
|
8
|
+
prose-blockquote:border-l-accent-primary prose-blockquote:text-muted-foreground
|
|
9
|
+
prose-hr:border-border
|
|
10
|
+
prose-th:text-foreground prose-td:text-foreground/90
|
|
11
|
+
prose-li:text-foreground/90`,children:(0,_.jsx)(b,{content:s.content,currentCategory:s.category,onNavigateDoc:(e,t)=>f(`/docs/${e}/${t}`)})})}):null}function S(){let{category:e,slug:n}=o(),{i18n:r}=p(`integrations`),i=r.language||`en`,[a,s]=(0,g.useState)(null),[c,l]=(0,g.useState)(!0),u=(0,g.useRef)(null);(0,g.useEffect)(()=>{fetch(`/api/docs?lang=${encodeURIComponent(i)}`).then(e=>e.json()).then(e=>s(e)).catch(()=>s({categories:[]})).finally(()=>l(!1))},[i]);let d=!!(e&&n);return(0,_.jsxs)(`div`,{className:`flex h-full overflow-hidden`,children:[c?(0,_.jsx)(`div`,{className:`w-56 flex-shrink-0 border-r border-border flex items-center justify-center`,children:(0,_.jsx)(t,{className:`w-3.5 h-3.5 animate-spin text-muted-foreground`})}):(0,_.jsx)(v,{categories:a?.categories??[],activeCategory:e,activeSlug:n}),(0,_.jsx)(`main`,{ref:u,className:`flex-1 overflow-y-auto`,children:d&&e&&n?(0,_.jsx)(x,{category:e,slug:n,lang:i,scrollContainerRef:u}):a&&(0,_.jsx)(y,{categories:a.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{Rn as t,Zt as n,qn as r,wn as i,zn as a}from"./index-BbVOi-dY.js";var o=e(r(),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:r,label:i,disabled:u}){let{t:d}=a(`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,...r}).toString()}`,[e,r]),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),t.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)(n,{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)(n,{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,3 @@
|
|
|
1
|
+
import{a as e}from"./chunk-BNv3lrIs.js";import{$ as t,Cn as n,Dt as r,Ft as i,G as a,K as o,Q as s,Rn as c,Tn as l,Tt as u,Vn as d,W as f,X as p,Z as m,Zt as h,bn as g,c as _,lt as v,nn as y,q as b,qn as x,rn as S,rt as C,ut as w,vn as T,wn as E,yn as D,zn as O}from"./index-BbVOi-dY.js";var k=e(x(),1),A=E(),j=[`todo`,`in_progress`,`on_review`,`done`,`cancelled`],M={todo:`todo`,in_progress:`inProgress`,on_review:`onReview`,done:`done`,cancelled:`cancelled`};function N({state:e,onChanged:t}){let{t:n}=O(`jira`),r=e.connection,[i,a]=(0,k.useState)(r.enabled),[o,s]=(0,k.useState)(!1),[l,u]=(0,k.useState)(!1),[d,p]=(0,k.useState)([]),[m,h]=(0,k.useState)([]),[g,_]=(0,k.useState)(r.discardStatus??``),[v,y]=(0,k.useState)(r.statusMap??{}),b=e.outbox??{pending:0,inflight:0,done:0,dead:0},x=(0,k.useCallback)(async()=>{try{let{ops:e}=await f.listOutbox(`dead`);p(e)}catch{p([])}},[]);(0,k.useEffect)(()=>{x()},[x]),(0,k.useEffect)(()=>{let e=!1;return f.listStatuses().then(({statuses:t})=>{e||h(t)}).catch(()=>{e||h([])}),()=>{e=!0}},[]);async function S(e){let r=g;_(e);try{await f.patchConnection({discardStatus:e||null}),t()}catch(e){_(r),c.error(F(e,n))}}async function w(e,r){let i=v,a={...v,[e]:r||void 0};y(a);let o=Object.fromEntries(Object.entries(a).filter(([,e])=>e));try{await f.patchConnection({statusMap:Object.keys(o).length?o:null}),t()}catch(e){y(i),c.error(F(e,n))}}async function T(){let e=!i;a(e),u(!0);try{await f.setEnabled(e)}catch(t){a(!e),c.error(F(t,n))}finally{u(!1)}}async function E(){s(!0);try{let e=await f.syncNow();c.success(n(`status.syncedToast`,{count:e.upserted}))}catch(e){c.error(F(e,n))}finally{s(!1)}}async function D(){if(window.confirm(n(`status.disconnectConfirm`))){u(!0);try{await f.disconnect(),c.success(n(`status.disconnectedToast`)),t()}catch(e){c.error(F(e,n))}finally{u(!1)}}}async function N(e){try{await f.retryOutbox(e),await x()}catch(e){c.error(F(e,n))}}let I=b.pending+b.inflight;return(0,A.jsxs)(`div`,{className:`space-y-4`,"data-testid":`jira-connected`,children:[(0,A.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`p`,{className:`text-sm font-medium text-foreground`,children:n(`status.connected`,{key:r.jiraProjectKey})}),(0,A.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[r.baseUrl,` · `,r.deployment===`cloud`?n(`review.cloud`):n(`review.dc`)]})]}),(0,A.jsx)(`a`,{href:`${r.baseUrl}/browse/${r.jiraProjectKey}`,target:`_blank`,rel:`noreferrer`,className:`text-xs text-accent-primary hover:underline`,children:n(`badge.openInJira`)})]}),(0,A.jsxs)(`div`,{className:`flex items-center justify-between rounded-md border border-border p-3`,children:[(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`p`,{className:`text-sm font-medium`,children:n(`status.enabledLabel`)}),(0,A.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:n(i?`status.enabledHelp`:`status.pausedHelp`)})]}),(0,A.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":i,"aria-label":n(`status.enabledLabel`),disabled:l,onClick:T,className:`relative inline-flex h-5 w-9 shrink-0 items-center rounded-full transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 ${i?`bg-accent-success`:`bg-input`}`,children:(0,A.jsx)(`span`,{className:`inline-block h-3.5 w-3.5 rounded-full bg-background shadow-sm transition-transform ${i?`translate-x-4`:`translate-x-0.5`}`})})]}),(0,A.jsxs)(`div`,{className:`rounded-md border border-border p-3`,"data-testid":`jira-status-map`,children:[(0,A.jsx)(`p`,{className:`text-sm font-medium`,children:n(`wizard.step3Title`)}),(0,A.jsx)(`p`,{className:`mt-0.5 mb-2 text-xs text-muted-foreground`,children:n(`mapping.intro`)}),(0,A.jsx)(`div`,{className:`space-y-2`,children:j.map(e=>(0,A.jsxs)(`label`,{className:`flex items-center justify-between gap-3`,children:[(0,A.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:n(`mapping.${M[e]}`)}),(0,A.jsxs)(`select`,{value:v[e]??``,onChange:t=>void w(e,t.target.value),className:`w-44 rounded-md border border-border bg-background px-2 py-1.5 text-sm`,"data-testid":`jira-statusmap-${e}`,children:[(0,A.jsx)(`option`,{value:``,children:n(`mapping.auto`)}),m.map(e=>(0,A.jsx)(`option`,{value:e.name,children:e.name},e.id)),v[e]&&!m.some(t=>t.name===v[e])&&(0,A.jsx)(`option`,{value:v[e],children:v[e]})]})]},e))})]}),(0,A.jsxs)(`div`,{className:`rounded-md border border-border p-3`,children:[(0,A.jsx)(`p`,{className:`text-sm font-medium`,children:n(`discard.configLabel`)}),(0,A.jsx)(`p`,{className:`mt-0.5 mb-2 text-xs text-muted-foreground`,children:n(`discard.configHelp`)}),(0,A.jsxs)(`select`,{value:g,onChange:e=>void S(e.target.value),className:`w-full rounded-md border border-border bg-background px-2 py-1.5 text-sm`,"data-testid":`jira-discard-status-select`,children:[(0,A.jsx)(`option`,{value:``,children:n(`discard.configNone`)}),m.map(e=>(0,A.jsx)(`option`,{value:e.name,children:e.name},e.id)),g&&!m.some(e=>e.name===g)&&(0,A.jsx)(`option`,{value:g,children:g})]})]}),(0,A.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,A.jsx)(C,{variant:`outline`,size:`sm`,onClick:E,disabled:o,children:n(o?`status.syncing`:`status.syncNow`)}),(0,A.jsx)(C,{variant:`ghost`,size:`sm`,onClick:D,disabled:l,className:`text-destructive`,children:n(`status.disconnect`)})]}),(0,A.jsxs)(`div`,{className:`rounded-md border border-border p-3`,"data-testid":`jira-outbox`,children:[(0,A.jsx)(`p`,{className:`text-sm font-medium`,children:n(`outbox.title`)}),b.dead>0?(0,A.jsx)(`p`,{className:`mt-1 text-xs text-accent-warning`,children:n(`outbox.dead`,{count:b.dead})}):I>0?(0,A.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:n(`outbox.pending`,{count:I})}):(0,A.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:n(`outbox.allSynced`)}),d.length>0&&(0,A.jsxs)(`div`,{className:`mt-2 space-y-2`,children:[(0,A.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:n(`outbox.deadHelp`)}),d.map(e=>(0,A.jsxs)(`div`,{className:`flex items-center justify-between gap-2 rounded border border-border/60 px-2 py-1`,children:[(0,A.jsxs)(`span`,{className:`truncate text-xs`,children:[P(e,n),` · `,e.deadReason??e.lastError??``]}),(0,A.jsx)(C,{variant:`outline`,size:`sm`,onClick:()=>N(e.id),children:n(`outbox.retry`)})]},e.id))]})]})]})}function P(e,t){return e.opType===`transition`?t(`outbox.opTransition`):e.opType===`comment`?t(`outbox.opComment`):t(`outbox.opCreate`)}function F(e,t){return e instanceof Error?e.message:t(`errors.generic`)}function I({activeProjectId:e}){let{t}=O(`integrations`),[n,i]=(0,k.useState)(null),[s,c]=(0,k.useState)(!0),[l,u]=(0,k.useState)(!1),[d,h]=(0,k.useState)(!1),g=(0,k.useCallback)(async()=>{try{i(await f.getConnection())}catch{i({connected:!1})}finally{c(!1)}},[]);if((0,k.useEffect)(()=>{!a||!e||(c(!0),g())},[e,g]),!a)return null;let v=!!(n?.connected&&n.connection);return(0,A.jsxs)(`div`,{className:`rounded-lg border border-border bg-card p-4 flex flex-col gap-3 h-full`,"data-testid":`jira-integration-card`,children:[(0,A.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,A.jsx)(`div`,{className:`grid place-items-center w-9 h-9 rounded-md bg-accent-info/15 text-accent-info shrink-0`,children:(0,A.jsx)(r,{className:`w-4 h-4`})}),(0,A.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,A.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,A.jsx)(`h3`,{className:`text-sm font-semibold`,children:t(`jiraCard.title`)}),v&&(0,A.jsxs)(`span`,{className:`text-[10px] px-1.5 py-0.5 rounded bg-accent-success/20 text-accent-success flex items-center gap-1`,"data-testid":`jira-connected-badge`,children:[(0,A.jsx)(S,{className:`w-3 h-3`}),` `,t(`jiraCard.connected`)]})]}),(0,A.jsx)(`p`,{className:`text-[10px] text-muted-foreground mt-0.5`,children:t(`jiraCard.category`)})]})]}),(0,A.jsx)(`p`,{className:`text-xs text-muted-foreground leading-relaxed`,children:v&&n?.connection?t(`jiraCard.connectedDescription`,{key:n.connection.jiraProjectKey}):t(`jiraCard.description`)}),(0,A.jsxs)(`ul`,{className:`text-xs space-y-1 list-disc pl-4 text-foreground/80`,children:[(0,A.jsx)(`li`,{children:t(`jiraCard.bullet1`)}),(0,A.jsx)(`li`,{children:t(`jiraCard.bullet2`)}),(0,A.jsx)(`li`,{children:t(`jiraCard.bullet3`)})]}),(0,A.jsx)(`div`,{className:`text-[10px] text-muted-foreground`,children:t(`jiraCard.requires`)}),(0,A.jsx)(`div`,{className:`mt-auto pt-2 flex items-center justify-end gap-2`,children:s?(0,A.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`…`}):v?(0,A.jsx)(`button`,{type:`button`,onClick:()=>h(!0),"data-testid":`jira-manage-btn`,className:`text-xs px-3 py-1.5 rounded-md border border-border hover:bg-muted/30 inline-flex items-center gap-1.5`,children:t(`jiraCard.manage`)}):(0,A.jsxs)(`button`,{type:`button`,onClick:()=>u(!0),"data-testid":`jira-connect-btn`,className:`text-xs px-3 py-1.5 rounded-md bg-accent-primary text-white hover:opacity-90 inline-flex items-center gap-1.5`,children:[(0,A.jsx)(r,{className:`w-3.5 h-3.5`}),t(`jiraCard.connect`)]})}),(0,A.jsx)(o,{open:l,onOpenChange:u,children:(0,A.jsxs)(b,{className:`max-w-lg`,children:[(0,A.jsx)(p,{children:(0,A.jsx)(m,{children:t(`jiraCard.modalTitle`)})}),(0,A.jsx)(_,{onConnected:()=>{u(!1),g()},onSkip:()=>u(!1)})]})}),(0,A.jsx)(o,{open:d,onOpenChange:h,children:(0,A.jsxs)(b,{className:`max-w-lg`,children:[(0,A.jsx)(p,{children:(0,A.jsx)(m,{children:t(`jiraCard.manageTitle`)})}),n?.connected&&n.connection&&(0,A.jsx)(N,{state:n,onChanged:()=>{g().then(()=>h(!1))}})]})})]})}function L(){let{t:e}=O(`integrations`),{activeProjectId:t,projects:r}=D(),i=r.find(e=>e.id===t),o=i?T(i).includes(`claude`):!0,{registerHandler:s,unregisterHandler:c}=n(),d=(0,k.useRef)(t);(0,k.useEffect)(()=>{d.current=t},[t]);let[f,p]=(0,k.useState)(null),[m,h]=(0,k.useState)(null),{data:_,isLoading:y,isFirstLoad:b,refresh:x}=g({namespace:`plugins`,projectId:t,initialValue:[],fetcher:(0,k.useCallback)(async()=>{let e=await fetch(`${l()}/plugins`);if(!e.ok)throw Error(`HTTP ${e.status}`);return(await e.json()).plugins??[]},[])});(0,k.useEffect)(()=>(s(`integrations-page`,e=>{let t=e;t.type&&(t.projectId&&t.projectId!==d.current||t.type.startsWith(`plugin.`)&&x())}),()=>c(`integrations-page`)),[s,c,x]),(0,k.useEffect)(()=>{p(!y&&!_?`Failed to load plugins`:null)},[y,_]);let S=(0,k.useMemo)(()=>(_??[]).filter(e=>e.status!==`orphan`),[_]),C=(0,k.useMemo)(()=>(_??[]).filter(e=>e.status===`orphan`),[_]);return t?(0,A.jsxs)(`div`,{className:`flex flex-col h-full`,children:[(0,A.jsxs)(`div`,{className:`flex-shrink-0 border-b border-border px-6 pt-4 pb-3 flex items-center gap-2`,children:[(0,A.jsx)(u,{className:`w-4 h-4 text-accent-primary`}),(0,A.jsxs)(`div`,{className:`flex-1`,children:[(0,A.jsx)(`h1`,{className:`text-lg font-semibold`,children:e(`page.title`)}),(0,A.jsx)(`p`,{className:`text-xs text-muted-foreground mt-0.5`,children:e(`page.subtitle`)})]})]}),(0,A.jsx)(`div`,{className:`flex-1 overflow-auto p-6`,children:b&&y?(0,A.jsx)(q,{}):f&&o?(0,A.jsx)(J,{onRetry:x}):(0,A.jsxs)(A.Fragment,{children:[(0,A.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4`,children:[(0,A.jsx)(I,{activeProjectId:t}),o&&S.map(e=>(0,A.jsx)(R,{plugin:e,isInstalling:m===e.name,onInstall:()=>h(e.name),onCloseInstall:()=>{h(null),x()}},e.name))]}),o&&C.length>0&&(0,A.jsxs)(`div`,{className:`mt-10`,children:[(0,A.jsxs)(`h2`,{className:`text-sm font-semibold text-muted-foreground mb-3 flex items-center gap-2`,children:[(0,A.jsx)(v,{className:`w-3.5 h-3.5`}),` `,e(`page.deprecated`)]}),(0,A.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4`,children:C.map(e=>(0,A.jsx)(U,{plugin:e,onRemoved:x},e.name))})]}),!a&&(!o||S.length===0)&&(0,A.jsx)(Y,{})]})})]}):(0,A.jsx)(`div`,{className:`flex flex-col items-center justify-center h-full text-muted-foreground text-sm`,children:e(`page.selectProject`)})}function R({plugin:e,isInstalling:t,onInstall:n,onCloseInstall:r}){let{t:i}=O(`integrations`),[a,o]=(0,k.useState)(!1);return(0,A.jsxs)(`div`,{className:`rounded-lg border border-border bg-card p-4 flex flex-col gap-3 h-full`,children:[(0,A.jsx)(`div`,{className:`flex items-start gap-2`,children:(0,A.jsxs)(`div`,{className:`flex-1`,children:[(0,A.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,A.jsx)(`h3`,{className:`text-sm font-semibold`,children:e.name}),(0,A.jsxs)(`span`,{className:`text-[10px] px-1.5 py-0.5 rounded bg-muted text-muted-foreground`,children:[`v`,e.version]}),e.status===`installed`&&(0,A.jsxs)(`span`,{className:`text-[10px] px-1.5 py-0.5 rounded bg-accent-success/20 text-accent-success flex items-center gap-1`,children:[(0,A.jsx)(S,{className:`w-3 h-3`}),` `,i(`card.statusActive`)]}),e.status===`deactivated`&&(0,A.jsxs)(`span`,{className:`text-[10px] px-1.5 py-0.5 rounded bg-muted text-muted-foreground flex items-center gap-1`,children:[(0,A.jsx)(y,{className:`w-3 h-3`}),` `,i(`card.statusDeactivated`)]}),e.status===`degraded`&&(0,A.jsxs)(`span`,{className:`text-[10px] px-1.5 py-0.5 rounded bg-accent-warning/20 text-accent-warning flex items-center gap-1`,children:[(0,A.jsx)(v,{className:`w-3 h-3`}),` `,i(`card.statusDegraded`)]}),e.updateAvailable&&(0,A.jsxs)(`span`,{className:`text-[10px] px-1.5 py-0.5 rounded bg-accent-info/20 text-accent-info flex items-center gap-1`,children:[(0,A.jsx)(h,{className:`w-3 h-3`}),` `,i(`card.updateAvailable`)]})]}),e.category&&(0,A.jsx)(`p`,{className:`text-[10px] text-muted-foreground mt-0.5`,children:e.category})]})}),(0,A.jsx)(`p`,{className:`text-xs text-muted-foreground leading-relaxed`,children:e.description}),e.whatItDoes.length>0&&(0,A.jsx)(`ul`,{className:`text-xs space-y-1 list-disc pl-4 text-foreground/80`,children:e.whatItDoes.map((e,t)=>(0,A.jsx)(`li`,{children:e},t))}),e.requirements.length>0&&(0,A.jsx)(`div`,{className:`text-[10px] text-muted-foreground`,children:i(`card.requires`,{list:e.requirements.map(e=>`${e.name}${e.minVersion?` ≥ ${e.minVersion}`:``}`).join(`, `)})}),e.healthReason&&e.status===`degraded`&&(0,A.jsx)(`div`,{className:`text-[11px] text-accent-warning`,children:e.healthReason}),e.status===`deactivated`&&(0,A.jsx)(`div`,{className:`text-[11px] text-muted-foreground leading-relaxed`,children:(0,A.jsx)(d,{t:i,i18nKey:`card.deactivatedHint`,components:{strong:(0,A.jsx)(`strong`,{})}})}),e.marketplaceConflicts&&e.marketplaceConflicts.length>0&&(0,A.jsx)(H,{pluginName:e.name,conflicts:e.marketplaceConflicts}),e.marketplaceCachedButDisabled&&e.marketplaceCachedButDisabled.length>0&&(0,A.jsx)(B,{keys:e.marketplaceCachedButDisabled}),e.updateAvailable&&(0,A.jsx)(V,{pluginName:e.name}),(0,A.jsx)(`div`,{className:`mt-auto pt-2 flex items-center justify-end gap-2`,children:e.status===`not-installed`?(0,A.jsx)(`button`,{type:`button`,onClick:n,className:`text-xs px-3 py-1.5 rounded-md bg-accent-primary text-white hover:opacity-90`,children:i(`card.install`)}):(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(z,{pluginName:e.name,active:e.status===`installed`}),(0,A.jsxs)(`button`,{type:`button`,onClick:()=>o(!0),className:`text-xs px-3 py-1.5 rounded-md border border-border hover:bg-destructive/10 hover:text-destructive flex items-center gap-1.5`,children:[(0,A.jsx)(w,{className:`w-3 h-3`}),` `,i(`card.uninstall`)]})]})}),t&&(0,A.jsx)(W,{pluginName:e.name,onClose:r}),a&&(0,A.jsx)(G,{pluginName:e.name,onClose:()=>o(!1),onUninstalled:()=>{o(!1)}})]})}function z({pluginName:e,active:t}){let{t:n}=O(`integrations`),[r,i]=(0,k.useState)(!1),[a,o]=(0,k.useState)(null);return(0,A.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,A.jsx)(`button`,{type:`button`,disabled:r,onClick:async()=>{i(!0),o(null);try{let n=`${l()}/plugins/${e}/${t?`deactivate`:`activate`}`,r=await fetch(n,{method:`POST`});if(!r.ok)throw Error((await r.json()).error??`HTTP ${r.status}`)}catch(e){o(e.message)}finally{i(!1)}},role:`switch`,"aria-checked":t,className:`relative inline-flex items-center h-5 w-9 rounded-full transition-colors disabled:opacity-50 ${t?`bg-accent-success`:`bg-muted`}`,title:n(t?`toggle.titleActive`:`toggle.titleDeactivated`),children:(0,A.jsx)(`span`,{className:`inline-block h-4 w-4 rounded-full bg-white shadow transition-transform ${t?`translate-x-4`:`translate-x-0.5`}`})}),(0,A.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:n(t?`card.statusActive`:`common:states.off`)}),a&&(0,A.jsx)(`span`,{className:`text-[10px] text-destructive`,children:a})]})}function B({keys:e}){let{t}=O(`integrations`);return(0,A.jsxs)(`div`,{className:`text-[11px] rounded-md border border-yellow-500/30 aurora-light:border-accent-warning/30 bg-yellow-500/5 aurora-light:bg-accent-warning/10 p-2 leading-relaxed space-y-1`,children:[(0,A.jsxs)(`div`,{className:`flex items-start gap-1.5`,children:[(0,A.jsx)(v,{className:`w-3 h-3 text-yellow-500 aurora-light:text-accent-warning mt-0.5 flex-shrink-0`}),(0,A.jsx)(`span`,{children:(0,A.jsx)(d,{t,i18nKey:`cachedNotice.body`,components:{strong:(0,A.jsx)(`strong`,{}),code:(0,A.jsx)(`code`,{className:`bg-muted px-1 rounded`})}})})]}),(0,A.jsx)(`div`,{className:`pl-5 space-y-0.5`,children:e.map(e=>(0,A.jsxs)(`pre`,{className:`text-[10px] bg-muted/40 rounded px-1.5 py-0.5 inline-block font-mono`,children:[`/plugin uninstall `,e]},e))}),(0,A.jsx)(`div`,{className:`pl-5 text-[10px] text-muted-foreground`,children:t(`cachedNotice.runInstruction`)})]})}function V({pluginName:e}){let{t}=O(`integrations`),[n,r]=(0,k.useState)(!1),[a,o]=(0,k.useState)(null);return(0,A.jsxs)(`div`,{className:`text-[11px] rounded-md border border-accent-info/30 bg-accent-info/5 p-2 leading-relaxed space-y-1.5`,children:[(0,A.jsxs)(`div`,{className:`flex items-start gap-1.5`,children:[(0,A.jsx)(h,{className:`w-3 h-3 text-accent-info mt-0.5 flex-shrink-0`}),(0,A.jsx)(`span`,{children:(0,A.jsx)(d,{t,i18nKey:`update.body`,components:{code:(0,A.jsx)(`code`,{className:`bg-muted px-1 rounded`})}})})]}),(0,A.jsxs)(`button`,{type:`button`,disabled:n,onClick:async()=>{r(!0),o(null);try{let t=await fetch(`${l()}/plugins/${e}/update`,{method:`POST`});if(!t.ok)throw Error((await t.json()).error??`HTTP ${t.status}`)}catch(e){o(e.message)}finally{r(!1)}},className:`text-[10px] px-2 py-0.5 rounded border border-accent-info/40 hover:bg-accent-info/10 disabled:opacity-50 flex items-center gap-1`,children:[n&&(0,A.jsx)(i,{className:`w-2.5 h-2.5 animate-spin`}),(0,A.jsx)(d,{t,i18nKey:`update.button`,components:{code:(0,A.jsx)(`code`,{})}})]}),a&&(0,A.jsx)(`div`,{className:`text-destructive text-[10px]`,children:a})]})}function H({pluginName:e,conflicts:t}){let{t:n}=O(`integrations`),[r,a]=(0,k.useState)(null),[o,s]=(0,k.useState)(null),c=async e=>{a(e),s(null);try{let t=await fetch(`${l()}/plugins/_marketplace/disable`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({key:e})});if(!t.ok)throw Error((await t.json()).error??`HTTP ${t.status}`)}catch(e){s(e.message)}finally{a(null)}};return(0,A.jsxs)(`div`,{className:`text-[11px] rounded-md border border-yellow-500/30 aurora-light:border-accent-warning/30 bg-yellow-500/5 aurora-light:bg-accent-warning/10 p-2 leading-relaxed space-y-1.5`,children:[(0,A.jsxs)(`div`,{className:`flex items-start gap-1.5`,children:[(0,A.jsx)(v,{className:`w-3 h-3 text-yellow-500 aurora-light:text-accent-warning mt-0.5 flex-shrink-0`}),(0,A.jsx)(`span`,{children:(0,A.jsx)(d,{t:n,i18nKey:`conflict.body`,values:{name:e},components:{strong:(0,A.jsx)(`strong`,{})}})})]}),(0,A.jsx)(`div`,{className:`flex flex-wrap gap-1.5 pt-1`,children:t.map(e=>(0,A.jsxs)(`button`,{type:`button`,disabled:r===e,onClick:()=>c(e),className:`text-[10px] px-2 py-0.5 rounded border border-yellow-500/40 aurora-light:border-accent-warning/40 hover:bg-yellow-500/10 aurora-light:hover:bg-accent-warning/10 disabled:opacity-50 flex items-center gap-1`,children:[r===e&&(0,A.jsx)(i,{className:`w-2.5 h-2.5 animate-spin`}),(0,A.jsx)(d,{t:n,i18nKey:`conflict.disableButton`,values:{key:e},components:{code:(0,A.jsx)(`code`,{})}})]},e))}),o&&(0,A.jsx)(`div`,{className:`text-destructive`,children:o})]})}function U({plugin:e,onRemoved:t}){let{t:n}=O(`integrations`),[r,i]=(0,k.useState)(!1);return(0,A.jsxs)(`div`,{className:`rounded-lg border border-yellow-500/30 aurora-light:border-accent-warning/30 bg-yellow-500/5 aurora-light:bg-accent-warning/10 p-4 flex flex-col gap-3`,children:[(0,A.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,A.jsx)(`h3`,{className:`text-sm font-semibold`,children:e.name}),(0,A.jsx)(`span`,{className:`text-[10px] px-1.5 py-0.5 rounded bg-yellow-500/20 aurora-light:bg-accent-warning/15 text-yellow-500 aurora-light:text-accent-warning`,children:n(`orphan.badge`)})]}),(0,A.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e.description}),(0,A.jsx)(`div`,{className:`flex items-center justify-end`,children:(0,A.jsxs)(`button`,{type:`button`,disabled:r,onClick:async()=>{i(!0);try{await fetch(`${l()}/plugins/${e.name}`,{method:`DELETE`}),t()}finally{i(!1)}},className:`text-xs px-3 py-1.5 rounded-md border border-border hover:bg-destructive/10 hover:text-destructive flex items-center gap-1.5`,children:[(0,A.jsx)(w,{className:`w-3 h-3`}),` `,n(`orphan.removeButton`)]})})]})}function W({pluginName:e,onClose:t}){let{t:r}=O(`integrations`),[a,o]=(0,k.useState)(null),[s,c]=(0,k.useState)(null),[u,d]=(0,k.useState)(!1),[f,p]=(0,k.useState)(null),[m,g]=(0,k.useState)([]),[_,b]=(0,k.useState)(null),[x,C]=(0,k.useState)([]),{registerHandler:w,unregisterHandler:T}=n(),E=(0,k.useCallback)(()=>{o(null),c(null),fetch(`${l()}/plugins/${e}/preview-install`).then(e=>e.ok?e.json():Promise.reject(Error(`HTTP ${e.status}`))).then(e=>o(e)).catch(e=>c(e.message))},[e]);(0,k.useEffect)(()=>{E()},[E]),(0,k.useEffect)(()=>(w(`install-${e}`,t=>{let n=t;if(n.type===`plugin.install_progress`&&n.name===e&&n.line&&g(e=>[...e,n.line]),n.type===`plugin.prereq_install_progress`&&n.line&&C(e=>[...e,n.line]),n.type===`plugin.prereq_installed`){b(null);let e=n.reason;e&&C(t=>[...t,`► ${e}`]),n.ok&&E()}}),()=>T(`install-${e}`)),[e,w,T,E]);let D=async e=>{b(e),C([r(`installDialog.installingPrereq`,{name:e})]);try{await fetch(`${l()}/plugins/_prerequisites/${e}/install`,{method:`POST`})}catch(e){C(t=>[...t,r(`installDialog.prereqStartFailed`,{message:e.message})]),b(null)}},j=(a?.requirements??[]).every(e=>e.installed&&e.executable&&e.meetsMinimum);return(0,A.jsxs)(K,{onClose:t,title:r(`installDialog.title`,{name:e}),children:[s&&(0,A.jsx)(`div`,{className:`text-xs text-destructive`,children:s}),!a&&!s&&(0,A.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-muted-foreground`,children:[(0,A.jsx)(i,{className:`w-3 h-3 animate-spin`}),` `,r(`installDialog.computingChanges`)]}),a&&(0,A.jsxs)(A.Fragment,{children:[a.platformNote&&(0,A.jsxs)(`div`,{className:`flex items-start gap-2 p-2.5 rounded-md border border-yellow-500/30 aurora-light:border-accent-warning/30 bg-yellow-500/5 aurora-light:bg-accent-warning/10 text-[11px] leading-relaxed`,children:[(0,A.jsx)(v,{className:`w-3.5 h-3.5 text-yellow-500 aurora-light:text-accent-warning mt-0.5 flex-shrink-0`}),(0,A.jsx)(`span`,{children:a.platformNote})]}),(0,A.jsxs)(`section`,{children:[(0,A.jsx)(`h4`,{className:`text-xs font-semibold mb-1.5`,children:r(`installDialog.filesHeading`)}),(0,A.jsx)(`ul`,{className:`text-xs space-y-0.5 font-mono`,children:a.files.map((e,t)=>(0,A.jsxs)(`li`,{className:e.op===`create`?`text-accent-success`:`text-accent-info`,children:[e.op===`create`?`+ `:`~ `,e.path,e.summary&&(0,A.jsxs)(`span`,{className:`text-muted-foreground`,children:[` `,e.summary]})]},t))})]}),a.requirements.length>0&&(0,A.jsxs)(`section`,{children:[(0,A.jsx)(`h4`,{className:`text-xs font-semibold mb-1.5`,children:r(`installDialog.prerequisites`)}),(0,A.jsx)(`ul`,{className:`text-xs space-y-1`,children:a.requirements.map(e=>{let t=e.installed&&e.executable&&e.meetsMinimum,n=e.name===`uv`;return(0,A.jsxs)(`li`,{className:`flex items-center gap-2`,children:[t?(0,A.jsx)(S,{className:`w-3 h-3 text-accent-success`}):(0,A.jsx)(y,{className:`w-3 h-3 text-accent-warning`}),(0,A.jsxs)(`span`,{children:[e.name,e.minVersion?` ≥ ${e.minVersion}`:``]}),e.version&&(0,A.jsxs)(`span`,{className:`text-muted-foreground`,children:[`(`,e.version,`)`]}),!t&&n&&(0,A.jsxs)(`button`,{type:`button`,disabled:_===e.name,onClick:()=>D(e.name),className:`ml-auto text-[10px] px-2 py-0.5 rounded border border-border hover:bg-muted disabled:opacity-50 flex items-center gap-1`,children:[_===e.name&&(0,A.jsx)(i,{className:`w-2.5 h-2.5 animate-spin`}),r(`installDialog.autoInstall`)]})]},e.name)})}),x.length>0&&(0,A.jsx)(`pre`,{className:`mt-2 text-[11px] bg-muted/40 rounded p-2 max-h-24 overflow-auto font-mono`,children:x.join(`
|
|
2
|
+
`)})]}),m.length>0&&(0,A.jsxs)(`section`,{children:[(0,A.jsx)(`h4`,{className:`text-xs font-semibold mb-1.5`,children:r(`installDialog.progress`)}),(0,A.jsx)(`pre`,{className:`text-[11px] bg-muted/40 rounded p-2 max-h-32 overflow-auto font-mono`,children:m.join(`
|
|
3
|
+
`)})]}),f&&(0,A.jsx)(`div`,{className:`text-xs text-destructive`,children:f})]}),(0,A.jsxs)(`div`,{className:`flex justify-end gap-2 pt-2`,children:[(0,A.jsx)(`button`,{type:`button`,onClick:t,className:`text-xs px-3 py-1.5 rounded-md border border-border`,children:r(`common:actions.cancel`)}),(0,A.jsxs)(`button`,{type:`button`,disabled:!a||!j||u,onClick:async()=>{d(!0),p(null);try{let n=await fetch(`${l()}/plugins/${e}/install`,{method:`POST`});if(!n.ok)throw Error((await n.json()).error??`HTTP ${n.status}`);setTimeout(t,1500)}catch(e){p(e.message)}finally{d(!1)}},className:`text-xs px-3 py-1.5 rounded-md bg-accent-primary text-white disabled:opacity-50 flex items-center gap-1.5`,children:[u?(0,A.jsx)(i,{className:`w-3 h-3 animate-spin`}):(0,A.jsx)(h,{className:`w-3 h-3`}),r(`card.install`)]})]})]})}function G({pluginName:e,onClose:t,onUninstalled:n}){let{t:r}=O(`integrations`),[a,o]=(0,k.useState)(!1),[s,c]=(0,k.useState)(null);return(0,A.jsxs)(K,{onClose:t,title:r(`uninstallDialog.title`,{name:e}),children:[(0,A.jsx)(`p`,{className:`text-xs`,children:(0,A.jsx)(d,{t:r,i18nKey:`uninstallDialog.body`,components:{code:(0,A.jsx)(`code`,{})}})}),s&&(0,A.jsx)(`div`,{className:`text-xs text-destructive`,children:s}),(0,A.jsxs)(`div`,{className:`flex justify-end gap-2 pt-2`,children:[(0,A.jsx)(`button`,{type:`button`,onClick:t,className:`text-xs px-3 py-1.5 rounded-md border border-border`,children:r(`common:actions.cancel`)}),(0,A.jsxs)(`button`,{type:`button`,disabled:a,onClick:async()=>{o(!0);try{let t=await fetch(`${l()}/plugins/${e}`,{method:`DELETE`});if(!t.ok)throw Error((await t.json()).error??`HTTP ${t.status}`);n()}catch(e){c(e.message)}finally{o(!1)}},className:`text-xs px-3 py-1.5 rounded-md bg-destructive text-white disabled:opacity-50 flex items-center gap-1.5`,children:[a&&(0,A.jsx)(i,{className:`w-3 h-3 animate-spin`}),r(`card.uninstall`)]})]})]})}function K({title:e,onClose:n,children:r}){let{panelRef:i,panelStyle:a,headerHandleProps:o,resizeHandles:c,isFloating:l,guardBackdrop:u}=t();return(0,A.jsxs)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/40`,role:`dialog`,tabIndex:-1,onClick:u(n),children:[(0,A.jsxs)(`div`,{ref:i,className:`bg-card border border-border rounded-lg shadow-xl w-full max-w-md p-5 flex flex-col gap-3`,onClick:e=>e.stopPropagation(),style:a,children:[(0,A.jsx)(`h3`,{className:`text-sm font-semibold ${l?`cursor-grab active:cursor-grabbing`:``}`,...o,children:e}),r]}),(0,A.jsx)(s,{handles:c})]})}function q(){return(0,A.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4`,children:Array.from({length:3},(e,t)=>(0,A.jsx)(`div`,{className:`rounded-lg border border-border bg-card p-4 h-40 animate-pulse`},t))})}function J({onRetry:e}){let{t}=O(`integrations`);return(0,A.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-12 gap-3 text-sm text-muted-foreground`,children:[(0,A.jsx)(v,{className:`w-5 h-5 text-destructive`}),(0,A.jsx)(`p`,{children:t(`page.loadError`)}),(0,A.jsx)(`button`,{type:`button`,onClick:e,className:`text-xs px-3 py-1.5 rounded-md border border-border`,children:t(`common:actions.retry`)})]})}function Y(){let{t:e}=O(`integrations`);return(0,A.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-12 gap-2 text-sm text-muted-foreground`,children:[(0,A.jsx)(u,{className:`w-6 h-6`}),(0,A.jsx)(`p`,{children:e(`page.empty`)})]})}export{L as default};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import{a as e}from"./chunk-BNv3lrIs.js";import{a as t}from"./auth-Cvsb7-Ek.js";import{t as n}from"./brain-Dia32foa.js";import{B as r,Cn as i,Ct as a,Ft as o,Gt as s,Ht as c,Lt as l,M as u,Ot as d,Qt as f,Rn as p,Sn as m,Tn as h,U as g,V as _,_n as v,a as y,cn as b,dt as x,g as S,i as C,it as w,j as T,nn as E,o as D,on as O,ot as k,pn as A,pt as j,qn as M,r as N,rn as P,rt as F,sn as ee,tn as I,vt as L,w as R,wn as te,xt as ne,yn as re,yt as ie,zn as z}from"./index-BbVOi-dY.js";import{t as ae}from"./lib-BxSZPd0W.js";var oe=v(`chevrons-down-up`,[[`path`,{d:`m7 20 5-5 5 5`,key:`13a0gw`}],[`path`,{d:`m7 4 5 5 5-5`,key:`1kwcof`}]]),se=v(`chevrons-up-down`,[[`path`,{d:`m7 15 5 5 5-5`,key:`1hf1tw`}],[`path`,{d:`m7 9 5-5 5 5`,key:`sgt6xg`}]]),B=v(`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 V(e){return e.command.startsWith(`loop:`)?`loop-run`:e.interactive?`interactive`:`job`}var H=15e3;function ce(e){if(typeof AbortSignal<`u`&&typeof AbortSignal.timeout==`function`)return AbortSignal.timeout(e)}async function le(e){let{projectId:n,jobId:r,timeoutMs:i=H}=e,a=n?`${t}/api/projects/${n}`:h(),o;try{o=await fetch(`${a}/jobs/${r}`,{method:`DELETE`,signal:ce(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 U=te();function ue({phases:e,phaseDefinitions:t}){return t.length===0?null:(0,U.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,U.jsxs)(`div`,{className:`flex items-center`,children:[(0,U.jsxs)(r,{children:[(0,U.jsx)(g,{asChild:!0,children:(0,U.jsxs)(`div`,{className:`flex flex-col items-center gap-1.5 cursor-default px-4`,children:[(0,U.jsx)(de,{state:a}),(0,U.jsx)(`span`,{className:w(`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,U.jsxs)(_,{side:`bottom`,className:`max-w-[200px]`,children:[(0,U.jsx)(`p`,{className:`font-medium`,children:n.label}),(0,U.jsx)(`p`,{className:`text-muted-foreground mt-0.5`,children:n.description})]})]}),o!==null&&(0,U.jsx)(`div`,{className:w(`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 de({state:e}){return(0,U.jsxs)(`div`,{className:w(`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,U.jsx)(o,{className:`w-6 h-6 text-blue-400 aurora-light:text-accent-info animate-spin`}),e===`done`&&(0,U.jsx)(P,{className:`w-6 h-6 text-emerald-400 aurora-light:text-accent-success`}),e===`error`&&(0,U.jsx)(E,{className:`w-6 h-6 text-red-400 aurora-light:text-destructive`}),e===`idle`&&(0,U.jsx)(I,{className:`w-6 h-6 text-muted-foreground/20`})]})}var W=e(M(),1);function fe(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 G=new Set;function K({ticketId:e,onOpen:t,children:n}){let{t:r}=z(`agent`),i=r(`refs.openTicket`,{id:e});return(0,U.jsx)(`button`,{type:`button`,"data-testid":`log-ticket-ref`,onClick:n=>{n.stopPropagation(),t(e)},title:i,"aria-label":i,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,G);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,U.jsx)(K,{ticketId:e.ticketId,onOpen:t,children:e.label},n):(0,U.jsx)(W.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,G);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}=re(),{openRef:n}=D(),r=e??t??void 0;return(0,W.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}:fe(t)?{id:n,content:t,type:`assistant`,timestamp:r}:{id:n,content:t,type:`plain`,timestamp:r}:null}catch{return null}if(e.event_type!==`log`&&e.event_type!==`result`)return null;if(e.event_type===`result`)try{let t=JSON.parse(e.payload),i=[];return t.duration_ms&&i.push(`${(t.duration_ms/1e3).toFixed(1)}s`),t.total_cost_usd&&i.push(`$${t.total_cost_usd.toFixed(4)}`),t.num_turns&&i.push(m.t(`jobs:logViewer.turns`,{count:t.num_turns})),{id:n,content:`▸ ${m.t(`jobs:logViewer.completed`)}${i.length?` — ${i.join(` · `)}`:``}`,type:`result`,timestamp:r}}catch{return null}return null}function 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:i}=z(`jobs`),[a,o]=(0,W.useState)(``),[s,c]=(0,W.useState)(!0),[l,u]=(0,W.useState)(new Set),d=(0,W.useRef)(null),m=(0,W.useRef)(null),h=ye(n),{processedLines:g,groups:_,totalLines:v}=(0,W.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,i.language]),y=(0,W.useMemo)(()=>{if(!a)return v;let e=a.toLowerCase();return g.filter(t=>t.content.toLowerCase().includes(e)).length},[a,g,v]),b=(0,W.useCallback)(()=>{let e=m.current;e&&(e.scrollTop=e.scrollHeight)},[]);(0,W.useEffect)(()=>{s&&b()},[e.length,s,b]);function x(){let e=m.current;e&&c(e.scrollHeight-e.scrollTop-e.clientHeight<50)}function C(e){u(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})}return t?(0,U.jsx)(`div`,{className:`flex-1 flex items-center justify-center`,children:(0,U.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:r(`logViewer.loading`)})}):v===0?(0,U.jsx)(`div`,{className:`flex-1 flex items-center justify-center`,children:(0,U.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:r(`logViewer.empty`)})}):(0,U.jsxs)(`div`,{className:`flex flex-col h-full`,children:[(0,U.jsxs)(`div`,{className:`px-4 py-2 border-b border-border flex items-center gap-2`,children:[(0,U.jsxs)(`div`,{className:`relative flex-1 max-w-xs`,children:[(0,U.jsx)(ie,{className:`absolute left-2.5 top-1/2 -translate-y-1/2 w-3 h-3 text-muted-foreground`}),(0,U.jsx)(S,{placeholder:r(`logViewer.filterPlaceholder`),value:a,onChange:e=>o(e.target.value),className:`pl-7 h-7`})]}),(0,U.jsx)(F,{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(()=>{p.success(r(`logViewer.copySuccess`))}).catch(()=>{p.error(r(`logViewer.copyFailed`))})},children:(0,U.jsx)(f,{className:`w-3.5 h-3.5`})}),(0,U.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:r(`logViewer.lineCount`,{filtered:y,total:v})})]}),(0,U.jsxs)(`div`,{ref:m,className:`flex-1 overflow-y-auto p-2 text-xs relative`,onScroll:x,children:[_.map(e=>(0,U.jsx)(Te,{group:e,filter:a,collapsed:l.has(e.key),onToggle:()=>C(e.key),onOpenTicket:h},e.key)),(0,U.jsx)(`div`,{ref:d})]}),!s&&(0,U.jsxs)(F,{size:`sm`,variant:`secondary`,onClick:()=>{c(!0),b()},className:`absolute bottom-16 right-6 h-7 gap-1 shadow-lg`,children:[(0,U.jsx)(ee,{className:`w-3 h-3`}),r(`logViewer.jumpToBottom`)]})]})}var Te=(0,W.memo)(function({group:e,filter:t,collapsed:n,onToggle:r,onOpenTicket:i}){let{t:a}=z(`jobs`),o=t?e.lines.filter(e=>e.content.toLowerCase().includes(t.toLowerCase())):e.lines;if(e.header===null)return o.length===0?null:(0,U.jsx)(`div`,{children:o.map((e,t)=>(0,U.jsx)(q,{line:e,even:t%2==0,onOpenTicket:i},e.id))});let s=e.header.content;return(0,U.jsxs)(`div`,{className:`mt-3 rounded-md overflow-hidden border border-border/20`,children:[(0,U.jsxs)(`button`,{type:`button`,onClick:r,className:w(`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,U.jsx)(O,{className:w(`w-3 h-3 text-primary/60 shrink-0 transition-transform duration-150`,!n&&`rotate-90`)}),(0,U.jsx)(`span`,{className:`flex-1 text-[12px] font-semibold text-foreground leading-none`,children:s}),e.header.timestamp&&(0,U.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,U.jsx)(`span`,{className:`text-[10px] text-muted-foreground/40 shrink-0`,children:a(`logViewer.phaseLines`,{count:e.lines.length})})]}),!n&&(0,U.jsx)(`div`,{className:`bg-muted/5`,children:o.length===0?(0,U.jsx)(`p`,{className:`px-4 py-2 text-[10px] text-muted-foreground/40 italic`,children:a(t?`logViewer.noMatchingLines`:`logViewer.noOutput`)}):o.map((e,t)=>(0,U.jsx)(q,{line:e,even:t%2==0,onOpenTicket:i},e.id))})]})}),Ee=[ae],De=[T],Oe=[T,ve],q=(0,W.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`,c=i||a||o||s,l=n!=null&&(e.type===`plain`||e.type===`log`),d=(0,W.useMemo)(()=>l&&n?me(e.content,n):e.content,[l,n,e.content]),f=r&&n?Oe:De,p=(0,W.useMemo)(()=>n?{a:({href:e,children:t})=>{let r=C(e);return r?.kind===`ticket`?(0,U.jsx)(K,{ticketId:r.ticketId,onOpen:n,children:t}):(0,U.jsx)(`a`,{href:e,children:t})}}:void 0,[n]);return(0,U.jsxs)(`div`,{className:w(`flex items-start gap-2 group px-2 py-0.5 rounded-sm`,!c&&(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,U.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,U.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,U.jsx)(u,{remarkPlugins:f,rehypePlugins:Ee,components:p,children:e.content})}):(0,U.jsx)(`span`,{className:w(`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=R(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:d,"ai-step":n,shell:x,decider:c,condition:c,end:s},ze=j,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:i}=z(`jobs`);return e.length===0&&!t?null:(0,U.jsxs)(`div`,{"data-testid":`loop-overview-strip`,role:`list`,"aria-label":i(`loopExplorer.stepMapAria`),className:w(`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),a=Be[e.kind]??`text-foreground`,o=Ve[e.kind]??`border-border/40`,s=e.label??i(`loops:builder.nodes.${e.kind}`,{defaultValue:e.kind}),c=e.latestSegmentKey!=null;return(0,U.jsxs)(W.Fragment,{children:[t>0&&(0,U.jsx)(O,{className:`w-3 h-3 text-muted-foreground/30 shrink-0`}),(0,U.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":`${s} — ${e.state}`,disabled:!c,onClick:()=>e.latestSegmentKey&&n(e.latestSegmentKey),className:w(`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`,c?`cursor-pointer hover:bg-surface/70`:`cursor-default`),children:[e.state===`running`&&(0,U.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,U.jsx)(r,{className:w(`w-3 h-3 shrink-0`,a)}),(0,U.jsx)(`span`,{className:w(`max-w-[120px] truncate font-medium text-foreground/90`,e.state===`running`&&`title-shimmer`),children:s}),e.state===`ok`&&(0,U.jsx)(b,{className:`w-3 h-3 text-accent-success shrink-0`}),e.state===`failed`&&(0,U.jsx)(k,{className:`w-3 h-3 text-destructive shrink-0`}),e.decision===`continue`&&(0,U.jsx)(ne,{className:`w-3 h-3 text-accent-highlight shrink-0`}),e.decision===`stop`&&(0,U.jsx)(A,{className:`w-3 h-3 text-accent-success shrink-0`})]})]},e.key)}),t&&(0,U.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,U.jsx)(a,{className:`w-3 h-3`}),t.limit==null?i(`loopExplorer.iterationBadge`,{count:t.current}):i(`loopExplorer.iteration`,{current:t.current,limit:t.limit})]})]})}var We=(0,W.memo)(Ue);function Ge({className:e}){return(0,U.jsxs)(`span`,{className:w(`relative flex h-2 w-2 shrink-0`,e),children:[(0,U.jsx)(`span`,{className:`motion-safe:animate-ping absolute inline-flex h-full w-full rounded-full bg-accent-primary opacity-60`}),(0,U.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,U.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,U.jsx)(q,{line:e,even:t%2==0,onOpenTicket:r},e.id))}function Je({label:e,value:t,copyLabel:n}){let[r,i]=(0,W.useState)(!1),a=async()=>{try{await navigator.clipboard.writeText(t),i(!0),window.setTimeout(()=>i(!1),1500)}catch{}};return(0,U.jsxs)(`div`,{className:`min-w-0`,children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,U.jsx)(`span`,{className:`text-[9px] font-semibold uppercase tracking-wider text-muted-foreground/50`,children:e}),(0,U.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,U.jsx)(b,{className:`w-2.5 h-2.5 text-accent-success`}):(0,U.jsx)(f,{className:`w-2.5 h-2.5`})})]}),(0,U.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:i,onCopy:a,setRef:o,onOpenTicket:s}){let{t:c}=z(`jobs`),{meta:u,lines:d,end:p,lastActivity:m}=e,h=He(u.kind),g=Be[u.kind]??`text-foreground`,_=Ke(d,r),v=t===`running`,y=!!(u.template||u.command),[x,S]=(0,W.useState)(!1);return(0,U.jsxs)(`div`,{ref:t=>o(e.key,t),"data-testid":`loop-step-section`,"data-status":t,"data-step-index":u.index,className:w(`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,U.jsxs)(`div`,{className:w(`flex items-stretch bg-primary/5 border-b`,t===`failed`?`border-destructive/20`:`border-primary/20`),children:[(0,U.jsxs)(`button`,{type:`button`,onClick:()=>i(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,U.jsx)(O,{className:w(`w-3 h-3 text-primary/60 shrink-0 transition-transform duration-150`,!n&&`rotate-90`)}),(0,U.jsx)(`span`,{className:`text-[10px] font-mono tabular-nums text-muted-foreground/60 shrink-0 w-5 text-right`,children:u.index}),(0,U.jsx)(h,{className:w(`w-3.5 h-3.5 shrink-0`,g)}),(0,U.jsx)(`span`,{className:`text-[12px] font-semibold text-foreground leading-none truncate`,children:X(u)}),u.iteration!=null&&u.iteration>=1&&(0,U.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:c(`loopExplorer.iterationBadge`,{count:u.iteration})}),v&&(0,U.jsxs)(`span`,{className:`flex items-center gap-1.5 min-w-0 shrink-0 max-w-[40%]`,children:[(0,U.jsx)(Ge,{}),m&&(0,U.jsx)(`span`,{className:`title-shimmer text-[10px] truncate`,children:c(`statusPanel.activity.${m.actionKey}`,{arg:m.actionArg??``})})]}),t===`ok`&&(0,U.jsx)(b,{className:`w-3.5 h-3.5 text-accent-success shrink-0`}),t===`failed`&&(0,U.jsx)(k,{className:`w-3.5 h-3.5 text-destructive shrink-0`}),t===`interrupted`&&(0,U.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:c(`loopExplorer.interrupted`)}),(0,U.jsx)(`span`,{className:`flex-1`}),p?.durationMs!=null&&(0,U.jsx)(`span`,{className:`text-[10px] text-muted-foreground/50 font-mono tabular-nums shrink-0`,children:Le(p.durationMs)}),t===`failed`&&p?.exitCode!=null&&p.exitCode!==0&&(0,U.jsx)(`span`,{className:`text-[10px] text-destructive/70 font-mono shrink-0`,children:c(`activeJob.exitCode`,{code:p.exitCode})}),(0,U.jsx)(`span`,{className:`text-[10px] text-muted-foreground/40 shrink-0`,children:c(`logViewer.phaseLines`,{count:d.length})})]}),y&&(0,U.jsx)(`button`,{type:`button`,onClick:()=>S(e=>!e),"aria-label":c(`loopExplorer.stepDetail`),"aria-expanded":x,title:c(`loopExplorer.stepDetail`),className:w(`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,U.jsx)(l,{className:`w-3 h-3`})}),(0,U.jsx)(`button`,{type:`button`,onClick:()=>a(e.key),"aria-label":c(`loopExplorer.copyStep`),title:c(`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,U.jsx)(f,{className:`w-3 h-3`})})]}),x&&y&&(0,U.jsxs)(`div`,{"data-testid":`loop-step-detail`,className:w(`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:[u.template&&(0,U.jsx)(Je,{label:c(`loopExplorer.stepDetailTemplate`),value:u.template,copyLabel:c(`loopExplorer.copyCommand`)}),u.command&&(0,U.jsx)(Je,{label:c(`loopExplorer.stepDetailCommand`),value:u.command,copyLabel:c(`loopExplorer.copyCommand`)})]}),!n&&(0,U.jsx)(`div`,{className:`bg-muted/5`,children:qe(_,r,c,s)})]})}var Xe=(0,W.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:i,onOpenTicket:a}){let{t:o}=z(`jobs`),s=Ke(e,n);return(0,U.jsxs)(`div`,{ref:e=>i(Q,e),"data-testid":`loop-setup-section`,className:`rounded-md overflow-hidden border border-border/20`,children:[(0,U.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,U.jsx)(O,{className:w(`w-3 h-3 text-muted-foreground/60 shrink-0 transition-transform duration-150`,!t&&`rotate-90`)}),(0,U.jsx)(d,{className:`w-3.5 h-3.5 text-accent-success/70 shrink-0`}),(0,U.jsx)(`span`,{className:`text-[11px] font-semibold text-muted-foreground leading-none uppercase tracking-wide`,children:o(`loopExplorer.setup`)}),(0,U.jsx)(`span`,{className:`flex-1`}),(0,U.jsx)(`span`,{className:`text-[10px] text-muted-foreground/40 shrink-0`,children:o(`logViewer.phaseLines`,{count:e.length})})]}),!t&&(0,U.jsx)(`div`,{className:`bg-muted/5`,children:qe(s,n,o,a)})]})}var Qe=(0,W.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,U.jsxs)(`span`,{className:`relative flex h-1.5 w-1.5 shrink-0`,children:[(0,U.jsx)(`span`,{className:`motion-safe:animate-ping absolute inline-flex h-full w-full rounded-full bg-accent-primary opacity-60`}),(0,U.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:i}){let{t:a,i18n:o}=z(`jobs`),[s,c]=(0,W.useState)(``),[l,u]=(0,W.useState)(`follow`),[d,m]=(0,W.useState)(new Set),h=(0,W.useRef)(null),g=(0,W.useRef)(new Map),_=ye(i),v=(0,W.useMemo)(()=>Me(e),[e,o.language]),y=t!=null&&t!==`running`&&t!==`queued`,b=t===`running`,x=(0,W.useMemo)(()=>v.segments.map((e,t)=>Ne(e,{isLast:t===v.segments.length-1,jobSettled:y})),[v,y]),C=(0,W.useMemo)(()=>{let e=v.segments.map(e=>e.key);return v.setup.length>0&&e.push(Q),e},[v]),T=v.segments.length>0?v.segments[v.segments.length-1].key:Q,E=(0,W.useMemo)(()=>s?new Set(C):l===`follow`?new Set([T]):d,[s,l,T,d,C]),D=(0,W.useRef)(E);D.current=E;let O=(0,W.useRef)(v);O.current=v;let k=(0,W.useCallback)(e=>{let t=new Set(D.current);e?.(t),m(t),u(`manual`)},[]),A=(0,W.useCallback)(e=>{k(t=>{t.has(e)?t.delete(e):t.add(e)})},[k]),j=(0,W.useCallback)(e=>{k(t=>t.add(e)),requestAnimationFrame(()=>{g.current.get(e)?.scrollIntoView?.({behavior:`smooth`,block:`start`})})},[k]),M=(0,W.useCallback)(()=>{let e=h.current;e&&(e.scrollTop=e.scrollHeight)},[]),N=(0,W.useCallback)(()=>{u(`follow`),requestAnimationFrame(M)},[M]),P=(0,W.useCallback)(()=>{m(new Set(C)),u(`manual`)},[C]),ee=(0,W.useCallback)(()=>{m(new Set),u(`manual`)},[]);(0,W.useEffect)(()=>{l===`follow`&&!s&&M()},[v.totalLines,v.segments.length,l,s,M]);let I=(0,W.useCallback)(()=>{let e=h.current;!e||l!==`follow`||e.scrollHeight-e.scrollTop-e.clientHeight>80&&k()},[l,k]),L=(0,W.useCallback)((e,t)=>{t?g.current.set(e,t):g.current.delete(e)},[]),R=(0,W.useCallback)(e=>{let t=O.current.segments.find(t=>t.key===e),n=e===`__setup__`?O.current.setup.map(e=>e.content).join(`
|
|
17
|
+
`):(t?.lines??[]).map(e=>e.content).join(`
|
|
18
|
+
`);navigator.clipboard.writeText(n).then(()=>p.success(a(`loopExplorer.copied`))).catch(()=>p.error(a(`logViewer.copyFailed`)))},[a]),te=(0,W.useCallback)(()=>{let e=O.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(()=>p.success(a(`logViewer.copySuccess`))).catch(()=>p.error(a(`logViewer.copyFailed`)))},[a]),ne=(0,W.useMemo)(()=>Ie(v,{jobSettled:y,jobFailed:t===`failed`}),[v,y,t]),re=v.graphMeta?.iterationLimit??v.graphMeta?.graph.config.maxIterations??null,ae=v.maxIteration>0?{current:v.maxIteration,limit:re}:null,B=(0,W.useMemo)(()=>{if(!s)return v.totalLines;let e=s.toLowerCase(),t=v.setup.filter(t=>t.content.toLowerCase().includes(e)).length;for(let n of v.segments)t+=n.lines.filter(t=>t.content.toLowerCase().includes(e)).length;return t},[s,v]),V=v.segments[v.segments.length-1],H=b&&(v.segments.length===0||V?.end!=null);return n?(0,U.jsx)(`div`,{className:`flex-1 flex items-center justify-center h-full`,children:(0,U.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:a(`logViewer.loading`)})}):v.totalLines===0&&v.segments.length===0?(0,U.jsx)(`div`,{"data-testid":`loop-step-explorer`,className:`flex-1 flex items-center justify-center h-full`,children:(0,U.jsxs)(`p`,{className:`text-xs text-muted-foreground flex items-center gap-2`,children:[b&&(0,U.jsx)($,{}),a(b?`loopExplorer.waiting`:`logViewer.empty`)]})}):(0,U.jsxs)(`div`,{"data-testid":`loop-step-explorer`,className:`relative flex flex-col h-full`,children:[(0,U.jsxs)(`div`,{className:w(`border-b border-border flex items-center gap-2`,r===`glass`?`px-3 py-1.5`:`px-4 py-2`),children:[(0,U.jsxs)(`div`,{className:`relative flex-1 max-w-xs`,children:[(0,U.jsx)(ie,{className:`absolute left-2.5 top-1/2 -translate-y-1/2 w-3 h-3 text-muted-foreground`}),(0,U.jsx)(S,{placeholder:a(`logViewer.filterPlaceholder`),value:s,onChange:e=>c(e.target.value),className:`pl-7 h-7`})]}),(0,U.jsx)(F,{variant:`ghost`,size:`sm`,className:`h-7 px-2 text-muted-foreground/50 hover:text-foreground`,onClick:P,"aria-label":a(`loopExplorer.expandAll`),title:a(`loopExplorer.expandAll`),children:(0,U.jsx)(se,{className:`w-3.5 h-3.5`})}),(0,U.jsx)(F,{variant:`ghost`,size:`sm`,className:`h-7 px-2 text-muted-foreground/50 hover:text-foreground`,onClick:ee,"aria-label":a(`loopExplorer.collapseAll`),title:a(`loopExplorer.collapseAll`),children:(0,U.jsx)(oe,{className:`w-3.5 h-3.5`})}),l===`follow`&&b&&(0,U.jsxs)(`span`,{className:`flex items-center gap-1.5 text-[10px] text-accent-primary shrink-0`,children:[(0,U.jsx)($,{}),a(`loopExplorer.follow`)]}),(0,U.jsx)(`span`,{className:`flex-1`}),(0,U.jsx)(F,{variant:`ghost`,size:`sm`,className:`h-7 px-2 text-muted-foreground/50 hover:text-foreground`,onClick:te,"aria-label":a(`logViewer.copySuccess`),children:(0,U.jsx)(f,{className:`w-3.5 h-3.5`})}),(0,U.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:a(`logViewer.lineCount`,{filtered:B,total:v.totalLines})})]}),(0,U.jsx)(We,{chips:ne,iteration:ae,onChipClick:j,variant:r}),(0,U.jsxs)(`div`,{ref:h,onScroll:I,className:`flex-1 overflow-y-auto p-2 text-xs`,children:[v.setup.length>0&&(0,U.jsx)(Qe,{lines:v.setup,collapsed:!E.has(`__setup__`),filter:s,onToggle:A,setRef:L,onOpenTicket:_}),v.segments.map((e,t)=>(0,U.jsx)(Xe,{segment:e,status:x[t],collapsed:!E.has(e.key),filter:s,onToggle:A,onCopy:R,setRef:L,onOpenTicket:_},e.key)),H&&(0,U.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,U.jsx)($,{}),a(`loopExplorer.waiting`)]})]}),l===`manual`&&b&&!s&&(0,U.jsxs)(`button`,{type:`button`,"data-testid":`resume-follow-pill`,onClick:N,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,U.jsx)($,{}),a(`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 i()}catch{return null}}function nt({jobId:e,projectId:n,settleMode:i,initialAcceptingTurns:a,kind:s=`job`,variant:c=`page`,onFinalized:l}){let{t:u}=z(`jobs`),d=i??`finalize`,f=()=>n?`${t}/api/projects/${n}`:h(),[m,v]=(0,W.useReducer)(et,{streaming:!1,queued:0,totals:null,accepting:a??!0,finalizing:!1}),[y,b]=(0,W.useState)(``),[x,S]=(0,W.useState)(!1),C=(0,W.useRef)(null);(0,W.useEffect)(()=>{a!==void 0&&v({type:`accepting`,accepting:a})},[a]);let T=(0,W.useRef)(l);T.current=l;let E=tt(),D=(0,W.useId)();(0,W.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=s===`loop-step`&&!m.accepting;async function k(){let t=y.trim();if(!(!t||x||O)){S(!0);try{let n=await fetch(`${f()}/jobs/${e}/messages`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({text:t})});if(n.ok)b(``),requestAnimationFrame(()=>C.current?.focus());else if(n.status===409&&s===`loop-step`)v({type:`blocked`});else{let e=await n.json().catch(()=>({}));p.error(u(`detail.toast.sendFailed`),{description:e.error})}}catch{p.error(u(`detail.toast.networkError`))}finally{S(!1)}}}async function A(){if(!m.finalizing){v({type:`finalize-request`});try{let t=await fetch(`${f()}/jobs/${e}/finalize`,{method:`POST`});if(t.ok)p.success(u(d===`finalize`?`detail.toast.finalizeScheduled`:s===`loop-step`?`detail.toast.wrapUpStepScheduled`:`detail.toast.wrapUpScheduled`));else if(t.status===409&&s===`loop-step`)v({type:`blocked`}),v({type:`finalize-reject`});else{let e=await t.json().catch(()=>({}));p.error(u(`detail.toast.finalizeFailed`),{description:e.error}),v({type:`finalize-reject`})}}catch{p.error(u(`detail.toast.networkError`)),v({type:`finalize-reject`})}}}let j=x||O||!y.trim(),M=u(`detail.interactive.working`);return(0,U.jsxs)(`div`,{"data-testid":`interactive-job-composer`,className:w(`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`,c===`glass`?`border-border/30 bg-surface/30`:`border-border/40 bg-surface/40`),children:[(0,U.jsxs)(`div`,{className:`flex items-center justify-between gap-3 text-[11px] text-muted-foreground`,children:[(0,U.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[O?(0,U.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,U.jsx)(B,{className:`h-3 w-3 motion-safe:animate-pulse`}),u(`detail.interactive.waitingForStepShort`)]}):m.streaming?(0,U.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,U.jsx)(o,{className:`h-3 w-3 animate-spin text-accent-primary`}),(0,U.jsxs)(`span`,{className:`relative`,children:[M,(0,U.jsx)(`span`,{"aria-hidden":!0,className:`title-shimmer pointer-events-none absolute inset-0`,children:M})]})]}):(0,U.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,U.jsx)(`span`,{className:`h-1.5 w-1.5 rounded-full bg-accent-success motion-safe:animate-pulse`}),u(`detail.interactive.ready`)]}),m.queued>0&&(0,U.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:u(`detail.interactive.queued`,{count:m.queued})})]}),(0,U.jsxs)(`span`,{className:`flex shrink-0 items-center gap-3`,children:[m.totals&&(0,U.jsx)(`span`,{className:`tabular-nums`,children:u(`detail.interactive.liveTotals`,{turns:m.totals.num_turns,cost:m.totals.total_cost_usd.toFixed(4)})}),d===`finalize`?(0,U.jsxs)(r,{children:[(0,U.jsx)(g,{asChild:!0,children:(0,U.jsxs)(F,{variant:`outline`,size:`sm`,onClick:()=>void A(),disabled:m.finalizing,className:`h-7 border-accent-success/40 text-accent-success hover:bg-accent-success/10`,children:[(0,U.jsx)(P,{className:`mr-1.5 h-3.5 w-3.5`}),m.finalizing?u(`detail.finalizing`):u(`detail.finalizeJob`)]})}),(0,U.jsx)(_,{children:u(`detail.finalizeJobTooltip`)})]}):(0,U.jsxs)(r,{children:[(0,U.jsx)(g,{asChild:!0,children:(0,U.jsx)(`button`,{type:`button`,onClick:()=>void A(),disabled:m.finalizing||O,className:w(`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:m.finalizing?u(`detail.interactive.wrappingUp`):u(s===`loop-step`?`detail.interactive.wrapUpStep`:`detail.interactive.wrapUp`)})}),(0,U.jsx)(_,{children:u(s===`loop-step`?`detail.interactive.wrapUpStepTooltip`:`detail.interactive.wrapUpTooltip`)})]})]})]}),d===`auto`&&(0,U.jsx)(`p`,{className:`text-[11px] leading-snug text-muted-foreground/60`,children:u(O?`detail.interactive.waitingForStep`:`detail.interactive.autoHint`)}),(0,U.jsxs)(`div`,{className:`flex items-end gap-2`,children:[(0,U.jsx)(`textarea`,{ref:C,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:u(O?`detail.interactive.waitingForStepShort`:`detail.interactive.placeholder`),"aria-label":u(`detail.interactive.placeholder`),disabled:O,className:w(`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,U.jsxs)(r,{children:[(0,U.jsx)(g,{asChild:!0,children:(0,U.jsx)(`span`,{className:`shrink-0`,children:(0,U.jsxs)(F,{size:`sm`,onClick:()=>void k(),disabled:j,className:`h-9`,children:[(0,U.jsx)(L,{className:`mr-1.5 h-3.5 w-3.5`}),u(`detail.interactive.send`)]})})}),j&&!x&&(0,U.jsx)(_,{children:u(O?`detail.interactive.sendDisabledWaiting`:`detail.interactive.sendDisabledEmpty`)})]})]})]})}export{le as a,ue as i,$e as n,V as o,we as r,nt as t};
|