farming-code 2.2.14 → 2.2.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -3
- package/README.zh_cn.md +3 -3
- package/THIRD_PARTY_NOTICES.md +17 -1
- package/backend/acp/packaged-codex-acp.js +13 -0
- package/backend/acp-runtime.js +413 -24
- package/backend/agent-manager.js +572 -557
- package/backend/agent-provider-session.js +15 -1
- package/backend/agent-runtime-binding.js +9 -55
- package/backend/chat-runtime.js +28 -0
- package/backend/codex-rollout-follower.js +83 -0
- package/backend/codex-session-archive.js +12 -1
- package/backend/codex-session-history.js +94 -0
- package/backend/codex-transcript.js +2 -1
- package/backend/config-manager.js +25 -17
- package/backend/control-api.js +3 -1
- package/backend/farming-app-cli.js +21 -0
- package/backend/farming-session-store.js +2 -1
- package/backend/native-pty-host-client.js +59 -2
- package/backend/npm-update-helper.js +65 -7
- package/backend/provider-adapters.js +123 -38
- package/backend/provider-session-service.js +138 -34
- package/backend/server.js +94 -105
- package/backend/storage-layout.js +5 -16
- package/backend/update-service.js +94 -5
- package/backend/usage-history-client.js +305 -0
- package/backend/usage-history-scanner.generated.js +2250 -0
- package/backend/usage-history-scanner.ts +2718 -0
- package/backend/usage-history-smoke.js +64 -0
- package/backend/usage-history-worker.js +34 -0
- package/backend/usage-monitor.js +188 -588
- package/backend/vendor/usage-parsers/CC_STATISTICS_LICENSE +21 -0
- package/backend/vendor/usage-parsers/CODEXBAR_LICENSE +21 -0
- package/backend/vendor/usage-parsers/VENDOR.json +45 -0
- package/dist/acp/LICENSE.codex-acp +190 -0
- package/dist/acp/codex-acp-1.1.4.js +30718 -0
- package/dist/assets/App-6yWdwzj8.js +210 -0
- package/dist/assets/{FileEditorMarkdownPreview-UlVd0O4D.js → FileEditorMarkdownPreview-R0jwwLME.js} +4 -4
- package/dist/assets/FileEditorPane-DNy3LAqS.js +2 -0
- package/dist/assets/{IconGlyphs-AU22gPDY.js → IconGlyphs-BsUfqpKN.js} +1 -1
- package/dist/assets/ProjectFilesSection-BhDEUVHA.js +12 -0
- package/dist/assets/{ReviewPage-CeDKDyZh.js → ReviewPage-ChtByBe3.js} +1 -1
- package/dist/assets/{abnfDiagram-VRR7QNED-BgawzDQT.js → abnfDiagram-VRR7QNED-nnglrXFi.js} +1 -1
- package/dist/assets/{architectureDiagram-ZJ3FMSHR-DUShwPg0.js → architectureDiagram-ZJ3FMSHR-BEXMaFfY.js} +1 -1
- package/dist/assets/{blockDiagram-677ZJIJ3-CeGZviXR.js → blockDiagram-677ZJIJ3-1mCezSBk.js} +1 -1
- package/dist/assets/{c4Diagram-LMCZKHZV-CLhYht6S.js → c4Diagram-LMCZKHZV-DhTiI6Uv.js} +1 -1
- package/dist/assets/channel-BVWNatUB.js +1 -0
- package/dist/assets/{chunk-32BRIVSS-LFYpT-Cu.js → chunk-32BRIVSS-CCdsKd73.js} +1 -1
- package/dist/assets/{chunk-52WLFC77-BH6jDw9J.js → chunk-52WLFC77-Gncjk4LF.js} +1 -1
- package/dist/assets/{chunk-C7G6YPKG-B_mIUlb7.js → chunk-C7G6YPKG-CiDVUP82.js} +1 -1
- package/dist/assets/{chunk-EX3LRPZG-C63hVuAJ.js → chunk-EX3LRPZG-z6gXP2_N.js} +1 -1
- package/dist/assets/{chunk-FWX5IMBZ-CboX-WF_.js → chunk-FWX5IMBZ-DMZBccQa.js} +2 -2
- package/dist/assets/{chunk-HOUHSVGY-BOgSd6Un.js → chunk-HOUHSVGY-D8tIeoPk.js} +1 -1
- package/dist/assets/{chunk-ICXQ74PX-C0K-pgZt.js → chunk-ICXQ74PX-b6oQ2Q17.js} +1 -1
- package/dist/assets/{chunk-MOJQB5TN-CVMfwN_7.js → chunk-MOJQB5TN-DAVH_p2a.js} +1 -1
- package/dist/assets/{chunk-OGEWGWER-DLT3pxyw.js → chunk-OGEWGWER-DxoiMCI-.js} +1 -1
- package/dist/assets/{chunk-PUDLZKDR-Cd079yIQ.js → chunk-PUDLZKDR-NsOWh7HM.js} +1 -1
- package/dist/assets/{chunk-Q4XR5HBZ-D0jHa6SO.js → chunk-Q4XR5HBZ-Di4H7L21.js} +1 -1
- package/dist/assets/{chunk-V7JOEXUC-CVDtR75H.js → chunk-V7JOEXUC-DttpZg9Y.js} +1 -1
- package/dist/assets/{chunk-VAUOI2AC-B-W2_9Ot.js → chunk-VAUOI2AC-UHNr_yhX.js} +1 -1
- package/dist/assets/{chunk-VR4S4FIN-FD3kWh32.js → chunk-VR4S4FIN-D-Fmtd4Z.js} +1 -1
- package/dist/assets/{chunk-WYO6CB5R-C2bGaS5r.js → chunk-WYO6CB5R-CUxMtfK2.js} +4 -4
- package/dist/assets/{chunk-ZGVPDNZ5-ymgts0zo.js → chunk-ZGVPDNZ5-CoV2QEl0.js} +1 -1
- package/dist/assets/classDiagram-OUVF2IWQ-Db0ib5iE.js +1 -0
- package/dist/assets/classDiagram-v2-EOCWNBFH-Bkf69XF9.js +1 -0
- package/dist/assets/code-dark-5esj0bRu.css +1 -0
- package/dist/assets/{cynefinDiagram-TSTJHNR4-CwpobXIl.js → cynefinDiagram-TSTJHNR4-0xPI92Lg.js} +1 -1
- package/dist/assets/{dagre-VKFMJZFB-Dkhlfjna.js → dagre-VKFMJZFB-DfuMG4gU.js} +1 -1
- package/dist/assets/{diagram-FQU43EPY-hA8dicp6.js → diagram-FQU43EPY-CT00bLZ6.js} +1 -1
- package/dist/assets/{diagram-G47NLZAW-BTY6JTzO.js → diagram-G47NLZAW-Xbh7zXUx.js} +1 -1
- package/dist/assets/{diagram-NH7WQ7WH-xkaHHX9M.js → diagram-NH7WQ7WH-SRDVPfn7.js} +1 -1
- package/dist/assets/{diagram-OA4YK3LP-gk_fg9UU.js → diagram-OA4YK3LP-CQRli4Np.js} +1 -1
- package/dist/assets/{diagram-WEI45ONY-BvC8xd6T.js → diagram-WEI45ONY-DMf17WQi.js} +1 -1
- package/dist/assets/{ebnfDiagram-CCIWWBDH-CR7RaNat.js → ebnfDiagram-CCIWWBDH-DhpFkgJ5.js} +1 -1
- package/dist/assets/{erDiagram-Q63AITRT-_M-JFPbj.js → erDiagram-Q63AITRT-1IwxWmJo.js} +1 -1
- package/dist/assets/file-icons-DpbrD5ZP.js +1 -0
- package/dist/assets/flowDiagram-23GEKE2U-DYFo2xmB.js +1 -0
- package/dist/assets/{ganttDiagram-NO4QXBWP-Bl8P1yf_.js → ganttDiagram-NO4QXBWP-BNCdfyr1.js} +1 -1
- package/dist/assets/{gitGraphDiagram-IHSO6WYX-DoHa5ysz.js → gitGraphDiagram-IHSO6WYX-pbyWZuiX.js} +1 -1
- package/dist/assets/{index-BA-iH2Kg.js → index-C8ZFKye1.js} +2 -2
- package/dist/assets/{infoDiagram-FWYZ7A6U-DSFcSuUs.js → infoDiagram-FWYZ7A6U-BcTOgDbe.js} +1 -1
- package/dist/assets/{ishikawaDiagram-FXEZZL3T-DdkqullI.js → ishikawaDiagram-FXEZZL3T-DCdvGKrn.js} +1 -1
- package/dist/assets/{journeyDiagram-5HDEW3XC-B4hRnQJr.js → journeyDiagram-5HDEW3XC-BZ-1q_IT.js} +1 -1
- package/dist/assets/{kanban-definition-HUTT4EX6-tm2FZB2E.js → kanban-definition-HUTT4EX6-BIgejCjj.js} +1 -1
- package/dist/assets/{line-CmsjK4kn.js → line-CfptFMmX.js} +1 -1
- package/dist/assets/main-DSO3i_Gs.css +1 -0
- package/dist/assets/{mermaid.core-C7UT_EEL.js → mermaid.core-gSpX30pV.js} +3 -3
- package/dist/assets/{mindmap-definition-LN4V7U3C-DplfjGms.js → mindmap-definition-LN4V7U3C-BKBaI4LW.js} +1 -1
- package/dist/assets/{pegDiagram-2B236MQR-lu3SdkQs.js → pegDiagram-2B236MQR-sBvDY3VX.js} +1 -1
- package/dist/assets/{pieDiagram-ENE6RG2P-3fHbmDf9.js → pieDiagram-ENE6RG2P-DWlWcu08.js} +1 -1
- package/dist/assets/{quadrantDiagram-ABIIQ3AL-a5qoWz-X.js → quadrantDiagram-ABIIQ3AL-DZutUd3J.js} +1 -1
- package/dist/assets/{railroadDiagram-RFXS5EU6-D2TOuXW9.js → railroadDiagram-RFXS5EU6-DQb3lXGM.js} +1 -1
- package/dist/assets/{requirementDiagram-TGXJPOKE-LQBWpUvd.js → requirementDiagram-TGXJPOKE-DqFGXu2e.js} +1 -1
- package/dist/assets/{sankeyDiagram-HTMAVEWB-B1ohYoyK.js → sankeyDiagram-HTMAVEWB-d7ECahnO.js} +1 -1
- package/dist/assets/{sequenceDiagram-DBY2YBRQ-C3vM-hMq.js → sequenceDiagram-DBY2YBRQ-DdsbKqct.js} +1 -1
- package/dist/assets/{stateDiagram-2N3HPSRC-BvFhOryI.js → stateDiagram-2N3HPSRC-P6iSrgwR.js} +1 -1
- package/dist/assets/stateDiagram-v2-6OUMAXLB-DIYSf_qh.js +1 -0
- package/dist/assets/{swimlanes-5IMT3BWC-DKF_b-2s.js → swimlanes-5IMT3BWC-BGnZJx1M.js} +1 -1
- package/dist/assets/swimlanesDiagram-G3AALYLV-BIkrlKrZ.js +8 -0
- package/dist/assets/{timeline-definition-FHXFAJF6-vAs11ux_.js → timeline-definition-FHXFAJF6-rA-r3aUR.js} +1 -1
- package/dist/assets/{vennDiagram-L72KCM5P-BybTX_9B.js → vennDiagram-L72KCM5P-DiVKUjA9.js} +1 -1
- package/dist/assets/{wardleyDiagram-EHGQE667-CicUmMBR.js → wardleyDiagram-EHGQE667-Cfxh7UOn.js} +1 -1
- package/dist/assets/workspace-editor-model-D0Im34S5.js +1 -0
- package/dist/assets/{workspace-editor-monaco-BICJESG0.js → workspace-editor-monaco-BIpqcWf1.js} +1 -1
- package/dist/assets/workspace-editor-monaco-DLlws5Ig.js +1 -0
- package/dist/assets/{workspace-view-state-DvYG_9PH.js → workspace-view-state-BpPINu84.js} +1 -1
- package/dist/assets/{xychartDiagram-FW5EYKEG-BhWDyCX-.js → xychartDiagram-FW5EYKEG--hmryQeL.js} +1 -1
- package/dist/crt-mermaid-renderer.js +313 -313
- package/dist/index.html +1 -1
- package/frontend/session-bridge.js +24 -2
- package/frontend/skins/crt/app.js +203 -85
- package/frontend/skins/crt/index.html +2 -11
- package/frontend/skins/crt/styles/effects.css +2 -34
- package/package.json +30 -12
- package/shared/backend-connection-status.d.ts +25 -0
- package/shared/backend-connection-status.js +40 -0
- package/shared/browser-protocol.js +3 -3
- package/backend/app-server-api.js +0 -917
- package/backend/codex-app-server-home.js +0 -39
- package/backend/codex-app-server-runtime.js +0 -901
- package/dist/assets/App-Bumi772v.js +0 -206
- package/dist/assets/FileEditorPane-Dxx4rKOg.js +0 -2
- package/dist/assets/ProjectFilesSection-DE7Nb9Jk.js +0 -12
- package/dist/assets/channel-Uw90AO0b.js +0 -1
- package/dist/assets/classDiagram-OUVF2IWQ-DKW_dtku.js +0 -1
- package/dist/assets/classDiagram-v2-EOCWNBFH-C8Fi7-yv.js +0 -1
- package/dist/assets/code-dark-DPiuyeSp.css +0 -1
- package/dist/assets/code-mobile-3C2Rr-CN.css +0 -1
- package/dist/assets/file-icons-Bw2qd5iT.js +0 -1
- package/dist/assets/flowDiagram-23GEKE2U-DAiS5Y7G.js +0 -1
- package/dist/assets/main-Bqtb5kuz.css +0 -1
- package/dist/assets/stateDiagram-v2-6OUMAXLB-WMrz4PNo.js +0 -1
- package/dist/assets/swimlanesDiagram-G3AALYLV-BGswC9oC.js +0 -8
- package/dist/assets/workspace-editor-model-BQol4qbA.js +0 -1
- package/dist/assets/workspace-editor-monaco-DRJ7IaXk.js +0 -1
- package/scripts/sync-ghostty-vendor.js +0 -66
- /package/dist/assets/{core-D0LFJkDt.js → core-B9MwRjDE.js} +0 -0
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{r as e}from"./chunk-DECur_0Z.js";import{i as t,t as n}from"./jsx-runtime-BthL93pI.js";import{c as r,s as i}from"./editor.api2-B9h6iFPK.js";import{r as a}from"./monaco.contribution-BXz-lfFB.js";import{C as o,E as s,T as c,b as l,g as u,k as d,l as f,m as p,n as m,o as h,r as g,s as _,u as v,v as y}from"./file-icons-Bw2qd5iT.js";import{_ as b}from"./IconGlyphs-AU22gPDY.js";import{d as x,t as S}from"./FileEditorMarkdownPreview-UlVd0O4D.js";import{i as C,l as w,n as T,p as E,r as D,t as O,u as k}from"./workspace-working-copy-D8-s_Sgh.js";import{A,C as ee,D as j,E as M,M as N,O as P,_ as F,a as I,b as te,d as L,f as R,g as ne,h as re,j as ie,k as z,m as ae,n as oe,o as se,p as B,r as ce,t as V,u as le,v as ue,w as H,y as de}from"./workspace-editor-model-BQol4qbA.js";import{t as fe}from"./useWorkspaceMenuKeyboard-Brws6Ar9.js";import{a as U,c as pe,d as W,f as me,h as he,l as G,m as ge,n as _e,r as ve,s as ye,t as K,u as be}from"./workspace-editor-monaco-BICJESG0.js";var q=e(t()),J=n();function xe({previewOpen:e}){return e?(0,J.jsx)(`svg`,{className:`code-file-editor-action-svg`,width:`16`,height:`16`,viewBox:`0 0 16 16`,fill:`currentColor`,"aria-hidden":`true`,focusable:`false`,children:(0,J.jsx)(`path`,{d:`M9 3.5V11.5C9 11.776 8.776 12 8.5 12C8.224 12 8 11.776 8 11.5V4.831L5.376 7.83C5.187 8.048 4.814 8.048 4.624 7.83L2 4.831V11.5C2 11.776 1.776 12 1.5 12C1.224 12 1 11.776 1 11.5V3.5C1 3.292 1.129 3.105 1.324 3.032C1.521 2.96 1.74 3.014 1.876 3.171L5 6.741L8.124 3.171C8.261 3.014 8.478 2.959 8.676 3.032C8.871 3.105 9 3.292 9 3.5ZM14.854 9.146C14.659 8.951 14.342 8.951 14.147 9.146L13.001 10.292V3.5C13.001 3.224 12.777 3 12.501 3C12.225 3 12.001 3.224 12.001 3.5V10.293L10.855 9.147C10.66 8.952 10.343 8.952 10.148 9.147C9.953 9.342 9.953 9.659 10.148 9.854L12.148 11.854C12.246 11.952 12.757 11.952 12.855 11.854L14.855 9.854C15.05 9.659 15.05 9.342 14.855 9.147L14.854 9.146Z`})}):(0,J.jsx)(`svg`,{className:`code-file-editor-action-svg`,width:`16`,height:`16`,viewBox:`0 0 16 16`,fill:`currentColor`,"aria-hidden":`true`,focusable:`false`,children:(0,J.jsx)(`path`,{d:`M12.5 1H3.5C2.122 1 1 2.122 1 3.5V12.5C1 13.878 2.122 15 3.5 15H12.5C13.878 15 15 13.878 15 12.5V3.5C15 2.122 13.878 1 12.5 1ZM14 12.5C14 13.327 13.327 14 12.5 14H3.5C2.673 14 2 13.327 2 12.5V3.5C2 2.673 2.673 2 3.5 2H12.5C13.327 2 14 2.673 14 3.5V12.5ZM12 3H4C3.448 3 3 3.448 3 4V6C3 6.552 3.448 7 4 7H12C12.552 7 13 6.552 13 6V4C13 3.448 12.552 3 12 3ZM12 6H4V4H12V6ZM12 8H9C8.448 8 8 8.448 8 9V12C8 12.552 8.448 13 9 13H12C12.552 13 13 12.552 13 12V9C13 8.448 12.552 8 12 8ZM12 12H9V9H12V12ZM7 8.5C7 8.776 6.776 9 6.5 9H3.5C3.224 9 3 8.776 3 8.5C3 8.224 3.224 8 3.5 8H6.5C6.776 8 7 8.224 7 8.5ZM7 10.5C7 10.776 6.776 11 6.5 11H3.5C3.224 11 3 10.776 3 10.5C3 10.224 3.224 10 3.5 10H6.5C6.776 10 7 10.224 7 10.5ZM7 12.5C7 12.776 6.776 13 6.5 13H3.5C3.224 13 3 12.776 3 12.5C3 12.224 3.224 12 3.5 12H6.5C6.776 12 7 12.224 7 12.5Z`})})}function Y(){return(0,J.jsx)(`svg`,{className:`code-file-editor-action-svg`,width:`16`,height:`16`,viewBox:`0 0 16 16`,xmlns:`http://www.w3.org/2000/svg`,fill:`currentColor`,"aria-hidden":`true`,focusable:`false`,children:(0,J.jsx)(`path`,{d:`M5.5 2H2.5C1.673 2 1 2.673 1 3.5V12.5C1 13.327 1.673 14 2.5 14H5.5C6.327 14 7 13.327 7 12.5V3.5C7 2.673 6.327 2 5.5 2ZM2.5 3H5.5C5.775 3 6 3.224 6 3.5V5H2V3.5C2 3.224 2.225 3 2.5 3ZM5.5 13H2.5C2.225 13 2 12.776 2 12.5V6H6V12.5C6 12.776 5.775 13 5.5 13ZM13.5 2H10.5C9.673 2 9 2.673 9 3.5V12.5C9 13.327 9.673 14 10.5 14H13.5C14.327 14 15 13.327 15 12.5V3.5C15 2.673 14.327 2 13.5 2ZM10.5 3H13.5C13.775 3 14 3.224 14 3.5V8H10V3.5C10 3.224 10.225 3 10.5 3ZM13.5 13H10.5C10.225 13 10 12.776 10 12.5V10H14V12.5C14 12.776 13.775 13 13.5 13Z`})})}function Se(){return(0,J.jsx)(`svg`,{className:`code-file-editor-action-svg`,width:`16`,height:`16`,viewBox:`0 0 16 16`,fill:`currentColor`,"aria-hidden":`true`,focusable:`false`,children:(0,J.jsx)(`path`,{d:`M2.5 2C1.673 2 1 2.673 1 3.5V12.5C1 13.327 1.673 14 2.5 14H13.5C14.327 14 15 13.327 15 12.5V3.5C15 2.673 14.327 2 13.5 2H2.5ZM2 3.5C2 3.224 2.225 3 2.5 3H7.5V13H2.5C2.225 13 2 12.776 2 12.5V3.5ZM8.5 13V3H13.5C13.775 3 14 3.224 14 3.5V12.5C14 12.776 13.775 13 13.5 13H8.5ZM3.5 5H6V6H3.5V5ZM3.5 7H6V8H3.5V7ZM10 5H12.5V6H10V5ZM10 7H12.5V8H10V7ZM10 9H12.5V10H10V9Z`})})}function X(){return(0,J.jsxs)(`svg`,{className:`code-file-editor-action-svg`,width:`16`,height:`16`,viewBox:`0 0 16 16`,xmlns:`http://www.w3.org/2000/svg`,fill:`currentColor`,"aria-hidden":`true`,focusable:`false`,children:[(0,J.jsx)(`path`,{fillRule:`evenodd`,clipRule:`evenodd`,d:`M5 6.5V3.75C5 2.765 4.121 2.25 3.251 2.25C2.363 2.25 1.99 2.553 1.897 2.646C1.702 2.841 1.688 3.17 1.883 3.365C2.077 3.561 2.38 3.573 2.576 3.378C2.588 3.37 2.773 3.25 3.25 3.25C3.28 3.25 4 3.256 4 3.75V4.056C3.796 4.023 3.552 4 3.25 4C1.937 4 1.25 4.754 1.25 5.5C1.25 6.246 1.937 7 3.25 7C3.622 7 3.911 6.937 4.145 6.851C4.236 6.943 4.361 7 4.5 7C4.776 7 5 6.776 5 6.5ZM3.251 5C3.623 5 3.857 5.038 4.001 5.074V5.811C3.908 5.885 3.698 6 3.251 6C2.602 6 2.251 5.742 2.251 5.5C2.251 5.258 2.602 5 3.251 5Z`}),(0,J.jsx)(`path`,{fillRule:`evenodd`,clipRule:`evenodd`,d:`M8.001 7C9.104 7 10.001 5.991 10.001 4.75C10.001 3.509 9.104 2.5 8.001 2.5C7.635 2.5 7.296 2.619 7.001 2.813V1.5C7.001 1.224 6.777 1 6.501 1C6.225 1 6.001 1.224 6.001 1.5V6.5C6.001 6.776 6.225 7 6.501 7C6.718 7 6.898 6.86 6.967 6.666C7.27 6.873 7.621 7 8.001 7ZM8.001 3.5C8.553 3.5 9.001 4.061 9.001 4.75C9.001 5.439 8.553 6 8.001 6C7.449 6 7.001 5.439 7.001 4.75C7.001 4.061 7.449 3.5 8.001 3.5Z`}),(0,J.jsx)(`path`,{fillRule:`evenodd`,clipRule:`evenodd`,d:`M4.539 13.653C4.31 13.857 3.699 13.976 3.33 13.514C3.117 13.248 3 12.888 3 12.5C3 12.112 3.118 11.752 3.33 11.486C3.701 11.022 4.311 11.141 4.54 11.347C4.744 11.533 5.06 11.515 5.246 11.311C5.431 11.106 5.415 10.79 5.209 10.605C4.422 9.895 3.233 10.009 2.549 10.861C2.195 11.305 2 11.886 2 12.5C2 13.114 2.195 13.696 2.549 14.139C2.93 14.613 3.445 14.875 4 14.875C4.441 14.875 4.859 14.709 5.208 14.395C5.413 14.21 5.43 13.894 5.245 13.689C5.059 13.484 4.743 13.466 4.539 13.653Z`}),(0,J.jsx)(`path`,{d:`M12.5 4H11.5C11.224 4 11 4.224 11 4.5C11 4.776 11.224 5 11.5 5H12.5C12.775 5 13 5.224 13 5.5V11.499C13 11.775 12.775 11.999 12.5 11.999H8.707L9.853 10.853C10.048 10.658 10.048 10.341 9.853 10.146C9.658 9.951 9.341 9.951 9.146 10.146L7.146 12.146C7.049 12.244 7 12.372 7 12.5C7 12.628 7.048 12.756 7.146 12.854L9.146 14.854C9.341 15.049 9.658 15.049 9.853 14.854C10.048 14.659 10.048 14.342 9.853 14.147L8.707 13.001H12.5C13.327 13.001 14 12.328 14 11.501V5.5C14 4.673 13.327 4 12.5 4Z`})]})}function Ce(e,t,n){return e.showMarkdownPreview?n?t.showMarkdownSource:t.openMarkdownPreview:n?t.showFileSource:t.openFilePreview}function we({actions:e,copy:t,diffOpen:n,markdownSplitOpen:r,openFile:i,sourcePreviewOpen:a,wordWrapEnabled:o,statusText:s,onReload:c,onSave:l,onToggleMarkdownSplit:u,onToggleSourcePreview:d,onToggleWordWrap:f,onToggleDiff:p}){let m=e.showMarkdownPreview||e.showSourcePreview,h=Ce(e,t,a),g=r?t.closeMarkdownSplitPreview:t.openMarkdownSplitPreview;return(0,J.jsxs)(`div`,{className:`code-file-editor-actions`,children:[e.showStatus&&s&&(0,J.jsx)(`span`,{className:`code-file-editor-status ${i.externalChanged?`warning`:``}`,children:s}),e.showSave&&(0,J.jsx)(`button`,{type:`button`,className:`code-file-editor-action save`,onClick:()=>l(!1),disabled:i.saving,"aria-label":t.saveFile,title:t.saveFile}),e.showDiff&&(0,J.jsx)(`button`,{type:`button`,className:`code-file-editor-action diff ${n?`active`:``}`,onClick:p,disabled:i.saving,"aria-label":n?t.closeDiff:t.openFileDiff,title:n?t.closeDiff:t.openFileDiff,children:(0,J.jsx)(Y,{})}),m&&(0,J.jsx)(`button`,{type:`button`,className:`code-file-editor-action source-preview`,onClick:d,disabled:i.saving,"aria-label":h,title:h,children:(0,J.jsx)(xe,{previewOpen:a})}),e.showMarkdownPreview&&(0,J.jsx)(`button`,{type:`button`,className:`code-file-editor-action markdown-split ${r?`active`:``}`,onClick:u,disabled:i.saving,"aria-label":g,title:g,children:(0,J.jsx)(Se,{})}),e.showWordWrap&&(0,J.jsx)(`button`,{type:`button`,className:`code-file-editor-action word-wrap ${o?`active`:``}`,onClick:f,disabled:i.saving,"aria-pressed":o,"aria-label":o?t.disableWordWrap:t.enableWordWrap,title:o?t.disableWordWrap:t.enableWordWrap,children:(0,J.jsx)(X,{})}),e.showReload&&(0,J.jsx)(`button`,{type:`button`,className:`code-file-editor-action reload`,onClick:c,disabled:i.saving,"aria-label":t.reloadFile,title:t.reloadFile}),e.showOverwrite&&(0,J.jsx)(`button`,{type:`button`,className:`code-file-editor-action overwrite`,onClick:()=>l(!0),disabled:i.saving,"aria-label":t.overwriteChangedFile,title:t.overwriteChangedFile,children:(0,J.jsx)(b,{className:`code-file-editor-action-svg`})})]})}function Z({openFile:e,copy:t,onRevealInExplorer:n}){let r=(0,q.useMemo)(()=>M(e.file.path),[e.file.path]);return r.length<=1?(0,J.jsx)(`span`,{"aria-hidden":`true`}):(0,J.jsx)(`nav`,{className:`code-file-editor-breadcrumbs`,title:e.file.path,"aria-label":t.filePath,children:r.map((r,i,a)=>{let o=i===a.length-1,s=j(a,i);return(0,J.jsxs)(`button`,{type:`button`,className:`code-file-editor-breadcrumb ${o?`current`:``}`,onClick:()=>n(e.agentId,s,o?`file`:`directory`),"aria-label":t.revealInExplorer(s),children:[(0,J.jsx)(`span`,{className:`code-file-editor-breadcrumb-name`,children:r}),!o&&(0,J.jsx)(`span`,{className:`code-file-editor-breadcrumb-separator`,"aria-hidden":`true`})]},`${i}-${r}`)})})}function Te(){return(0,J.jsx)(`svg`,{className:`code-file-editor-action-svg`,width:`16`,height:`16`,viewBox:`0 0 16 16`,fill:`currentColor`,"aria-hidden":`true`,focusable:`false`,children:(0,J.jsx)(`path`,{d:`M13.5 8.00023H3.70701L7.85301 3.85423C8.04801 3.65923 8.04801 3.34223 7.85301 3.14723C7.65801 2.95223 7.34101 2.95223 7.14601 3.14723L2.14601 8.14723C1.95101 8.34223 1.95101 8.65923 2.14601 8.85423L7.14601 13.8542C7.24401 13.9522 7.37201 14.0002 7.50001 14.0002C7.62801 14.0002 7.75601 13.9512 7.85401 13.8542C8.04901 13.6592 8.04901 13.3422 7.85401 13.1472L3.70801 9.00123H13.501C13.777 9.00123 14.001 8.77723 14.001 8.50123C14.001 8.22523 13.777 8.00123 13.501 8.00123L13.5 8.00023Z`})})}function Ee(){return(0,J.jsx)(`svg`,{className:`code-file-editor-action-svg`,width:`16`,height:`16`,viewBox:`0 0 16 16`,fill:`currentColor`,"aria-hidden":`true`,focusable:`false`,children:(0,J.jsx)(`path`,{d:`M13.854 8.14576L8.854 3.14576C8.659 2.95076 8.342 2.95076 8.147 3.14576C7.952 3.34076 7.952 3.65776 8.147 3.85276L12.293 7.99876H2.5C2.224 7.99876 2 8.22276 2 8.49876C2 8.77476 2.224 8.99876 2.5 8.99876H12.293L8.147 13.1448C7.952 13.3398 7.952 13.6568 8.147 13.8518C8.245 13.9498 8.373 13.9978 8.501 13.9978C8.629 13.9978 8.757 13.9488 8.855 13.8518L13.855 8.85176C14.05 8.65676 14.05 8.33976 13.855 8.14476L13.854 8.14576Z`})})}function De(){return(0,J.jsx)(`svg`,{className:`code-file-editor-action-svg`,width:`16`,height:`16`,viewBox:`0 0 16 16`,fill:`currentColor`,"aria-hidden":`true`,focusable:`false`,children:(0,J.jsx)(`path`,{d:`M13 13.5C13 13.776 12.776 14 12.5 14C9.46198 14 6.99998 11.538 6.99998 8.50001V3.70701L4.35398 6.35301C4.15898 6.54801 3.84198 6.54801 3.64698 6.35301C3.45198 6.15801 3.45198 5.84101 3.64698 5.64601L7.14698 2.14601C7.34198 1.95101 7.65898 1.95101 7.85398 2.14601L11.354 5.64601C11.549 5.84101 11.549 6.15801 11.354 6.35301C11.159 6.54801 10.842 6.54801 10.647 6.35301L8.00098 3.70701V8.50001C8.00098 10.985 10.016 13 12.501 13C12.777 13 13.001 13.224 13.001 13.5H13Z`})})}function Oe({openFile:e,openFiles:t,copy:n,onBackToAgent:r,onSelectOpenFile:i,canNavigateBack:a,canNavigateForward:o,onNavigateHistory:s,onSetTabRef:c,onOpenTabContextMenu:l,onTabAuxClick:u,onTabKeyDown:d,onCloseTab:f}){return(0,J.jsxs)(`div`,{className:`code-file-editor-tab-strip`,children:[(0,J.jsxs)(`div`,{className:`code-file-editor-navigation`,children:[e.sourceAgentId&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`button`,{type:`button`,className:`code-file-editor-action code-file-editor-agent-return`,onClick:()=>r(e.sourceAgentId),"aria-label":n.backToAgent,title:n.backToAgent,"data-testid":`code-file-editor-back`,children:(0,J.jsx)(De,{})}),(0,J.jsx)(`span`,{className:`code-file-editor-navigation-divider`,"aria-hidden":`true`})]}),(0,J.jsx)(`button`,{type:`button`,className:`code-file-editor-action code-file-editor-history-back`,onClick:()=>{s(-1)},disabled:!a,"aria-label":n.goBack,title:n.goBack,"data-testid":`code-file-editor-history-back`,children:(0,J.jsx)(Te,{})}),(0,J.jsx)(`button`,{type:`button`,className:`code-file-editor-action code-file-editor-history-forward`,onClick:()=>{s(1)},disabled:!o,"aria-label":n.goForward,title:n.goForward,"data-testid":`code-file-editor-history-forward`,children:(0,J.jsx)(Ee,{})})]}),(0,J.jsx)(`div`,{className:`code-file-editor-tabs`,role:`tablist`,children:t.map((t,r)=>{let a=H(t),o=a===H(e),s=E(t),p=k(t);return(0,J.jsxs)(`div`,{id:A(t),ref:e=>c(a,e),className:`code-file-editor-tab ${o?`active`:``} ${s}`.trim(),title:t.file.path,role:`tab`,"aria-selected":o,"aria-controls":`code-file-editor-panel`,"aria-label":ie(t),tabIndex:o?0:-1,onClick:()=>i(t.agentId,t.file.path),onContextMenu:e=>l(e,r),onAuxClick:e=>u(e,r),onKeyDown:e=>d(e,r),children:[(0,J.jsx)(`img`,{className:`code-file-type-icon file`,src:m(t.file.path),alt:``,"aria-hidden":`true`}),(0,J.jsx)(`span`,{className:`code-file-editor-tab-name`,children:B(t.file.path)}),(0,J.jsxs)(`span`,{className:`code-file-editor-tab-tail`,children:[p&&(0,J.jsx)(`span`,{className:`code-file-editor-dirty`,title:p===`external`?n.changedOnDisk:n.unsavedChanges}),(0,J.jsx)(`button`,{type:`button`,tabIndex:-1,className:`code-file-editor-close`,onClick:e=>{e.stopPropagation(),f(r)},"aria-label":n.closeFile(t.file.path)})]})]},a)})})]})}function ke({openFile:e,openFiles:t,editorMode:n,copy:r,statusText:i,onBackToAgent:a,onSelectOpenFile:o,canNavigateBack:s,canNavigateForward:c,onNavigateHistory:l,onSetTabRef:u,onOpenTabContextMenu:d,onTabAuxClick:f,onTabKeyDown:p,onCloseTab:m,onRevealInExplorer:h,onSave:g,onReload:_,onToggleSourcePreview:v,onToggleMarkdownSplit:y,onToggleWordWrap:b,onToggleDiff:x,canPreviewMarkdown:S,canPreviewSource:C,diffOpen:w,markdownSplitOpen:T,sourcePreviewOpen:E,wordWrapEnabled:D}){let O=R(e,n,{canPreviewMarkdown:S,canPreviewSource:C,statusText:i,showBreadcrumbs:e.file.path.includes(`/`)});return(0,J.jsxs)(`header`,{className:`code-file-editor-header`,children:[(0,J.jsx)(Oe,{openFile:e,openFiles:t,copy:r,onBackToAgent:a,onSelectOpenFile:o,canNavigateBack:s,canNavigateForward:c,onNavigateHistory:l,onSetTabRef:u,onOpenTabContextMenu:d,onTabAuxClick:f,onTabKeyDown:p,onCloseTab:m}),O.showBar&&(0,J.jsxs)(`div`,{className:`code-file-editor-bar`,children:[(0,J.jsx)(Z,{openFile:e,copy:r,onRevealInExplorer:h}),(0,J.jsx)(we,{actions:O,copy:r,diffOpen:w,openFile:e,markdownSplitOpen:T,sourcePreviewOpen:E,wordWrapEnabled:D,statusText:i,onReload:_,onSave:g,onToggleMarkdownSplit:y,onToggleSourcePreview:v,onToggleWordWrap:b,onToggleDiff:x})]})]})}function Q({blame:e,loading:t,error:n,copy:r}){return!t&&!n&&(!e||e.isGitRepo&&e.lines.length>0)?null:(0,J.jsx)(`div`,{className:`code-file-blame-toast ${n?`error`:``}`,"data-testid":`code-file-blame-state`,children:t?r.loadingBlame:n||(e&&!e.isGitRepo?r.notGitRepository:r.noCommittedLines)})}function Ae({x:e,y:t,copy:n,blameOpen:r,readOnly:i,showBlameContextAction:a,showLineChangesContextActions:o,onClose:s,onRunAction:c}){let l=(0,q.useRef)(null),u=fe({menuOpen:!0,menuRef:l,onClose:s});return(0,J.jsxs)(`div`,{ref:l,className:`code-editor-context-menu`,"data-testid":`code-editor-context-menu`,role:`menu`,style:{left:e,top:t},onKeyDown:u,onMouseDown:e=>e.stopPropagation(),children:[a&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`button`,{type:`button`,role:`menuitem`,onClick:()=>c(`toggle-blame`),children:r?n.hideBlame:n.annotateWithBlame}),(0,J.jsx)(`div`,{className:`code-editor-context-separator`,role:`separator`})]}),o&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`button`,{type:`button`,role:`menuitem`,onClick:()=>c(`line-changes-previous`),children:n.openLineChangesWithPreviousRevision}),(0,J.jsx)(`button`,{type:`button`,role:`menuitem`,onClick:()=>c(`line-changes-working`),children:n.openLineChangesWithWorkingFile}),(0,J.jsx)(`div`,{className:`code-editor-context-separator`,role:`separator`})]}),(0,J.jsx)(`button`,{type:`button`,role:`menuitem`,onClick:()=>c(`cut`),disabled:i,children:n.cut}),(0,J.jsx)(`button`,{type:`button`,role:`menuitem`,onClick:()=>c(`copy`),children:n.copy}),(0,J.jsx)(`button`,{type:`button`,role:`menuitem`,onClick:()=>c(`paste`),disabled:i,children:n.paste}),(0,J.jsx)(`button`,{type:`button`,role:`menuitem`,onClick:()=>c(`select-all`),children:n.selectAll})]})}function je({label:e,saving:t,copy:n,onConfirmSave:r,onDiscard:i,onCancel:a}){return(0,J.jsx)(`div`,{className:`code-file-save-confirm-backdrop`,"data-testid":`code-file-save-confirm`,role:`presentation`,onMouseDown:e=>e.stopPropagation(),children:(0,J.jsxs)(`div`,{className:`code-file-save-confirm-dialog`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`code-file-save-confirm-title`,"aria-describedby":`code-file-save-confirm-description`,onKeyDown:e=>{e.key===`Escape`&&!t&&(e.preventDefault(),a())},children:[(0,J.jsx)(`div`,{className:`code-file-save-confirm-brand`,"aria-hidden":`true`,children:`F`}),(0,J.jsx)(`h2`,{id:`code-file-save-confirm-title`,children:n.saveBeforeCloseTitle(e)}),(0,J.jsx)(`p`,{id:`code-file-save-confirm-description`,children:n.saveBeforeCloseDescription}),(0,J.jsxs)(`div`,{className:`code-file-save-confirm-actions`,children:[(0,J.jsx)(`button`,{type:`button`,className:`primary`,onClick:r,disabled:t,children:t?n.savingFile:n.save}),(0,J.jsx)(`button`,{type:`button`,onClick:i,disabled:t,children:n.dontSave}),(0,J.jsx)(`button`,{type:`button`,onClick:a,disabled:t,children:n.cancel})]})]})})}function Me({menu:e,openFiles:t,copy:n,onRunAction:r}){return(0,J.jsxs)(`div`,{className:`code-context-menu code-file-tab-context-menu`,"data-testid":`code-file-tab-context-menu`,role:`menu`,style:{left:e.x,top:e.y},children:[(0,J.jsx)(`button`,{type:`button`,role:`menuitem`,onClick:()=>r(`close`),children:n.close}),(0,J.jsx)(`button`,{type:`button`,role:`menuitem`,onClick:()=>r(`close-others`),disabled:t.length<=1,children:n.closeOthers}),(0,J.jsx)(`button`,{type:`button`,role:`menuitem`,onClick:()=>r(`close-right`),disabled:e.index>=t.length-1,children:n.closeToRight}),(0,J.jsx)(`button`,{type:`button`,role:`menuitem`,onClick:()=>r(`close-saved`),disabled:!O(t),children:n.closeSaved}),(0,J.jsx)(`div`,{className:`code-context-menu-separator`,role:`separator`}),(0,J.jsx)(`button`,{type:`button`,role:`menuitem`,onClick:()=>r(`close-all`),children:n.closeAll})]})}function Ne({blame:e,blameError:t,blameLoading:n,blameOpen:r,copy:i,editorContextMenu:a,readOnly:o,openFiles:s,pendingCloseOpen:c,pendingCloseLabel:l,pendingCloseSaving:u,showBlameContextAction:d,showLineChangesContextActions:f,tabContextMenu:p,onCancelPendingClose:m,onCloseEditorContextMenu:h,onConfirmSaveAndClose:g,onDiscardAndClose:_,onRunEditorContextAction:v,onRunTabContextAction:y}){return(0,J.jsxs)(J.Fragment,{children:[a&&(0,J.jsx)(Ae,{x:a.x,y:a.y,copy:i,blameOpen:r,readOnly:o,showBlameContextAction:d,showLineChangesContextActions:f,onClose:h,onRunAction:e=>void v(e)}),p&&(0,J.jsx)(Me,{menu:p,openFiles:s,copy:i,onRunAction:y}),c&&(0,J.jsx)(je,{label:l,saving:u,copy:i,onConfirmSave:()=>void g(),onDiscard:_,onCancel:m}),r&&(0,J.jsx)(Q,{blame:e,loading:n,error:t,copy:i})]})}function Pe({filePath:e,line:t,authorProfileUrl:n,copy:r,onClose:i}){return(0,J.jsxs)(`section`,{className:`code-file-blame-detail`,"data-testid":`code-file-blame-detail`,"aria-label":r.gitBlameDetails,children:[(0,J.jsxs)(`div`,{className:`code-file-blame-detail-main`,children:[(0,J.jsxs)(`div`,{className:`code-file-blame-detail-title`,children:[(0,J.jsx)(`strong`,{children:t.summary||t.shortCommit}),(0,J.jsx)(`code`,{title:t.commit,children:t.shortCommit})]}),(0,J.jsx)(`div`,{className:`code-file-blame-detail-subtitle`,children:e})]}),(0,J.jsxs)(`div`,{className:`code-file-blame-detail-rows`,children:[(0,J.jsxs)(`div`,{className:`code-file-blame-detail-row`,children:[(0,J.jsx)(`span`,{children:r.author}),n?(0,J.jsx)(`a`,{href:n,target:`_blank`,rel:`noreferrer`,children:t.author}):(0,J.jsx)(`strong`,{children:t.author||r.unknown})]}),(0,J.jsxs)(`div`,{className:`code-file-blame-detail-row`,children:[(0,J.jsx)(`span`,{children:r.commit}),(0,J.jsx)(`strong`,{title:t.commit,children:t.shortCommit})]}),(0,J.jsxs)(`div`,{className:`code-file-blame-detail-row`,children:[(0,J.jsx)(`span`,{children:r.date}),(0,J.jsx)(`strong`,{children:oe(t.authorTime)||r.uncommitted})]}),(0,J.jsxs)(`div`,{className:`code-file-blame-detail-row`,children:[(0,J.jsx)(`span`,{children:r.line}),(0,J.jsx)(`strong`,{children:t.lineNumber})]})]}),(0,J.jsx)(`button`,{type:`button`,className:`code-file-blame-detail-close`,onClick:i,"aria-label":r.closeBlameDetails})]})}function Fe(e,t){if(e.loading)return t.loadingDiff;if(e.error)return e.error;let n=e.diff;return n?n.isGitRepo?n.binary?t.binaryDiffUnavailable:n.truncated?t.diffTooLarge:n.patch.trim()?typeof n.originalContent!=`string`||typeof n.modifiedContent!=`string`?t.diffUnavailable:``:t.noFileDiff:t.notGitRepository:``}function Ie(e){let t=e.diff;return!!(t&&t.isGitRepo&&!t.binary&&!t.truncated&&t.patch.trim()&&typeof t.originalContent==`string`&&typeof t.modifiedContent==`string`)}function Le(e,t){let n=w(e.file.path,e.workspaceRoot);return i.from({scheme:`farming-diff`,path:n.startsWith(`/`)?n:`/${n}`,query:t})}function Re(e,t,n,i){let a=Le(e,t);return r.getModel(a)?.dispose(),r.createModel(n,i,a)}function ze({openFile:e,diffState:t,copy:n,onClose:i}){let a=(0,q.useRef)(null),o=(0,q.useRef)(null),s=(0,q.useRef)(null),c=(0,q.useRef)(null),l=Ie(t),u=(0,q.useMemo)(()=>Fe(t,n),[n,t]);return(0,q.useEffect)(()=>{if(!l)return;let e=a.current;if(!e)return;_e(),K();let t=r.createDiffEditor(e,{theme:ge(),automaticLayout:!1,renderSideBySide:!d(),originalEditable:!1,readOnly:!0,minimap:{enabled:!1},scrollBeyondLastLine:!1,fixedOverflowWidgets:!0,renderOverviewRuler:!0,enableSplitViewResizing:!d(),ignoreTrimWhitespace:!1,glyphMargin:!0,lineNumbersMinChars:4,unicodeHighlight:{ambiguousCharacters:!1,invisibleCharacters:!0,nonBasicASCII:!1}});o.current=t;let n=new ResizeObserver(()=>t.layout());n.observe(e);let i=new MutationObserver(()=>K(t));return i.observe(document.body,{attributes:!0,attributeFilter:[`data-appearance`]}),window.requestAnimationFrame(()=>t.layout()),()=>{n.disconnect(),i.disconnect(),t.dispose(),s.current?.dispose(),c.current?.dispose(),s.current=null,c.current=null,o.current=null}},[l]),(0,q.useEffect)(()=>{if(!l||!t.diff)return;let n=o.current;if(!n)return;s.current?.dispose(),c.current?.dispose();let r=W(e.file.path,t.diff.modifiedContent),i=Re(e,`original`,t.diff.originalContent??``,r),a=Re(e,`modified`,t.diff.modifiedContent??``,r);s.current=i,c.current=a,n.setModel({original:i,modified:a}),window.requestAnimationFrame(()=>n.layout())},[t.diff,e,l]),(0,J.jsxs)(`section`,{className:`code-file-diff-view`,"data-testid":`code-file-diff-view`,"aria-label":n.fileDiff,children:[(0,J.jsxs)(`header`,{className:`code-file-diff-header`,children:[(0,J.jsxs)(`div`,{className:`code-file-diff-title`,children:[(0,J.jsx)(`strong`,{children:n.fileDiff}),(0,J.jsx)(`span`,{children:e.file.path})]}),(0,J.jsx)(`button`,{type:`button`,className:`code-file-diff-close`,"aria-label":n.closeDiff,onClick:i})]}),u&&(0,J.jsx)(`div`,{className:`code-file-diff-state ${t.error?`error`:``}`,children:u}),(0,J.jsx)(`div`,{ref:a,className:`code-file-diff-monaco ${l?``:`hidden`}`,"data-testid":`code-file-diff-monaco`})]})}function Be({left:e,width:t,rows:n,copy:r,onShowDetail:i}){return n.length===0?null:(0,J.jsx)(`div`,{className:`code-file-inline-blame-layer`,"aria-label":r.gitBlameAnnotations,children:n.map(({line:n,top:a})=>(0,J.jsx)(`button`,{type:`button`,className:`code-file-inline-blame ${n.uncommitted?`uncommitted`:``}`,style:{left:e,top:a,width:t},title:`${n.shortCommit} ${n.author||r.unknown} ${n.summary}`,onClick:e=>{e.preventDefault(),e.stopPropagation(),i(n)},children:L(n)},`${n.lineNumber}-${n.commit}-${n.author}`))})}function Ve(e,t){return e===`previous`?t.openLineChangesWithPreviousRevision:t.openLineChangesWithWorkingFile}function He({mode:e,lineNumber:t,loading:n,error:r,changes:i,copy:a,onClose:o}){let s=i?.commit?`${i.commit.shortHash} ${i.commit.summary||``}`.trim():``,c=n?a.loadingLineChanges:r||(i&&!i.available?a.noLineChanges:``),l=i?.patch?i.patch.split(`
|
|
2
|
-
`):[];return(0,J.jsxs)(`div`,{className:`code-file-line-changes-panel`,"data-testid":`code-file-line-changes-panel`,children:[(0,J.jsxs)(`div`,{className:`code-file-line-changes-main`,children:[(0,J.jsxs)(`div`,{className:`code-file-line-changes-title`,children:[(0,J.jsx)(`strong`,{children:Ve(e,a)}),(0,J.jsxs)(`code`,{children:[a.line,` `,t]})]}),s&&(0,J.jsx)(`div`,{className:`code-file-line-changes-subtitle`,children:s}),c&&(0,J.jsx)(`div`,{className:`code-file-line-changes-state ${r?`error`:``}`,children:c}),!n&&!r&&i?.available&&(0,J.jsx)(`pre`,{className:`code-file-line-changes-patch`,"aria-label":a.lineChanges,children:l.map((e,t)=>(0,J.jsx)(`span`,{className:`code-file-line-changes-line ${te(e)}`,children:e||` `},`${t}-${e}`))})]}),(0,J.jsx)(`button`,{type:`button`,className:`code-file-line-changes-close`,"aria-label":a.closeLineChanges,onClick:o})]})}function Ue({openFile:e,activeTabDomId:t,copy:n,sourcePreviewOpen:r}){let i=e.file.preview??null,a=r&&se(e.file.path)?{kind:`image`,mediaType:`image/svg+xml`}:null,o=i?.kind===`image`?i:a,s=i?.kind===`pdf`?i:null,c=i?.kind===`binary`?i:null;return o?(0,J.jsx)(`section`,{className:`code-file-preview-panel`,"data-testid":`code-file-preview-panel`,role:`tabpanel`,"aria-labelledby":t,tabIndex:-1,children:(0,J.jsx)(`div`,{className:`code-file-image-preview-frame`,children:(0,J.jsx)(`img`,{className:`code-file-image-preview`,"data-testid":`code-file-image-preview`,src:u(e.agentId,e.file.path,e.file.sha1),alt:B(e.file.path),draggable:!1})})}):s?(0,J.jsx)(`section`,{className:`code-file-preview-panel`,"data-testid":`code-file-preview-panel`,role:`tabpanel`,"aria-labelledby":t,tabIndex:-1,children:(0,J.jsx)(`iframe`,{className:`code-file-pdf-preview`,"data-testid":`code-file-pdf-preview`,src:u(e.agentId,e.file.path,e.file.sha1),title:n.previewFor(e.file.path)})}):c?(0,J.jsx)(`section`,{className:`code-file-preview-panel metadata`,"data-testid":`code-file-preview-panel`,role:`tabpanel`,"aria-labelledby":t,"aria-label":n.previewFor(e.file.path),tabIndex:-1,children:(0,J.jsx)(`img`,{className:`code-file-metadata-preview-icon`,"data-testid":`code-file-metadata-preview-icon`,src:m(e.file.path),alt:``,"aria-hidden":`true`,draggable:!1})}):null}function We({activeTabDomId:e,blame:t,blameAuthorProfileUrl:n,blameDetailLine:r,blameOpen:i,blameOverlay:a,copy:o,cursorPosition:s,diffState:c,editorMode:l,editorHostRef:u,lineChanges:d,markdownSplitOpen:f,markdownPreviewOpen:p,sourcePreviewOpen:m,openFile:h,onClearBlameDetail:g,onCloseLineChanges:_,onCloseDiff:v,onOpenFilePath:y,onShowBlameDetail:b}){let x=z({diffOnly:l.diffOnly,diffOpen:c.open,markdownSplitOpen:f,markdownPreviewOpen:p,sourcePreviewOpen:m,visualPreview:l.visualPreview}),C=(0,q.useRef)(null),w=x.showEditorOverlays||x.showMarkdownPreview;return(0,J.jsxs)(J.Fragment,{children:[x.showDiffView&&(0,J.jsx)(ze,{openFile:h,diffState:c,copy:o,onClose:v}),(0,J.jsxs)(`div`,{className:`code-file-editor-source-region ${x.showMarkdownSplit?`markdown-split`:``} ${x.showMonaco||x.showMarkdownSplit?``:`hidden`}`.trim(),"data-testid":x.showMarkdownSplit?`code-file-markdown-split`:void 0,children:[(0,J.jsx)(`div`,{id:`code-file-editor-panel`,ref:u,className:`code-file-monaco`,"data-testid":`code-file-monaco`,role:`tabpanel`,"aria-labelledby":e,tabIndex:-1}),x.showMarkdownSplit&&(0,J.jsx)(S,{ref:C,activeTabDomId:e,openFile:h,onOpenFilePath:y,copy:o})]}),x.showDiffOnlyPreview&&(0,J.jsx)(`section`,{className:`code-file-preview-panel metadata`,"data-testid":`code-file-preview-panel`,role:`tabpanel`,"aria-labelledby":e,tabIndex:-1,children:(0,J.jsx)(`div`,{className:`code-file-diff-state`,children:o.deletedFileDiffOnly})}),x.showMarkdownPreview&&(0,J.jsx)(S,{activeTabDomId:e,openFile:h,onOpenFilePath:y,copy:o}),x.showEditorOverlays&&i&&t?.isGitRepo&&(0,J.jsx)(Be,{left:a.left,width:a.width,rows:a.rows,copy:o,onShowDetail:b}),(0,J.jsx)(Ue,{openFile:h,activeTabDomId:e,copy:o,sourcePreviewOpen:x.showSourcePreview}),x.showEditorOverlays&&i&&r&&(0,J.jsx)(Pe,{filePath:h.file.path,line:r,authorProfileUrl:n,copy:o,onClose:g}),x.showEditorOverlays&&d&&(0,J.jsx)(He,{mode:d.mode,lineNumber:d.lineNumber,loading:d.loading,error:d.error,changes:d.changes,copy:o,onClose:_}),w&&(0,J.jsx)(`div`,{className:`code-file-editor-statusbar`,"data-testid":`code-file-editor-statusbar`,children:(0,J.jsx)(`span`,{className:`code-file-editor-cursor-position`,children:o.cursorPosition(s.lineNumber,s.column)})})]})}function Ge(e){return e instanceof g&&ce(e.status)}function Ke({openFile:e,disabled:t,onRevealLine:n}){let r=(0,q.useRef)(0),i=(0,q.useRef)(H(e)),[a,o]=(0,q.useState)(!1),[s,c]=(0,q.useState)(!1),[l,u]=(0,q.useState)(null),[d,f]=(0,q.useState)(null),[p,m]=(0,q.useState)(`unknown`),[g,v]=(0,q.useState)(null);i.current=H(e);let y=(0,q.useMemo)(()=>{let e=l?.lines??[];return{compact:V(e,!0),regular:V(e,!1)}},[l]),b=(0,q.useCallback)(()=>{v(null)},[]),x=(0,q.useCallback)(async()=>{if(t)return m(`unavailable`),null;c(!0),f(null);try{let t=await h(e.agentId,e.file.path);return u(t),m(t.isGitRepo&&t.lines.length>0?`available`:`unavailable`),t}catch(e){return u(null),f(e instanceof Error?e.message:`Failed to load blame`),m(Ge(e)?`unavailable`:`unknown`),null}finally{c(!1)}},[t,e.agentId,e.file.path,e.file.sha1]),S=(0,q.useCallback)(async()=>{if(t)return m(`unavailable`),`unavailable`;let n=H(e),a=r.current+1;r.current=a;try{let t=await _(e.agentId,e.file.path);if(r.current!==a||i.current!==n)return null;let o=t.available?`available`:`unavailable`;return m(o),o}catch{return r.current!==a||i.current!==n?null:(m(`unavailable`),`unavailable`)}},[t,e]),C=(0,q.useCallback)(async()=>{if(!t){if(a){o(!1),v(null);return}(p===`unknown`?await S():p)!==`unavailable`&&o(!0)}},[p,a,S,t]),w=(0,q.useCallback)(e=>{n(e.lineNumber,{focusEditor:!1}),v({line:e})},[n]);return(0,q.useEffect)(()=>{u(null),f(null),m(t?`unavailable`:`unknown`)},[t,e.agentId,e.file]),(0,q.useEffect)(()=>{t&&(o(!1),u(null),f(null),m(`unavailable`))},[t,e.agentId,e.file.path]),(0,q.useEffect)(()=>{if(!a)return;let e=!1;return x().then(t=>{e||(!t?.isGitRepo||t.lines.length===0)&&(o(!1),v(null))}),()=>{e=!0}},[a,x]),(0,q.useEffect)(()=>{v(null)},[a,e.agentId,e.file.path]),{blameOpen:a,blameLoading:s,blame:l,blameError:d,blameCapability:p,blameDetail:g,blameLabelWidths:y,checkBlameCapability:S,toggleBlame:C,showBlameDetail:w,clearBlameDetail:b}}function qe({blame:e,blameLabelWidths:t,blameOpen:n,editorHostRef:i,editorRef:a,disabled:o}){let[s,c]=(0,q.useState)({left:0,width:112,rows:[]}),l=(0,q.useCallback)(()=>{let s=a.current,l=i.current;if(!s||!l||!n||!e?.isGitRepo||o){c({left:0,width:112,rows:[]}),s?.updateOptions({lineDecorationsWidth:10});return}let u=l.clientWidth<=520?t.compact:t.regular;s.updateOptions({lineDecorationsWidth:u+12});let d=s.getLayoutInfo(),f=l.offsetTop,p=s.getScrollTop(),m=s.getOption(r.EditorOption.lineHeight),h=l.offsetLeft+Math.max(0,d.contentLeft-u-8),g=N({visibleRanges:s.getVisibleRanges(),scrollTop:p,hostHeight:l.clientHeight,lineHeight:m});c({left:h,width:u,rows:ae(e.lines,{...g,hostTop:f,scrollTop:p,hostHeight:l.clientHeight,lineHeight:m,getTopForLineNumber:e=>s.getTopForLineNumber(e)})})},[e,t,n,o,i,a]);return(0,q.useEffect)(()=>{let e=a.current;if(!e)return;l();let t=e.onDidScrollChange(l),n=e.onDidLayoutChange(l),r=window.requestAnimationFrame(l);return()=>{t.dispose(),n.dispose(),window.cancelAnimationFrame(r)}},[a,l]),{blameOverlay:s}}function Je({blameCapability:e,blameOpen:t,canShowBlame:n,canShowLineChanges:i,editorRef:a,readOnly:o,onCheckBlameCapability:s,onClearBlameDetail:c,onCloseTabContextMenu:l,onOpenLineChanges:u,onToggleBlame:d}){let[f,p]=(0,q.useState)(null),m=(0,q.useCallback)(()=>{p(null)},[]),h=(0,q.useCallback)(e=>{let i=e.target.type,o=new Set([r.MouseTargetType.GUTTER_GLYPH_MARGIN,r.MouseTargetType.GUTTER_LINE_NUMBERS,r.MouseTargetType.GUTTER_LINE_DECORATIONS,r.MouseTargetType.GUTTER_VIEW_ZONE]),u=e.target.position?.lineNumber??a.current?.getPosition()?.lineNumber??1,d=o.has(i)?`gutter`:`editor`;e.event.preventDefault(),e.event.stopPropagation(),c(),l();let f={x:Math.max(8,Math.min(e.event.posx,window.innerWidth-220)),y:Math.max(8,Math.min(e.event.posy,window.innerHeight-230)),kind:d,lineNumber:u};if(d===`gutter`&&n&&!t){s().then(e=>{e!==null&&p(f)});return}p(f)},[t,n,a,s,c,l]),g=(0,q.useCallback)(async e=>{let t=a.current,r=f;if(m(),!t)return;let s=t.getModel(),c=t.getSelection();if(e===`toggle-blame`){if(!n)return;await d();return}if(e===`line-changes-previous`||e===`line-changes-working`){if(!i)return;let n=r?.lineNumber??t.getPosition()?.lineNumber??1;await u(e===`line-changes-previous`?`previous`:`working`,n);return}if(e===`select-all`&&s){t.setSelection(s.getFullModelRange()),t.focus();return}if(!(!s||!c)){if(e===`copy`||e===`cut`){let n=s.getValueInRange(c);n&&await navigator.clipboard?.writeText(n).catch(()=>{}),e===`cut`&&n&&!o&&t.executeEdits(`farming-context-menu`,[{range:c,text:``,forceMoveMarkers:!0}]),t.focus();return}if(e===`paste`&&!o){let e=await navigator.clipboard?.readText().catch(()=>``)??``;e&&t.executeEdits(`farming-context-menu`,[{range:c,text:e,forceMoveMarkers:!0}]),t.focus()}}},[n,i,m,f,a,u,d,o]),_=!!(f&&f.kind===`gutter`&&n&&(t||e===`available`)),v=!!(f&&f.kind===`gutter`&&i);return(0,q.useEffect)(()=>{let e=e=>{let t=e.target;t instanceof Element&&t.closest(`.code-editor-context-menu, .code-file-tab-context-menu, .code-file-blame-detail, .code-file-inline-blame, .code-file-line-changes-panel`)||(p(null),l())},t=e=>{e.key===`Escape`&&(p(null),l())};return document.addEventListener(`mousedown`,e,!0),document.addEventListener(`keydown`,t,!0),()=>{document.removeEventListener(`mousedown`,e,!0),document.removeEventListener(`keydown`,t,!0)}},[l]),{editorContextMenu:f,closeEditorContextMenu:m,openEditorContextMenu:h,runEditorContextAction:g,showBlameContextAction:_,showLineChangesContextActions:v}}function Ye({openFile:e,diffDisabled:t,onClearBlameDetail:n}){let r=(0,q.useRef)(0),i=(0,q.useRef)(void 0),a=(0,q.useRef)(H(e)),[o,s]=(0,q.useState)({open:!1,loading:!1,error:null,diff:null});a.current=H(e);let c=(0,q.useCallback)(()=>{r.current+=1,s({open:!1,loading:!1,error:null,diff:null})},[]),l=(0,q.useCallback)(async()=>{if(t)return;let i=r.current+1,o=H(e);r.current=i,n(),s({open:!0,loading:!0,error:null,diff:null});try{let t=await f(e.agentId,e.file.path);if(r.current!==i||a.current!==o)return;s({open:!0,loading:!1,error:null,diff:t})}catch(e){if(r.current!==i||a.current!==o)return;s({open:!0,loading:!1,error:e instanceof Error?e.message:`Failed to load diff`,diff:null})}},[t,n,e]),u=(0,q.useCallback)(()=>{if(o.open){c();return}l()},[c,o.open,l]);return(0,q.useEffect)(()=>{r.current+=1,s({open:!1,loading:!1,error:null,diff:null})},[t,e.agentId,e.file]),(0,q.useEffect)(()=>{!e.diffRequestId||t||i.current===e.diffRequestId||(i.current=e.diffRequestId,l())},[t,l,e.diffRequestId]),{diffState:o,closeDiff:c,toggleDiff:u}}function Xe({openFile:e,disabled:t,onClearBlameDetail:n,onRevealLine:r}){let i=(0,q.useRef)(0),a=(0,q.useRef)(H(e)),[o,s]=(0,q.useState)(null);a.current=H(e);let c=(0,q.useCallback)(()=>{s(null)},[]),l=(0,q.useCallback)(async(o,c)=>{if(t)return;let l=i.current+1,u=H(e);i.current=l,n(),s(de(o,c)),r(c,{focusEditor:!1});try{let t=await p(e.agentId,e.file.path,c,o);if(i.current!==l||a.current!==u)return;s(ue(o,c,t))}catch(e){if(i.current!==l||a.current!==u)return;s(F(o,c,e))}},[t,n,r,e]);return(0,q.useEffect)(()=>{i.current+=1,s(null)},[t,e.agentId,e.file]),{lineChanges:o,openLineChanges:l,closeLineChanges:c}}function Ze({editorRef:e,onFocusEditor:t}){(0,q.useEffect)(()=>{if(!window.__FARMING_E2E__)return;let n={focus(){return t(),!!e.current},revealLine(t){let n=e.current,r=n?.getModel();if(!n||!r)return!1;let i=Math.min(Math.max(1,t),r.getLineCount());return n.setPosition({lineNumber:i,column:1}),n.revealLineInCenter(i),n.focus(),!0},insertText(t){let n=e.current,r=n?.getSelection();return!n||!r?!1:(n.pushUndoStop(),n.executeEdits(`farming-e2e`,[{range:r,text:t,forceMoveMarkers:!0}]),n.pushUndoStop(),n.focus(),!0)},undo(){let t=e.current;return t?(t.focus(),t.trigger(`farming-e2e`,`undo`,null),!0):!1},getValue(){return e.current?.getValue()??``},getScrollTop(){return e.current?.getScrollTop()??0},getMarkers(){let t=e.current?.getModel();return t?r.getModelMarkers({resource:t.uri}).map(e=>({code:String(e.code??``),message:e.message,severity:e.severity})):[]},getTypeScriptDiagnosticsOptions(){return a.getDiagnosticsOptions()}};return window.__farmingFileEditorTest=n,()=>{window.__farmingFileEditorTest===n&&delete window.__farmingFileEditorTest}},[e,t])}function Qe({openFile:e,openFiles:t,readOnly:n,wordWrapEnabled:i,editorLabel:a,onChangeDraft:u,onFocusFilesSearch:d,onRecordNavigationCursor:f,onSaveShortcut:p,onOpenContextMenuRef:m}){let h=(0,q.useRef)(null),g=(0,q.useRef)(null),_=(0,q.useRef)(new Map),v=(0,q.useRef)(null),y=(0,q.useRef)(new Map),b=(0,q.useRef)(null),x=(0,q.useRef)(null),S=(0,q.useRef)(null),C=(0,q.useRef)(null),w=(0,q.useRef)(null),T=(0,q.useRef)(u),E=(0,q.useRef)(d),D=(0,q.useRef)(f),O=(0,q.useRef)(p),k=(0,q.useRef)(e.agentId),A=(0,q.useRef)(e.file.path),j=(0,q.useRef)(e.workspaceRoot),M=(0,q.useRef)(i),N=(0,q.useRef)(a),P=(0,q.useRef)(null),F=(0,q.useRef)(0),I=(0,q.useRef)(0),[te,L]=(0,q.useState)({lineNumber:1,column:1});T.current=u,E.current=d,D.current=f,O.current=p,k.current=e.agentId,A.current=e.file.path,j.current=e.workspaceRoot,M.current=i,N.current=a;let R=(0,q.useCallback)(e=>{let t=e?.getPosition();t&&L(e=>e.lineNumber===t.lineNumber&&e.column===t.column?e:{lineNumber:t.lineNumber,column:t.column})},[]),ne=(0,q.useCallback)(()=>{let e=()=>{let e=g.current;e&&e.focus()};e(),window.requestAnimationFrame(e)},[]),ie=(0,q.useCallback)((e,t={})=>{let n=g.current;n&&(n.setPosition({lineNumber:e,column:1}),n.revealLineInCenter(e),t.focusEditor!==!1&&n.focus())},[]),z=(0,q.useCallback)(e=>{if(!e)return;let t=e.getVisibleRanges()[0]?.startLineNumber;if(!t||t<1)return;let n=e.getPosition(),r=j.current||`agent:${k.current}`,i=A.current;s({version:1,surface:`file`,resource:{kind:`file`,workspace:r,path:i},locator:{kind:`file-line`,id:i},position:{unit:`line-column`,value:t,...n?.column?{column:n.column}:{}}})},[]);return Ze({editorRef:g,onFocusEditor:ne}),(0,q.useEffect)(()=>{let t=h.current;if(!t)return;_e(),K();let n=r.create(t,be({value:e.draft,language:W(e.file.path,e.draft),ariaLabel:N.current,wordWrapEnabled:M.current}));K(n);let i=()=>G(n,M.current),a=he(),o=()=>i();typeof a.addEventListener==`function`?a.addEventListener(`change`,o):a.addListener(o),i(),g.current=n,b.current=n.onDidChangeModelContent(()=>{F.current>0||T.current(n.getValue())}),x.current=n.onDidChangeCursorPosition(e=>{if(R(n),z(n),I.current>0||e.reason!==r.CursorChangeReason.Explicit||e.source===`api`)return;let t=n.getSelection();D.current?.({agentId:k.current,filePath:A.current,lineNumber:e.position.lineNumber,column:e.position.column,endColumn:t?.endColumn})}),S.current=n.onDidScrollChange(()=>{z(n)}),pe(n,{getAgentId:()=>k.current,onFocusFilesSearch:e=>E.current(e),onSaveShortcut:()=>O.current()}),C.current=n.onContextMenu(e=>m.current(e));let s=e=>{let t=U(n,e);t&&m.current(t)};t.addEventListener(`contextmenu`,s,!0),w.current=new ResizeObserver(()=>n.layout()),w.current.observe(t);let c=new MutationObserver(()=>K(n));return c.observe(document.body,{attributes:!0,attributeFilter:[`data-appearance`]}),()=>{let e=v.current;e&&_.current.set(e,n.saveViewState()),z(n),w.current?.disconnect(),w.current=null,c.disconnect(),C.current?.dispose(),C.current=null,t.removeEventListener(`contextmenu`,s,!0),typeof a.removeEventListener==`function`?a.removeEventListener(`change`,o):a.removeListener(o),x.current?.dispose(),x.current=null,S.current?.dispose(),S.current=null,b.current?.dispose(),b.current=null,n.dispose(),ve(),_.current.clear(),g.current=null,v.current=null}},[m,z,R]),(0,q.useEffect)(()=>{let t=g.current;if(!t)return;let n=H(e),r=ee(e),i=v.current;i&&i!==n&&_.current.set(i,t.saveViewState());let a=me(e);t.getModel()!==a&&t.setModel(a);let s=y.current.get(n);if((i!==n||s!==r)&&a.getValue()!==e.draft){F.current+=1;try{a.setValue(e.draft)}finally{--F.current}}if(y.current.set(n,r),i!==n){let r=_.current.get(n);if(r)t.restoreViewState(r);else{let n=c(e.workspaceRoot||`agent:${e.agentId}`,e.file.path),r=o(n);r?.surface===`file`&&r.resource.kind===`file`&&r.position.value<=a.getLineCount()?t.revealLineInCenter(r.position.value):r&&l(n)}v.current=n}R(t)},[e,R]),(0,q.useEffect)(()=>{ye([...t,e],_.current)},[e,t]),(0,q.useEffect)(()=>{let t=g.current,n=e.cursor;if(!t||!n||P.current===n.requestId)return;let r=t.getModel(),i=re(n,{lineCount:r?.getLineCount()??1,getLineMaxColumn:e=>r?.getLineMaxColumn(e)??1});I.current+=1;try{t.setSelection(i),t.revealLineInCenter(i.startLineNumber),t.focus()}finally{window.setTimeout(()=>{I.current=Math.max(0,I.current-1)},120)}P.current=n.requestId,L({lineNumber:i.startLineNumber,column:i.startColumn})},[e.cursor,e.file.path]),(0,q.useEffect)(()=>{let e=g.current;e&&e.updateOptions({readOnly:n,domReadOnly:n})},[n]),(0,q.useEffect)(()=>{let e=g.current;e&&G(e,i)},[i]),{editorHostRef:h,editorRef:g,cursorPosition:te,focusEditor:ne,revealLine:ie}}function $e({openFile:e,openFiles:t,onCloseEditorTab:n,onFocusEditorTab:r,onFocusFilesSearch:i,onSaveFile:a}){let o=(0,q.useCallback)(e=>{i(e),window.requestAnimationFrame(()=>i(e)),window.setTimeout(()=>i(e),120)},[i]);return(0,q.useCallback)(i=>{if(i.altKey||!(i.ctrlKey||i.metaKey))return;if(i.key.toLowerCase()===`p`){i.preventDefault(),i.stopPropagation(),o(e.agentId);return}if(i.key.toLowerCase()===`s`){i.preventDefault(),i.stopPropagation(),a(!1);return}let s=t.findIndex(t=>H(t)===H(e));if(s!==-1){if(i.key===`PageUp`){i.preventDefault(),i.stopPropagation(),r((s-1+t.length)%t.length);return}if(i.key===`PageDown`){i.preventDefault(),i.stopPropagation(),r((s+1)%t.length);return}i.key.toLowerCase()===`w`&&(i.preventDefault(),i.stopPropagation(),n(s))}},[n,r,a,e,t,o])}function $(e){return H(e)}function et(e){return e.filter((e,t,n)=>n.findIndex(t=>$(t)===$(e))===t)}function tt(e,t,n){let r=e[n];if(!r||$(r)!==$(t))return t;let i=e.filter(e=>$(e)!==$(r));return i[Math.max(0,n-1)]??i[n]??null}function nt(e,t,n){let r=new Set(n.map($)),i=e.filter(e=>!r.has($(e)));return i.find(e=>$(e)===$(t))??i[0]??null}function rt(e,t){let n=et(e),r=n.filter(C);return{closeFiles:n,dirtyFiles:r,pendingClose:r.length>0?{files:r,closeFiles:n,nextFocusFile:t}:null,nextFocusFile:t}}function it(e){return e.nextFocusFile&&e.closeFiles.some(t=>$(t)===$(e.nextFocusFile))?null:e.nextFocusFile}function at(e,t,n){if(e===`close`){let e=t[n];return e?[e]:[]}return e===`close-others`?t.filter((e,t)=>t!==n):e===`close-right`?t.slice(n+1):e===`close-saved`?t.filter(T):[...t]}function ot({openFile:e,openFiles:t,filesLabel:n,onSelectOpenFile:r,onCloseOpenFile:i,onCloseOpenFiles:a,onDismissEditorContextMenu:o,onSaveOpenFile:s}){let c=(0,q.useRef)(new Map),l=(0,q.useRef)(null),[u,d]=(0,q.useState)(null),[f,p]=(0,q.useState)(null),[m,h]=(0,q.useState)(!1),g=(0,q.useCallback)(()=>{d(null)},[]),_=(0,q.useCallback)((e,t)=>{t?c.current.set(e,t):c.current.delete(e)},[]),v=(0,q.useCallback)(e=>{let n=t[e];n&&(l.current=H(n),r(n.agentId,n.file.path))},[r,t]),y=(0,q.useCallback)((e,t)=>{if(e.length===0)return;let n=e.map(e=>({agentId:e.agentId,filePath:e.file.path,workspaceRoot:e.workspaceRoot}));if(l.current=t?H(t):null,n.length===1){let e=n[0];e&&i(e.agentId,e.filePath,e.workspaceRoot);return}a(n)},[i,a]),b=(0,q.useCallback)((e,t)=>{let n=rt(e,t),r=n.closeFiles;if(r.length!==0){if(n.pendingClose){p(n.pendingClose),h(!1);return}y(r,n.nextFocusFile)}},[y]),x=(0,q.useCallback)(n=>{let r=t[n];r&&b([r],tt(t,e,n))},[e,t,b]),S=(0,q.useCallback)(n=>{b(n,nt(t,e,n))},[e,t,b]),C=(0,q.useCallback)((e,n)=>{e.preventDefault(),e.stopPropagation();let i=t[n];i&&r(i.agentId,i.file.path),o(),d({x:Math.max(8,Math.min(e.clientX,window.innerWidth-230)),y:Math.max(8,Math.min(e.clientY,window.innerHeight-190)),index:n})},[o,r,t]),w=(0,q.useCallback)(e=>{if(!u)return;let n=u.index;if(d(null),e===`close`){x(n);return}S(at(e,t,n))},[x,S,t,u]),T=(0,q.useCallback)((e,n)=>{if(!(e.altKey||e.ctrlKey||e.metaKey)){if(e.key===`ArrowLeft`){e.preventDefault(),v((n-1+t.length)%t.length);return}if(e.key===`ArrowRight`){e.preventDefault(),v((n+1)%t.length);return}if(e.key===`Home`){e.preventDefault(),v(0);return}if(e.key===`End`){e.preventDefault(),v(t.length-1);return}if(e.key===`Enter`||e.key===` `){e.preventDefault(),v(n);return}(e.key===`Delete`||e.key===`Backspace`)&&(e.preventDefault(),x(n))}},[x,v,t.length]),E=(0,q.useCallback)((e,t)=>{e.button===1&&(e.preventDefault(),e.stopPropagation(),x(t))},[x]),D=(0,q.useCallback)(async()=>{if(!f||m)return;h(!0);for(let e of f.files)if(!await s(e,!1)){h(!1);return}let e=it(f),t=f.closeFiles;p(null),h(!1),y(t,e)},[y,s,f,m]),O=(0,q.useCallback)(()=>{if(!f)return;let e=it(f),t=f.closeFiles;p(null),h(!1),y(t,e)},[y,f]),k=(0,q.useCallback)(()=>{p(null),h(!1)},[]),A=(0,q.useMemo)(()=>f?f.files.length===1?B(f.files[0]?.file.path??``):`${f.files.length} ${n}`:``,[n,f]);return(0,q.useEffect)(()=>{let t=H(e),n=c.current.get(t);n?.scrollIntoView({block:`nearest`,inline:`nearest`}),l.current===t&&(n?.focus(),l.current=null)},[e,t.length]),{tabContextMenu:u,pendingClose:f,pendingCloseSaving:m,pendingCloseLabel:A,closeTabContextMenu:g,setTabRef:_,focusEditorTab:v,closeEditorTab:x,openEditorTabContextMenu:C,runTabContextAction:w,handleEditorTabKeyDown:T,handleEditorTabAuxClick:E,confirmSaveAndClose:D,discardAndClose:O,cancelPendingClose:k}}function st({openFile:e,readOnly:t,onUpdateOpenFile:n}){let r=(0,q.useCallback)(async(e,t=!1)=>{if(D(e))return!0;if(e.saving)return!1;if(!t&&!e.dirty)return!0;n({...e,saving:!0,error:null});try{let r=await y(e.agentId,e.file.path,e.draft,e.file.sha1,t);return n({...e,file:r,draft:r.content,dirty:!1,externalChanged:!1,saving:!1,error:null}),!0}catch(t){let r=t instanceof g&&t.status===409;return n({...e,saving:!1,externalChanged:e.externalChanged||r,error:t instanceof Error?t.message:`Failed to save file`}),!1}},[n]);return{saveOpenWorkspaceFile:r,saveFile:(0,q.useCallback)(async(n=!1)=>{t||await r(e,n)},[e,t,r]),reloadFile:(0,q.useCallback)(async()=>{n({...e,saving:!0,error:null});try{let t=await v(e.agentId,e.file.path);n({...e,file:t,draft:t.content,dirty:!1,externalChanged:!1,saving:!1,error:null})}catch(t){n({...e,saving:!1,error:t instanceof Error?t.message:`Failed to reload file`})}},[n,e])}}var ct=``,lt=`farming.code.fileEditor.wordWrap`;function ut(){if(typeof window>`u`)return!1;try{return window.localStorage.getItem(lt)===`1`}catch{return!1}}function dt(e){if(!(typeof window>`u`))try{window.localStorage.setItem(lt,e?`1`:`0`)}catch{}}function ft({openFile:e,openFiles:t,onChangeDraft:n,onUpdateOpenFile:r,onSelectOpenFile:i,onOpenFilePath:a,canNavigateBack:o,canNavigateForward:s,onNavigateHistory:c,onCloseOpenFile:l,onCloseOpenFiles:u,onRevealInExplorer:d,onFocusFilesSearch:f,onRecordNavigationCursor:p,onBackToAgent:m,copy:h}){let g=(0,q.useRef)(()=>{}),_=(0,q.useRef)(()=>{}),v=A(e),y=ne(e),[b,S]=(0,q.useState)({}),[C,w]=(0,q.useState)({}),[T,E]=(0,q.useState)(ut),D=H(e),O=!y.preview&&!y.diffOnly&&I(e.file.path),k=!y.preview&&!y.diffOnly&&se(e.file.path),ee=b[D],j=O||k?ee!==!1:!1,M=O&&j,N=M&&C[D]===!0,F=M&&!N,te=k&&j,L=!y.canEditText||x(e.agentId)||e.file.readOnly===!0,R=y.canShowBlame&&e.file.external!==!0,re=y.canShowLineChanges&&e.file.external!==!0,{saveOpenWorkspaceFile:ie,saveFile:z,reloadFile:ae}=st({openFile:e,readOnly:L,onUpdateOpenFile:r}),{tabContextMenu:oe,pendingClose:B,pendingCloseSaving:ce,pendingCloseLabel:V,closeTabContextMenu:ue,setTabRef:de,focusEditorTab:fe,closeEditorTab:U,openEditorTabContextMenu:pe,runTabContextAction:W,handleEditorTabKeyDown:me,handleEditorTabAuxClick:he,confirmSaveAndClose:G,discardAndClose:ge,cancelPendingClose:_e}=ot({openFile:e,openFiles:t,filesLabel:h.files,onSelectOpenFile:i,onCloseOpenFile:l,onCloseOpenFiles:u,onDismissEditorContextMenu:()=>_.current(),onSaveOpenFile:ie}),ve=$e({openFile:e,openFiles:t,onCloseEditorTab:U,onFocusEditorTab:fe,onFocusFilesSearch:f,onSaveFile:z}),{editorHostRef:ye,editorRef:K,cursorPosition:be,revealLine:xe}=Qe({openFile:e,openFiles:t,readOnly:L,wordWrapEnabled:T,editorLabel:h.editorFor(e.file.path),onChangeDraft:n,onFocusFilesSearch:f,onRecordNavigationCursor:p,onSaveShortcut:()=>{z(!1)},onOpenContextMenuRef:g}),{blameOpen:Y,blameLoading:Se,blame:X,blameError:Ce,blameCapability:we,blameDetail:Z,blameLabelWidths:Te,checkBlameCapability:Ee,toggleBlame:De,showBlameDetail:Oe,clearBlameDetail:Q}=Ke({openFile:e,disabled:!R,onRevealLine:xe}),{lineChanges:Ae,openLineChanges:je,closeLineChanges:Me}=Xe({openFile:e,disabled:!re,onClearBlameDetail:Q,onRevealLine:xe}),{diffState:Pe,closeDiff:Fe,toggleDiff:Ie}=Ye({openFile:e,diffDisabled:!y.canShowDiff,onClearBlameDetail:Q}),{blameOverlay:Le}=qe({blame:X,blameLabelWidths:Te,blameOpen:Y,editorHostRef:ye,editorRef:K,disabled:!R}),{editorContextMenu:Re,closeEditorContextMenu:ze,openEditorContextMenu:Be,runEditorContextAction:Ve,showBlameContextAction:He,showLineChangesContextActions:Ue}=Je({blameCapability:we,blameOpen:Y,canShowBlame:R,canShowLineChanges:re,editorRef:K,readOnly:L,onCheckBlameCapability:Ee,onClearBlameDetail:Q,onCloseTabContextMenu:ue,onOpenLineChanges:je,onToggleBlame:De});g.current=Be,_.current=ze;let Ge=P(e)===`changedOnDisk`?h.changedOnDisk:null,Ze=Z?le(Z.line.author,ct):``;return(0,q.useEffect)(()=>{if(!(typeof document>`u`))return document.body.classList.toggle(`code-mobile-markdown-reading`,M),()=>{document.body.classList.remove(`code-mobile-markdown-reading`)}},[M]),(0,q.useEffect)(()=>{let e=K.current;if(!e)return;let t=window.requestAnimationFrame(()=>e.layout());return()=>window.cancelAnimationFrame(t)},[K,N,F,j]),(0,J.jsxs)(`section`,{className:`code-file-editor ${M?`markdown-reading`:``}`.trim(),"data-testid":`code-file-editor`,onKeyDownCapture:ve,children:[(0,J.jsx)(ke,{openFile:e,openFiles:t,editorMode:y,copy:h,statusText:Ge,onBackToAgent:m,onSelectOpenFile:i,canNavigateBack:o,canNavigateForward:s,onNavigateHistory:c,onSetTabRef:de,onOpenTabContextMenu:pe,onTabAuxClick:he,onTabKeyDown:me,onCloseTab:U,onRevealInExplorer:d,onSave:z,onReload:ae,onToggleSourcePreview:()=>{if(!O&&!k)return;let e=!j;S(t=>({...t,[D]:e})),O&&!e&&w(e=>({...e,[D]:!1}))},onToggleMarkdownSplit:()=>{O&&(S(e=>({...e,[D]:!0})),w(e=>({...e,[D]:!N})))},onToggleWordWrap:()=>{E(e=>{let t=!e;return dt(t),t})},onToggleDiff:Ie,canPreviewMarkdown:O,canPreviewSource:k,diffOpen:Pe.open,markdownSplitOpen:N,sourcePreviewOpen:j,wordWrapEnabled:T}),e.error&&(0,J.jsx)(`div`,{className:`code-file-editor-alert`,"data-testid":`code-file-editor-alert`,children:e.error}),(0,J.jsx)(We,{activeTabDomId:v,blame:X,blameAuthorProfileUrl:Ze,blameDetailLine:Z?.line??null,blameOpen:Y,blameOverlay:Le,copy:h,cursorPosition:be,diffState:Pe,editorMode:y,editorHostRef:ye,lineChanges:Ae,markdownSplitOpen:N,markdownPreviewOpen:F,sourcePreviewOpen:te,openFile:e,onClearBlameDetail:Q,onCloseDiff:Fe,onCloseLineChanges:Me,onOpenFilePath:a,onShowBlameDetail:Oe}),(0,J.jsx)(Ne,{blame:X,blameError:Ce,blameLoading:Se,blameOpen:Y,copy:h,editorContextMenu:Re,readOnly:L,openFiles:t,pendingCloseOpen:!!B,pendingCloseLabel:V,pendingCloseSaving:ce,showBlameContextAction:He,showLineChangesContextActions:Ue,tabContextMenu:oe,onCancelPendingClose:_e,onCloseEditorContextMenu:ze,onConfirmSaveAndClose:G,onDiscardAndClose:ge,onRunEditorContextAction:Ve,onRunTabContextAction:W})]})}export{ft as FileEditorPane};
|