farming-code 2.2.22 → 2.2.23
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.
|
@@ -205,6 +205,6 @@ void main() {
|
|
|
205
205
|
|
|
206
206
|
`)).trimEnd()}function _j(e,t){let n=t.filter(e=>!e.path).map(e=>e.messageBlock||``).filter(Boolean);return aj(e.trimEnd(),n.join(`
|
|
207
207
|
|
|
208
|
-
`)).trimEnd()}function vj(e){return e.flatMap(e=>e.status===`ready`&&e.path?[{kind:e.kind,path:e.path,name:e.name,type:e.type,size:e.size}]:[])}function yj(e){return new Promise((t,n)=>{let r=new FileReader;r.onerror=()=>n(r.error??Error(`File read failed`)),r.onload=()=>t(typeof r.result==`string`?r.result:``),r.readAsText(e)})}async function bj(e){let t=cj(e)?`/api/attachments/audio`:`/api/attachments/image`,n=await fetch(ij(t),{method:`POST`,headers:{"Content-Type":e.type||(cj(e)?`audio/wav`:`image/png`)},body:e});if(!n.ok)throw Error(`Image upload failed: ${n.status}`);return n.json()}async function xj(e){if(sj(e))return uj(await bj(e));if(cj(e))return dj(await bj(e));try{return lj(e,await yj(e))}catch{return`Attached file: ${oj(e)}\n\n[Unable to read this file as text]`}}function Sj(e){return sj(e)?`Attached image: ${oj(e,`pasted image`)}\n\n[Unable to upload this image]`:cj(e)?`Attached audio: ${oj(e,`pasted audio`)}\n\n[Unable to upload this audio]`:`Attached file: ${oj(e)}\n\n[Unable to read this file as text]`}function Cj(e){if(!e)return[];let t=Array.from(e.files??[]).filter(e=>sj(e)||cj(e));return t.length>0?t:Array.from(e.items??[]).filter(e=>e.kind===`file`&&/^(image|audio)\//.test(e.type)).map(e=>e.getAsFile()).filter(e=>!!(e&&(sj(e)||cj(e))))}function wj(e,t){return e===`default`?t:`${nj[e]}\n\n${t}`}function Tj(e){return!!(e&&e.runtimeBinding.kind===`acp`&&e.status===`running`&&e.requiresProcessExitAcknowledgement!==!0)}function Ej({agent:e,composerKey:t,draft:n,attachments:r,composerMode:i,turnActive:a,supportsSteer:o,sendMessage:s,updateComposerState:c}){let l=vj(r),u=wj(i,_j(n,r).trim());if(!u&&l.length===0||!e||!Tj(e)||!t)return!1;let d=a&&o;return(!a||d)&&!s(e,u,l)?!1:(c(t,e=>({...e,draft:``,attachments:[],mode:`default`,history:VA(e.history,n),...a&&!d?{pendingFollowUp:{messages:[...e.pendingFollowUp?.messages||[],qA(u,l)],createdAt:e.pendingFollowUp?.createdAt||Date.now()}}:{}})),r.forEach(mj),!0)}function Dj(e,t,n,i=!1){return fetch(r(`/api/agents/${encodeURIComponent(e)}/acp-permission`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({requestId:t,optionId:n,cancelled:i})})}function Oj(e,t,n,i){return fetch(r(`/api/agents/${encodeURIComponent(e)}/acp-elicitation`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({requestId:t,action:n,content:i})})}var kj=`acp:`;function Aj(e){let t=$A(e);return t?`${kj}${t}`:``}function jj(e){return ej(e).map(e=>`${kj}${e}`)}function Mj(e){return e.startsWith(kj)}function Nj(){return typeof window>`u`?!1:navigator.standalone===!0||window.matchMedia(`(display-mode: standalone)`).matches}function Pj(){return(0,K.jsx)(`svg`,{viewBox:`0 0 20 20`,"aria-hidden":`true`,focusable:`false`,children:(0,K.jsx)(`path`,{d:`M10 13V3m0 0L6.5 6.5M10 3l3.5 3.5M4 9v6.5A1.5 1.5 0 0 0 5.5 17h9a1.5 1.5 0 0 0 1.5-1.5V9`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`,strokeLinejoin:`round`})})}function Fj(){return(0,K.jsxs)(`svg`,{viewBox:`0 0 20 20`,"aria-hidden":`true`,focusable:`false`,children:[(0,K.jsx)(`rect`,{x:`3`,y:`3`,width:`14`,height:`14`,rx:`3`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.4`}),(0,K.jsx)(`path`,{d:`M10 6.5v7M6.5 10h7`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.4`,strokeLinecap:`round`})]})}function Ij(){return(0,K.jsxs)(`svg`,{viewBox:`0 0 20 20`,"aria-hidden":`true`,focusable:`false`,children:[(0,K.jsx)(`rect`,{x:`6.5`,y:`6.5`,width:`9`,height:`9`,rx:`2`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`}),(0,K.jsx)(`path`,{d:`M13.5 6.5v-2A1.5 1.5 0 0 0 12 3H4.5A1.5 1.5 0 0 0 3 4.5V12A1.5 1.5 0 0 0 4.5 13.5h2`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`})]})}function Lj({copy:e,title:t,url:n,onClose:r}){let i=Nj(),[a,o]=(0,G.useState)(!1),[s,c]=(0,G.useState)(!1);(0,G.useEffect)(()=>{let e=e=>{e.key===`Escape`&&r()};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[r]),(0,G.useEffect)(()=>{if(!a&&!s)return;let e=window.setTimeout(()=>{o(!1),c(!1)},1800);return()=>window.clearTimeout(e)},[a,s]);let l=(0,G.useCallback)(async()=>{let e=await S(n);o(e),c(!e)},[n]);return(0,K.jsx)(`div`,{className:`code-mobile-share-backdrop`,"data-testid":`code-mobile-share-sheet`,role:`presentation`,onPointerDown:r,children:(0,K.jsxs)(`section`,{className:`code-mobile-share-sheet`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`code-mobile-share-title`,onPointerDown:e=>e.stopPropagation(),children:[(0,K.jsxs)(`header`,{className:`code-mobile-share-header`,children:[(0,K.jsx)(`h2`,{id:`code-mobile-share-title`,children:e.mobileShareTitle}),(0,K.jsx)(`button`,{type:`button`,"aria-label":e.cancel,onClick:r,children:`×`})]}),(0,K.jsxs)(`section`,{className:`code-mobile-share-choice code-mobile-share-forward`,children:[(0,K.jsxs)(`div`,{className:`code-mobile-share-choice-copy`,children:[(0,K.jsx)(`h3`,{children:e.mobileForwardTitle}),(0,K.jsx)(`p`,{children:e.mobileForwardHint})]}),(0,K.jsxs)(`div`,{className:`code-mobile-share-link-row`,children:[(0,K.jsx)(`span`,{className:`code-mobile-share-link`,title:t,children:n}),(0,K.jsxs)(`button`,{type:`button`,"data-testid":`code-mobile-share-copy-action`,onClick:()=>void l(),children:[(0,K.jsx)(Ij,{}),(0,K.jsx)(`span`,{children:a?e.mobileShareCopied:e.mobileShareCopyAction})]})]}),s&&(0,K.jsx)(`span`,{className:`code-mobile-share-status`,role:`status`,children:e.copyFailed})]}),(0,K.jsxs)(`section`,{className:`code-mobile-share-choice code-mobile-share-install-guide`,children:[(0,K.jsx)(`h3`,{children:e.mobileInstallTitle}),i?(0,K.jsx)(`p`,{className:`code-mobile-install-complete`,children:e.mobileShareInstalled}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`p`,{className:`code-mobile-install-hint`,children:e.mobileInstallChromeHint}),(0,K.jsxs)(`div`,{className:`code-mobile-install-steps`,children:[(0,K.jsxs)(`div`,{className:`code-mobile-install-step`,children:[(0,K.jsxs)(`span`,{className:`code-mobile-install-controls`,"aria-hidden":`true`,children:[(0,K.jsx)(`span`,{className:`code-mobile-install-control`,children:(0,K.jsx)(Pj,{})}),(0,K.jsx)(`span`,{className:`code-mobile-install-or`,children:`/`}),(0,K.jsx)(`span`,{className:`code-mobile-install-control code-mobile-install-more`,children:`•••`})]}),(0,K.jsxs)(`span`,{children:[e.mobileInstallShareStep,(0,K.jsx)(`small`,{children:e.mobileInstallMoreStep})]})]}),(0,K.jsxs)(`div`,{className:`code-mobile-install-step`,children:[(0,K.jsx)(`span`,{className:`code-mobile-install-controls`,"aria-hidden":`true`,children:(0,K.jsx)(`span`,{className:`code-mobile-install-control`,children:(0,K.jsx)(Fj,{})})}),(0,K.jsxs)(`span`,{children:[e.mobileInstallAddStep,(0,K.jsx)(`small`,{children:e.mobileInstallOpenStep})]})]})]})]})]})]})})}function Rj(e){let t=e.filter(e=>!e.hidden),n=[];for(t.forEach(e=>{e.type===`separator`&&(n.length===0||n[n.length-1]?.type===`separator`)||n.push(e)});n[n.length-1]?.type===`separator`;)n.pop();return n}function zj({contextMenuAgent:e,contextMenuAgentSession:t,contextMenuProject:n,agentMenu:r,projectMenu:i,agentSessionMenu:a,renameDialog:o,killDialog:s,deleteWorktreeDialog:c,copyNotice:l,contextMenuRef:u,renameDialogRef:d,renameInputRef:f,killDialogRef:p,killCancelButtonRef:m,deleteWorktreeDialogRef:h,deleteWorktreeCancelButtonRef:g,onContextMenuKeyDown:_,runtimeSwitchDisabled:v,onSwitchAgentRuntime:y,onUpdateAgentFlags:b,onRenameAgent:x,onRenameProject:S,onCopyAgentWorkingDirectory:C,onForkAgent:w,onKillAgent:T,onOpenSession:ee,onToggleSessionPinned:E,onArchiveSession:D,onCopySessionWorkingDirectory:O,onToggleProjectPinned:k,onRevealProject:A,onCreatePermanentWorktree:j,onMarkProjectRead:M,onArchiveProject:N,onRemoveProject:P,onDeleteWorktree:te,onCloseRenameDialog:F,onRenameDialogTitleChange:ne,onSubmitRenameDialog:I,onCloseKillDialog:L,onSubmitKillDialog:R,onCloseDeleteWorktreeDialog:z,onSubmitDeleteWorktreeDialog:B,copy:V}){let re=MD(e),ie=FD(n),H=ID(n),ae=!!n?.agents.some(e=>e.unread),oe=e?.runtimeBinding.kind!==`terminal`,se=Rj([{type:`item`,id:`switch-agent-runtime`,label:oe?V.switchToTerminal:V.switchToChat,hidden:!ND(e),disabled:v||wD(e),onSelect:()=>{e&&y(e.id,oe?`terminal`:`chat`)}},{type:`separator`,id:`agent-runtime-separator`},{type:`item`,id:`pin-agent`,label:e?.pinned?V.unpinAgent:V.pinAgent,hidden:!re.actions.pin,onSelect:()=>b({pinned:!e?.pinned})},{type:`item`,id:`rename-agent`,label:V.renameAgent,hidden:!re.actions.rename,onSelect:x},{type:`item`,id:`archive-agent`,label:V.archiveAgent,hidden:!re.actions.archive,onSelect:()=>b({archived:!0})},{type:`item`,id:`toggle-agent-unread`,label:e?.unread?V.markAsRead:V.markAsUnread,hidden:!re.actions.markUnread,onSelect:()=>b({unread:!e?.unread})},{type:`separator`,id:`agent-copy-separator`},{type:`item`,id:`copy-agent-working-directory`,label:V.copyWorkingDirectory,hidden:!re.actions.copyWorkingDirectory,onSelect:C},{type:`separator`,id:`agent-fork-separator`},{type:`item`,id:`fork-same-worktree`,label:V.forkSameWorktree,hidden:!re.actions.forkSameWorktree,onSelect:()=>w(`same-worktree`)},{type:`item`,id:`fork-new-worktree`,label:V.forkNewWorktree,hidden:!re.actions.forkNewWorktree,onSelect:()=>w(`new-worktree`)},{type:`item`,id:`kill-agent`,label:V.killAgent,danger:!0,hidden:!re.actions.kill,onSelect:T}]),ce=Rj([{type:`item`,id:`open-session`,label:V.openSession,onSelect:()=>{t&&ee(t.provider,t.id)}},{type:`item`,id:`toggle-session-pinned`,label:t?.pinned?V.unpinChat:V.pinChat,onSelect:E},{type:`item`,id:`archive-session`,label:V.archiveChat,onSelect:D},{type:`item`,id:`copy-session-working-directory`,label:V.copyWorkingDirectory,onSelect:O}]),le=Rj([{type:`item`,id:`pin-project`,label:n?.pinned?V.unpinProject:V.pinProject,icon:`pin`,hidden:!n?.workspace,onSelect:k},{type:`item`,id:`reveal-project`,label:V.revealInFinder,icon:`folder`,hidden:!n?.workspace||n.hasMain,onSelect:A},{type:`item`,id:`create-permanent-worktree`,label:V.createPermanentWorktree,icon:`worktree`,hidden:!n?.workspace||n.hasMain,onSelect:j},{type:`separator`,id:`project-primary-separator`},{type:`item`,id:`rename-project`,label:V.renameProject,icon:`rename`,hidden:!n?.workspace,onSelect:S},{type:`item`,id:`mark-project-read`,label:V.markAllAsRead,icon:`check`,disabled:!ae,onSelect:M},{type:`item`,id:`archive-project`,label:V.archiveChats,icon:`archive`,disabled:!ie,onSelect:N},{type:`separator`,id:`project-destructive-separator`},{type:`item`,id:`remove-project`,label:V.removeProject,removeIcon:!0,hidden:!n?.workspace||n.hasMain,disabled:!!(n&&(n.agents.length>0||n.agentSessions.length>0||n.hasOpenFile)),onSelect:P},{type:`item`,id:`delete-worktree`,label:V.deleteWorktree,icon:`trash`,danger:!0,hidden:!H,onSelect:te}]);return(0,K.jsxs)(K.Fragment,{children:[e&&(0,K.jsx)(`div`,{className:`code-context-menu`,"data-testid":`code-agent-context-menu`,style:{left:r?.x??0,top:r?.y??0},role:`menu`,ref:u,onKeyDownCapture:_,onKeyDown:_,children:(0,K.jsx)(Bj,{entries:se})}),t&&(0,K.jsx)(`div`,{className:`code-context-menu`,"data-testid":`code-session-context-menu`,style:{left:a?.x??0,top:a?.y??0},role:`menu`,ref:u,onKeyDownCapture:_,onKeyDown:_,children:(0,K.jsx)(Bj,{entries:ce})}),n&&(0,K.jsx)(`div`,{className:`code-context-menu code-project-context-menu`,"data-testid":`code-project-context-menu`,style:{left:i?.x??0,top:i?.y??0},role:`menu`,ref:u,onKeyDownCapture:_,onKeyDown:_,children:(0,K.jsx)(Bj,{entries:le})}),o&&(0,K.jsx)(`div`,{className:`code-rename-backdrop`,"data-testid":`code-rename-backdrop`,onMouseDown:F,children:(0,K.jsxs)(`form`,{className:`code-rename-dialog`,"data-testid":`code-rename-dialog`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`code-rename-title`,ref:d,onMouseDown:e=>e.stopPropagation(),onKeyDownCapture:e=>Uj(e,d.current),onKeyDown:e=>Uj(e,d.current),onSubmit:e=>{e.preventDefault(),I()},children:[(0,K.jsx)(`label`,{id:`code-rename-title`,htmlFor:`code-rename-input`,children:o.kind===`project`?V.renameProject:V.renameAgent}),(0,K.jsx)(`input`,{id:`code-rename-input`,ref:f,"data-testid":`code-rename-input`,type:`text`,name:`farming-rename-title`,inputMode:`text`,autoComplete:`off`,autoCorrect:`off`,autoCapitalize:`none`,spellCheck:!1,enterKeyHint:`done`,"data-lpignore":`true`,"data-1p-ignore":`true`,"data-bwignore":`true`,"data-form-type":`other`,value:o.title,onChange:e=>ne(e.target.value),onKeyDown:e=>{e.key===`Escape`&&(e.preventDefault(),F())}}),(0,K.jsxs)(`div`,{className:`code-rename-actions`,children:[(0,K.jsx)(`button`,{type:`button`,onClick:F,children:V.cancel}),(0,K.jsx)(`button`,{type:`submit`,className:`primary`,disabled:!o.title.trim(),children:V.save})]})]})}),s&&(0,K.jsx)(`div`,{className:`code-rename-backdrop`,"data-testid":`code-kill-backdrop`,onMouseDown:L,children:(0,K.jsxs)(`div`,{className:`code-rename-dialog code-kill-dialog`,"data-testid":`code-kill-dialog`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`code-kill-title`,ref:p,onMouseDown:e=>e.stopPropagation(),onKeyDownCapture:e=>Uj(e,p.current),onKeyDown:e=>Uj(e,p.current),children:[(0,K.jsx)(`h2`,{id:`code-kill-title`,children:V.killAgentQuestion}),(0,K.jsx)(`p`,{children:s.acknowledgeUnprovenAcpExit?V.acknowledgeUnprovenAcpExitDescription(s.title):V.stopAgentDescription(s.title)}),(0,K.jsxs)(`div`,{className:`code-rename-actions`,children:[(0,K.jsx)(`button`,{type:`button`,ref:m,onClick:L,autoFocus:!0,children:V.cancel}),(0,K.jsx)(`button`,{type:`button`,className:`danger`,onClick:R,children:s.acknowledgeUnprovenAcpExit?V.acknowledgeUnprovenAcpExit:V.killAgent})]})]})}),c&&(0,K.jsx)(`div`,{className:`code-rename-backdrop`,"data-testid":`code-delete-worktree-backdrop`,onMouseDown:z,children:(0,K.jsxs)(`div`,{className:`code-rename-dialog code-kill-dialog`,"data-testid":`code-delete-worktree-dialog`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`code-delete-worktree-title`,ref:h,onMouseDown:e=>e.stopPropagation(),onKeyDownCapture:e=>Uj(e,h.current),onKeyDown:e=>Uj(e,h.current),children:[(0,K.jsx)(`h2`,{id:`code-delete-worktree-title`,children:V.deleteWorktreeQuestion}),(0,K.jsx)(`p`,{children:V.deleteWorktreeDescription}),(0,K.jsxs)(`div`,{className:`code-rename-actions`,children:[(0,K.jsx)(`button`,{type:`button`,ref:g,onClick:z,autoFocus:!0,children:V.cancel}),(0,K.jsx)(`button`,{type:`button`,className:`danger`,onClick:B,children:V.forceDelete})]})]})}),l&&(0,K.jsx)(`div`,{className:`code-copy-toast ${l.kind}`,"data-testid":`code-copy-toast`,role:`status`,children:l.message})]})}function Bj({entries:e}){return(0,K.jsx)(K.Fragment,{children:e.map(e=>e.type===`separator`?(0,K.jsx)(`div`,{className:`code-context-menu-separator`,role:`separator`},e.id):(0,K.jsxs)(`button`,{type:`button`,role:`menuitem`,className:e.danger?`danger`:void 0,disabled:e.disabled,onClick:e.onSelect,children:[(e.icon||e.removeIcon)&&(0,K.jsx)(`span`,{className:`code-context-menu-icon`,"aria-hidden":`true`,children:e.removeIcon?(0,K.jsx)(Vj,{}):(0,K.jsx)(Hj,{kind:e.icon})}),(0,K.jsx)(`span`,{children:e.label})]},e.id))})}function Vj(){return(0,K.jsx)(`svg`,{width:`16`,height:`16`,viewBox:`0 0 16 16`,"aria-hidden":`true`,focusable:`false`,children:(0,K.jsx)(`path`,{fill:`currentColor`,d:`M4.354 3.646a.5.5 0 0 0-.708.708L7.293 8l-3.647 3.646a.5.5 0 0 0 .708.708L8 8.707l3.646 3.647a.5.5 0 0 0 .708-.708L8.707 8l3.647-3.646a.5.5 0 0 0-.708-.708L8 7.293 4.354 3.646Z`})})}function Hj({kind:e}){return e===`pin`?(0,K.jsx)(`svg`,{width:`16`,height:`16`,viewBox:`0 0 16 16`,fill:`currentColor`,"aria-hidden":`true`,focusable:`false`,children:(0,K.jsx)(`path`,{d:`M13.5 3C13.303 3 13.109 3.038 12.923 3.114L8.481 4.967L5.659 4.026C5.505 3.976 5.339 4.001 5.209 4.095C5.078 4.189 5.001 4.339 5.001 4.5V7H1.257L0.5 7.5L1.257 8H5V10.5C5 10.661 5.077 10.812 5.208 10.905C5.338 11 5.504 11.023 5.658 10.974L8.48 10.033L12.925 11.887C13.109 11.962 13.302 12 13.499 12C14.326 12 14.999 11.327 14.999 10.5V4.5C14.999 3.673 14.326 3 13.499 3H13.5ZM14 10.5C14 10.843 13.615 11.09 13.308 10.962L8.693 9.038C8.631 9.013 8.566 9 8.501 9C8.447 9 8.395 9.009 8.343 9.025L6.001 9.806V5.193L8.343 5.974C8.457 6.011 8.581 6.007 8.694 5.961L13.306 4.038C13.629 3.902 14.001 4.156 14.001 4.499V10.499L14 10.5Z`})}):e===`folder`?(0,K.jsx)(`svg`,{width:`16`,height:`16`,viewBox:`0 0 16 16`,fill:`currentColor`,"aria-hidden":`true`,focusable:`false`,children:(0,K.jsx)(`path`,{d:`M2 4.5V9.10022L2.92389 7.5C3.45979 6.5718 4.45017 6 5.52196 6L11.9146 6C11.7087 5.4174 11.1531 5 10.5 5H7C6.86739 5 6.74021 4.94732 6.64645 4.85355L4.93934 3.14645C4.84557 3.05268 4.71839 3 4.58579 3H3.5C2.67157 3 2 3.67157 2 4.5ZM7.06895 13.9953C7.04641 13.9984 7.02339 14 7 14H3.5C2.11929 14 1 12.8807 1 11.5V4.5C1 3.11929 2.11929 2 3.5 2H4.58579C4.98361 2 5.36514 2.15804 5.64645 2.43934L7.20711 4H10.5C11.724 4 12.7426 4.87965 12.958 6.04127C14.605 6.34148 15.5443 8.22106 14.6616 9.75L13.0766 12.4953C12.5407 13.4235 11.5503 13.9953 10.4785 13.9953H7.06895ZM5.52196 7C4.80743 7 4.14718 7.3812 3.78991 8L2.20492 10.7453C1.62757 11.7453 2.34926 12.9953 3.50396 12.9953L10.4785 12.9953C11.193 12.9953 11.8533 12.6141 12.2105 11.9953L13.7955 9.25C14.3729 8.25 13.6512 7 12.4965 7L5.52196 7Z`})}):e===`worktree`?(0,K.jsx)(`svg`,{width:`16`,height:`16`,viewBox:`0 0 16 16`,fill:`currentColor`,"aria-hidden":`true`,focusable:`false`,children:(0,K.jsx)(`path`,{d:`M14 5.5C14 4.121 12.879 3 11.5 3C10.121 3 9 4.121 9 5.5C9 6.682 9.826 7.669 10.93 7.928C10.744 8.546 10.177 9 9.5 9H6.5C5.935 9 5.419 9.195 5 9.512V4.949C6.14 4.717 7 3.707 7 2.5C7 1.121 5.879 0 4.5 0C3.121 0 2 1.121 2 2.5C2 3.708 2.86 4.717 4 4.949V11.05C2.86 11.282 2 12.292 2 13.499C2 14.878 3.121 15.999 4.5 15.999C5.879 15.999 7 14.878 7 13.499C7 12.317 6.174 11.33 5.07 11.071C5.256 10.453 5.823 9.999 6.5 9.999H9.5C10.723 9.999 11.74 9.115 11.954 7.953C13.116 7.738 14 6.723 14 5.5ZM3 2.5C3 1.673 3.673 1 4.5 1C5.327 1 6 1.673 6 2.5C6 3.327 5.327 4 4.5 4C3.673 4 3 3.327 3 2.5ZM6 13.5C6 14.327 5.327 15 4.5 15C3.673 15 3 14.327 3 13.5C3 12.673 3.673 12 4.5 12C5.327 12 6 12.673 6 13.5ZM11.5 7C10.673 7 10 6.327 10 5.5C10 4.673 10.673 4 11.5 4C12.327 4 13 4.673 13 5.5C13 6.327 12.327 7 11.5 7Z`})}):e===`check`?(0,K.jsx)(`svg`,{width:`16`,height:`16`,viewBox:`0 0 16 16`,fill:`currentColor`,"aria-hidden":`true`,focusable:`false`,children:(0,K.jsx)(`path`,{d:`M13.6572 3.13573C13.8583 2.9465 14.175 2.95614 14.3643 3.15722C14.5535 3.35831 14.5438 3.675 14.3428 3.86425L5.84277 11.8642C5.64597 12.0494 5.33756 12.0446 5.14648 11.8535L1.64648 8.35351C1.45121 8.15824 1.45121 7.84174 1.64648 7.64647C1.84174 7.45121 2.15825 7.45121 2.35351 7.64647L5.50976 10.8027L13.6572 3.13573Z`})}):e===`archive`?(0,K.jsx)(`svg`,{width:`16`,height:`16`,viewBox:`0 0 16 16`,"aria-hidden":`true`,focusable:`false`,children:(0,K.jsx)(`path`,{fill:`currentColor`,d:`M6.5 8C6.22386 8 6 8.22386 6 8.5C6 8.77614 6.22386 9 6.5 9H9.5C9.77614 9 10 8.77614 10 8.5C10 8.22386 9.77614 8 9.5 8H6.5ZM1 3.5C1 2.67157 1.67157 2 2.5 2H13.5C14.3284 2 15 2.67157 15 3.5V4.5C15 5.15311 14.5826 5.70873 14 5.91465V11.5C14 12.8807 12.8807 14 11.5 14H4.5C3.11929 14 2 12.8807 2 11.5V5.91465C1.4174 5.70873 1 5.15311 1 4.5V3.5ZM2.5 3C2.22386 3 2 3.22386 2 3.5V4.5C2 4.77614 2.22386 5 2.5 5H13.5C13.7761 5 14 4.77614 14 4.5V3.5C14 3.22386 13.7761 3 13.5 3H2.5ZM3 6V11.5C3 12.3284 3.67157 13 4.5 13H11.5C12.3284 13 13 12.3284 13 11.5V6H3Z`})}):e===`trash`?(0,K.jsx)(`svg`,{width:`16`,height:`16`,viewBox:`0 0 16 16`,"aria-hidden":`true`,focusable:`false`,children:(0,K.jsx)(`path`,{fill:`currentColor`,d:`M6.25 2h3.5l.5 1H13v1H3V3h2.75l.5-1ZM4.2 5h7.6l-.48 8.1A1 1 0 0 1 10.32 14H5.68a1 1 0 0 1-1-.9L4.2 5Zm2.05 1 .35 7h.95L7.2 6h-.95Zm2.2 0v7h.95V6h-.95Z`})}):(0,K.jsx)(`svg`,{width:`16`,height:`16`,viewBox:`0 0 16 16`,"aria-hidden":`true`,focusable:`false`,children:(0,K.jsx)(`path`,{fill:`currentColor`,d:`M11.3536 1.64645C10.963 1.25592 10.3299 1.25592 9.93934 1.64645L3.14645 8.43934C3.05268 8.53311 2.99999 8.66029 2.99999 8.79289V11.5C2.99999 11.7761 3.22385 12 3.49999 12H6.2071C6.33971 12 6.46689 11.9473 6.56066 11.8536L13.3536 5.06066C13.7441 4.67014 13.7441 4.037 13.3536 3.64645L11.3536 1.64645ZM3.99999 9L8.99999 4L11 6L6 11H3.99999V9ZM9.7071 3.29289L10.6464 2.35355L12.6464 4.35355L11.7071 5.29289L9.7071 3.29289ZM2.5 14C2.22386 14 2 14.2239 2 14.5C2 14.7761 2.22386 15 2.5 15H13.5C13.7761 15 14 14.7761 14 14.5C14 14.2239 13.7761 14 13.5 14H2.5Z`})})}function Uj(e,t){if(e.key!==`Tab`||!t)return;let n=Array.from(t.querySelectorAll(`button:not(:disabled), input:not(:disabled), select:not(:disabled), textarea:not(:disabled), [href], [tabindex]:not([tabindex="-1"])`)).filter(e=>e.offsetParent!==null);if(n.length===0){e.preventDefault();return}let r=n[0],i=n[n.length-1];!r||!i||(e.shiftKey&&document.activeElement===r?(e.preventDefault(),i.focus()):!e.shiftKey&&document.activeElement===i&&(e.preventDefault(),r.focus()))}var Wj=o();function Gj({canInstall:e,canFullscreen:t,fullscreenActive:n,installUnavailableReason:i,copy:a,onClose:o,onInstall:s,onToggleFullscreen:c}){let l=(0,G.useRef)(null);return(0,G.useEffect)(()=>{let e=document.activeElement instanceof HTMLElement?document.activeElement:null;l.current?.focus({preventScroll:!0});let t=e=>{e.key===`Escape`&&o()};return document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`keydown`,t),e?.focus({preventScroll:!0})}},[o]),(0,Wj.createPortal)((0,K.jsx)(`div`,{className:`code-app-mode-backdrop`,"data-testid":`code-app-mode-dialog`,role:`presentation`,onPointerDown:o,children:(0,K.jsxs)(`section`,{className:`code-app-mode-dialog`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`code-app-mode-title`,onPointerDown:e=>e.stopPropagation(),children:[(0,K.jsx)(`button`,{ref:l,type:`button`,className:`code-app-mode-close`,"aria-label":a.cancel,onClick:o,children:`×`}),(0,K.jsxs)(`header`,{className:`code-app-mode-heading`,children:[(0,K.jsx)(`img`,{src:r(`/farming-2/app-icon-v2-180.png`),alt:``,"aria-hidden":`true`}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h2`,{id:`code-app-mode-title`,children:a.appModeTitle}),(0,K.jsx)(`p`,{children:a.appModeDescription})]})]}),e?(0,K.jsxs)(`section`,{className:`code-app-mode-choice recommended`,children:[(0,K.jsx)(`span`,{className:`code-app-mode-recommended`,children:a.appModeRecommended}),(0,K.jsx)(`h3`,{children:a.appModeInstallTitle}),(0,K.jsx)(`p`,{children:a.appModeInstallDescription}),(0,K.jsx)(`button`,{type:`button`,className:`code-app-mode-install`,"data-testid":`code-app-mode-install`,onClick:s,children:a.appModeInstallAction}),(0,K.jsxs)(`ol`,{className:`code-app-mode-install-steps`,children:[(0,K.jsx)(`li`,{children:a.appModeInstallStepOne}),(0,K.jsx)(`li`,{children:a.appModeInstallStepTwo})]})]}):(0,K.jsxs)(`section`,{className:`code-app-mode-choice unavailable`,"data-testid":`code-app-mode-install-unavailable`,children:[(0,K.jsx)(`h3`,{children:a.appModeInstallUnavailableTitle}),(0,K.jsx)(`p`,{children:i})]}),t&&(0,K.jsxs)(`section`,{className:`code-app-mode-choice temporary`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h3`,{children:a.appModeFullscreenTitle}),(0,K.jsx)(`p`,{children:a.appModeFullscreenDescription})]}),(0,K.jsx)(`button`,{type:`button`,"data-testid":`code-app-mode-fullscreen`,onClick:c,children:n?a.exitFocusMode:a.enterFocusMode})]})]})}),document.body)}var Kj=`https://github.com/zhuwenzhuang/farming`;function qj({copy:e,version:t,onClose:n,returnFocusRef:i}){let a=(0,G.useRef)(null);return(0,G.useEffect)(()=>{a.current?.focus({preventScroll:!0});let e=e=>{e.key===`Escape`&&n()};return document.addEventListener(`keydown`,e),()=>{document.removeEventListener(`keydown`,e),i.current?.focus({preventScroll:!0})}},[n,i]),(0,Wj.createPortal)((0,K.jsx)(`div`,{className:`code-brand-backdrop`,"data-testid":`code-brand-dialog`,role:`presentation`,onPointerDown:n,children:(0,K.jsxs)(`section`,{className:`code-brand-dialog`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`code-brand-title`,onPointerDown:e=>e.stopPropagation(),children:[(0,K.jsx)(`button`,{ref:a,type:`button`,className:`code-brand-close`,"aria-label":e.cancel,onClick:n,children:`×`}),(0,K.jsx)(`img`,{className:`code-brand-logo`,src:r(`/farming-2/app-icon-v2-180.png`),alt:``,"aria-hidden":`true`}),(0,K.jsxs)(`div`,{className:`code-brand-heading`,children:[(0,K.jsx)(`h2`,{id:`code-brand-title`,children:`Farming Code`}),t&&(0,K.jsx)(`span`,{children:t})]}),(0,K.jsxs)(`div`,{className:`code-brand-story`,children:[(0,K.jsx)(`p`,{children:e.brandStoryOrigin}),(0,K.jsx)(`p`,{children:e.brandStoryPurpose})]}),(0,K.jsx)(`a`,{className:`code-brand-github`,href:Kj,target:`_blank`,rel:`noreferrer`,children:e.brandGithub})]})}),document.body)}var Jj=80;function Yj({copy:e,instanceName:t,onClose:n,onSave:r,returnFocusRef:i}){let[a,o]=(0,G.useState)(t),[s,c]=(0,G.useState)(!1),[l,u]=(0,G.useState)(!1),d=(0,G.useRef)(null),f=(0,G.useRef)(!1);return(0,G.useEffect)(()=>{f.current=s},[s]),(0,G.useEffect)(()=>{d.current?.focus({preventScroll:!0}),d.current?.select();let e=e=>{e.key===`Escape`&&!f.current&&n()};return document.addEventListener(`keydown`,e),()=>{document.removeEventListener(`keydown`,e),i.current?.focus({preventScroll:!0})}},[n,i]),(0,Wj.createPortal)((0,K.jsx)(`div`,{className:`code-brand-backdrop`,"data-testid":`code-instance-name-dialog`,role:`presentation`,onPointerDown:()=>!s&&n(),children:(0,K.jsxs)(`form`,{className:`code-brand-dialog code-instance-name-dialog`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`code-instance-name-title`,onPointerDown:e=>e.stopPropagation(),onSubmit:async e=>{if(e.preventDefault(),!s){if(c(!0),u(!1),await r(a)){n();return}c(!1),u(!0)}},children:[(0,K.jsx)(`h2`,{id:`code-instance-name-title`,children:e.instanceNameTitle}),(0,K.jsx)(`p`,{children:e.instanceNameDescription}),(0,K.jsx)(`input`,{ref:d,value:a,maxLength:Jj,placeholder:e.instanceNamePlaceholder,"aria-label":e.instanceNameTitle,onChange:e=>o(e.target.value)}),l&&(0,K.jsx)(`p`,{className:`code-instance-name-error`,role:`alert`,children:e.instanceNameSaveFailed}),(0,K.jsxs)(`div`,{className:`code-instance-name-actions`,children:[(0,K.jsx)(`button`,{type:`button`,onClick:n,disabled:s,children:e.cancel}),(0,K.jsx)(`button`,{type:`submit`,className:`primary`,disabled:s,children:e.save})]})]})}),document.body)}var Xj=8,Zj=26,Qj=11,$j=10;function eM(){return typeof window>`u`?{width:220+Xj*2,height:$j+Xj*2}:{width:window.innerWidth,height:window.innerHeight}}function tM(e,t=0){return $j+e*Zj+t*Qj}function nM(e,t,n,r=eM(),i=220){let a=Math.max(Xj,r.width-i-Xj),o=Math.max(Xj,r.height-n-Xj);return{x:Math.max(Xj,Math.min(e,a)),y:Math.max(Xj,Math.min(t,o))}}function rM(e,t,n=eM(),r=220){let i=e.right+Xj,a=e.left-r-Xj,o=i+r<=n.width-Xj?i:a>=Xj?a:nM(i,e.top,t,n,r).x;return{x:o,y:nM(o,e.top,t,n,r).y}}function iM(e,t,n=eM(),r=220){let i=Math.max(Xj,n.width-r-Xj),a=Math.max(Xj,Math.min(e.right-r,i)),o=e.bottom+6,s=Math.max(Xj,n.height-t-Xj),c=e.top-t-6;return{x:a,y:o<=s?o:Math.max(Xj,Math.min(c,s))}}function aM(e){let t=LD(e);return tM(t.itemCount,t.separatorCount)}var oM=140,sM=264,cM=340,lM=4,uM=null;function dM(e){if(typeof e==`function`)return e;if(typeof e.default==`function`)return e.default;if(typeof e.qrcode==`function`)return e.qrcode;throw Error(`QR renderer failed to load`)}function fM(){return uM||=s(()=>import(`./qrcode-DV-_rjU8.js`).then(e=>dM(e)),[]),uM}function pM(e){let t=Math.max(0,Math.ceil(e/1e3)),n=Math.floor(t/60),r=t%60;return`${n}:${String(r).padStart(2,`0`)}`}function mM(e,t){return!!(e&&e.expiresAt>t+1e3)}function hM(e){return e.split(`-`).map(e=>e.trim()).filter(Boolean)}async function gM(e){e?.code&&await fetch(r(`/api/share/qr-ticket/${encodeURIComponent(e.code)}`),{method:`DELETE`}).catch(()=>{})}function _M(e,t,n){let r=e<7,i=t<7,a=t>=n-7,o=e>=n-7;return r&&i||r&&a||o&&i}function vM(e,t,n,r){let i=Math.floor((n-r)/2),a=i+r;return e>=i&&e<a&&t>=i&&t<a}function yM(e,t){return(e+t)%11==0?`#6d8a63`:(e*3+t)%17==0?`#9b7a35`:`#263327`}function bM(e,t,n){return(0,K.jsxs)(`g`,{children:[(0,K.jsx)(`rect`,{x:e,y:t,width:`7`,height:`7`,rx:`1.45`,fill:`#263327`}),(0,K.jsx)(`rect`,{x:e+1,y:t+1,width:`5`,height:`5`,rx:`1`,fill:`#fbfaf2`}),(0,K.jsx)(`rect`,{x:e+2,y:t+2,width:`3`,height:`3`,rx:`0.72`,fill:`#263327`}),(0,K.jsx)(`rect`,{x:e+3.05,y:t+3.05,width:`0.9`,height:`0.9`,rx:`0.32`,fill:`#d9a735`})]},n)}function xM({value:e,badgeUrl:t,qrCodeFactory:n}){let r=(0,G.useId)().replace(/:/g,``),i=(0,G.useMemo)(()=>{let t=n(0,`H`);return t.addData(e),t.make(),t},[n,e]),a=i.getModuleCount(),o=a+lM*2,s=Math.max(7,Math.min(11,Math.floor(a*.26)|1)),c=s+1.4,l=lM+(a-c)/2,u=lM+(a-c)/2,d=`farming-qr-badge-${r}`,f=[];for(let e=0;e<a;e+=1)for(let t=0;t<a;t+=1)i.isDark(e,t)&&(_M(e,t,a)||vM(e,t,a,s)||f.push((0,K.jsx)(`rect`,{x:lM+t+.14,y:lM+e+.14,width:`0.72`,height:`0.72`,rx:`0.24`,fill:yM(e,t)},`${e}-${t}`)));return(0,K.jsxs)(`svg`,{className:`code-share-qr-svg`,viewBox:`0 0 ${o} ${o}`,role:`img`,"aria-label":`QR code`,shapeRendering:`geometricPrecision`,children:[(0,K.jsx)(`defs`,{children:(0,K.jsx)(`clipPath`,{id:d,children:(0,K.jsx)(`rect`,{x:l+.55,y:u+.55,width:c-1.1,height:c-1.1,rx:`2.1`})})}),(0,K.jsx)(`rect`,{x:`0`,y:`0`,width:o,height:o,rx:`4`,fill:`#fbfaf2`}),f,bM(lM,lM,`top-left`),bM(lM+a-7,lM,`top-right`),bM(lM,lM+a-7,`bottom-left`),(0,K.jsx)(`rect`,{x:l,y:u,width:c,height:c,rx:`2.6`,fill:`#fbfaf2`}),(0,K.jsx)(`rect`,{x:l+.35,y:u+.35,width:c-.7,height:c-.7,rx:`2.25`,fill:`#ffffff`}),(0,K.jsx)(`image`,{href:t,x:l+.55,y:u+.55,width:c-1.1,height:c-1.1,preserveAspectRatio:`xMidYMid slice`,clipPath:`url(#${d})`})]})}function SM({copy:e,sidebarCollapsed:t,shareTarget:n,openRequest:i=0}){let[a,o]=(0,G.useState)(!1),[s,c]=(0,G.useState)(!1),[l,u]=(0,G.useState)(null),[d,f]=(0,G.useState)(!1),[p,g]=(0,G.useState)(``),[_,v]=(0,G.useState)(!1),[y,b]=(0,G.useState)(()=>Date.now()),[x,C]=(0,G.useState)({x:0,y:0}),w=(0,G.useRef)(null),T=(0,G.useRef)(null),ee=(0,G.useRef)(null),E=(0,G.useRef)(null),D=(0,G.useRef)(null),O=(0,G.useRef)(0),k=(0,G.useRef)(null),A=(0,G.useRef)(null),j=(0,G.useRef)(0),[M,N]=(0,G.useState)(!0),[P,te]=(0,G.useState)(null),F=r(`/farming-2/app-icon-v2-180.png`),ne=h(n);(0,G.useEffect)(()=>{k.current=l},[l]);let I=(0,G.useCallback)(()=>{D.current!==null&&(window.clearTimeout(D.current),D.current=null)},[]),L=(0,G.useCallback)(()=>{let e=T.current?.getBoundingClientRect();if(!e)return;let t=e.right+8,n=e.left-sM-8;C({x:t+sM+10<=window.innerWidth?t:Math.max(8,n),y:Math.max(8,Math.min(e.top-4,window.innerHeight-cM-8))})},[]),R=(0,G.useCallback)(()=>{t||fM().then(e=>te(()=>e)).catch(()=>g(e.shareLinkFailed))},[e.shareLinkFailed,t]),z=(0,G.useCallback)(async(t=!1)=>{let i=k.current;if(!t&&mM(i,Date.now()))return i;let a=O.current+1;O.current=a,f(!0),g(``);try{let t=m(n),i=await fetch(r(`/api/share/qr-ticket`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t?{target:t}:{})}),o=await i.json();if(!i.ok||!(`shortUrl`in o))throw Error(`error`in o&&o.error?o.error:e.shareLinkFailed);return a===O.current?(u(o),b(Date.now()),v(!1),o):(await gM(o),null)}catch(t){return a===O.current&&g(t instanceof Error?t.message:e.shareLinkFailed),null}finally{a===O.current&&f(!1)}},[e.shareLinkFailed,n,ne]),B=(0,G.useCallback)(()=>{I(),O.current+=1,o(!1),c(!1),g(``),v(!1),f(!1);let e=k.current;k.current=null,u(null),gM(e)},[I]),V=(0,G.useCallback)((e,t=!1)=>{I(),L(),o(!0),c(e),R(),z(t)},[I,z,R,L]);(0,G.useEffect)(()=>{!i||j.current===i||(j.current=i,V(!0,!0))},[V,i]);let re=(0,G.useCallback)(()=>{!a||s||(I(),D.current=window.setTimeout(()=>{D.current=null,B()},oM))},[I,B,a,s]),ie=(0,G.useCallback)(()=>{if(a&&s){B();return}V(!0,!0)},[B,a,V,s]),H=(0,G.useCallback)(async()=>{let t=mM(k.current,Date.now())?k.current:await z(!0);if(t){if(!await S(t.longUrl)){g(e.copyFailed);return}v(!0),A.current!==null&&window.clearTimeout(A.current),A.current=window.setTimeout(()=>{v(!1),A.current=null},1800)}},[e.copyFailed,z]);(0,G.useLayoutEffect)(()=>{if(a)return L(),window.addEventListener(`resize`,L),()=>window.removeEventListener(`resize`,L)},[a,L]),(0,G.useEffect)(()=>{if(!a)return;let e=window.setInterval(()=>b(Date.now()),1e3);return()=>window.clearInterval(e)},[a]),(0,G.useEffect)(()=>{let e=k.current;e&&(k.current=null,u(null),v(!1),gM(e))},[ne]),(0,G.useLayoutEffect)(()=>{if(!a)return;let e=()=>{let e=ee.current,t=E.current;!e||!t||N(t.scrollWidth<=e.clientWidth+1)};e();let t=typeof ResizeObserver<`u`?new ResizeObserver(e):null;return t&&ee.current&&t.observe(ee.current),window.addEventListener(`resize`,e),()=>{t?.disconnect(),window.removeEventListener(`resize`,e)}},[a,l?.tokenLabel,l?.shortPath]),(0,G.useEffect)(()=>{if(!a)return;let e=e=>{let t=e.target;t instanceof Node&&w.current?.contains(t)||B()},t=e=>{e.key===`Escape`&&B()};return document.addEventListener(`pointerdown`,e,!0),document.addEventListener(`keydown`,t,!0),()=>{document.removeEventListener(`pointerdown`,e,!0),document.removeEventListener(`keydown`,t,!0)}},[B,a]),(0,G.useEffect)(()=>()=>{I(),A.current!==null&&window.clearTimeout(A.current),O.current+=1,gM(k.current)},[I]);let ae=!!(l&&l.expiresAt<=y),oe=l?pM(l.expiresAt-y):``,se=l?.tokenLabel||l?.shortPath||e.copyFullShareLink,ce=hM(se),le=M||ce.length<=1?[se]:ce;return(0,K.jsxs)(`div`,{ref:w,className:`code-share-root`,onMouseEnter:R,onMouseLeave:re,onFocus:()=>{I(),R()},onBlur:e=>{!e.currentTarget.contains(e.relatedTarget)&&!s&&B()},children:[(0,K.jsx)(`button`,{ref:T,type:`button`,className:`code-share-button`,"data-testid":`code-share-button`,"aria-label":e.sharePage,title:e.sharePage,"aria-haspopup":`dialog`,"aria-expanded":a,onClick:ie,children:(0,K.jsx)(be,{className:`code-share-icon`})}),a&&(0,K.jsxs)(`div`,{className:`code-share-popover`,"data-testid":`code-share-popover`,role:`dialog`,"aria-label":e.scanToOpenOnPhone,style:{left:x.x,top:x.y},onMouseEnter:()=>{I()},onMouseLeave:re,onKeyDown:e=>{e.key===`Escape`&&(B(),T.current?.focus())},children:[(0,K.jsxs)(`div`,{className:`code-share-qr-frame`,"data-expired":ae?`true`:`false`,children:[(0,K.jsx)(`div`,{className:`code-share-qr-canvas`,children:l&&!d&&P?(0,K.jsx)(xM,{value:l.shortUrl,badgeUrl:F,qrCodeFactory:P}):(0,K.jsx)(`div`,{className:`code-share-qr-loading`,children:d?e.loading:e.shareLinkFailed})}),l&&(0,K.jsx)(`div`,{className:`code-share-countdown`,children:ae?e.shareLinkExpired:oe}),ae&&(0,K.jsx)(`button`,{type:`button`,className:`code-share-refresh`,onClick:()=>void z(!0),children:e.refreshShareLink})]}),(0,K.jsxs)(`button`,{type:`button`,className:`code-share-copy-token`,"data-testid":`code-share-copy-link`,disabled:!l&&d,onClick:()=>void H(),children:[(0,K.jsxs)(`span`,{ref:ee,className:`code-share-token ${M?`single-line`:``}`,"aria-label":se,children:[(0,K.jsx)(`span`,{ref:E,className:`code-share-token-measure`,"aria-hidden":`true`,children:se}),le.map((e,t)=>(0,K.jsx)(`span`,{className:`code-share-token-line`,children:e},`${t}-${e}`))]}),(0,K.jsx)(`span`,{className:`code-share-copy-action`,children:_?e.copiedShareLink:e.copyFullShareLink})]}),p&&(0,K.jsx)(`div`,{className:`code-share-error`,role:`status`,children:p})]})]})}function CM(e,t){return e&&t.some(t=>!t.isMain&&t.id===e)?e:t.find(e=>!e.isMain)?.id??null}function wM(e){return e&&(e.projectWorkspace||e.cwd)||``}function TM(e,t,n={},r=[],i=e,a=[],o=[]){let s=aO(e,t),c=new Map(s.map(e=>[e.workspace,e]));r.forEach(e=>{let t=e.sourceAgentId?i.find(t=>t.id===e.sourceAgentId):i.find(t=>t.id===e.agentId),n=e.workspaceRoot||(t?UD(t):``);if(!n||n===`/`)return;let r=c.get(n);if(r){r.hasOpenFile=!0,!r.gitWorktree&&t?.gitWorktree?.workspace&&(r.gitWorktree=t.gitWorktree);return}let a={id:n,name:WD(n),workspace:n,agents:[],agentSessions:[],hasMain:!1,hasProjectAgent:!1,hasAgentSession:!1,hasOpenFile:!0,gitWorktree:t?.gitWorktree??null};s.push(a),c.set(n,a)}),a.forEach(e=>{if(!e||e===`/`||c.get(e))return;let t={id:e,name:WD(e),workspace:e,agents:[],agentSessions:[],hasMain:!1,hasProjectAgent:!1,hasAgentSession:!1,gitWorktree:null};s.push(t),c.set(e,t)});let l=new Map(o.map((e,t)=>[e,t]));return s.map((e,t)=>{let r=e.workspace?n[e.workspace]?.trim():``,i=r&&!e.hasMain?{...e,name:r}:e,a=l.get(e.workspace);return{project:{...i,pinned:a!==void 0},pinIndex:a,sourceIndex:t}}).sort((e,t)=>e.pinIndex!==void 0&&t.pinIndex!==void 0?e.pinIndex-t.pinIndex:e.pinIndex===void 0?t.pinIndex===void 0?e.sourceIndex-t.sourceIndex:1:-1).map(e=>e.project)}function EM(e,t,n,r=new Set,i=new Set){return t?jk(e.map(e=>{let n=[e.name,e.workspace].some(e=>e.toLowerCase().includes(t)),a=n?e.agents:e.agents.filter(e=>i.has(e.id)||ee(e).toLowerCase().includes(t)),o=n?e.agentSessions:e.agentSessions.filter(e=>r.has(ZD(e))||e.title.toLowerCase().includes(t));return a.length>0||o.length>0||e.workspace&&n?{...e,agents:a,agentSessions:o}:null}).filter(e=>!!e),n,!0):e}function DM(e,t,n){return e.flatMap(e=>t.has(e.id)&&!n?[]:[...e.agents.map(e=>({kind:`agent`,id:e.id})),...e.agentSessions.map(e=>({kind:`agent-session`,provider:e.provider,id:e.id,...e.providerHomeId?{providerHomeId:e.providerHomeId}:{}}))])}var OM=5,kM=5,AM=`__project_agent_drop_end__`;function jM(){return typeof window>`u`?!1:navigator.standalone===!0||window.matchMedia(`(display-mode: standalone)`).matches}function MM(e){let t=e?.trim().toLowerCase()||``;if(t===`claude-code`)return`claude`;if([`codex`,`claude`,`opencode`,`qoder`,`bash`,`zsh`].includes(t))return t}function NM(e){return MM(e.providerSessionProvider)||MM(e.command.trim().split(/\s+/).find(e=>e!==`env`&&!/^[A-Za-z_][A-Za-z0-9_]*=/.test(e))?.split(`/`).pop())}function PM(){return(0,K.jsxs)(`svg`,{width:`12`,height:`12`,viewBox:`0 0 16 16`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.4`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,K.jsx)(`circle`,{cx:`4`,cy:`3`,r:`1.5`}),(0,K.jsx)(`circle`,{cx:`4`,cy:`13`,r:`1.5`}),(0,K.jsx)(`circle`,{cx:`12`,cy:`5`,r:`1.5`}),(0,K.jsx)(`path`,{d:`M4 4.5v7M5.5 8h2.25A4.25 4.25 0 0 0 12 3.75`})]})}function FM(e){let t=e.trim().replace(/^v/i,``);if(!t)return``;let n=/^(\d+\.\d+\.\d+)-(\d+)-g[0-9a-f]+(?:-dirty)?$/i.exec(t);if(n)return`${n[1]}-${n[2]}`;let r=/^(\d+\.\d+\.\d+)-dirty$/i.exec(t);return r?`${r[1]}-1`:t.replace(/-dirty$/i,``)}var IM=(0,G.lazy)(()=>s(()=>import(`./ProjectFilesSection-C1RAJWOE.js`).then(e=>({default:e.ProjectFilesSection})),__vite__mapDeps([18,1,5,6,7,19,20,15,16])));function LM({sidebarCollapsed:e,emptyHomeActionRequest:t,activeView:n,searchOpen:i,displayedProjects:a,collapsedProjectIds:o,normalizedSearch:s,hasProjectListItems:c,hasDisplayedProjectListItems:l,activeTerminalId:u,selectedSearchAgentId:d,selectedSearchSessionHandle:f,claimedAgentSessionKeyByAgentId:p,agentShortcutKeys:m,keyboardShortcutsEnabled:h,now:g,mainAgent:_,usageSummary:v,instanceName:y,shareTarget:b,agentLaunchOptions:x,agentCreationWorkspace:S,openWorkspaceFile:C,openWorkspaceFiles:w,fileRevealRequest:T,fileSearchFocusRequest:ee,projectListRef:E,canLoadMoreAgentSessions:D,onLoadMoreAgentSessions:O,onNewAgent:k,onStartAgent:A,onToggleSidebar:j,onOpenSearch:M,onOpenWorkspaceView:N,onOpenMainAgent:P,onRestartMainAgent:te,onProjectListKeyDown:F,onToggleProject:ne,onToggleProjectSessions:I,onMountProject:L,onOpenProjectContextMenu:R,onOpenProjectKeyboardMenu:B,onOpenAgent:V,onUpdateAgentFlags:re,onReorderAgent:ie,onOpenAgentContextMenu:H,onOpenAgentKeyboardMenu:ae,onResumeAgentSession:oe,onOpenAgentSessionContextMenu:se,onOpenAgentSessionKeyboardMenu:ce,onOpenProjectFile:le,onSelectOpenWorkspaceFile:ue,onCloseOpenWorkspaceFile:de,onMoveWorkspaceEntries:fe,onDeleteWorkspaceEntries:pe,onRefreshProjectOpenFiles:me,onOpenOptionsMenu:he,onRenameInstance:_e,copy:ye}){let[be,xe]=(0,G.useState)(null),Se=(0,G.useRef)(null),we=(0,G.useRef)(!1),Te=(0,G.useRef)(new Map),[De,Oe]=(0,G.useState)(!0),[ke,je]=(0,G.useState)(!1),[W,Ne]=(0,G.useState)(!1),[Pe,Fe]=(0,G.useState)(!1),Ie=(0,G.useRef)(null),Le=(0,G.useRef)(null),Re=(0,G.useCallback)(()=>Ne(!1),[]),[Be,He]=(0,G.useState)(!1),[Ue,We]=(0,G.useState)(!1),[Ge,qe]=(0,G.useState)(jM),[Je,Xe]=(0,G.useState)(!1),[Ze,Qe]=(0,G.useState)(null),$e=(0,G.useRef)(0),[et,tt]=(0,G.useState)(!1),nt=(0,G.useCallback)(e=>{D&&e.scrollHeight-e.scrollTop-e.clientHeight<=240&&O()},[D,O]),rt=(0,G.useCallback)(()=>{Se.current!==null&&(window.clearTimeout(Se.current),Se.current=null)},[]),it=(0,G.useCallback)(()=>{rt(),xe(null)},[rt]),at=(0,G.useCallback)(()=>{we.current=!1,it()},[it]),ot=(0,G.useCallback)((e,t,n=!1)=>{rt();let i=e.currentTarget,a=we.current?0:n?450:1500;Se.current=window.setTimeout(()=>{if(Se.current=null,!i.matches(`:hover`))return;let e=i.getBoundingClientRect(),n=e.right+10,a=Math.min(320,window.innerWidth-n-12);if(a<200)return;let o=Math.max(8,Math.min(e.top-4,window.innerHeight-152)),s=t.workspaceRootId?Te.current.get(t.workspaceRootId):void 0,c=s&&s.expiresAt>Date.now()?s.branch:``;we.current=!0,xe({...t,x:n,y:o,width:a,branch:c}),!(!t.workspaceRootId||c)&&fetch(r(`/api/files/branch?rootId=${encodeURIComponent(t.workspaceRootId)}`)).then(e=>e.ok?e.json():null).then(e=>{let n=typeof e?.branch==`string`?e.branch.trim():``;Te.current.set(t.workspaceRootId,{branch:n,expiresAt:Date.now()+3e4}),xe(e=>e?.key===t.key?{...e,branch:n}:e)}).catch(()=>{Te.current.set(t.workspaceRootId,{branch:``,expiresAt:Date.now()+3e4})})},a)},[rt]);(0,G.useEffect)(()=>()=>rt(),[rt]),(0,G.useEffect)(()=>{We(!!(document.fullscreenEnabled&&document.documentElement.requestFullscreen));let e=()=>{He(!!document.fullscreenElement)};return document.addEventListener(`fullscreenchange`,e),e(),()=>{document.removeEventListener(`fullscreenchange`,e)}},[]),(0,G.useEffect)(()=>{let e=window.matchMedia(`(display-mode: standalone)`),t=()=>{let e=jM();qe(e),e&&Xe(!1)},n=e=>{e.preventDefault(),Qe(e)};return e.addEventListener(`change`,t),window.addEventListener(`beforeinstallprompt`,n),t(),()=>{e.removeEventListener(`change`,t),window.removeEventListener(`beforeinstallprompt`,n)}},[]);let st=(0,G.useCallback)(()=>{if(document.fullscreenElement){document.exitFullscreen().catch(()=>{});return}document.documentElement.requestFullscreen({navigationUI:`hide`}).catch(()=>{})},[]);(0,G.useEffect)(()=>{if(!(!t||$e.current===t.nonce)&&($e.current=t.nonce,t.kind===`focus`)){if(Ge){st();return}Xe(!0)}},[t,Ge,st]);let ct=(0,G.useCallback)(()=>{let e=Ze;e&&e.prompt().then(()=>e.userChoice).then(e=>{Qe(null),e.outcome===`accepted`&&Xe(!1)}).catch(()=>Qe(null))},[Ze]),lt=(0,G.useCallback)(()=>{Xe(!1),st()},[st]),ut=window.isSecureContext?ye.appModeInstallUnavailableBrowser:ye.appModeInstallUnavailableInsecure,dt=a.flatMap(e=>[...e.agents.filter(e=>e.pinned).map(e=>({kind:`agent`,agent:e})),...e.agentSessions.filter(e=>e.pinned).map(e=>({kind:`agent-session`,session:e}))]).sort((e,t)=>e.kind===`agent`&&t.kind===`agent`?(e.agent.pinnedOrder??0)-(t.agent.pinnedOrder??0)||(e.agent.startedAt??0)-(t.agent.startedAt??0):e.kind===t.kind?e.kind===`agent-session`&&t.kind===`agent-session`?rO(t.session)-rO(e.session):0:e.kind===`agent`?-1:1),ft=a.filter(e=>e.agents.some(e=>!e.pinned||!e.isMain)||e.agentSessions.some(e=>!e.pinned)||(e.hiddenAgentSessionCount??0)>0||e.hasOpenFile||!!e.workspace),pt=a.flatMap(e=>[...e.agents.filter(e=>!e.isMain).map(t=>({agent:t,projectName:e.name}))]),mt=w.filter(e=>Ke(e.agentId)),ht=C&&Ke(C.agentId)?C:null,gt=T?.agentId===Ye,_t=mt.length>0||gt;(0,G.useEffect)(()=>{_t||tt(!1)},[_t]),(0,G.useEffect)(()=>{gt&&tt(!1)},[gt]);let vt=FM(`2.2.22`),yt=vt?`v${vt}`:``,bt=e;return(0,K.jsxs)(`aside`,{className:`code-sidebar ${e?`collapsed`:``}`,"data-testid":`code-sidebar`,onMouseLeave:at,children:[(0,K.jsx)(`div`,{className:`code-nav`,children:(0,K.jsxs)(`div`,{className:`code-nav-top-row`,children:[(0,K.jsxs)(`button`,{type:`button`,className:`code-nav-item primary`,"data-testid":`code-new-agent`,onClick:e=>k(S,void 0,e.currentTarget),children:[(0,K.jsx)(`span`,{className:`code-nav-icon`,children:(0,K.jsx)(Ce,{})}),(0,K.jsx)(`span`,{children:ye.newAgent}),h&&(0,K.jsx)(`kbd`,{children:`N`})]}),(0,K.jsx)(SM,{copy:ye,sidebarCollapsed:e,shareTarget:b,openRequest:t?.kind===`share`?t.nonce:0}),!Ge&&!e&&(0,K.jsx)(`button`,{type:`button`,className:`code-sidebar-focus-toggle ${Be?`active`:``}`,"data-testid":`code-sidebar-focus-toggle`,"aria-label":ye.appModeOpen,title:ye.appModeOpen,"aria-haspopup":`dialog`,"aria-expanded":Je,onClick:()=>Xe(!0),children:(0,K.jsx)(`span`,{className:`code-sidebar-focus-icon`,children:(0,K.jsx)(U,{})})}),!e&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`button`,{type:`button`,className:`code-sidebar-search-toggle ${n===`search`||i?`active`:``}`,"data-testid":`code-nav-search`,"aria-label":ye.search,title:ye.search,"aria-pressed":n===`search`||i,onClick:M,children:(0,K.jsx)(`span`,{className:`code-sidebar-search-icon`,"aria-hidden":`true`,children:(0,K.jsx)(Ae,{})})}),(0,K.jsx)(`button`,{type:`button`,className:`code-sidebar-history-toggle ${n===`history`?`active`:``}`,"data-testid":`code-nav-history`,"aria-label":ye.history,title:ye.history,"aria-pressed":n===`history`,onClick:()=>N(`history`),children:(0,K.jsx)(`span`,{className:`code-sidebar-history-icon`,"aria-hidden":`true`,children:(0,K.jsx)(Ve,{})})})]}),(0,K.jsx)(`button`,{type:`button`,className:`code-sidebar-toggle`,"data-testid":`code-sidebar-toggle`,"aria-label":e?ye.expandSidebar:ye.collapseSidebar,title:e?ye.expandSidebar:ye.collapseSidebar,onClick:j,children:(0,K.jsx)(`span`,{className:`code-sidebar-toggle-icon ${e?`collapsed`:`expanded`}`,"aria-hidden":`true`,children:e?(0,K.jsx)(Ee,{}):(0,K.jsx)(ze,{})})})]})}),e&&pt.length>0&&(0,K.jsx)(PN,{items:pt,activeTerminalId:u,now:g,onOpenAgent:V,onShowPreview:ot,onHidePreview:it,copy:ye}),(0,K.jsxs)(`div`,{className:`code-project-list`,"data-testid":`code-project-list`,ref:E,tabIndex:0,onKeyDown:F,onScroll:e=>nt(e.currentTarget),"aria-label":ye.projectsAndAgents,children:[!c&&(0,K.jsx)(`div`,{className:`code-empty-project`,children:ye.noAgentsYet}),c&&!l&&(0,K.jsx)(`div`,{className:`code-empty-project`,"data-testid":`code-empty-search`,children:ye.noMatchingProjectsOrAgents}),dt.length>0&&(0,K.jsx)(RN,{items:dt,collapsed:ke,compressed:bt,activeTerminalId:u,selectedSearchAgentId:d,selectedSearchSessionHandle:f,claimedAgentSessionKeyByAgentId:p,agentShortcutKeys:m,keyboardShortcutsEnabled:h,now:g,onOpenAgent:V,onUpdateAgentFlags:re,onReorderAgent:ie,onOpenAgentContextMenu:H,onOpenAgentKeyboardMenu:ae,onResumeAgentSession:oe,onOpenAgentSessionContextMenu:se,onOpenAgentSessionKeyboardMenu:ce,onShowAgentPreview:ot,onHideAgentPreview:it,onToggleCollapsed:()=>je(e=>!e),copy:ye}),_t&&(0,K.jsxs)(`section`,{className:`code-project-group code-root-files-group`,"data-testid":`code-root-files-group`,children:[(0,K.jsx)(`div`,{className:`code-project-row code-root-files-row`,children:(0,K.jsxs)(`button`,{type:`button`,className:`code-project-title`,"data-testid":`code-root-files-title`,"aria-expanded":!et,onClick:()=>tt(e=>!e),children:[(0,K.jsx)(`span`,{className:`code-folder-icon ${et?`collapsed`:`expanded`}`,"aria-hidden":`true`,children:et?(0,K.jsx)(Ee,{}):(0,K.jsx)(Me,{})}),(0,K.jsx)(`span`,{children:`/`})]})}),!et&&(0,K.jsx)(`div`,{className:`code-project-expanded`,children:(0,K.jsx)(G.Suspense,{fallback:null,children:(0,K.jsx)(IM,{projectId:`__farming_global_files_project__`,projectWorkspace:`/`,agentId:`wroot_global`,agentLaunchOptions:[],activeFilePath:ht?.file.path,openFiles:mt.map(e=>({agentId:e.agentId,workspaceRoot:e.workspaceRoot,key:z(e),path:e.file.path,dirty:e.dirty,externalChanged:e.externalChanged})),revealRequest:T?.agentId===`wroot_global`?T:void 0,focusSearchRequest:ee?.agentId===`wroot_global`?ee:void 0,onOpenFile:le,onSelectOpenFile:ue,onCloseOpenFile:de,onMoveEntries:fe,onDeleteEntries:pe,onRefreshOpenFiles:me,readOnly:!0,copy:ye})})})]}),ft.map(e=>(0,K.jsx)(HN,{project:e,collapsed:o.has(e.id)&&!s,forceAgentsExpanded:!!s,compactAgents:bt,activeTerminalId:u,selectedSearchAgentId:d,selectedSearchSessionHandle:f,claimedAgentSessionKeyByAgentId:p,agentShortcutKeys:m,keyboardShortcutsEnabled:h,now:g,openWorkspaceFile:C,openWorkspaceFiles:w,agentLaunchOptions:x,fileRevealRequest:T,fileSearchFocusRequest:ee,onToggleProject:ne,onToggleProjectSessions:I,onMountProject:L,onNewAgent:k,onStartAgent:A,onOpenProjectContextMenu:R,onOpenProjectKeyboardMenu:B,onOpenAgent:V,onUpdateAgentFlags:re,onReorderAgent:ie,onOpenAgentContextMenu:H,onOpenAgentKeyboardMenu:ae,onResumeAgentSession:oe,onOpenAgentSessionContextMenu:se,onOpenAgentSessionKeyboardMenu:ce,onShowAgentPreview:ot,onHideAgentPreview:it,onOpenProjectFile:le,onSelectOpenWorkspaceFile:ue,onCloseOpenWorkspaceFile:de,onMoveWorkspaceEntries:fe,onDeleteWorkspaceEntries:pe,onRefreshProjectOpenFiles:me,copy:ye},e.id))]}),(0,K.jsxs)(`div`,{className:`code-sidebar-footer`,children:[!e&&(0,K.jsxs)(`button`,{ref:Le,type:`button`,className:`code-instance-name`,"data-testid":`code-instance-name-edit`,"aria-label":ye.renameInstance,title:y,onClick:()=>Fe(!0),children:[(0,K.jsx)(`span`,{className:`code-instance-name-copy`,children:y}),(0,K.jsx)(ge,{})]}),(0,K.jsxs)(`div`,{className:`code-product-row`,children:[(0,K.jsxs)(`button`,{ref:Ie,type:`button`,className:`code-product-mark`,"data-testid":`code-product-mark`,title:`Farming Code`,"aria-label":`Farming Code`,onClick:()=>Ne(!0),children:[(0,K.jsx)(`img`,{className:`code-product-logo`,src:r(`/farming-2/app-icon-v2-180.png`),alt:``,"aria-hidden":`true`}),(0,K.jsxs)(`span`,{className:`code-product-mark-copy`,children:[(0,K.jsxs)(`span`,{className:`code-product-mark-main-slot`,children:[(0,K.jsx)(`span`,{className:`code-product-mark-main code-product-mark-main-full`,children:`Farming Code`}),(0,K.jsx)(`span`,{className:`code-product-mark-main code-product-mark-main-short`,"aria-hidden":`true`,children:`Farming`})]}),yt&&(0,K.jsx)(`span`,{className:`code-product-mark-badge`,children:yt})]})]}),(0,K.jsx)(`button`,{type:`button`,className:`code-sidebar-options`,"data-testid":`code-sidebar-options`,"aria-label":ye.openSettings,title:ye.openSettings,onClick:he,children:(0,K.jsx)(ve,{})})]}),!e&&(0,K.jsx)(lN,{collapsed:De,mainAgent:_,now:g,usageSummary:v,onToggleCollapsed:()=>Oe(e=>!e),onOpenMainAgent:P,onRestartMainAgent:te})]}),be&&(0,K.jsx)(XN,{preview:be,now:g}),W&&(0,K.jsx)(qj,{copy:ye,version:yt,onClose:Re,returnFocusRef:Ie}),Pe&&(0,K.jsx)(Yj,{copy:ye,instanceName:y,onClose:()=>Fe(!1),onSave:_e,returnFocusRef:Le}),Je&&(0,K.jsx)(Gj,{canInstall:!!Ze,canFullscreen:Ue,fullscreenActive:Be,installUnavailableReason:ut,copy:ye,onClose:()=>Xe(!1),onInstall:ct,onToggleFullscreen:lt})]})}function RM(e){let t=Number(e);return!Number.isFinite(t)||t<=0?`Window`:t===10080?`Weekly`:t%1440==0?`${t/1440}d`:t%60==0?`${t/60}h`:`${t}m`}function zM(e){let t=Number(e);return Number.isFinite(t)?`${Math.round(t)}%`:`--`}function BM(e){let t=Number(e);if(!Number.isFinite(t))return`-- left`;let n=Math.max(0,Math.min(100,100-t));return`${Math.round(n)}% left`}function VM(e){let t=e.forecast?.remainingTokens,n=t==null?null:Number(t);return typeof n==`number`&&Number.isFinite(n)&&n>=0?`${GM(Math.round(n))} tok left`:BM(e.usedPercent)}function HM(e){return VM(e)}function UM(e,t){let n=[e],r=zM(t.usedPercent),i=VM(t);return r!==`--`&&n.push(`${r} used`),i!==`-- left`&&n.push(i),n.filter(Boolean).join(` / `)}function WM(e,t){let n=Number(e);if(!Number.isFinite(n)||n<=0)return null;let r=Math.max(0,Math.round((n-t)/6e4));return r===0?`reset now`:r>=1440?`reset ${Math.floor(r/1440)}d ${Math.floor(r%1440/60)}h`:r>=60?`reset ${Math.floor(r/60)}h ${r%60}m`:`reset ${r}m`}function GM(e){if(e>=1e9){let t=e/1e9;return`${t>=10?Math.round(t):Math.round(t*10)/10}B`}if(e>=1e6){let t=e/1e6;return`${t>=10?Math.round(t):Math.round(t*10)/10}M`}if(e>=1e3){let t=e/1e3;return`${t>=10?Math.round(t):Math.round(t*10)/10}k`}return`${e}`}function KM(e,t=!1){let n=Number(e);if(!Number.isFinite(n))return`-- tok/min`;let r=n<10?Math.round(n*10)/10:Math.round(n);return`${t?`~`:``}${GM(r)} tok/min`}function qM(e){let t=e.auth?.status||``;return e.auth?.available?/logged in/i.test(t)?`logged in`:t||`available`:`offline`}function JM(e){if(e.tokenUsage.available===!1)return!1;let t=Number(e.tokenUsage.eventCount),n=Number(e.tokenUsage.totalTokens),r=Number.isFinite(t)&&t>0||Number.isFinite(n)&&n>0;return e.auth.available||r}function YM(e){return e?.providers.filter(JM)??[]}function XM(e){let t=YM(e);return t.length?t.reduce((e,t)=>{let n=Number(t.tokenUsage.tokensPerMinute);return e+(Number.isFinite(n)?n:0)},0):null}function ZM(e){let t=e.forecast?.remainingPercent;if(typeof t==`number`&&Number.isFinite(t))return Math.max(0,Math.min(100,t));let n=Number(e.usedPercent);return Number.isFinite(n)?Math.max(0,Math.min(100,100-n)):null}function QM(e){let t=Number(e.windowMinutes);return Number.isFinite(t)&&t>=10020?0:Number.isFinite(t)&&t>=285&&t<=315?1:2}function $M(e){return[e.quota.primary,e.quota.secondary].filter(e=>!!e).map(e=>({label:RM(e.windowMinutes),limit:e,remaining:ZM(e),exhaustedAt:typeof e.forecast?.projectedExhaustedAt==`number`&&Number.isFinite(e.forecast.projectedExhaustedAt)?e.forecast.projectedExhaustedAt:null})).filter(e=>e.remaining!==null).sort((e,t)=>QM(e.limit)-QM(t.limit))}function eN(e){let t=Number(e.tokenUsage.tokensPerMinute);return Number.isFinite(t)&&t>0}function tN(e){let t=YM(e);return t.length?t.filter(e=>eN(e)&&e.quota.available).map(e=>{let t=$M(e),n=t.filter(e=>e.remaining!==null&&e.remaining<50);return n.length?{provider:e,limits:t,earliestExhaustedAt:n.reduce((e,t)=>t.exhaustedAt===null?e:e===null?t.exhaustedAt:Math.min(e,t.exhaustedAt),null),lowestRemaining:n.reduce((e,t)=>Math.min(e,t.remaining??100),100)}:null}).filter(e=>!!e).sort((e,t)=>e.earliestExhaustedAt!==null&&t.earliestExhaustedAt!==null?e.earliestExhaustedAt-t.earliestExhaustedAt:e.earliestExhaustedAt===null?t.earliestExhaustedAt===null?e.lowestRemaining-t.lowestRemaining:1:-1)[0]??null:null}function nN(e,t){let n=tN(e);if(!n)return null;let r=[n.provider.providerName];return n.limits.forEach(e=>{r.push(`${e.label} ${Math.round(e.remaining??0)}%`);let n=WM(e.limit.resetsAt,t);n&&r.push(n)}),r.join(` · `)}function rN(e,t){let n=[],r=XM(e);return r!==null&&n.push(KM(r)),t&&n.push(`CPU ${t.cpu}% / MEM ${t.memory.percentage}%`),n.join(` · `)||`5m`}function iN(e,t,n){return nN(e,n)||rN(e,t)}function aN(e){return e.status===`pending`?`starting`:e.status===`dead`?`offline`:e.status}function oN(e,t){return e??t?.systemStats??null}function sN({usageSummary:e,now:t}){let n=iN(e,oN(bt(),e),t);return(0,K.jsx)(`span`,{className:`code-usage-summary`,"data-testid":`code-usage-summary`,title:n,children:n})}function cN({usageSummary:e}){let t=oN(bt(),e);return t?(0,K.jsxs)(`div`,{className:`code-usage-row`,children:[(0,K.jsx)(`span`,{children:`System`}),(0,K.jsxs)(`strong`,{children:[`CPU `,t.cpu,`% / MEM `,t.memory.percentage,`%`]})]}):null}function lN(e){let t=xt();return!e.usageSummary&&!e.mainAgent&&!t?null:(0,K.jsx)(MN,{...e})}function uN(e){return new Date(e).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`})}function dN(e){return`${String(new Date(e).getHours()).padStart(2,`0`)}:00`}function fN(e){return Math.round(e).toLocaleString(`en-US`)}function pN(e){let t=e.map(e=>Math.max(0,Number(e)||0)).filter(e=>e>0).sort((e,t)=>e-t);if(!t.length)return[];let n=t[0],r=t[t.length-1];return n===r?[.2,.4,.6,.8].map(e=>r*e):[.2,.4,.6,.8].map(e=>{let n=(t.length-1)*e,r=Math.floor(n),i=Math.ceil(n),a=t[r];return a+(t[i]-a)*(n-r)})}function mN(e,t){let n=Math.max(0,Number(e)||0);return n<=0?0:Math.max(1,Math.min(5,1+t.filter(e=>n>e).length))}function hN(e){let t=e.timeline,n=Array.isArray(t?.points)?t.points:[];return n.length>0&&n.every((e,t)=>Number.isFinite(Number(e.startedAt))&&Number.isFinite(Number(e.endedAt))&&Number(e.endedAt)>Number(e.startedAt)&&Number.isFinite(Number(e.totalTokens))&&Number(e.totalTokens)>=0&&(t===0||Number(e.startedAt)>=Number(n[t-1].startedAt)))?n:null}function gN(e){let t=/^(\d{4})-(\d{2})-(\d{2})$/.exec(e);if(!t)return null;let n=Number(t[1]),r=Number(t[2]),i=Number(t[3]),a=new Date(n,r-1,i,12,0,0,0);return a.getFullYear()!==n||a.getMonth()!==r-1||a.getDate()!==i?null:a}function _N(e){let t=Array.isArray(e.daily?.points)?e.daily.points:[];return t.length>0&&t.every((e,n)=>!!gN(e.date)&&Number.isFinite(Number(e.totalTokens))&&Number(e.totalTokens)>=0&&(n===0||e.date>t[n-1].date))?t.slice(-364):null}var vN=200;function yN({usageSummary:e,points:t,onInspect:n}){let r=e.timeline,i=t.reduce((e,t)=>e+Number(t.totalTokens),0),a=RM(Number(r.windowMs)/6e4).toLowerCase(),o=pN(t.map(e=>e.totalTokens)),s=[0,.25,.5,.75,1].map(e=>r.startAt+(r.endAt-r.startAt)*e);return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`div`,{className:`code-usage-heatmap`,"data-testid":`code-usage-heatmap`,role:`img`,"aria-label":`Token activity over the last ${a}, ${GM(i)} tokens`,title:`Local token activity · last ${a}`,children:t.map((e,t)=>{let r=Number(e.totalTokens),i=`${uN(e.startedAt)}–${uN(e.endedAt)}`,a=`${i} · ${fN(r)} tokens`;return(0,K.jsx)(`span`,{className:`code-usage-heatmap-cell`,"data-level":mN(r,o),"data-start":e.startedAt,title:a,"aria-label":a,onMouseEnter:()=>n({label:i,tokens:r})},`${e.startedAt}-${t}`)})}),(0,K.jsx)(`div`,{className:`code-usage-time-axis`,"data-testid":`code-usage-time-axis`,"aria-hidden":`true`,children:s.map((e,t)=>(0,K.jsx)(`span`,{children:dN(e)},`${e}-${t}`))})]})}function bN({points:e,onInspect:t,inspection:n=null,showDayHighlight:r=!1}){let i=(0,G.useRef)(null),a=(0,G.useCallback)(()=>{i.current!==null&&(window.clearTimeout(i.current),i.current=null)},[]),o=(0,G.useCallback)(e=>{a(),i.current=window.setTimeout(()=>{i.current=null,t(e)},vN)},[a,t]);(0,G.useEffect)(()=>a,[a]);let s=(gN(e[0].date).getDay()+6)%7,c=Math.max(1,Math.ceil((s+e.length)/7)),l=c*7-s-e.length,u=pN(e.map(e=>e.totalTokens)),d=e.filter(e=>e.totalTokens>0).length,f=Math.max(0,e.length-7),p=e.slice(f).reduce((e,t)=>e+t.totalTokens,0),m=e.reduce((e,t)=>!e||t.totalTokens>e.totalTokens?t:e,null),h=m&&m.totalTokens>0?m:null,g=n?e.find(e=>e.date===n.label)??null:null,_=e[e.length-1]??null,v=g??_,y=!!(v&&v.date===h?.date);return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{className:`code-usage-activity-heading`,children:[(0,K.jsx)(`span`,{children:`52w · daily`}),r&&v?(0,K.jsxs)(`div`,{className:`code-usage-detail-day-highlight`,"data-state":g?`selected`:`today`,"data-testid":`code-usage-detail-day-highlight`,children:[(0,K.jsxs)(`span`,{children:[g&&y?`Top · `:``,CN(v.date)]}),(0,K.jsx)(`strong`,{children:GM(v.totalTokens)}),(0,K.jsx)(`small`,{children:`tokens`})]}):(0,K.jsxs)(`span`,{children:[`7d `,GM(p)]})]}),(0,K.jsxs)(`div`,{className:`code-usage-daily-heatmap`,"data-testid":`code-usage-daily-heatmap`,role:`img`,"aria-label":`Daily token activity over 52 weeks, ${d} active days`,style:{gridTemplateColumns:`repeat(${c}, minmax(2px, 1fr))`},children:[Array.from({length:s},(e,t)=>(0,K.jsx)(`span`,{className:`code-usage-daily-spacer`,"aria-hidden":`true`},`leading-${t}`)),e.map((e,n)=>{let i=Number(e.totalTokens),s=e.date===h?.date,c=i>1e9,l=s?`Token king`:c?`Over 1B tokens`:``,d=`${e.date} · ${fN(i)} tokens${l?` · ${l}`:``}`,p=e.date===g?.date,m={label:e.date,tokens:i},_=()=>{a(),t(m)};return(0,K.jsx)(`span`,{className:`code-usage-heatmap-cell code-usage-daily-heatmap-cell`,"data-date":e.date,"data-level":mN(i,u),"data-peak":s?`true`:void 0,"data-billion":c?`true`:void 0,"data-shape":r?s?`crown`:c?`flame`:void 0:void 0,"data-recent":n>=f?`true`:void 0,"data-selected":p?`true`:void 0,title:d,"aria-label":d,role:r?`button`:void 0,tabIndex:r?0:void 0,onClick:r?_:void 0,onFocus:r?_:void 0,onKeyDown:r?e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),_())}:void 0,onMouseEnter:r?void 0:_,onPointerMove:r?()=>o(m):void 0,onPointerLeave:r?a:void 0},e.date)}),Array.from({length:l},(e,t)=>(0,K.jsx)(`span`,{className:`code-usage-daily-spacer`,"aria-hidden":`true`},`trailing-${t}`))]}),r&&v&&(0,K.jsxs)(`label`,{className:`code-usage-mobile-date-picker`,children:[(0,K.jsx)(`span`,{children:`Selected day`}),(0,K.jsx)(`input`,{type:`date`,min:e[0].date,max:_?.date,value:v.date,"data-testid":`code-usage-mobile-date-picker`,onChange:n=>{let r=e.find(e=>e.date===n.currentTarget.value);r&&t({label:r.date,tokens:r.totalTokens})}})]})]})}function xN(e){return e.reduce((e,t)=>e+Number(t.totalTokens),0)}function SN(e,t){if(t<=0)return e>0?`New`:`0%`;let n=Math.round((e-t)/t*100);return`${n>0?`+`:``}${n}%`}function CN(e){let t=gN(e);return t?t.toLocaleDateString([],{month:`short`,day:`numeric`}):e}function wN(e,t){if(!e||typeof e!=`object`)return!1;let n=e;return n.date===t&&Array.isArray(n.hours)&&n.hours.length===24&&n.hours.every((e,t)=>e.hour===t&&Number.isFinite(Number(e.totalTokens))&&e.totalTokens>=0&&!!(e.agents&&typeof e.agents==`object`))&&Array.isArray(n.agents)&&n.agents.every(e=>!!(e.key&&e.label)&&Number.isFinite(Number(e.totalTokens))&&e.totalTokens>=0)}function TN(e,t){let[n,i]=(0,G.useState)(0),[a,o]=(0,G.useState)({date:``,detail:null,error:``,loading:!1});return(0,G.useEffect)(()=>{if(!e){o({date:``,detail:null,error:``,loading:!1});return}let n=new AbortController;o({date:e,detail:null,error:``,loading:!0});let i=new URLSearchParams({date:e});return t&&i.set(`live`,`1`),fetch(r(`/api/usage/day?${i.toString()}`),{signal:n.signal}).then(async t=>{let n=await t.json();if(!t.ok)throw Error(n.error||`Failed to load day activity`);if(!wN(n.detail,e))throw Error(`Day activity response was incomplete`);return n.detail}).then(t=>{n.signal.aborted||o({date:e,detail:t,error:``,loading:!1})}).catch(t=>{n.signal.aborted||o({date:e,detail:null,error:t instanceof Error?t.message:`Failed to load day activity`,loading:!1})}),()=>n.abort()},[e,t,n]),{...a,retry:()=>i(e=>e+1)}}var EN=[`#245f1d`,`#3b782f`,`#548f47`,`#70a766`,`#8dbc86`,`#aacda5`,`#486d42`,`#789473`];function DN(e){let t=0;for(let n of e)t=(t<<5)-t+n.charCodeAt(0)|0;return EN[Math.abs(t)%EN.length]}function ON({date:e,detail:t,error:n,loading:r,onRetry:i}){let[a,o]=(0,G.useState)(null);if((0,G.useEffect)(()=>o(null),[e]),r)return(0,K.jsx)(`div`,{className:`code-usage-day-breakdown loading`,"data-testid":`code-usage-day-histogram-loading`,children:(0,K.jsx)(`div`,{className:`code-usage-day-breakdown-status`,children:`Loading hourly Agent activity…`})});if(n)return(0,K.jsxs)(`div`,{className:`code-usage-day-breakdown error`,"data-testid":`code-usage-day-histogram-error`,children:[(0,K.jsx)(`span`,{children:n}),(0,K.jsx)(`button`,{type:`button`,onClick:i,children:`Retry`})]});if(!t)return null;let s=Math.max(0,...t.hours.map(e=>e.totalTokens)),c=Array.from(t.agents.reduce((e,t)=>{let n=e.get(t.provider);return n?n.totalTokens+=t.totalTokens:e.set(t.provider,{key:t.provider,label:w(t.provider),totalTokens:t.totalTokens}),e},new Map).values()).sort((e,t)=>t.totalTokens-e.totalTokens||e.label.localeCompare(t.label)),l=a?`${a.label} · ${GM(a.tokens)} tokens`:`${CN(t.date)} · ${GM(t.total.totalTokens)} tokens`;return(0,K.jsxs)(`div`,{className:`code-usage-day-breakdown`,"data-testid":`code-usage-day-histogram`,onMouseLeave:()=>o(null),children:[(0,K.jsxs)(`div`,{className:`code-usage-day-breakdown-heading`,children:[(0,K.jsx)(`span`,{children:`Hourly by Agent type`}),(0,K.jsx)(`strong`,{"data-testid":`code-usage-day-histogram-readout`,children:l})]}),(0,K.jsxs)(`div`,{className:`code-usage-day-histogram-chart`,role:`img`,"aria-label":`Hourly token activity for ${t.date}, split across ${c.length} Agent types`,children:[(0,K.jsxs)(`div`,{className:`code-usage-day-histogram-scale`,"aria-hidden":`true`,children:[(0,K.jsx)(`span`,{children:GM(s)}),(0,K.jsx)(`span`,{children:`0`})]}),(0,K.jsxs)(`div`,{className:`code-usage-day-histogram-plot`,children:[(0,K.jsx)(`div`,{className:`code-usage-day-histogram-bars`,children:t.hours.map(e=>{let n=s>0?e.totalTokens/s*100:0;return(0,K.jsx)(`div`,{className:`code-usage-day-histogram-column`,"data-hour":e.hour,title:`${e.label}:00 · ${fN(e.totalTokens)} tokens`,children:(0,K.jsx)(`div`,{className:`code-usage-day-histogram-stack`,style:{height:`${n}%`},children:c.map(n=>{let r=t.agents.reduce((t,r)=>r.provider===n.key?t+(Number(e.agents[r.key]?.totalTokens)||0):t,0);if(r<=0||e.totalTokens<=0)return null;let i=`${e.label}:00 · ${n.label}`,a=`${i} · ${fN(r)} tokens`;return(0,K.jsx)(`span`,{className:`code-usage-day-histogram-segment`,"data-agent-type":n.key,style:{backgroundColor:DN(n.key),height:`${r/e.totalTokens*100}%`},title:a,onMouseEnter:()=>o({label:i,tokens:r})},n.key)})})},e.hour)})}),(0,K.jsxs)(`div`,{className:`code-usage-day-histogram-axis`,"aria-hidden":`true`,children:[(0,K.jsx)(`span`,{children:`00:00`}),(0,K.jsx)(`span`,{children:`06:00`}),(0,K.jsx)(`span`,{children:`12:00`}),(0,K.jsx)(`span`,{children:`18:00`}),(0,K.jsx)(`span`,{children:`23:00`})]})]})]}),c.length>0&&(0,K.jsx)(`div`,{className:`code-usage-day-agent-legend`,"data-testid":`code-usage-day-agent-legend`,children:c.map(e=>(0,K.jsxs)(`span`,{title:`${e.label} · ${fN(e.totalTokens)} tokens`,children:[(0,K.jsx)(`i`,{style:{backgroundColor:DN(e.key)},"aria-hidden":`true`}),(0,K.jsx)(`b`,{children:e.label}),(0,K.jsx)(`small`,{children:GM(e.totalTokens)})]},e.key))})]})}function kN({label:e,value:t,detail:n}){return(0,K.jsxs)(`div`,{className:`code-usage-detail-stat`,children:[(0,K.jsx)(`span`,{children:e}),(0,K.jsx)(`strong`,{children:t}),n&&(0,K.jsx)(`small`,{children:n})]})}function AN({initialRange:e,usageSummary:t,onClose:n}){let[r,i]=(0,G.useState)(e),[a,o]=(0,G.useState)(null),s=hN(t),c=_N(t),l=c?.reduce((e,t)=>!e||t.totalTokens>e.totalTokens?t:e,null)??null,u=c?.[c.length-1]??null,d=c?.find(e=>e.date===a?.label)??null,f=r===`year`&&(d??u)?.date||``,p=TN(f,!!(f&&c&&f===c[c.length-1]?.date));if((0,G.useEffect)(()=>{let e=e=>{e.key===`Escape`&&n()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[n]),typeof document>`u`)return null;let m=s?.reduce((e,t)=>e+t.totalTokens,0)??0,h=s?.filter(e=>e.totalTokens>0).length??0,g=s?.reduce((e,t)=>!e||t.totalTokens>e.totalTokens?t:e,null)??null,_=c?.slice(-7)??[],v=c?.slice(-14,-7)??[],y=xN(_),b=xN(v),x=c?xN(c):0,S=c?.filter(e=>e.totalTokens>0).length??0,C=_.reduce((e,t)=>e+(Number(t.cacheReadTokens)||0)+(Number(t.cacheWriteTokens)||0),0),w=y>0?Math.min(100,Math.round(C/y*100)):0,T=a?`${a.label} · ${fN(a.tokens)} tokens`:`Last 24 hours · ${fN(m)} tokens`,ee=a?`${a.label} · ${fN(a.tokens)} tokens`:`Last 52 weeks · ${fN(x)} tokens`;return(0,Wj.createPortal)((0,K.jsx)(`div`,{className:`code-usage-detail-backdrop`,"data-testid":`code-usage-detail-backdrop`,onMouseDown:e=>{e.target===e.currentTarget&&n()},children:(0,K.jsxs)(`section`,{className:`code-usage-detail-dialog`,"data-testid":`code-usage-detail-dialog`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`code-usage-detail-title`,children:[(0,K.jsxs)(`header`,{className:`code-usage-detail-header`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`span`,{className:`code-usage-detail-eyebrow`,children:`Local provider tokens`}),(0,K.jsx)(`h2`,{id:`code-usage-detail-title`,children:`Usage activity`})]}),(0,K.jsx)(`button`,{type:`button`,className:`code-usage-detail-close`,"aria-label":`Close usage activity`,onClick:n,children:(0,K.jsx)(Fe,{})})]}),(0,K.jsxs)(`div`,{className:`code-usage-detail-tabs`,role:`tablist`,"aria-label":`Usage activity range`,children:[(0,K.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":r===`day`,"data-testid":`code-usage-detail-day-tab`,onClick:()=>{o(null),i(`day`)},children:`1 Day`}),(0,K.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":r===`year`,"data-testid":`code-usage-detail-year-tab`,onClick:()=>{o(null),i(`year`)},children:`52 Weeks`})]}),(0,K.jsxs)(`div`,{className:`code-usage-detail-chart`,onBlur:e=>{e.currentTarget.contains(e.relatedTarget)||o(null)},onMouseLeave:()=>o(null),children:[r===`day`&&s&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{className:`code-usage-detail-chart-heading`,children:[(0,K.jsx)(`span`,{children:`Hourly activity`}),(0,K.jsxs)(`strong`,{children:[GM(m),` tokens`]})]}),(0,K.jsx)(yN,{usageSummary:t,points:s,onInspect:o})]}),r===`year`&&c&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(bN,{points:c,inspection:a,showDayHighlight:!0,onInspect:o}),(0,K.jsx)(ON,{date:f,detail:p.date===f?p.detail:null,error:p.date===f?p.error:``,loading:p.date===f?p.loading:!0,onRetry:p.retry})]}),(0,K.jsx)(`div`,{className:`code-usage-detail-readout`,"data-testid":`code-usage-detail-readout`,children:r===`day`?T:ee})]}),(0,K.jsx)(`div`,{className:`code-usage-detail-analysis`,"data-testid":`code-usage-detail-analysis`,children:r===`day`?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(kN,{label:`24-hour tokens`,value:GM(m)}),(0,K.jsx)(kN,{label:`Active hours`,value:`${h}`,detail:`hours with token activity`}),(0,K.jsx)(kN,{label:`Peak hour`,value:g?dN(g.startedAt):`--`,detail:g?`${GM(g.totalTokens)} tokens`:`no activity`})]}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(kN,{label:`Last 7 days`,value:GM(y)}),(0,K.jsx)(kN,{label:`Previous 7 days`,value:GM(b),detail:`${SN(y,b)} change`}),(0,K.jsx)(kN,{label:`Peak day`,value:l?CN(l.date):`--`,detail:l?`${GM(l.totalTokens)} tokens`:`no activity`}),(0,K.jsx)(kN,{label:`Active days`,value:`${S}`,detail:`within 52 weeks`}),(0,K.jsx)(kN,{label:`7-day cache share`,value:`${w}%`,detail:`read and write tokens`}),(0,K.jsx)(kN,{label:`52-week tokens`,value:GM(x)})]})})]})}),document.body)}function jN({usageSummary:e}){let t=hN(e),n=_N(e),[r,i]=(0,G.useState)(null),[a,o]=(0,G.useState)(null);if(!t&&!n)return null;let s=t?.reduce((e,t)=>e+t.totalTokens,0)??0,c=RM(Number(e.timeline?.windowMs)/6e4).toLowerCase(),l=n?.slice(-7).reduce((e,t)=>e+t.totalTokens,0)??0,u=n?.reduce((e,t)=>e+t.totalTokens,0)??0,d=`${r?`${r.label} · ${fN(r.tokens)} tokens`:`${t?`${c} ${GM(s)}`:``}${t&&n?` · `:``}${n?`7d ${GM(l)} · 52w ${GM(u)}`:``}`}${e.daily?.syncing===!0?` · syncing history`:``}`;return(0,K.jsxs)(`div`,{className:`code-usage-activity`,onMouseLeave:()=>i(null),children:[t&&(0,K.jsxs)(`button`,{type:`button`,className:`code-usage-chart-trigger`,"data-testid":`code-usage-open-day`,title:`Open 1-day usage details`,onClick:()=>o(`day`),children:[(0,K.jsxs)(`div`,{className:`code-usage-activity-heading`,children:[(0,K.jsxs)(`span`,{children:[c,` · activity`]}),(0,K.jsxs)(`span`,{children:[RM(e.timeline.bucketMs/6e4).toLowerCase(),` buckets`]})]}),(0,K.jsx)(yN,{usageSummary:e,points:t,onInspect:i})]}),n&&(0,K.jsx)(`button`,{type:`button`,className:`code-usage-chart-trigger`,"data-testid":`code-usage-open-year`,title:`Open 52-week usage details`,onClick:()=>o(`year`),children:(0,K.jsx)(bN,{points:n,onInspect:i})}),(0,K.jsx)(`div`,{className:`code-usage-activity-readout`,"data-testid":`code-usage-activity-readout`,title:d,children:d}),a&&(0,K.jsx)(AN,{initialRange:a,usageSummary:e,onClose:()=>o(null)})]})}function MN({collapsed:e,mainAgent:t,now:n,usageSummary:r,onToggleCollapsed:i,onOpenMainAgent:a,onRestartMainAgent:o}){let s=YM(r),c=XM(r),[l,d]=(0,G.useState)(!1),[f,p]=(0,G.useState)(!1),m=r&&_N(r)?`year`:r&&hN(r)?`day`:null;return(0,K.jsxs)(`div`,{className:`code-usage-panel ${e?`collapsed`:``} ${m?``:`mobile-unavailable`}`,"data-testid":`code-usage-panel`,children:[m&&(0,K.jsxs)(`button`,{type:`button`,className:`code-usage-mobile-open`,"data-testid":`code-mobile-usage-open`,onClick:()=>p(!0),children:[(0,K.jsx)(`span`,{children:`Usage activity`}),(0,K.jsxs)(`span`,{children:[m===`year`?`52 Weeks`:`1 Day`,(0,K.jsx)(Ee,{})]})]}),(0,K.jsxs)(`button`,{type:`button`,className:`code-usage-header`,"data-testid":`code-usage-toggle`,"aria-expanded":!e,title:`Provider local token usage refreshes periodically.`,onClick:i,children:[(0,K.jsxs)(`span`,{className:`code-usage-title`,children:[(0,K.jsx)(`span`,{className:`code-usage-chevron ${e?`collapsed`:`expanded`}`,"aria-hidden":`true`,children:e?(0,K.jsx)(Ee,{}):(0,K.jsx)(Me,{})}),(0,K.jsx)(`span`,{children:`Usage`})]}),(0,K.jsx)(`span`,{className:`code-usage-header-meta`,children:e?(0,K.jsx)(sN,{usageSummary:r,now:n}):(0,K.jsx)(`span`,{className:`code-usage-summary`,"data-testid":`code-usage-summary`,title:`5-minute rate · hourly and daily activity`,children:`5m rate · activity`})})]}),!e&&(0,K.jsxs)(K.Fragment,{children:[s.length>0&&r?.timeline&&(0,K.jsx)(jN,{usageSummary:r}),t&&(0,K.jsxs)(`div`,{className:`code-usage-main-agent-block`,children:[(0,K.jsxs)(`div`,{className:`code-usage-row code-usage-main-agent`,title:`${u(t)} · ${t.command} · ${t.cwd}`,"data-testid":`code-main-agent-usage-row`,children:[(0,K.jsxs)(`button`,{type:`button`,className:`code-usage-main-agent-open`,"data-testid":`code-main-agent-open`,onClick:a,children:[(0,K.jsx)(`span`,{children:`Main Agent`}),(0,K.jsx)(`strong`,{children:aN(t)})]}),(0,K.jsx)(`button`,{type:`button`,className:`code-usage-main-agent-restart`,"data-testid":`code-main-agent-restart`,"aria-expanded":l,onClick:()=>d(e=>!e),children:`Restart`})]}),l&&(0,K.jsx)(`div`,{className:`code-main-agent-restart-menu`,"data-testid":`code-main-agent-restart-menu`,role:`menu`,children:[[`codex`,`Codex`],[`claude`,`Claude Code`],[`opencode`,`OpenCode`],[`qoder`,`Qoder`],[`bash`,`bash`],[`zsh`,`zsh`]].map(([e,t])=>(0,K.jsx)(`button`,{type:`button`,role:`menuitem`,"data-testid":`code-main-agent-restart-${e}`,onClick:()=>{d(!1),o(e)},children:t},e))})]}),s.map(e=>(0,K.jsx)(NN,{provider:e},e.provider)),s.length>1&&c!==null&&(0,K.jsxs)(`div`,{className:`code-usage-row`,title:`Sum of local token usage reported by providers.`,children:[(0,K.jsx)(`span`,{children:`Total local tokens`}),(0,K.jsx)(`strong`,{children:KM(c)})]}),(0,K.jsx)(cN,{usageSummary:r})]}),f&&m&&r&&(0,K.jsx)(AN,{initialRange:m,usageSummary:r,onClose:()=>p(!1)})]})}function NN({provider:e}){let t=e.quota.primary??null,n=e.quota.secondary??null,r=e.quota.available?e.quota.source:e.quota.reason||e.quota.source;return(0,K.jsxs)(`div`,{className:`code-usage-provider`,children:[(0,K.jsxs)(`div`,{className:`code-usage-row`,children:[(0,K.jsx)(`span`,{children:e.providerName}),(0,K.jsx)(`strong`,{title:e.auth?.status,children:qM(e)})]}),e.quota.available&&(0,K.jsxs)(K.Fragment,{children:[t&&(0,K.jsxs)(`div`,{className:`code-usage-row code-usage-subrow`,title:UM(r,t),children:[(0,K.jsx)(`span`,{children:RM(t.windowMinutes)}),(0,K.jsx)(`strong`,{children:HM(t)})]}),n&&(0,K.jsxs)(`div`,{className:`code-usage-row code-usage-subrow`,title:UM(r,n),children:[(0,K.jsx)(`span`,{children:RM(n.windowMinutes)}),(0,K.jsx)(`strong`,{children:HM(n)})]})]}),(0,K.jsxs)(`div`,{className:`code-usage-row code-usage-subrow`,title:e.tokenUsage.source,children:[(0,K.jsx)(`span`,{children:`Local tokens`}),(0,K.jsx)(`strong`,{children:KM(e.tokenUsage.tokensPerMinute)})]})]})}function PN({items:e,activeTerminalId:t,now:n,onOpenAgent:r,onShowPreview:i,onHidePreview:a,copy:o}){return(0,K.jsx)(`div`,{className:`code-agent-rail`,"data-testid":`code-agent-rail`,"aria-label":o.projectsAndAgents,children:e.map((e,o)=>(0,K.jsx)(FN,{item:e,index:o,activeTerminalId:t,now:n,onOpenAgent:r,onShowPreview:i,onHidePreview:a},oA({kind:`agent`,agent:e.agent})))})}function FN({item:e,index:t,activeTerminalId:n,now:r,onOpenAgent:i,onShowPreview:a,onHidePreview:o}){let s=_A({kind:`agent`,agent:e.agent},r),c=e.agent.id===n,l=[s.title,s.commandTitle,e.projectName].filter(Boolean).join(` · `);return(0,K.jsxs)(`button`,{type:`button`,className:`code-agent-rail-button ${c?`active`:``} ${s.unread?`unread`:``}`,"data-testid":`code-agent-rail-item`,"data-agent-id":e.agent.id,"aria-label":l,onClick:()=>{i(e.agent.id)},onMouseEnter:t=>a(t,JN(e.agent,s,e.projectName),!0),onMouseLeave:o,children:[(0,K.jsx)(`span`,{className:`code-agent-rail-label`,children:t+1}),s.statusIndicatorVisible&&(0,K.jsx)(`span`,{className:`code-agent-rail-status ${s.lifecycleStatus} ${s.turnActive?`turn-active`:``}`,"aria-hidden":`true`}),s.unread&&(0,K.jsx)(`span`,{className:`code-agent-rail-unread`,"aria-hidden":`true`})]})}function IN({agents:e,activeTerminalId:t,selectedSearchAgentId:n,claimedAgentSessionKeyByAgentId:r,now:i,onOpenAgent:a,onOpenAgentContextMenu:o,onOpenAgentKeyboardMenu:s,onShowPreview:c,onHidePreview:l}){return(0,K.jsx)(`div`,{className:`code-project-agent-strip`,"data-testid":`code-project-agent-strip`,"aria-label":`Project agents`,children:e.map((e,u)=>{let d=_A({kind:`agent`,agent:e},i),f=e.id===t,p=e.id===n,m=d.rowTitle||d.title;return(0,K.jsxs)(`button`,{type:`button`,className:`code-project-agent-compact ${f?`active`:``} ${p?`search-selected`:``} ${d.unread?`unread`:``}`,"data-testid":`code-project-agent-compact`,"data-agent-id":e.id,"aria-label":m,onClick:()=>a(e.id),onMouseEnter:t=>c(t,JN(e,d),!0),onMouseLeave:l,onContextMenu:t=>o(t,e.id),onKeyDown:t=>{s(t,e.id),!t.defaultPrevented&&(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),a(e.id))},children:[(0,K.jsx)(`span`,{className:`code-project-agent-compact-label`,children:u+1}),d.statusIndicatorVisible&&(0,K.jsx)(`span`,{className:`code-project-agent-compact-status ${d.lifecycleStatus} ${d.turnActive?`turn-active`:``}`,"aria-hidden":`true`}),d.unread&&(0,K.jsx)(`span`,{className:`code-project-agent-compact-unread`,"aria-hidden":`true`})]},oA({kind:`agent`,agent:e,claimedSessionKey:r.get(e.id)}))})})}function LN({items:e,activeTerminalId:t,selectedSearchAgentId:n,selectedSearchSessionHandle:r,claimedAgentSessionKeyByAgentId:i,now:a,onOpenAgent:o,onOpenAgentContextMenu:s,onOpenAgentKeyboardMenu:c,onResumeAgentSession:l,onOpenAgentSessionContextMenu:u,onOpenAgentSessionKeyboardMenu:d,onShowPreview:f,onHidePreview:p}){return(0,K.jsx)(`div`,{className:`code-project-agent-strip code-pinned-agent-strip`,"data-testid":`code-pinned-agent-strip`,"aria-label":`Pinned agents`,children:e.map((e,m)=>{let h=e.kind===`agent`?_A({kind:`agent`,agent:e.agent},a):_A({kind:`history`,session:e.session,fallbackTitle:e.session.providerName||e.session.provider||`Agent`},a),g=e.kind===`agent`?e.agent:null,_=e.kind===`agent`?null:e.session,v=_?ZD(_):null,y=g?g.id===t:!1,b=g?g.id===n:v===r,x=h.rowTitle||h.title;return(0,K.jsxs)(`button`,{type:`button`,className:`code-project-agent-compact ${y?`active`:``} ${b?`search-selected`:``} ${h.unread?`unread`:``}`,"data-testid":`code-pinned-agent-compact`,"data-agent-id":g?.id,"data-session-id":v??void 0,"aria-label":x,onClick:()=>{if(g){o(g.id);return}_&&l(_.provider,_.id,_.providerHomeId)},onMouseEnter:e=>f(e,g?JN(g,h):YN(_,h),!0),onMouseLeave:p,onContextMenu:e=>{if(g){s(e,g.id);return}_&&u(e,_.provider,ZD(_))},onKeyDown:e=>{g?c(e,g.id):_&&d(e,_.provider,ZD(_)),!e.defaultPrevented&&(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),g?o(g.id):_&&l(_.provider,_.id,_.providerHomeId))},children:[(0,K.jsx)(`span`,{className:`code-project-agent-compact-label`,children:m+1}),h.statusIndicatorVisible&&(0,K.jsx)(`span`,{className:`code-project-agent-compact-status ${h.lifecycleStatus} ${h.turnActive?`turn-active`:``}`,"aria-hidden":`true`}),h.unread&&(0,K.jsx)(`span`,{className:`code-project-agent-compact-unread`,"aria-hidden":`true`})]},e.kind===`agent`?oA({kind:`agent`,agent:e.agent,claimedSessionKey:i.get(e.agent.id)}):oA({kind:`history`,session:e.session}))})})}function RN({items:e,collapsed:t,compressed:n,activeTerminalId:r,selectedSearchAgentId:i,selectedSearchSessionHandle:a,claimedAgentSessionKeyByAgentId:o,agentShortcutKeys:s,keyboardShortcutsEnabled:c,now:l,onOpenAgent:u,onUpdateAgentFlags:d,onReorderAgent:f,onOpenAgentContextMenu:p,onOpenAgentKeyboardMenu:m,onResumeAgentSession:h,onOpenAgentSessionContextMenu:g,onOpenAgentSessionKeyboardMenu:_,onShowAgentPreview:v,onHideAgentPreview:y,onToggleCollapsed:b,copy:x}){let S=e.flatMap(e=>e.kind===`agent`?[e.agent]:[]),[C,w]=(0,G.useState)(null),T=(e,t)=>{e.dataTransfer.effectAllowed=`move`,e.dataTransfer.setData(`text/plain`,t),y(),w({agentId:t,targetAgentId:``,position:`before`})},ee=(e,t)=>{if(!C||C.agentId===t)return;e.preventDefault(),e.dataTransfer.dropEffect=`move`;let n=e.currentTarget.getBoundingClientRect(),r=e.clientY<n.top+n.height/2?`before`:`after`;C.targetAgentId===t&&C.position===r||w(e=>e?{...e,targetAgentId:t,position:r}:null)},E=()=>w(null),D=(e,t)=>{if(e.preventDefault(),!C||C.agentId===t){E();return}let n=S.filter(e=>e.id!==C.agentId),r=n.findIndex(e=>e.id===t);if(r<0){E();return}let i=C.position===`before`?r:r+1;f(C.agentId,i>0?n[i-1]?.id??``:``,i<n.length?n[i]?.id??``:``),E()};return(0,K.jsxs)(`section`,{className:`code-pinned-section ${t?`collapsed`:``}`,"data-testid":`code-pinned-section`,children:[(0,K.jsxs)(`button`,{type:`button`,className:`code-pinned-title`,"data-testid":`code-pinned-title`,"aria-expanded":!t,onClick:b,children:[(0,K.jsx)(`span`,{className:`code-folder-icon ${t?`collapsed`:`expanded`}`,"aria-hidden":`true`,children:t?(0,K.jsx)(Ee,{}):(0,K.jsx)(Me,{})}),(0,K.jsx)(`span`,{children:x.pinned})]}),!t&&(0,K.jsx)(`div`,{className:`code-agent-list code-pinned-list`,children:n?(0,K.jsx)(LN,{items:e,activeTerminalId:r,selectedSearchAgentId:i,selectedSearchSessionHandle:a,claimedAgentSessionKeyByAgentId:o,now:l,onOpenAgent:u,onOpenAgentContextMenu:p,onOpenAgentKeyboardMenu:m,onResumeAgentSession:h,onOpenAgentSessionContextMenu:g,onOpenAgentSessionKeyboardMenu:_,onShowPreview:v,onHidePreview:y}):e.map(e=>{if(e.kind===`agent`){let t=e.agent;return(0,K.jsx)(rP,{agent:t,shortcutHint:c?s.get(t.id):void 0,active:t.id===r,searchSelected:t.id===i,now:l,onOpenAgent:u,onUpdateAgentFlags:d,reorderable:!0,dragging:C?.agentId===t.id,dropPosition:C?.targetAgentId===t.id?C.position:void 0,onAgentDragStart:T,onAgentDragEnd:E,onAgentDragOver:ee,onAgentDrop:D,onOpenAgentContextMenu:p,onOpenAgentKeyboardMenu:m,onShowPreview:v,onHidePreview:y,copy:x},oA({kind:`agent`,agent:t,claimedSessionKey:o.get(t.id)}))}return(0,K.jsx)(rP,{session:e.session,searchSelected:ZD(e.session)===a,now:l,onResume:h,onOpenSessionContextMenu:g,onOpenSessionKeyboardMenu:_,onShowPreview:v,onHidePreview:y,copy:x},oA({kind:`history`,session:e.session}))})})]})}function zN(e,t){return e.branch?e.branch:e.detached?`${t.worktreeDetached}@${e.head.slice(0,7)}`:e.bare?`bare`:e.head.slice(0,7)}function BN({agentId:e,anchorRef:t,copy:n,fallback:r,point:i,onClose:a,onMountProject:o}){let s=(0,G.useRef)(null),c=(0,G.useRef)(null),[l,u]=(0,G.useState)(r),[d,f]=(0,G.useState)(!1),[p,m]=(0,G.useState)(``),h=(0,G.useCallback)(()=>{c.current?.abort();let t=new AbortController;c.current=t,f(!0),m(``),se(e,{signal:t.signal}).then(e=>{t.signal.aborted||u(e)}).catch(e=>{t.signal.aborted||e?.name===`AbortError`||m(n.worktreeLoadFailed)}).finally(()=>{t.signal.aborted||f(!1)})},[e,n.worktreeLoadFailed]);return(0,G.useEffect)(()=>(h(),()=>c.current?.abort()),[h]),(0,G.useEffect)(()=>{let e=e=>{let n=e.target;n&&(s.current?.contains(n)||t.current?.contains(n))||a()},n=e=>{e.key===`Escape`&&(e.preventDefault(),a(),t.current?.focus())};return window.addEventListener(`pointerdown`,e,!0),window.addEventListener(`keydown`,n,!0),()=>{window.removeEventListener(`pointerdown`,e,!0),window.removeEventListener(`keydown`,n,!0)}},[t,a]),(0,K.jsxs)(`div`,{ref:s,className:`code-worktree-popover`,"data-testid":`code-project-worktree-menu`,role:`dialog`,"aria-label":n.worktrees,style:{left:i.x,top:i.y},children:[(0,K.jsxs)(`div`,{className:`code-worktree-popover-header`,children:[(0,K.jsx)(`span`,{children:n.worktrees}),(0,K.jsx)(`span`,{className:`code-worktree-popover-count`,children:l.items.length}),(0,K.jsx)(`button`,{type:`button`,className:d?`loading`:``,disabled:d,onClick:h,children:n.refresh})]}),p&&(0,K.jsx)(`div`,{className:`code-worktree-popover-status error`,children:p}),!p&&!l.isGitRepo&&(0,K.jsx)(`div`,{className:`code-worktree-popover-status`,children:n.gitHistoryNotRepository}),(0,K.jsx)(`div`,{className:`code-worktree-list`,children:l.items.map(e=>(0,K.jsxs)(`button`,{type:`button`,className:`code-worktree-row ${e.current?`current`:``}`,"data-current":e.current?`true`:void 0,"data-main":e.main?`true`:void 0,title:e.workspace,onClick:()=>{o(e.workspace),a()},children:[(0,K.jsx)(`span`,{className:`code-worktree-row-marker`,"aria-hidden":`true`}),(0,K.jsxs)(`span`,{className:`code-worktree-row-content`,children:[(0,K.jsxs)(`span`,{className:`code-worktree-row-heading`,children:[(0,K.jsx)(`strong`,{children:zN(e,n)}),(0,K.jsxs)(`span`,{className:`code-worktree-row-badges`,children:[e.current&&(0,K.jsx)(`span`,{children:n.worktreeCurrent}),e.main&&(0,K.jsx)(`span`,{children:n.worktreeMain}),e.locked&&(0,K.jsx)(`span`,{title:e.lockReason,children:n.worktreeLocked}),e.prunable&&(0,K.jsx)(`span`,{title:e.pruneReason,children:n.worktreePrunable})]}),e.head&&(0,K.jsx)(`code`,{children:e.head.slice(0,7)})]}),(0,K.jsx)(`span`,{className:`code-worktree-row-path`,children:e.workspace})]})]},e.workspace))})]})}function VN(e){return e?.workspace?{isGitRepo:!0,commonDir:e.commonDir,currentWorkspace:e.workspace,mainWorkspace:e.mainWorkspace,items:Array.isArray(e.worktrees)?e.worktrees:[]}:null}function HN({project:e,collapsed:t,forceAgentsExpanded:n,compactAgents:r,activeTerminalId:i,selectedSearchAgentId:a,selectedSearchSessionHandle:o,claimedAgentSessionKeyByAgentId:s,agentShortcutKeys:l,keyboardShortcutsEnabled:u,now:d,openWorkspaceFile:f,openWorkspaceFiles:p,agentLaunchOptions:m,fileRevealRequest:h,fileSearchFocusRequest:g,onToggleProject:_,onToggleProjectSessions:v,onMountProject:y,onNewAgent:b,onStartAgent:x,onOpenProjectContextMenu:S,onOpenProjectKeyboardMenu:C,onOpenAgent:T,onUpdateAgentFlags:ee,onReorderAgent:E,onOpenAgentContextMenu:D,onOpenAgentKeyboardMenu:O,onResumeAgentSession:k,onOpenAgentSessionContextMenu:A,onOpenAgentSessionKeyboardMenu:j,onShowAgentPreview:M,onHideAgentPreview:N,onOpenProjectFile:P,onSelectOpenWorkspaceFile:te,onCloseOpenWorkspaceFile:F,onMoveWorkspaceEntries:ne,onDeleteWorkspaceEntries:I,onRefreshProjectOpenFiles:L,copy:R}){let B=(0,G.useRef)(null),V=(0,G.useRef)(null),re=(0,G.useRef)(null),ie=(0,G.useRef)(null),H=(0,G.useRef)(null),ae=(0,G.useRef)(null),[oe,le]=(0,G.useState)(null),[ue,de]=(0,G.useState)(null),[fe,pe]=(0,G.useState)(()=>VN(e.gitWorktree)),[me,he]=(0,G.useState)(!1),[ge,_e]=(0,G.useState)(!1),[ve,ye]=(0,G.useState)(!1),[be,xe]=(0,G.useState)(null),[Se,Ce]=(0,G.useState)(()=>CM(null,e.agents)),we=CM((i&&e.agents.some(e=>!e.isMain&&e.id===i)?i:null)??Se,e.agents),U=e.agents.find(e=>!e.isMain&&e.id===we)??null,Te=e.workspace?Un(e.workspace):``,De=e.id!==`__farming_main_agent__`&&!!Te,Oe=new Set([Te,...e.agents.filter(e=>!e.isMain).map(e=>e.id),...U&&!U.isMain?[U.id]:[]]),ke=t=>t.workspaceRoot===e.workspace||Oe.has(t.agentId),Ae=f&&ke(f)?f:null,je=p.filter(ke),W=new Set(je.filter(e=>e.dirty).map(e=>e.file.path)),Ne=new Set(je.filter(e=>e.externalChanged).map(e=>e.file.path)),Pe=e.agents.filter(e=>!e.pinned),Fe=e.agentSessions.filter(e=>!e.pinned),Ie=Pe.length>0||Fe.length>0||(e.hiddenAgentSessionCount??0)>0,Le=ve&&ce()&&Pe.length>1,Re=(r||Le)&&Pe.length>0,ze=Re||me?Pe:KN(Pe,kM,[i,a]),Be=Math.max(0,Pe.length-ze.length),Ve=ge&&!n;(0,G.useEffect)(()=>{Se!==we&&Ce(we)},[we,Se]),(0,G.useEffect)(()=>{let t=VN(e.gitWorktree);t&&pe(t)},[e.gitWorktree]),(0,G.useEffect)(()=>{if(!Te)return;let e=new AbortController;return se(Te,{signal:e.signal}).then(pe).catch(()=>{}),()=>e.abort()},[Te]);let He=(0,G.useCallback)(e=>!U?.id||e?.sourceAgentId?e:{...e,sourceAgentId:U.id},[U?.id]),Ue=(0,G.useCallback)((e,t,n)=>{P(e,t,He(n))},[P,He]),We=(0,G.useCallback)((e,t,n)=>te(e,t,He(n)),[te,He]),Ge=(0,G.useCallback)(e=>{ye(!e)},[]),Ke=(e,t)=>{e.dataTransfer.effectAllowed=`move`,e.dataTransfer.setData(`text/plain`,t),N(),xe({agentId:t,targetAgentId:``,position:`before`})},qe=(e,t)=>{if(!be||be.agentId===t)return;e.preventDefault(),e.dataTransfer.dropEffect=`move`;let n=e.currentTarget.getBoundingClientRect(),r=e.clientY<n.top+n.height/2?`before`:`after`;be.targetAgentId===t&&be.position===r||xe(e=>e?{...e,targetAgentId:t,position:r}:null)},Je=()=>xe(null),Ye=(e,t)=>{if(e.preventDefault(),!be||be.agentId===t){Je();return}let n=Pe.filter(e=>e.id!==be.agentId),r=n.findIndex(e=>e.id===t);if(r<0){Je();return}let i=be.position===`before`?r:r+1;E(be.agentId,i>0?n[i-1]?.id??``:``,i<n.length?n[i]?.id??``:``),Je()},Xe=e=>{if(e.preventDefault(),!be)return;let t=Pe.filter(e=>e.id!==be.agentId);E(be.agentId,t[t.length-1]?.id??``,``),Je()},Ze=e=>{be&&(e.preventDefault(),e.dataTransfer.dropEffect=`move`,be.targetAgentId!==AM&&xe(e=>e?{...e,targetAgentId:AM,position:`after`}:null))};(0,G.useEffect)(()=>{Pe.length<=kM&&me&&he(!1)},[me,Pe.length]),(0,G.useLayoutEffect)(()=>{let e=B.current;if(!e)return;let t=()=>{let t=V.current;e.style.setProperty(`--code-project-sticky-height`,t?`${Math.ceil(t.getBoundingClientRect().height)}px`:``);let n=re.current;e.style.setProperty(`--code-agents-sticky-height`,n?`${Math.ceil(n.getBoundingClientRect().height)}px`:`0px`)};t();let n=V.current,r=re.current,i=typeof ResizeObserver<`u`?new ResizeObserver(t):null;return n&&i?.observe(n),r&&i?.observe(r),window.addEventListener(`resize`,t),()=>{i?.disconnect(),window.removeEventListener(`resize`,t)}},[t,e.id,Ie]),(0,G.useEffect)(()=>{if(!oe)return;let e=e=>{let t=e.target;t&&(H.current?.contains(t)||ie.current?.contains(t))||le(null)},t=e=>{e.key===`Escape`&&(e.preventDefault(),le(null),ie.current?.focus())};return window.addEventListener(`pointerdown`,e,!0),window.addEventListener(`keydown`,t,!0),()=>{window.removeEventListener(`pointerdown`,e,!0),window.removeEventListener(`keydown`,t,!0)}},[oe]);let Qe=t=>{if(t.preventDefault(),t.stopPropagation(),m.length===0){b(e.workspace,void 0,t.currentTarget);return}let n=t.currentTarget.getBoundingClientRect(),r=Math.min(260,m.length*34+12);le(ce()?iM(n,r,void 0,160):rM(n,r,void 0,160))},$e=t=>{le(null),x(t,e.workspace)},et=fe?.items.find(e=>e.current),tt=fe?.isGitRepo&&et&&et?et.branch||`detached@${et.head.slice(0,7)}`:``,nt=fe?.items.length||0;return(0,K.jsxs)(`section`,{ref:B,className:`code-project-group`,"data-testid":`code-project-group`,children:[(0,K.jsxs)(`div`,{ref:V,className:`code-project-row`,children:[(0,K.jsxs)(`span`,{className:`code-project-title-content`,children:[(0,K.jsxs)(`button`,{type:`button`,className:`code-project-title`,"data-testid":`code-project-title`,"data-project-id":e.id,"aria-expanded":!t,onClick:()=>_(e.id),onContextMenu:t=>S(t,e.id),onKeyDown:t=>C(t,e.id),children:[(0,K.jsx)(`span`,{className:`code-folder-icon ${t?`collapsed`:`expanded`}`,"aria-hidden":`true`,children:t?(0,K.jsx)(Ee,{}):(0,K.jsx)(Me,{})}),(0,K.jsx)(`span`,{className:`code-project-title-name`,children:e.name})]}),tt&&fe&&(0,K.jsxs)(`button`,{ref:ae,type:`button`,className:`code-project-worktree`,"data-testid":`code-project-worktree`,title:`${tt} · ${nt} ${R.worktrees.toLocaleLowerCase()} · ${R.showWorktrees}`,"aria-label":`${tt} · ${nt} ${R.worktrees}`,"aria-haspopup":`dialog`,"aria-expanded":ue?!0:void 0,onClick:e=>{e.preventDefault(),e.stopPropagation();let t=e.currentTarget.getBoundingClientRect(),n=Math.min(440,Math.max(320,window.innerWidth-24)),r=Math.min(420,Math.max(132,(fe?.items.length||2)*58+54));de(ce()?iM(t,r,void 0,n):rM(t,r,void 0,n))},children:[(0,K.jsx)(`span`,{className:`code-project-worktree-icon`,"aria-hidden":`true`,children:(0,K.jsx)(PM,{})}),(0,K.jsx)(`span`,{className:`code-project-worktree-name`,children:tt}),nt>1&&(0,K.jsx)(`span`,{className:`code-project-worktree-count`,"aria-hidden":`true`,children:nt})]})]}),(0,K.jsxs)(`span`,{className:`code-project-title-actions`,"aria-hidden":!1,children:[Ie&&!n&&(0,K.jsx)(`button`,{type:`button`,className:`code-project-title-action`,"data-testid":`code-project-agent-visibility`,"data-collapsed":Ve?`true`:`false`,"aria-expanded":!Ve,"aria-label":Ve?R.showAgents:R.hideAgents,title:Ve?R.showAgents:R.hideAgents,onClick:()=>_e(e=>!e),children:Ve?(0,K.jsx)(WN,{}):(0,K.jsx)(GN,{})}),(0,K.jsx)(`button`,{type:`button`,className:`code-project-title-action`,"data-testid":`code-project-actions`,"aria-label":R.openOptions,title:R.openOptions,onClick:t=>S(t,e.id),children:(0,K.jsx)(qN,{})}),(0,K.jsx)(`button`,{ref:ie,type:`button`,className:`code-project-title-action`,"data-testid":`code-project-new-agent`,"aria-label":R.newAgent,title:R.newAgent,"aria-haspopup":`menu`,"aria-expanded":oe?!0:void 0,onClick:Qe,children:(0,K.jsx)(UN,{})})]}),oe&&typeof document<`u`&&(0,Wj.createPortal)((0,K.jsx)(`div`,{ref:H,className:`code-context-menu code-project-launch-menu`,"data-testid":`code-project-new-agent-menu`,role:`menu`,style:{left:oe.x,top:oe.y},children:m.map(e=>(0,K.jsxs)(`button`,{type:`button`,role:`menuitem`,"data-testid":`code-project-agent-launch-${e.name}`,onClick:()=>$e(e.command||e.name),children:[(0,K.jsx)(c,{name:e.name}),(0,K.jsx)(`span`,{children:w(e.name)})]},e.name))}),document.body),ue&&fe&&typeof document<`u`&&(0,Wj.createPortal)((0,K.jsx)(BN,{agentId:Te,anchorRef:ae,copy:R,fallback:fe,point:ue,onClose:()=>de(null),onMountProject:y}),document.body)]}),!t&&(0,K.jsxs)(`div`,{className:`code-project-expanded`,children:[Ie&&(0,K.jsx)(`div`,{ref:re,className:`code-agents-section`,"data-testid":`code-agents-section`,"data-project-id":e.id,children:(0,K.jsxs)(`div`,{className:`code-agent-list`,children:[!Ve&&(0,K.jsxs)(K.Fragment,{children:[Re?(0,K.jsx)(IN,{agents:Pe,activeTerminalId:i,selectedSearchAgentId:a,claimedAgentSessionKeyByAgentId:s,now:d,onOpenAgent:T,onOpenAgentContextMenu:D,onOpenAgentKeyboardMenu:O,onShowPreview:M,onHidePreview:N}):ze.map(e=>(0,K.jsx)(rP,{agent:e,shortcutHint:u?l.get(e.id):void 0,active:e.id===i,searchSelected:e.id===a,now:d,onOpenAgent:T,onUpdateAgentFlags:ee,reorderable:!0,dragging:be?.agentId===e.id,dropPosition:be?.targetAgentId===e.id?be.position:void 0,onAgentDragStart:Ke,onAgentDragEnd:Je,onAgentDragOver:qe,onAgentDrop:Ye,onOpenAgentContextMenu:D,onOpenAgentKeyboardMenu:O,onShowPreview:M,onHidePreview:N,copy:R},oA({kind:`agent`,agent:e,claimedSessionKey:s.get(e.id)}))),Fe.map(e=>(0,K.jsx)(rP,{session:e,searchSelected:ZD(e)===o,now:d,onResume:k,onOpenSessionContextMenu:A,onOpenSessionKeyboardMenu:j,onShowPreview:M,onHidePreview:N,copy:R},oA({kind:`history`,session:e}))),(e.hiddenAgentSessionCount??0)>0&&(0,K.jsxs)(`button`,{type:`button`,className:`code-agent-row code-session-show-more`,"data-testid":`code-session-show-more`,onClick:()=>v(e.id),children:[(0,K.jsx)(`span`,{className:`code-agent-row-copy`,children:(0,K.jsx)(`span`,{className:`code-agent-name`,children:R.showMore})}),(0,K.jsx)(`span`,{className:`code-agent-row-trailing`,children:(0,K.jsx)(`span`,{className:`code-agent-age`,children:e.hiddenAgentSessionCount})})]}),e.agentSessionsExpanded&&e.agentSessions.length>OM&&(0,K.jsx)(`button`,{type:`button`,className:`code-agent-row code-session-show-more`,"data-testid":`code-session-show-less`,onClick:()=>v(e.id),children:(0,K.jsx)(`span`,{className:`code-agent-row-copy`,children:(0,K.jsx)(`span`,{className:`code-agent-name`,children:R.showLess})})})]}),!n&&!Ve&&!Re&&Pe.length>kM&&(0,K.jsxs)(`div`,{className:`code-agent-list-controls`,"data-testid":`code-agent-list-controls`,children:[Be>0&&(0,K.jsxs)(`button`,{type:`button`,className:`code-agent-row code-session-show-more ${be?.targetAgentId===AM?`drop-after`:``}`,"data-testid":`code-agent-show-more`,onClick:()=>he(!0),onDragOver:Ze,onDrop:Xe,children:[(0,K.jsx)(`span`,{className:`code-agent-row-copy`,children:(0,K.jsx)(`span`,{className:`code-agent-name`,children:R.showMore})}),(0,K.jsx)(`span`,{className:`code-agent-row-trailing`,children:(0,K.jsx)(`span`,{className:`code-agent-age`,children:Be})})]}),me&&(0,K.jsx)(`button`,{type:`button`,className:`code-agent-row code-session-show-more`,"data-testid":`code-agent-show-less`,onClick:()=>he(!1),children:(0,K.jsx)(`span`,{className:`code-agent-row-copy`,children:(0,K.jsx)(`span`,{className:`code-agent-name`,children:R.showLess})})})]})]})}),De&&(0,K.jsx)(G.Suspense,{fallback:null,children:(0,K.jsx)(IM,{projectId:e.id,projectWorkspace:e.workspace,agentId:Te,agentLaunchOptions:m,activeFilePath:Ae?.file.path,openFiles:je.map(e=>({agentId:e.agentId,workspaceRoot:e.workspaceRoot,key:z(e),path:e.file.path,dirty:e.dirty,externalChanged:e.externalChanged})),revealRequest:h&&Oe.has(h.agentId)?h:void 0,focusSearchRequest:g&&Oe.has(g.agentId)?g:void 0,editorDirtyFilePaths:W,editorExternalChangedFilePaths:Ne,onOpenFile:Ue,onSelectOpenFile:We,onCloseOpenFile:F,onNewAgent:b,onStartAgent:x,onMoveEntries:ne,onDeleteEntries:I,onRefreshOpenFiles:L,onFilesCollapsedChange:Ge,copy:R})})]})]})}function UN(){return(0,K.jsx)(`svg`,{width:`16`,height:`16`,viewBox:`0 0 16 16`,"aria-hidden":`true`,focusable:`false`,children:(0,K.jsx)(`path`,{fill:`currentColor`,d:`M7.5 3C7.77614 3 8 3.22386 8 3.5V7H11.5C11.7761 7 12 7.22386 12 7.5C12 7.77614 11.7761 8 11.5 8H8V11.5C8 11.7761 7.77614 12 7.5 12C7.22386 12 7 11.7761 7 11.5V8H3.5C3.22386 8 3 7.77614 3 7.5C3 7.22386 3.22386 7 3.5 7H7V3.5C7 3.22386 7.22386 3 7.5 3Z`})})}function WN(){return(0,K.jsx)(`svg`,{width:`16`,height:`16`,viewBox:`0 0 16 16`,fill:`currentColor`,"aria-hidden":`true`,focusable:`false`,children:(0,K.jsx)(`path`,{d:`M2.98444 8.62471L2.98346 8.62815C2.91251 8.8948 2.63879 9.05404 2.37202 8.9833C1.94098 8.86907 2.01687 8.37186 2.01687 8.37186L2.03453 8.31047C2.03453 8.31047 2.06063 8.22636 2.08166 8.1653C2.12369 8.04329 2.18795 7.87274 2.27931 7.66977C2.46154 7.26493 2.75443 6.72477 3.19877 6.18295C4.09629 5.08851 5.60509 4 8.00017 4C10.3952 4 11.904 5.08851 12.8016 6.18295C13.2459 6.72477 13.5388 7.26493 13.721 7.66977C13.8124 7.87274 13.8766 8.04329 13.9187 8.1653C13.9397 8.22636 13.9552 8.27541 13.9658 8.31047C13.9711 8.328 13.9752 8.34204 13.9781 8.35236L13.9816 8.365L13.9827 8.36916L13.9832 8.37069L13.9835 8.37186C14.0542 8.63878 13.8952 8.91253 13.6283 8.9833C13.3618 9.05397 13.0885 8.89556 13.0172 8.62937L13.0169 8.62815L13.0159 8.62471L13.0085 8.5997C13.0014 8.57616 12.9898 8.53927 12.9732 8.49095C12.9399 8.39422 12.8866 8.25227 12.8091 8.08023C12.6538 7.73508 12.4041 7.27523 12.0283 6.81706C11.2857 5.9115 10.0445 5 8.00017 5C5.95584 5 4.71464 5.9115 3.97201 6.81706C3.59627 7.27523 3.34655 7.73508 3.19119 8.08023C3.11375 8.25227 3.06047 8.39422 3.02715 8.49095C3.01051 8.53927 2.9989 8.57616 2.99179 8.5997L2.98444 8.62471ZM8.00024 7C6.61953 7 5.50024 8.11929 5.50024 9.5C5.50024 10.8807 6.61953 12 8.00024 12C9.38096 12 10.5002 10.8807 10.5002 9.5C10.5002 8.11929 9.38096 7 8.00024 7ZM6.50024 9.5C6.50024 8.67157 7.17182 8 8.00024 8C8.82867 8 9.50024 8.67157 9.50024 9.5C9.50024 10.3284 8.82867 11 8.00024 11C7.17182 11 6.50024 10.3284 6.50024 9.5Z`})})}function GN(){return(0,K.jsx)(`svg`,{width:`16`,height:`16`,viewBox:`0 0 16 16`,fill:`currentColor`,"aria-hidden":`true`,focusable:`false`,children:(0,K.jsx)(`path`,{d:`M10.1196 10.8267L14.1464 14.8536C14.3417 15.0488 14.6583 15.0488 14.8536 14.8536C15.0488 14.6583 15.0488 14.3417 14.8536 14.1464L1.85355 1.14645C1.65829 0.951184 1.34171 0.951184 1.14645 1.14645C0.951184 1.34171 0.951184 1.65829 1.14645 1.85355L4.37624 5.08334C3.90117 5.4183 3.5126 5.80026 3.19877 6.18295C2.75443 6.72477 2.46154 7.26493 2.27931 7.66977C2.18795 7.87274 2.12369 8.04329 2.08166 8.1653C2.06063 8.22636 2.03453 8.31047 2.03453 8.31047L2.01687 8.37186C2.01687 8.37186 1.94098 8.86907 2.37202 8.9833C2.63879 9.05404 2.91251 8.8948 2.98346 8.62815L2.98444 8.62471L2.99179 8.5997C2.9989 8.57616 3.01051 8.53927 3.02715 8.49095C3.06047 8.39421 3.11375 8.25227 3.19119 8.08023C3.34655 7.73507 3.59627 7.27523 3.97201 6.81706C4.26363 6.46146 4.63213 6.10494 5.09595 5.80306L6.67356 7.38067C5.9688 7.82277 5.50024 8.60667 5.50024 9.5C5.50024 10.8807 6.61953 12 8.00024 12C8.89358 12 9.67747 11.5314 10.1196 10.8267ZM9.3807 10.0878C9.15205 10.6241 8.62005 11 8.00024 11C7.17182 11 6.50024 10.3284 6.50024 9.5C6.50024 8.88019 6.87616 8.34819 7.41244 8.11955L9.3807 10.0878ZM6.31962 4.19853L7.174 5.05291C7.43366 5.01852 7.70875 5 8.00017 5C10.0445 5 11.2857 5.9115 12.0283 6.81706C12.4041 7.27523 12.6538 7.73507 12.8091 8.08023C12.8866 8.25227 12.9399 8.39421 12.9732 8.49095C12.9898 8.53927 13.0014 8.57616 13.0085 8.5997L13.0159 8.62471L13.0169 8.62815L13.0172 8.62937C13.0885 8.89555 13.3618 9.05397 13.6283 8.9833C13.8952 8.91253 14.0542 8.63878 13.9835 8.37186L13.9832 8.37069L13.9827 8.36916L13.9816 8.365L13.9781 8.35236C13.9752 8.34204 13.9711 8.328 13.9658 8.31047C13.9552 8.27541 13.9397 8.22636 13.9187 8.1653C13.8766 8.04329 13.8124 7.87274 13.721 7.66977C13.5388 7.26493 13.2459 6.72477 12.8016 6.18295C11.904 5.0885 10.3952 4 8.00017 4C7.38264 4 6.82403 4.07236 6.31962 4.19853Z`})})}function KN(e,t,n){if(e.length<=t)return e;let r=e.slice(0,t),i=new Set(r.map(e=>e.id)),a=new Set(n.filter(e=>!!e));for(let n of e)if(!(!a.has(n.id)||i.has(n.id))){if(r.length>=t&&r.length>0){let e=r[r.length-1];i.delete(e.id),r[r.length-1]=n}else r.push(n);i.add(n.id)}return r}function qN(){return(0,K.jsx)(`svg`,{width:`16`,height:`16`,viewBox:`0 0 16 16`,"aria-hidden":`true`,focusable:`false`,children:(0,K.jsx)(`path`,{fill:`currentColor`,d:`M4 8C4 8.55228 3.55228 9 3 9C2.44772 9 2 8.55228 2 8C2 7.44772 2.44772 7 3 7C3.55228 7 4 7.44772 4 8ZM9 8C9 8.55228 8.55228 9 8 9C7.44772 9 7 8.55228 7 8C7 7.44772 7.44772 7 8 7C8.55228 7 9 7.44772 9 8ZM13 9C13.5523 9 14 8.55228 14 8C14 7.44772 13.5523 7 13 7C12.4477 7 12 7.44772 12 8C12 8.55228 12.4477 9 13 9Z`})})}function JN(e,t,n){return{key:`agent:${e.id}`,title:t.title,project:n||WD(e.projectWorkspace||e.cwd),lastActive:e.lastActivity||e.startedAt||0,provider:NM(e),workspaceRootId:e.workspaceRootId}}function YN(e,t){return{key:`session:${ZD(e)}`,title:t.title,project:nO(e),lastActive:rO(e),provider:MM(e.provider)}}function XN({preview:e,now:t}){return(0,K.jsxs)(`div`,{className:`code-agent-hover-preview`,"data-testid":`code-agent-hover-preview`,style:{left:e.x,top:e.y,width:e.width},"aria-hidden":`true`,children:[(0,K.jsxs)(`div`,{className:`code-agent-hover-preview-header`,children:[(0,K.jsx)(`strong`,{children:e.title}),(0,K.jsx)(`span`,{children:T(e.lastActive,t)})]}),(0,K.jsxs)(`div`,{className:`code-agent-hover-preview-line`,children:[(0,K.jsx)(`span`,{className:`code-agent-hover-preview-icon`,children:(0,K.jsx)(ZN,{})}),(0,K.jsxs)(`div`,{className:`code-agent-hover-preview-project`,children:[(0,K.jsx)(`span`,{className:`code-agent-hover-preview-project-name`,children:e.project}),e.provider&&(0,K.jsx)(c,{name:e.provider,variant:`color`,className:`code-agent-hover-preview-provider-icon`})]})]}),(0,K.jsxs)(`div`,{className:`code-agent-hover-preview-line`,children:[(0,K.jsx)(`span`,{className:`code-agent-hover-preview-icon`,children:(0,K.jsx)(QN,{})}),(0,K.jsx)(`span`,{children:e.branch||`—`})]})]})}function ZN(){return(0,K.jsx)(`svg`,{width:`16`,height:`16`,viewBox:`0 0 16 16`,"aria-hidden":`true`,focusable:`false`,children:(0,K.jsx)(`path`,{fill:`currentColor`,d:`M1.5 3.75C1.5 2.784 2.284 2 3.25 2h3.104c.464 0 .91.184 1.237.513l.841.842c.14.14.33.22.528.22h3.79c.966 0 1.75.784 1.75 1.75v6.925c0 .966-.784 1.75-1.75 1.75H3.25a1.75 1.75 0 0 1-1.75-1.75V3.75Zm1.75-.75a.75.75 0 0 0-.75.75v8.5c0 .414.336.75.75.75h9.5a.75.75 0 0 0 .75-.75V5.325a.75.75 0 0 0-.75-.75H8.96a1.75 1.75 0 0 1-1.235-.512l-.841-.842A.75.75 0 0 0 6.354 3H3.25Z`})})}function QN(){return(0,K.jsx)(`svg`,{width:`24`,height:`24`,viewBox:`0 0 24 24`,fill:`currentColor`,"aria-hidden":`true`,focusable:`false`,children:(0,K.jsx)(`path`,{d:`M21 8.25C21 6.1815 19.3185 4.5 17.25 4.5C15.1815 4.5 13.5 6.1815 13.5 8.25C13.5 10.023 14.739 11.5035 16.395 11.892C16.116 12.819 15.2655 13.5 14.25 13.5H9.75C8.9025 13.5 8.1285 13.7925 7.5 14.268V7.4235C9.21 7.0755 10.5 5.5605 10.5 3.75C10.5 1.6815 8.8185 0 6.75 0C4.6815 0 3 1.6815 3 3.75C3 5.562 4.29 7.0755 6 7.4235V16.575C4.29 16.923 3 18.438 3 20.2485C3 22.317 4.6815 23.9985 6.75 23.9985C8.8185 23.9985 10.5 22.317 10.5 20.2485C10.5 18.4755 9.261 16.995 7.605 16.6065C7.884 15.6795 8.7345 14.9985 9.75 14.9985H14.25C16.0845 14.9985 17.61 13.6725 17.931 11.9295C19.674 11.607 21 10.0845 21 8.25ZM4.5 3.75C4.5 2.5095 5.5095 1.5 6.75 1.5C7.9905 1.5 9 2.5095 9 3.75C9 4.9905 7.9905 6 6.75 6C5.5095 6 4.5 4.9905 4.5 3.75ZM9 20.25C9 21.4905 7.9905 22.5 6.75 22.5C5.5095 22.5 4.5 21.4905 4.5 20.25C4.5 19.0095 5.5095 18 6.75 18C7.9905 18 9 19.0095 9 20.25ZM17.25 10.5C16.0095 10.5 15 9.4905 15 8.25C15 7.0095 16.0095 6 17.25 6C18.4905 6 19.5 7.0095 19.5 8.25C19.5 9.4905 18.4905 10.5 17.25 10.5Z`})})}function $N(){return(0,K.jsx)(`svg`,{width:`16`,height:`16`,viewBox:`0 0 16 16`,"aria-hidden":`true`,focusable:`false`,children:(0,K.jsx)(`path`,{fill:`currentColor`,d:`M10.0589 2.44511C9.34701 1.73063 8.14697 1.90829 7.67261 2.79839L5.6526 6.58878L2.8419 7.52568C2.6775 7.58048 2.5532 7.71649 2.51339 7.88514C2.47357 8.0538 2.52392 8.23104 2.64646 8.35357L4.79291 10.5L2.14645 13.1465L2 14L2.85356 13.8536L5.50002 11.2071L7.64646 13.3536C7.76899 13.4761 7.94623 13.5265 8.11489 13.4866C8.28354 13.4468 8.41955 13.3225 8.47435 13.1581L9.41143 10.3469L13.1897 8.32423C14.0759 7.84982 14.2538 6.6551 13.5443 5.94305L10.0589 2.44511ZM8.55511 3.2687C8.71323 2.972 9.11324 2.91278 9.35055 3.15094L12.836 6.64889C13.0725 6.88624 13.0131 7.28448 12.7178 7.44262L8.76403 9.55921C8.65137 9.61952 8.56608 9.72068 8.52567 9.84191L7.7815 12.0744L3.92562 8.21853L6.15812 7.47436C6.27966 7.43385 6.38101 7.34823 6.44126 7.23518L8.55511 3.2687Z`})})}function eP(){return(0,K.jsx)(`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,K.jsx)(`path`,{d:`M9.56016 10.2673L14.1464 14.8536C14.3417 15.0488 14.6583 15.0488 14.8536 14.8536C15.0488 14.6583 15.0488 14.3417 14.8536 14.1464L1.85355 1.14645C1.65829 0.951184 1.34171 0.951184 1.14645 1.14645C0.951184 1.34171 0.951184 1.65829 1.14645 1.85355L5.73223 6.43934L5.6526 6.58876L2.8419 7.52566C2.6775 7.58046 2.5532 7.71648 2.51339 7.88513C2.47357 8.05378 2.52392 8.23102 2.64646 8.35356L4.79291 10.5L2.14645 13.1465L2 14L2.85356 13.8536L5.50002 11.2071L7.64646 13.3536C7.76899 13.4761 7.94623 13.5264 8.11489 13.4866C8.28354 13.4468 8.41955 13.3225 8.47435 13.1581L9.41143 10.3469L9.56016 10.2673ZM8.82138 9.52849L8.76403 9.5592C8.65137 9.61951 8.56608 9.72066 8.52567 9.84189L7.7815 12.0744L3.92562 8.21851L6.15812 7.47435C6.27966 7.43383 6.38101 7.34822 6.44126 7.23516L6.47143 7.17854L8.82138 9.52849ZM12.7178 7.4426L10.6636 8.54227L11.4024 9.28105L13.1897 8.32422C14.0759 7.84981 14.2538 6.65509 13.5443 5.94304L10.0589 2.44509C9.34701 1.73062 8.14697 1.90828 7.67261 2.79838L6.71556 4.59421L7.45476 5.33341L8.55511 3.26869C8.71323 2.97199 9.11324 2.91277 9.35055 3.15093L12.836 6.64888C13.0725 6.88623 13.0131 7.28446 12.7178 7.4426Z`})})}function tP(){return(0,K.jsx)(`svg`,{width:`16`,height:`16`,viewBox:`0 0 16 16`,"aria-hidden":`true`,focusable:`false`,children:(0,K.jsx)(`path`,{fill:`currentColor`,d:`M6.5 8C6.22386 8 6 8.22386 6 8.5C6 8.77614 6.22386 9 6.5 9H9.5C9.77614 9 10 8.77614 10 8.5C10 8.22386 9.77614 8 9.5 8H6.5ZM1 3.5C1 2.67157 1.67157 2 2.5 2H13.5C14.3284 2 15 2.67157 15 3.5V4.5C15 5.15311 14.5826 5.70873 14 5.91465V11.5C14 12.8807 12.8807 14 11.5 14H4.5C3.11929 14 2 12.8807 2 11.5V5.91465C1.4174 5.70873 1 5.15311 1 4.5V3.5ZM2.5 3C2.22386 3 2 3.22386 2 3.5V4.5C2 4.77614 2.22386 5 2.5 5H13.5C13.7761 5 14 4.77614 14 4.5V3.5C14 3.22386 13.7761 3 13.5 3H2.5ZM3 6V11.5C3 12.3284 3.67157 13 4.5 13H11.5C12.3284 13 13 12.3284 13 11.5V6H3Z`})})}function nP(){return(0,K.jsx)(`svg`,{width:`16`,height:`16`,viewBox:`0 0 16 16`,"aria-hidden":`true`,focusable:`false`,children:(0,K.jsx)(`path`,{fill:`currentColor`,d:`M12.854 14.8542L14.854 12.8542C15.049 12.6592 15.049 12.3422 14.854 12.1472L12.854 10.1472C12.659 9.95223 12.342 9.95223 12.147 10.1472C11.952 10.3422 11.952 10.6592 12.147 10.8542L13.293 12.0002H8.5C8.225 12.0002 8 11.7752 8 11.5002V5.50023C8 5.22523 8.225 5.00023 8.5 5.00023H13.293L12.147 6.14623C12.049 6.24423 12.001 6.37223 12.001 6.50023C12.001 6.62823 12.05 6.75623 12.147 6.85423C12.342 7.04923 12.659 7.04923 12.854 6.85423L14.854 4.85423C15.049 4.65923 15.049 4.34223 14.854 4.14723L12.854 2.14723C12.659 1.95223 12.342 1.95223 12.147 2.14723C11.952 2.34223 11.952 2.65923 12.147 2.85423L13.293 4.00023H8.5C7.673 4.00023 7 4.67323 7 5.50023V8.00023H1.5C1.224 8.00023 1 8.22423 1 8.50023C1 8.77623 1.224 9.00023 1.5 9.00023H7V11.5002C7 12.3272 7.673 13.0002 8.5 13.0002H13.293L12.147 14.1462C12.049 14.2442 12.001 14.3722 12.001 14.5002C12.001 14.6282 12.05 14.7562 12.147 14.8542C12.342 15.0492 12.659 15.0492 12.854 14.8542Z`})})}function rP({agent:e,session:t,shortcutHint:n,active:r=!1,searchSelected:i,now:a,onOpenAgent:o,onUpdateAgentFlags:s,reorderable:l=!1,dragging:u=!1,dropPosition:d,onAgentDragStart:f,onAgentDragEnd:p,onAgentDragOver:m,onAgentDrop:h,onOpenAgentContextMenu:g,onOpenAgentKeyboardMenu:_,onResume:v,onOpenSessionContextMenu:y,onOpenSessionKeyboardMenu:b,onShowPreview:x,onHidePreview:S,copy:C}){let w=(0,G.useRef)(!1),T=Lt(e),ee=T?{kind:`agent`,agent:T}:t?{kind:`history`,session:t,fallbackTitle:C.sessionFallbackTitle(t.providerName)}:null;if(!ee)return null;let E=_A(ee,a),D=E.requiresResume,O=T?.id??``,k=t?.provider??``,A=t?.id??``,j=D?`code-active-session-row`:`code-agent-row`,M=T?NM(T):MM(t?.provider),N=()=>{if(D){S?.(),k&&A&&v?.(k,A,t?.providerHomeId);return}O&&o?.(O)};return(0,K.jsxs)(`div`,{tabIndex:0,className:`code-agent-row ${M?`has-provider`:``} ${D?`requires-resume`:``} ${r?`active`:``} ${i?`search-selected`:``} ${E.pinned?`pinned`:``} ${E.unread?`unread`:``} ${u?`dragging`:``} ${d?`drop-${d}`:``}`,draggable:l||void 0,"data-testid":j,"data-agent-id":T?.id,"data-activity-level":T?.activityLevel,"data-provider":t?.provider,"data-session-id":t?ZD(t):void 0,"aria-label":E.rowTitle||E.title,onDragStart:e=>{!O||!l||(w.current=!0,f?.(e,O))},onDragEnd:()=>{p?.(),window.setTimeout(()=>{w.current=!1},0)},onDragOver:e=>O&&m?.(e,O),onDrop:e=>O&&h?.(e,O),onClick:e=>{if(w.current){e.preventDefault(),e.stopPropagation();return}N()},onMouseEnter:e=>{T?x?.(e,JN(T,E)):t&&x?.(e,YN(t,E))},onMouseLeave:S,onContextMenu:e=>{if(D){S?.(),k&&t&&y?.(e,k,ZD(t));return}O&&g?.(e,O)},onKeyDown:e=>{D?k&&t&&b?.(e,k,ZD(t)):O&&_?.(e,O),!e.defaultPrevented&&(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),N())},children:[M&&(0,K.jsx)(`span`,{className:`code-agent-row-provider-icon`,"aria-hidden":`true`,children:(0,K.jsx)(c,{name:M,variant:`color`})}),(0,K.jsxs)(`span`,{className:`code-agent-row-copy ${E.detailLabel?`has-details`:``}`,children:[(0,K.jsx)(`span`,{className:`code-agent-name`,children:E.title}),E.detailLabel&&(0,K.jsx)(`span`,{className:`code-agent-meta`,"data-testid":`code-agent-row-detail`,title:E.detailLabel,children:E.detailLabel})]}),(0,K.jsxs)(`span`,{className:`code-agent-row-trailing`,children:[E.statusIndicatorVisible&&(0,K.jsx)(`span`,{className:`code-agent-dot ${E.lifecycleStatus} ${E.turnActive?`turn-active`:``}`,title:E.commandTitle||E.lifecycleStatus}),E.forkedToNewWorktree&&(0,K.jsx)(`span`,{className:`code-agent-fork-new-worktree`,"data-testid":`code-agent-new-worktree-fork`,title:C.newWorktreeFork,"aria-label":C.newWorktreeFork,role:`img`,children:(0,K.jsx)(nP,{})}),E.scheduled&&(0,K.jsx)(`span`,{className:`code-agent-schedule-clock`,"data-testid":`code-agent-schedule-clock`,title:E.scheduleTitle,"aria-label":E.scheduleTitle||C.scheduledTask}),E.unread&&(0,K.jsx)(`span`,{className:`code-agent-unread`,title:C.unread}),E.ageVisible&&(0,K.jsx)(`span`,{className:`code-agent-age code-agent-relative-age`,"data-testid":`code-agent-row-age`,title:E.ageTitle,children:E.ageLabel}),e&&(0,K.jsxs)(`span`,{className:`code-agent-row-actions`,"aria-hidden":!1,children:[(0,K.jsx)(`button`,{type:`button`,className:`code-agent-row-action pin ${E.pinned?`active`:``}`,"data-testid":`code-agent-row-pin`,"aria-label":E.pinned?C.unpinAgent:C.pinAgent,title:E.pinned?C.unpinAgent:C.pinAgent,onClick:e=>{e.preventDefault(),e.stopPropagation(),T&&s?.(T,{pinned:!E.pinned})},children:E.pinned?(0,K.jsx)(eP,{}):(0,K.jsx)($N,{})}),(0,K.jsx)(`button`,{type:`button`,className:`code-agent-row-action archive`,"data-testid":`code-agent-row-archive`,"aria-label":C.archiveAgent,title:C.archiveAgent,onClick:e=>{e.preventDefault(),e.stopPropagation(),T&&s?.(T,{archived:!0})},children:(0,K.jsx)(tP,{})})]}),(e||t)&&(0,K.jsx)(`button`,{type:`button`,className:`code-agent-row-more`,"data-testid":`code-agent-row-more`,"aria-label":C.openOptions,title:C.openOptions,onClick:e=>{if(e.preventDefault(),e.stopPropagation(),D){S?.(),k&&t&&y?.(e,k,ZD(t));return}O&&g?.(e,O)},children:(0,K.jsx)(qN,{})}),n&&(0,K.jsx)(`kbd`,{children:n})]})]})}var iP=[`codex`,`claude`,`opencode`,`qoder`],aP=new Set([`bash`,`zsh`]),oP=/^[A-Za-z0-9._-]+$/,sP=[3,5,10,15,30,60,180],cP=15e3;async function lP(e,t){let n=new AbortController,r=window.setTimeout(()=>n.abort(),cP);try{return await fetch(e,{...t,signal:n.signal})}finally{window.clearTimeout(r)}}function uP(e){let t=e/1e3;return sP.reduce((e,n)=>Math.abs(n-t)<Math.abs(e-t)?n:e)}function dP(e){let t=Number(e?.receivedBytes),n=Number(e?.totalBytes);return!Number.isFinite(t)||!Number.isFinite(n)||n<=0?null:Math.max(0,Math.min(100,Math.floor(t/n*100)))}function fP(e,t=Date.now()){let n=Date.parse(String(e?.startedAt||``)),r=e?.completedAt?Date.parse(e.completedAt):e?.preparedAt?Date.parse(e.preparedAt):t;return!Number.isFinite(n)||!Number.isFinite(r)||r<n?null:Math.floor((r-n)/1e3)}function pP(e){let t=e===`zh`;return{title:t?`设置`:`Settings`,subtitle:t?`管理 Farming 的本地元数据。`:`Manage local Farming metadata.`,close:t?`关闭`:`Close`,back:t?`返回导航`:`Back to navigation`,general:t?`通用`:`General`,appearance:t?`外观`:`Appearance`,system:t?`跟随系统`:`System`,light:t?`浅色`:`Light`,dark:t?`深色`:`Dark`,interface:t?`界面`:`Interface`,interfaceSkin:t?`界面皮肤`:`Interface skin`,farmingCode:`Farming Code`,farmingCrt:`Farming CRT`,language:t?`语言`:`Language`,english:`English`,chinese:`中文`,search:t?`搜索`:`Search`,agentPermissions:t?`Agent 权限`:`Agent Permissions`,dangerousSkipLabel:t?`默认跳过所有 agent 权限检查`:`Skip all agent permission checks by default`,dangerousSkipHint:t?`开启后,新启动的 Codex、Claude、OpenCode、Qoder、Qwen、Aider、GitHub Copilot CLI、Amazon Q 等会使用各自的危险跳过权限 flag。只在可信沙箱中使用。`:`When enabled, new Codex, Claude, OpenCode, Qoder, Qwen, Aider, GitHub Copilot CLI, Amazon Q, and similar agents launch with their provider-specific dangerous skip flags. Use only in trusted sandboxes.`,searchTimeout:t?`搜索超时`:`Search timeout`,searchTimeoutValue:e=>t?e>=60?`${e/60} 分钟`:`${e} 秒`:e>=60?`${e/60} min`:`${e} sec`,updates:t?`更新`:`Updates`,updateUrl:t?`更新 URL`:`Update URL`,updateUrlPlaceholder:`https://github.com/zhuwenzhuang/farming/releases/latest`,updateUrlEmpty:t?`等待检查更新`:`Waiting for update check`,saveUpdateUrl:t?`保存更新 URL`:`Save Update URL`,refreshUpdates:t?`刷新`:`Refresh`,updateAction:t?`准备更新`:`Prepare update`,updateToVersion:e=>t?`准备 ${e}`:`Prepare ${e}`,updating:t?`准备中…`:`Preparing…`,restartToUpdate:t?`重启并应用`:`Restart to update`,checkingUpdates:t?`正在检查更新…`:`Checking for updates…`,currentVersion:t?`当前版本`:`Current`,latestVersion:t?`最新版本`:`Latest`,targetVersion:t?`升级版本`:`Target`,updateSource:t?`更新源`:`Update source`,updateMethodLabel:e=>({npm:`npm`,"app-bundle":t?`兼容包`:`App bundle`,"source-deploy":t?`源码部署`:`Source deployment`,source:t?`源码检出`:`Source checkout`,"standalone-cli":t?`单文件 CLI`:`Standalone CLI`})[e]||e||`-`,upToDate:t?`已是最新版本`:`Up to date`,updateAvailable:t?`有新版本可用`:`Update available`,updateNotInstallable:t?`当前更新不可安装`:`Update is not installable`,updateDownloading:e=>e===null?t?`正在下载更新包…`:`Downloading update package…`:t?`正在下载更新包 ${e}%`:`Downloading update package ${e}%`,updateExtracting:t?`正在解压更新包…`:`Extracting update package…`,updateInstalling:t?`正在准备更新…`:`Preparing update…`,updateReady:t?`更新已准备好,重启后应用。`:`Update ready. Restart to apply it.`,updateRestarting:t?`新版本已安装,正在重启 Farming。`:`The new version is installed. Restarting Farming.`,updateRollingBack:t?`正在回退到旧版本…`:`Rolling back to the previous version…`,updateSucceeded:t?`更新成功。`:`Update completed.`,updateRolledBack:t?`新版本启动失败,已回退到旧版本。`:`The new version failed to start and Farming rolled back.`,updateElapsed:e=>{let n=Math.floor(e/60),r=e%60;return t?`已用时 ${n>0?`${n} 分 `:``}${r} 秒`:`Elapsed ${n>0?`${n}m `:``}${r}s`},agentHomes:`Agent Homes`,agentHomesHint:t?`为不同 Agent 配置独立的主目录。`:`Configure a separate home directory for each agent.`,addHome:e=>t?`添加 ${e} home`:`Add ${e} home`,edit:t?`编辑`:`Edit`,remove:t?`删除`:`Remove`,save:t?`保存`:`Save`,cancel:t?`取消`:`Cancel`,homeName:t?`Home 名称(可选)`:`Home name (optional)`,homePath:t?`Home 路径`:`Home path`,homeNameHint:t?`留空时将根据路径自动生成。允许字母、数字、点、下划线和短横线。`:`Leave empty to generate it from the path. Use letters, numbers, dots, underscores, and hyphens.`,homeNamePlaceholder:t?`例如:work`:`e.g. work`,pathPlaceholder:`~/.codex.local`,loading:t?`加载中…`:`Loading…`,saving:t?`保存中…`:`Saving…`,saved:t?`已保存`:`Saved`,loadFailed:t?`加载设置失败`:`Failed to load settings`,saveFailed:t?`保存失败`:`Failed to save`,invalidId:t?`Home 名称只能包含字母、数字、点、下划线和短横线。`:`Home name can only contain letters, numbers, dots, underscores, and hyphens.`,duplicateId:t?`同一个 provider 下 Home 名称不能重复。`:`Home name must be unique under the same provider.`,missingPath:t?`Home 路径不能为空。`:`Home path is required.`,removeLastHint:t?`至少保留一个 home。`:`Keep at least one home.`,removeDefaultHint:t?`default home 不能删除。`:`The default home cannot be removed.`,editDisabledHint:t?`home 不支持编辑;请删除后重新添加。`:`Homes cannot be edited. Remove and add again.`,confirmRemove:e=>t?`删除 home ${e}?`:`Remove home ${e}?`,empty:t?`还没有配置 home。`:`No homes configured.`,noAgents:t?`当前机器没有识别到可配置的 coding agent。`:`No configurable coding agents were detected on this machine.`,unavailable:t?`未安装`:`Not installed`}}function mP(e){return e.trim().toLowerCase()}function hP(e){let t=e&&typeof e==`object`&&!Array.isArray(e)?e:{},n={};return Object.entries(t).forEach(([e,t])=>{let r=mP(e);if(!r||!/^[a-z0-9._-]+$/.test(r)||!Array.isArray(t))return;let i=new Set,a=[];t.forEach(e=>{if(!e||typeof e!=`object`)return;let t=e,n=String(t.id??``).trim(),r=String(t.path??``).trim();if(!n||!r||!oP.test(n))return;let o=n.toLowerCase();i.has(o)||(i.add(o),a.push({id:n,path:r}))}),a.length>0&&(n[r]=a)}),n}function gP(e){return e===`codex`?`Codex`:e===`claude`?`Claude`:e===`opencode`?`OpenCode`:e===`qoder`?`Qoder`:e}function _P(e){return{codex:`~/.codex`,claude:`~/.claude`,opencode:`~/.opencode`,qoder:`~/.qoder`}[e]??`~/.${e}`}function vP(e){return!!e?.some(e=>e.id.toLowerCase()!==`default`)}function yP(e){return e.filter(e=>e.supported!==!1&&e.interactive!==!1).filter(e=>!aP.has(e.name)).filter(e=>iP.includes(e.name)).map(e=>mP(e.name)).filter(Boolean)}function bP(e,t){let n=new Set(yP(t)),r=Object.keys(e).filter(t=>vP(e[t])),i=new Set([...n,...r]);return Array.from(i).sort((e,t)=>{let n=iP.indexOf(e),r=iP.indexOf(t),i=n===-1?iP.length:n,a=r===-1?iP.length:r;return i===a?e.localeCompare(t):i-a})}function xP(e,t){let n=e[t]??[];return n.some(e=>e.id.toLowerCase()===`default`)?n:[{id:`default`,path:_P(t)},...n]}function SP(e,t){let n=e.trim().replace(/\/+$/,``).split(`/`).filter(Boolean),r=(n[n.length-1]??``).replace(/^\.+/,``).replace(/[^A-Za-z0-9._-]+/g,`-`).replace(/^[.-]+|[.-]+$/g,``).slice(0,64)||`home`,i=new Set(t.map(e=>e.id.toLowerCase())),a=1,o=r;for(;i.has(o.toLowerCase());)a+=1,o=`${r}-${a}`;return{id:o}}function CP(e){return{provider:e,id:``,path:``}}function wP({open:e,activeAgentId:t=null,language:n,uiPreferences:i,agentLaunchOptions:a,onClose:o,onUpdateUiPreferences:s}){let c=(0,G.useMemo)(()=>pP(n),[n]),l=(0,G.useRef)(null),u=(0,G.useRef)(null),d=(0,G.useRef)(``),f=(0,G.useRef)({open:e,generation:0}),p=(0,G.useRef)(0),m=(0,G.useRef)(null),h=(0,G.useRef)(0),[g,_]=(0,G.useState)(!1),[v,y]=(0,G.useState)(``),[b,x]=(0,G.useState)(15),[S,C]=(0,G.useState)(null),[w,T]=(0,G.useState)(``),[ee,E]=(0,G.useState)(!1),[D,O]=(0,G.useState)(!1),[k,A]=(0,G.useState)(()=>hP({codex:[{id:`default`,path:`~/.codex`}],claude:[{id:`default`,path:`~/.claude`}],opencode:[{id:`default`,path:`~/.opencode`}],qoder:[{id:`default`,path:`~/.qoder`}]})),[j,M]=(0,G.useState)(!1),[N,P]=(0,G.useState)(!1),[te,F]=(0,G.useState)(``),[ne,I]=(0,G.useState)(``),[L,R]=(0,G.useState)(null);f.current.open!==e&&(f.current={open:e,generation:f.current.generation+1});let z=(0,G.useCallback)(()=>{if(!f.current.open||m.current)return;let e=f.current.generation,t=p.current+1;p.current=t,M(!0),I(``),lP(r(`/api/settings`)).then(e=>e.json()).then(n=>{p.current!==t||f.current.generation!==e||!f.current.open||m.current||(A(hP(n.settings?.agentHomes)),_(n.settings?.dangerouslySkipAgentPermissionsByDefault===!0),y(String(n.settings?.updateUrl??``)),x(uP(Number(n.settings?.searchTimeoutMs??15e3))))}).catch(()=>{p.current===t&&f.current.generation===e&&f.current.open&&!m.current&&I(c.loadFailed)}).finally(()=>{p.current===t&&f.current.generation===e&&f.current.open&&!m.current&&M(!1)})},[c.loadFailed]);(0,G.useEffect)(()=>(f.current.open=e,()=>{f.current={open:!1,generation:f.current.generation+1},p.current+=1,u.current!==null&&window.clearTimeout(u.current)}),[]),(0,G.useEffect)(()=>{e&&(m.current||P(!1),z(),window.requestAnimationFrame(()=>l.current?.focus({preventScroll:!0})))},[z,e]),(0,G.useEffect)(()=>{if(!e)return;let t=e=>{e.key===`Escape`&&(e.preventDefault(),o())};return window.addEventListener(`keydown`,t),()=>window.removeEventListener(`keydown`,t)},[o,e]);let B=(0,G.useCallback)(e=>{if(!f.current.open||m.current)return;let t=f.current.generation,n=h.current+1;h.current=n,m.current=n,p.current+=1,M(!1),P(!0),I(``),F(``);let i=!1;lP(r(`/api/settings`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({agentHomes:e})}).then(async r=>{let i=await r.json().catch(()=>null);if(!r.ok)throw Error(i?.error||c.saveFailed);m.current!==n||f.current.generation!==t||!f.current.open||(A(hP(i?.settings?.agentHomes??e)),R(null),F(c.saved),window.dispatchEvent(new CustomEvent(`farming-agent-homes-saved`)))}).catch(e=>{i=!0,m.current===n&&f.current.generation===t&&f.current.open&&I(e instanceof Error?e.message:c.saveFailed)}).finally(()=>{m.current===n&&(m.current=null,f.current.open&&(P(!1),(i||f.current.generation!==t)&&z()))})},[c.saveFailed,c.saved,z]),V=(0,G.useCallback)((e=!0,t=!1)=>{t||(E(!0),I(``)),fetch(r(`/api/update${e?`?force=1`:``}`)).then(async e=>{let t=await e.json().catch(()=>null);if(!e.ok)throw Error(t?.error||c.loadFailed);let n=t?.update??null;C(n);let r=n?.versions??[];T(e=>{if(n?.state?.phase===`ready-to-restart`){let e=n.state.version,t=r.find(t=>t.version===e);if(t?.assetName)return t.assetName}return e&&r.some(t=>t.assetName===e)?e:r[0]?.assetName||``})}).catch(e=>{t||I(e instanceof Error?e.message:c.loadFailed)}).finally(()=>{t||E(!1)})},[c.loadFailed]),re=(0,G.useCallback)(()=>{O(!0),I(``),F(``),fetch(r(`/api/settings`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({updateUrl:v})}).then(async e=>{let t=await e.json().catch(()=>null);if(!e.ok)throw Error(t?.error||c.saveFailed);y(String(t?.settings?.updateUrl??``)),F(c.saved),V(!0)}).catch(e=>I(e instanceof Error?e.message:c.saveFailed)).finally(()=>O(!1))},[c.saveFailed,c.saved,V,v]),ie=(0,G.useCallback)(e=>{x(e),I(``),u.current!==null&&window.clearTimeout(u.current),u.current=window.setTimeout(()=>{fetch(r(`/api/settings`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({searchTimeoutMs:e*1e3})}).then(async t=>{let n=await t.json().catch(()=>null);if(!t.ok)throw Error(n?.error||c.saveFailed);x(uP(Number(n?.settings?.searchTimeoutMs??e*1e3)))}).catch(e=>I(e instanceof Error?e.message:c.saveFailed))},120)},[c.saveFailed]),H=(0,G.useCallback)(()=>{let e=S?.state?.phase===`ready-to-restart`,t=S?.versions?.find(e=>e.assetName===w);if(!e&&!t?.available){V(!0);return}E(!0),I(``),F(``),d.current=e?S?.state?.version||``:t?.version||t?.assetName||``,fetch(r(e?`/api/update/restart`:`/api/update/install`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e?{}:{assetName:w})}).then(async e=>{let t=await e.json().catch(()=>null);if(!e.ok){let e=t?.blockingAgents||[],n=e.length?`: ${e.map(e=>e.command).join(`, `)}`:``;throw Error(`${t?.error||c.saveFailed}${n}`)}C(e=>({...e??{},state:t?.update?.state??e?.state,blockingAgents:t?.update?.blockingAgents??e?.blockingAgents}))}).catch(e=>{d.current=``,I(e instanceof Error?e.message:c.saveFailed)}).finally(()=>E(!1))},[c,V,w,S]);(0,G.useEffect)(()=>{e&&V(!1)},[e,V]);let ae=(0,G.useCallback)(e=>{_(e),P(!0),I(``),F(``),fetch(r(`/api/settings`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({dangerouslySkipAgentPermissionsByDefault:e})}).then(async e=>{let t=await e.json().catch(()=>null);if(!e.ok)throw Error(t?.error||c.saveFailed);_(t?.settings?.dangerouslySkipAgentPermissionsByDefault===!0),F(c.saved)}).catch(t=>{_(!e),I(t instanceof Error?t.message:c.saveFailed)}).finally(()=>P(!1))},[c.saveFailed,c.saved]),oe=(0,G.useCallback)(()=>{if(!L)return;let e=mP(L.provider),t=L.path.trim();if(!t){I(c.missingPath);return}let n=k[e]??[],r=L.id.trim()||SP(t,n).id;if(!oP.test(r)){I(c.invalidId);return}if(n.some(e=>e.id.toLowerCase()===r.toLowerCase())){I(c.duplicateId);return}B({...k,[e]:[...n,{id:r,path:t}]})},[c.duplicateId,c.invalidId,c.missingPath,L,k,B]),se=(0,G.useCallback)((e,t)=>{if(t.toLowerCase()===`default`)return;let n=k[e]??[];window.confirm(c.confirmRemove(t))&&B({...k,[e]:n.filter(e=>e.id!==t)})},[c,k,B]),ce=S?.state?.phase||``;if((0,G.useEffect)(()=>{if(!e||![`downloading`,`extracting`,`installing`,`restarting`,`rolling-back`].includes(ce))return;let t=window.setInterval(()=>V(!1,!0),1500);return()=>window.clearInterval(t)},[e,V,ce]),(0,G.useEffect)(()=>{!e||ce!==`succeeded`||!d.current||(S?.state?.version||S?.current?.releaseVersion||S?.current?.packageVersion||``)===d.current&&(d.current=``,window.location.reload())},[e,ce,S]),!e)return null;let le=bP(k,a),ue=S?.versions??[],de=ue.find(e=>e.assetName===w),fe=[`downloading`,`extracting`,`installing`,`restarting`,`rolling-back`].includes(ce),pe=ce===`ready-to-restart`,me=ee||D||fe,ge=S?.method||S?.current?.type||``,_e=c.updateMethodLabel(ge),ve=ge===`app-bundle`||ge===`source-deploy`,ye=S?.current?.releaseVersion||S?.current?.packageVersion||S?.state?.previousVersion||`-`,be=S?.latest?.version||`-`,xe=pe?S?.state?.version||de?.version||S?.selected?.version||be:de?.version||S?.selected?.version||be,Se=ye!==`-`&&xe!==`-`&&ye!==xe&&(S?.available===!0||me||pe),Ce=dP(S?.state),we=S?ce===`rolled-back`?c.updateRolledBack:ce===`failed`&&S?.state?.error?S.state.error:ce===`downloading`?c.updateDownloading(Ce):pe?c.updateReady:ce===`extracting`?c.updateExtracting:ce===`installing`?c.updateInstalling:ce===`restarting`?c.updateRestarting:ce===`rolling-back`?c.updateRollingBack:S.available?c.updateAvailable:ce===`succeeded`?c.updateSucceeded:S.latest?.blockedReason||c.upToDate:c.checkingUpdates,U=fe||pe||[`succeeded`,`failed`,`rolled-back`].includes(ce)?fP(S?.state):null,Ee=U===null?``:c.updateElapsed(U),De=fe?c.updating:pe?c.restartToUpdate:de?.available&&xe!==`-`?c.updateToVersion(xe):c.updateAction;return(0,K.jsx)(`div`,{className:`code-settings-panel-overlay`,"data-testid":`code-settings-panel`,onPointerDown:e=>{e.target===e.currentTarget&&o()},children:(0,K.jsxs)(`aside`,{className:`code-settings-panel`,"aria-modal":`true`,role:`dialog`,"aria-labelledby":`code-settings-panel-title`,children:[(0,K.jsxs)(`header`,{className:`code-settings-panel-header`,children:[(0,K.jsx)(`button`,{type:`button`,className:`code-settings-panel-back`,onClick:o,"aria-label":c.back,children:(0,K.jsx)(ze,{})}),(0,K.jsx)(`div`,{children:(0,K.jsx)(`h2`,{id:`code-settings-panel-title`,children:c.title})}),(0,K.jsx)(`button`,{ref:l,type:`button`,className:`code-settings-panel-close`,onClick:o,"aria-label":c.close,children:(0,K.jsx)(Fe,{})})]}),(0,K.jsxs)(`div`,{className:`code-settings-panel-body`,children:[(0,K.jsx)(`section`,{className:`code-settings-section compact`,children:(0,K.jsxs)(`div`,{className:`code-settings-inline-preferences`,children:[(0,K.jsxs)(`div`,{className:`code-settings-inline-choice`,children:[(0,K.jsx)(W,{"aria-hidden":`true`}),(0,K.jsxs)(`div`,{className:`code-settings-segmented`,role:`group`,"aria-label":c.appearance,children:[(0,K.jsx)(`button`,{type:`button`,className:i.appearance===`system`?`active`:``,onClick:()=>s({appearance:`system`}),children:c.system}),(0,K.jsx)(`button`,{type:`button`,className:i.appearance===`light`?`active`:``,onClick:()=>s({appearance:`light`}),children:c.light}),(0,K.jsx)(`button`,{type:`button`,className:i.appearance===`dark`?`active`:``,onClick:()=>s({appearance:`dark`}),children:c.dark})]})]}),(0,K.jsx)(`div`,{className:`code-settings-inline-choice code-settings-language-choice`,children:(0,K.jsxs)(`div`,{className:`code-settings-segmented`,role:`group`,"aria-label":c.language,children:[(0,K.jsx)(`button`,{type:`button`,className:i.language===`en`?`active`:``,onClick:()=>s({language:`en`}),children:c.english}),(0,K.jsx)(`button`,{type:`button`,className:i.language===`zh`?`active`:``,onClick:()=>s({language:`zh`}),children:c.chinese})]})})]})}),(0,K.jsxs)(`section`,{className:`code-settings-section code-settings-group`,children:[(0,K.jsx)(`div`,{className:`code-settings-section-heading`,children:(0,K.jsx)(`div`,{children:(0,K.jsx)(`h3`,{children:c.interface})})}),(0,K.jsx)(`div`,{className:`code-settings-card`,children:(0,K.jsxs)(`div`,{className:`code-settings-choice-row code-settings-runtime-row`,children:[(0,K.jsx)(`div`,{className:`code-settings-row-copy`,children:(0,K.jsx)(`strong`,{children:c.interfaceSkin})}),(0,K.jsxs)(`div`,{className:`code-settings-segmented`,role:`group`,"aria-label":c.interfaceSkin,children:[(0,K.jsx)(`button`,{type:`button`,className:`active`,"data-testid":`code-settings-skin-code`,"aria-pressed":`true`,children:c.farmingCode}),(0,K.jsx)(`button`,{type:`button`,"data-testid":`code-settings-skin-crt`,"aria-pressed":`false`,onClick:()=>window.location.assign(`${r(`/crt/`)}${t?`?agent=${encodeURIComponent(t)}`:``}`),children:c.farmingCrt})]})]})})]}),(0,K.jsxs)(`section`,{className:`code-settings-section code-settings-group`,children:[(0,K.jsx)(`div`,{className:`code-settings-section-heading`,children:(0,K.jsx)(`div`,{children:(0,K.jsx)(`h3`,{children:c.search})})}),(0,K.jsx)(`div`,{className:`code-settings-card`,children:(0,K.jsxs)(`div`,{className:`code-settings-choice-row code-settings-search-timeout-row`,children:[(0,K.jsx)(`div`,{className:`code-settings-row-copy`,children:(0,K.jsx)(`strong`,{children:c.searchTimeout})}),(0,K.jsx)(`input`,{type:`range`,min:`0`,max:String(sP.length-1),step:`1`,value:sP.indexOf(b),"aria-label":c.searchTimeout,onChange:e=>ie(sP[Number(e.target.value)]??15)}),(0,K.jsx)(`output`,{children:c.searchTimeoutValue(b)})]})})]}),(0,K.jsxs)(`section`,{className:`code-settings-section`,children:[(0,K.jsx)(`div`,{className:`code-settings-section-heading`,children:(0,K.jsx)(`div`,{children:(0,K.jsx)(`h3`,{children:c.updates})})}),(0,K.jsxs)(`div`,{className:`code-settings-update-card ${S?.available?`available`:``}`,"data-testid":`code-settings-update-card`,children:[(0,K.jsxs)(`div`,{className:`code-settings-update-overview`,children:[(0,K.jsxs)(`div`,{className:`code-settings-update-versions`,"aria-label":`${c.currentVersion} ${ye}; ${c.latestVersion} ${be}`,children:[(0,K.jsx)(`span`,{children:ye}),Se&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`span`,{className:`code-settings-update-arrow`,"aria-hidden":`true`,children:`→`}),(0,K.jsx)(`strong`,{children:xe})]})]}),(0,K.jsxs)(`div`,{className:`code-settings-update-summary ${S?.available?`available`:``} ${ce?`phase-${ce}`:``}`,role:`status`,"aria-live":`polite`,children:[(0,K.jsxs)(`span`,{className:`code-settings-update-summary-text`,children:[ge&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`span`,{children:_e}),(0,K.jsx)(`span`,{"aria-hidden":`true`,children:` · `})]}),(0,K.jsx)(`span`,{children:we})]}),Ee&&(0,K.jsx)(`span`,{className:`code-settings-update-elapsed`,"aria-hidden":`true`,children:Ee})]})]}),(0,K.jsxs)(`div`,{className:`code-settings-update-actions`,children:[(0,K.jsx)(`button`,{type:`button`,className:`code-settings-update-refresh`,onClick:()=>V(!0),disabled:me,"aria-label":c.refreshUpdates,title:c.refreshUpdates,children:`↻`}),(0,K.jsx)(`button`,{type:`button`,className:`primary`,"data-testid":`code-settings-update-action`,onClick:H,disabled:me||!pe&&!de?.available,children:De})]}),ve&&(0,K.jsxs)(`label`,{className:`code-settings-update-url`,children:[(0,K.jsx)(`span`,{children:c.updateSource}),(0,K.jsx)(`input`,{type:`url`,name:`farming-update-url`,inputMode:`url`,autoComplete:`off`,autoCorrect:`off`,autoCapitalize:`none`,spellCheck:!1,enterKeyHint:`done`,"data-lpignore":`true`,"data-1p-ignore":`true`,"data-bwignore":`true`,"data-form-type":`other`,value:v,placeholder:c.updateUrlPlaceholder,"aria-label":c.updateUrl,onChange:e=>y(e.target.value),disabled:me})]}),ve&&(0,K.jsx)(`button`,{type:`button`,className:`code-settings-update-save`,onClick:re,disabled:me,children:c.saveUpdateUrl}),ue.length>1&&(0,K.jsx)(`label`,{className:`code-settings-update-version`,children:(0,K.jsx)(`select`,{value:w,"aria-label":c.targetVersion,onChange:e=>T(e.target.value),disabled:me||pe||ue.length===0,children:ue.map(e=>(0,K.jsxs)(`option`,{value:e.assetName||``,children:[e.version||e.assetName||`-`,e.assetName&&e.assetName!==e.version?` · ${e.assetName}`:``]},e.assetName||e.version))})})]})]}),(0,K.jsxs)(`section`,{className:`code-settings-section`,children:[(0,K.jsx)(`div`,{className:`code-settings-section-heading`,children:(0,K.jsx)(`div`,{children:(0,K.jsx)(`h3`,{children:c.agentPermissions})})}),(0,K.jsxs)(`div`,{className:`code-settings-choice-row dangerous`,children:[(0,K.jsx)(`span`,{children:c.dangerousSkipLabel}),(0,K.jsx)(`button`,{type:`button`,className:`code-settings-permission-toggle ${g?`active`:``}`,role:`checkbox`,"aria-label":c.dangerousSkipLabel,"aria-pressed":g,disabled:N,onClick:()=>ae(!g),children:(0,K.jsx)(Te,{})})]})]}),(0,K.jsxs)(`section`,{className:`code-settings-section`,children:[(0,K.jsxs)(`div`,{className:`code-settings-section-heading`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h3`,{children:c.agentHomes}),(0,K.jsx)(`p`,{children:c.agentHomesHint})]}),(j||N||te)&&(0,K.jsx)(`span`,{className:`code-settings-status`,children:j?c.loading:N?c.saving:te})]}),ne&&(0,K.jsx)(`div`,{className:`code-settings-error`,role:`alert`,children:ne}),le.length===0&&(0,K.jsx)(`div`,{className:`code-agent-home-empty`,children:c.noAgents}),(0,K.jsx)(`div`,{className:`code-agent-homes-list`,children:le.map(e=>{let t=xP(k,e),n=yP(a).includes(e),r=t.find(e=>e.id.toLowerCase()===`default`),i=t.filter(e=>e.id.toLowerCase()!==`default`);return(0,K.jsxs)(`div`,{className:`code-agent-home-provider`,children:[(0,K.jsxs)(`div`,{className:`code-agent-home-provider-header`,children:[(0,K.jsxs)(`div`,{className:`code-agent-home-provider-title`,children:[(0,K.jsxs)(`strong`,{children:[gP(e),n?``:` · ${c.unavailable}`]}),r&&(0,K.jsxs)(`span`,{title:r.path,children:[r.path,` default`]})]}),(0,K.jsx)(`button`,{type:`button`,className:`code-agent-home-add`,disabled:j||N,onClick:()=>{I(``),F(``),R(CP(e))},"aria-label":c.addHome(gP(e)),title:c.addHome(gP(e)),children:(0,K.jsx)(he,{})})]}),i.map(t=>(0,K.jsxs)(`div`,{className:`code-agent-home-row`,children:[(0,K.jsx)(`div`,{className:`code-agent-home-path`,title:t.path,children:t.path}),(0,K.jsx)(`div`,{className:`code-agent-home-id`,children:t.id}),(0,K.jsx)(`div`,{className:`code-agent-home-actions`,children:(0,K.jsx)(`button`,{type:`button`,disabled:j||N,onClick:()=>se(e,t.id),"aria-label":c.remove,title:c.remove,children:(0,K.jsx)(Fe,{})})})]},t.id)),L&&L.provider===e&&(0,K.jsxs)(`div`,{className:`code-agent-home-form`,children:[(0,K.jsxs)(`label`,{children:[(0,K.jsx)(`span`,{children:c.homePath}),(0,K.jsx)(`input`,{type:`text`,name:`farming-agent-home-${e}-path`,inputMode:`text`,autoComplete:`off`,autoCorrect:`off`,autoCapitalize:`none`,spellCheck:!1,enterKeyHint:`next`,"data-lpignore":`true`,"data-1p-ignore":`true`,"data-bwignore":`true`,"data-form-type":`other`,value:L.path,placeholder:c.pathPlaceholder,"aria-label":c.homePath,onChange:e=>R(t=>t&&{...t,path:e.target.value})})]}),(0,K.jsxs)(`label`,{children:[(0,K.jsx)(`span`,{children:c.homeName}),(0,K.jsx)(`input`,{type:`text`,name:`farming-agent-home-${e}-name`,inputMode:`text`,autoComplete:`off`,autoCorrect:`off`,autoCapitalize:`none`,spellCheck:!1,enterKeyHint:`done`,"data-lpignore":`true`,"data-1p-ignore":`true`,"data-bwignore":`true`,"data-form-type":`other`,value:L.id,placeholder:c.homeNamePlaceholder,"aria-label":c.homeName,onChange:e=>R(t=>t&&{...t,id:e.target.value})}),(0,K.jsx)(`span`,{children:c.homeNameHint})]}),(0,K.jsxs)(`div`,{className:`code-agent-home-form-actions`,children:[(0,K.jsx)(`button`,{type:`button`,onClick:()=>R(null),"aria-label":c.cancel,title:c.cancel,children:(0,K.jsx)(Fe,{})}),(0,K.jsx)(`button`,{type:`button`,className:`primary`,disabled:j||N,onClick:oe,"aria-label":c.save,title:c.save,children:(0,K.jsx)(Te,{})})]})]})]},e)})})]})]})]})})}var TP=`\r`;function EP(e){return[{type:`paste`,text:e},TP]}var DP={newAgent:`New Agent`,search:`Search`,history:`History`,codex:`Farming Code`,expandSidebar:`Expand sidebar`,collapseSidebar:`Collapse sidebar`,enterFocusMode:`Enter focus mode`,exitFocusMode:`Exit focus mode`,appModeOpen:`App mode and fullscreen`,appModeTitle:`Use Farming without browser controls`,appModeDescription:`Use a clean app window where the browser supports it, or fullscreen temporarily.`,appModeRecommended:`Recommended`,appModeInstallTitle:`Install Farming 2`,appModeInstallDescription:`Opens as its own window without tabs, the address bar, or browser extensions.`,appModeInstallAction:`Install Farming 2`,appModeInstallStepOne:`Open Chrome’s ⋮ menu, then choose “Cast, save and share”.`,appModeInstallStepTwo:`Choose “Install page as app”, then open Farming 2 from its app icon.`,appModeInstallUnavailableTitle:`Browser app installation is unavailable`,appModeInstallUnavailableInsecure:`This deployment uses an insecure HTTP connection, so the browser cannot install it as an app.`,appModeInstallUnavailableBrowser:`This browser has not provided an app-install prompt for this deployment.`,appModeFullscreenTitle:`Fullscreen for now`,appModeFullscreenDescription:`Hide browser controls for this window. Press Esc to leave fullscreen.`,terminalView:`Terminal`,transcriptView:`Chat`,switchToTerminal:`Switch to Terminal`,switchToChat:`Switch to Chat`,collapseComposer:`Hide input`,restoreComposer:`Show input`,agentTranscriptSyncing:`Syncing chat history...`,agentTranscriptUnavailable:`This session’s Chat history could not be loaded.`,agentTranscriptEmpty:`No conversation yet.`,agentTranscriptWaiting:`Agent is still working...`,agentTranscriptProcess:`Process`,agentTranscriptWorking:`Processing`,agentTranscriptThinking:`Thinking`,agentTranscriptRunning:`Running`,agentTranscriptReading:`Reading`,agentTranscriptSearching:`Searching`,agentTranscriptEditing:`Editing`,agentTranscriptPlanActive:`On plan`,agentTranscriptPlanProgress:(e,t)=>`Plan ${e}/${t}`,agentTranscriptFetching:`Fetching`,agentTranscriptUsingTool:`Using tool`,agentTranscriptActionRunning:e=>`Running: ${e}`,agentTranscriptActionFailed:e=>`Failed: ${e}`,agentTranscriptEarlierActions:e=>`${e} earlier ${e===1?`action`:`actions`}`,agentTranscriptTerminalStatusUnavailable:`Terminal status could not be synchronized.`,agentTranscriptRetryTerminalStatus:`Retry`,agentTranscriptWorkedFor:e=>`Worked for ${e}`,agentTranscriptProcessCount:e=>`${e} ${e===1?`event`:`events`}`,agentTranscriptCopyDetails:`Copy details`,agentTranscriptCopiedDetails:`Copied`,agentTranscriptCopyAnswer:`Copy answer`,agentTranscriptCopiedAnswer:`Copied answer`,agentTranscriptFork:`Fork conversation`,agentTranscriptForkedFromAgent:`Forked from agent`,agentTranscriptReviewChanges:`Review`,agentTranscriptShowChanges:`Show file changes`,agentTranscriptLoadingChanges:`Loading exact changes…`,agentTranscriptKeepChange:`Keep`,agentTranscriptRevertChange:`Revert`,agentTranscriptChangeKept:`Kept`,agentTranscriptChangeReverted:`Reverted`,agentTranscriptShowMoreFiles:e=>`Show ${e} more file${e===1?``:`s`}`,codexGoalTitle:`Goal`,codexGoalEmpty:`No active goal`,codexGoalOpen:`Open goal controls`,codexGoalObjective:`Objective`,codexGoalStatus:`Status`,codexGoalTokenBudget:`Token budget`,codexGoalNoBudget:`No budget`,codexGoalUsage:(e,t)=>`${e.toLocaleString()} tokens · ${Math.round(t/60)}m`,codexGoalStatusLabel:e=>({active:`Active`,paused:`Paused`,blocked:`Blocked`,usageLimited:`Usage limited`,budgetLimited:`Budget limited`,complete:`Complete`})[e]??e,codexGoalEdit:`Edit`,codexGoalStart:`Start`,codexGoalStop:`Stop`,codexGoalDelete:`Delete`,codexGoalSave:`Save goal`,codexGoalClear:`Clear`,codexGoalSaving:`Saving...`,searchProjectsOrAgents:`Search projects or agents`,clearSearch:`Clear search`,projectsAndAgents:`Projects and agents`,noAgentsYet:`No agents yet.`,noMatchingProjectsOrAgents:`No matching projects or agents.`,openNavigation:`Open navigation`,closeNavigation:`Close navigation`,resizeNavigation:`Resize navigation`,openOptions:`Open options`,openSettings:`Settings`,agentActions:`Agent actions`,appearanceSystem:`Appearance: System`,appearanceLight:`Appearance: Light`,appearanceDark:`Appearance: Dark`,languageEnglish:`Language: English`,languageChinese:`Language: 中文`,pinAgent:`Pin Agent`,unpinAgent:`Unpin Agent`,pinProject:`Pin project`,unpinProject:`Unpin project`,revealInFinder:`Reveal in Finder`,revealInFinderFailed:`Failed to reveal project in Finder`,createPermanentWorktree:`Create permanent worktree`,permanentWorktreeCreated:`Permanent worktree created`,permanentWorktreeFailed:`Failed to create permanent worktree`,markAllAsRead:`Mark all as read`,renameAgent:`Rename Agent`,renameProject:`Rename project`,archiveAgent:`Archive`,reorderAgentFailed:`Failed to reorder Agent`,markAsRead:`Mark as read`,markAsUnread:`Mark as unread`,copyWorkingDirectory:`Copy working directory`,copiedWorkingDirectory:`Copied working directory`,copyFailed:`Copy failed`,sharePage:`Share page`,scanToOpenOnPhone:`Scan to open on phone`,copyFullShareLink:`Copy full link`,copiedShareLink:`Copied full link`,shareLinkFailed:`Share link unavailable`,sharedLocationUnavailable:e=>`Unable to locate shared path: ${e}`,shareLinkExpired:`Expired`,refreshShareLink:`Refresh`,brandStoryOrigin:`Farming Code began with a simple idea: when several coding agents work at once, people should not have to bounce between terminals, editors, and browser tabs.`,brandStoryPurpose:`It brings conversations, terminals, project files, and progress into one calm workspace, so attention stays on what matters.`,brandGithub:`GitHub`,renameInstance:`Rename instance`,instanceNameTitle:`Rename Farming instance`,instanceNameDescription:`This name appears in the sidebar and browser tab for this Farming machine.`,instanceNamePlaceholder:`Machine name`,instanceNameSaveFailed:`Could not save the instance name.`,mobileShareTitle:`Share page`,mobileForwardTitle:`Send this page`,mobileForwardHint:`Copy the link to send the current view to someone else.`,mobileShareCopyAction:`Copy link`,mobileShareCopied:`Copied`,mobileInstallTitle:`Add to Home Screen`,mobileInstallChromeHint:`Make sure this page is open in your system browser or Chrome.`,mobileInstallShareStep:`Tap Share in the browser toolbar.`,mobileInstallMoreStep:`If it is hidden, tap •••, then Share.`,mobileInstallAddStep:`Choose “Add to Home Screen”.`,mobileInstallOpenStep:`Open Farming from its Home Screen icon next time.`,mobileShareInstalled:`Farming is already open as a Home Screen app.`,forkSameWorktree:`Fork into same worktree`,forkNewWorktree:`Fork into new worktree`,newWorktreeFork:`Forked to new worktree`,scheduledTask:`Scheduled task`,killAgent:`Kill Agent`,killAgentQuestion:`Kill Agent?`,openSession:`Open Session`,pinChat:`Pin chat`,unpinChat:`Unpin chat`,archiveChat:`Archive`,archiveChats:`Archive chats`,archiveProject:`Archive Project`,removeProject:`Remove Project`,deleteWorktree:`Permanently Delete Worktree`,deleteWorktreeQuestion:`Permanently delete worktree?`,deleteWorktreeDescription:`This permanently deletes the worktree and all of its files.`,forceDelete:`Permanently Delete`,cancel:`Cancel`,retry:`Retry`,save:`Save`,stopAgentDescription:e=>`Stop ${e} and close its terminal.`,acknowledgeUnprovenAcpExit:`Confirm Exit and Remove`,acknowledgeUnprovenAcpExitDescription:e=>`Farming cannot prove that ${e}'s legacy ACP process exited during the upgrade. Continue only after verifying it has exited at the operating-system level. This removes Farming metadata and does not stop an unknown process.`,permissionModeLabel:(e,t)=>t,permissionModeDescription:(e,t)=>t,acpModeLabel:(e,t)=>({"read-only":`Read-only`,agent:`Workspace`,"agent-full-access":`Full access`,auto:`Auto`,default:`Manual`,acceptEdits:`Accept edits`,plan:`Plan`,dontAsk:`Don't ask`,bypassPermissions:`Bypass permissions`,build:`Build`})[e]??t,acpModeDescription:(e,t)=>({"read-only":`Read and analyze by default. File writes and commands that need more access require approval. Network access is off.`,agent:`Read and write inside this workspace and run sandboxed commands. Network and out-of-workspace access require approval.`,"agent-full-access":`Access files outside this workspace and use the network without approval prompts. Use only in a trusted environment.`,auto:`Use the model classifier to approve or deny permission requests.`,default:`Prompt before operations that require approval.`,acceptEdits:`Approve file edits automatically; ask about other operations that need permission.`,plan:`Plan and inspect without modifying files.`,dontAsk:`Do not show permission prompts; deny operations that were not already allowed.`,bypassPermissions:`Bypass permission checks. Use only in a trusted environment.`,build:`Run tools according to the permissions configured for this Agent.`})[e]??t,reasoningOptionLabel:(e,t)=>t,serviceTierLabel:(e,t)=>t,serviceTierDescription:(e,t)=>t,messageMode:`Message`,goalMode:`Goal`,planMode:`Plan`,askFollowUpChanges:`Ask for follow-up changes`,shellCommandPlaceholder:`Type a shell command`,describeAgentGoal:`Describe the goal for this agent`,describePlanFirst:`Describe what should be planned first`,openAgentTerminalFirst:`Open an agent terminal first`,queuedMessages:e=>`${e} queued messages`,sendQueuedMessage:`Send next`,discardQueuedMessage:`Discard queued message`,addContext:`Add context`,attachFile:`Attach file`,fileContext:`File context`,acpSignOut:`Sign out`,acpSigningOut:`Signing out…`,acpSignOutDescription:`Sign out of this ACP Agent`,setObjective:`Set objective`,planFirst:`Plan first`,clearComposerMode:`Clear composer mode`,agentPermissionMode:`Agent permission mode`,permissionsPrompt:`Launch permission profile`,permissionProfileSavedForNextLaunch:`Saved for new agents. Running sessions keep the permissions they launched with.`,permissionProfileRestarting:`Switching agent permissions…`,runtimeModeRestarting:`Restarting Agent…`,terminalProfileApplying:`Applying model to Codex Terminal…`,terminalProfileApplied:`Codex Terminal model updated.`,terminalProfileFailed:e=>`Codex Terminal model was not changed: ${e}`,agentRestartTimedOut:`Agent restart timed out. The previous Agent remains available; try switching again.`,permissionRestartHint:`The running agent restarts to apply these permissions. If it has no resumable session id yet, a fresh session starts.`,modelAndReasoning:`Model and reasoning`,reasoning:`Reasoning`,speed:`Speed`,startDictation:`Start dictation`,stopDictation:`Stop dictation`,speechUnsupported:`Speech recognition is not supported in this browser`,mobileDictationHint:`Use the microphone key on the iOS keyboard to dictate.`,sendMessage:`Send message`,interruptAgent:`Interrupt agent`,startOrSelectAgent:`Start or select an agent`,startOrSelectAgentDescription:`Projects live on the left. Open any agent terminal without closing the rest of the workspace.`,emptyWorkspaceWelcome:`Welcome to Farming`,emptyWorkspaceWelcomeDescription:`Continue earlier work, or start a new Agent.`,emptyWorkspaceContinue:`Continue earlier work`,emptyWorkspaceContinueDescription:`Resume Codex, Claude, and other Agent sessions from History.`,emptyWorkspaceNewAgentDescription:`Start a new coding task in the current project.`,emptyWorkspaceSearchDescription:`Find projects, Agents, and history.`,emptyWorkspaceShareDescription:`Open Farming on your phone or another device.`,emptyWorkspaceFocus:`Focus mode`,emptyWorkspaceFocusDescription:`Hide distractions and focus on the current task.`,emptyWorkspaceCollapseDescription:`Give the workspace more room.`,historySummary:(e,t,n,r)=>`${n+r} history agents`,searchHistory:`Search history`,noHistoryYet:`No history yet`,noHistoryDescription:`Agents moved off the main page will appear here.`,historyAgents:`History Agents`,historyPagination:`History pages`,historyPageStatus:(e,t,n,r)=>`${e} / ${t}${r?`+`:``} · ${n} loaded`,previousPage:`Previous page`,nextPage:`Next page`,agentSessions:`Agent Sessions`,recentWorkspaces:`Recent Workspaces`,agentsSessionsSummary:(e,t)=>`${e} agents · ${t} sessions`,restore:`Restore`,continueRun:`Continue`,open:`Open`,archived:`Archived`,pinned:`Pinned`,unread:`Unread`,showMore:`Show more`,showLess:`Show less`,showAgents:`Show agents`,hideAgents:`Hide agents`,latest:`Latest`,upgrade:`UPGRADE`,updating:`UPDATING`,retryUpdate:`RETRY`,checkForUpdates:`Check for updates`,updateFailed:`Update failed`,upgradeToVersion:e=>e?`Upgrade to ${e}`:`Upgrade Farming Code`,sessionFallbackTitle:e=>`${e||`Agent`} session`,resumeSessionAria:e=>`Resume ${e}`,resultsCount:e=>`${e} results`,noMatchingAgents:`No matching agents`,searchHint:`Search by Agent title, session title, or project.`,searchEmptyTitle:`Start a search`,searchEmptyDescription:`Type an Agent title, session title, or project name or path.`,agents:`Agents`,files:`Files`,changes:`Changes`,changedFiles:`Changed files`,trackedChanges:`Tracked`,untrackedChanges:`Untracked`,reviewChanges:`Review`,refreshChanges:`Refresh changes`,worktrees:`Worktrees`,showWorktrees:`Show repository worktrees`,worktreeCurrent:`current`,worktreeMain:`main`,worktreeDetached:`detached`,worktreeLocked:`locked`,worktreePrunable:`prunable`,worktreeLoadFailed:`Unable to load repository worktrees`,gitHistory:`History`,gitHistoryEmpty:`No commits yet`,gitHistoryNotRepository:`This project is not a Git repository`,gitHistoryLoadMore:`Load more`,gitHistoryView:`History view`,gitHistoryCurrentScope:`Current`,gitHistoryAllScope:`All`,gitHistoryCurrentBranch:`Current branch`,gitHistoryAllBranches:`All branches`,gitHistoryCommitMessage:`Message`,gitHistoryParent:`Compare with parent`,gitHistoryRootCommit:`Root commit`,gitHistoryReviewCommit:`Review commit`,gitHistoryCommitChanges:e=>`${e} file${e===1?``:`s`} changed`,gitHistoryNoChanges:`No file changes`,gitHistoryChangesTruncated:`More changed files were omitted`,searchOrPathLine:`Search or path:line`,searchFilesOrJump:`Search files or jump to path line`,openEditors:`OPEN EDITORS`,loading:`Loading...`,searching:`Searching...`,noMatches:`No matches`,searchIgnoredFolders:`Also search ignored folders`,searchIncomplete:e=>`Search stopped early. Current timeout: ${Math.round(e/1e3)}s.`,terminalSearchPlaceholder:`Find in terminal`,terminalSearchPrevious:`Previous match`,terminalSearchNext:`Next match`,terminalSearchClose:`Close terminal search`,terminalSearchCaseSensitive:`Match case`,terminalSearchWholeWord:`Match whole word`,terminalSearchRegex:`Use regular expression`,terminalSearchNoResults:`No results`,terminalSearchResults:(e,t)=>`${e}/${t}`,terminalRecoveryRequesting:`Loading terminal state…`,terminalRecoveryInstalling:`Terminal state received. Restoring screen…`,terminalRecoveryRetrying:e=>`Terminal state unavailable. Retrying in ${e}s…`,terminalRecoveryElapsed:e=>`Waiting ${e}s`,terminalRecoveryAttempt:e=>`Attempt ${e}`,terminalSessionUnavailable:`Terminal session unavailable`,acpPermissionAllow:`Allow`,acpPermissionTitle:`Agent needs permission`,acpPermissionTool:`Requested tool`,file:`File`,folder:`Folder`,go:`Go`,moreMatchesOmitted:`More matches omitted`,stickyFolderPath:`Sticky folder path`,containsUncommittedChanges:`Contains uncommitted changes`,changedOnDisk:`Changed on disk`,unsavedChanges:`Unsaved changes`,gitStatus:e=>`Git status: ${e}`,renameEntry:e=>`Rename ${e}`,newFile:`New File`,newFolder:`New Folder`,refreshFiles:`Refresh files`,refreshingFiles:`Refreshing files…`,filesRefreshed:`Files refreshed`,filesRefreshFailed:`Files refresh failed`,refresh:`Refresh`,rename:`Rename`,copyRelativePath:`Copy Relative Path`,copyShareUrl:`Copy Share URL`,delete:`Delete`,deleteFolderContents:e=>`Delete folder and all contents: ${e||``}`,deleteFile:e=>`Delete file: ${e||``}`,saveFile:`Save file`,savingFile:`Saving file`,reloadFile:`Reload file`,overwriteChangedFile:`Overwrite changed file`,openFileDiff:`Open File Diff`,openFileDiffFor:e=>`Open diff for ${e}`,closeDiff:`Close diff`,openFilePreview:`Open preview`,showFileSource:`Show source`,enableWordWrap:`Enable word wrap`,disableWordWrap:`Disable word wrap`,openMarkdownPreview:`Open Markdown preview`,showMarkdownSource:`Show Markdown source`,openMarkdownSplitPreview:`Open Markdown preview to side`,closeMarkdownSplitPreview:`Close Markdown side preview`,markdownPreviewFor:e=>`Markdown preview for ${e}`,markdownFrontMatter:`Front matter`,markdownHeadingAnchor:`Link to heading`,mermaidDiagram:`Mermaid diagram`,mermaidDiagramControls:`Mermaid diagram controls`,mermaidRendering:`Rendering diagram...`,mermaidRenderFailed:`Unable to render Mermaid diagram`,mermaidZoomIn:`Zoom in`,mermaidZoomOut:`Zoom out`,mermaidPanMode:`Toggle pan mode`,mermaidEnterFullscreen:`Open fullscreen diagram`,mermaidExitFullscreen:`Close fullscreen diagram`,mermaidResetView:`Reset view`,mermaidCopySource:`Copy Mermaid source`,mermaidCopiedSource:`Copied Mermaid source`,fileDiff:`File Diff`,loadingDiff:`Loading diff...`,noFileDiff:`No file changes.`,diffUnavailable:`Diff content is unavailable for this file.`,binaryDiffUnavailable:`Binary file diff is unavailable.`,diffTooLarge:`Diff is too large to display.`,deletedFileDiffOnly:`This deleted file is only available as a diff.`,showGitBlame:`Show git blame`,hideGitBlame:`Hide git blame`,gitBlameAnnotations:`Git blame annotations`,gitBlameDetails:`Git blame details`,filePath:`File path`,editorFor:e=>`Editor for ${e}`,revealInExplorer:e=>`Reveal ${e} in Explorer`,previewFor:e=>`Preview for ${e}`,author:`Author`,commit:`Commit`,date:`Date`,line:`Line`,unknown:`Unknown`,uncommitted:`Uncommitted`,closeBlameDetails:`Close blame details`,cut:`Cut`,copy:`Copy`,paste:`Paste`,selectAll:`Select All`,annotateWithBlame:`Annotate with Blame`,hideBlame:`Hide Blame`,openLineChangesWithPreviousRevision:`Open Line Changes with Previous Revision`,openLineChangesWithWorkingFile:`Open Line Changes with Working File`,lineChanges:`Line changes`,loadingLineChanges:`Loading line changes...`,noLineChanges:`No line changes for this line.`,closeLineChanges:`Close line changes`,close:`Close`,closeFile:e=>`Close ${e}`,closeOthers:`Close Others`,closeToRight:`Close to the Right`,closeSaved:`Close Saved`,closeAll:`Close All`,saveBeforeCloseTitle:e=>`Save changes to ${e}?`,saveBeforeCloseDescription:`If you do not save, your changes will be lost.`,dontSave:`Don't Save`,loadingBlame:`Loading blame...`,notGitRepository:`Not a git repository.`,noCommittedLines:`No committed lines.`,cursorPosition:(e,t)=>`Ln ${e}, Col ${t}`,startMainAgent:`Start Main Agent`,startNewAgent:`Start New Agent`,loadingAgents:`Loading agents...`,agentListUnavailable:`Agent list unavailable.`,noSupportedAgentsFound:`No supported agents found.`,resumePreviousMainAgent:`Resume previous Main Agent`,codingAgents:`coding agents`,otherAgents:`Shell`,workspace:`Workspace:`,workspacePathPlaceholder:`/path/to/workspace`,chooseWorkspaceDirectory:`Choose workspace folder`,workspaceDirectoryBrowserFailed:`Couldn’t read this directory.`,workspaceDirectoryBrowserHostHint:`Browse folders on the Farming host.`,workspaceDirectoryBrowserGo:`Go to directory`,workspaceDirectoryBrowserParent:`Parent directory`,workspaceDirectoryBrowserEmpty:`No subdirectories.`,workspaceDirectoryBrowserTruncated:`Only the first 500 folders are shown. Enter a more specific path to continue.`,workspaceDirectoryBrowserSelect:`Select this folder`,workspaceMissingTitle:`Create this workspace?`,workspaceMissingDescription:`This directory does not exist yet. Farming can create it and start the Agent there.`,workspaceCreateAndStart:`Create & Start`,workspaceCreating:`Creating...`,workspaceCreateFailedTitle:`Couldn’t create workspace`,workspaceCreateForbiddenDescription:`Farming does not have permission to create this directory. Choose another location or update the parent directory permissions.`,workspaceCreateFailedDescription:`Farming couldn’t create this directory. Check the path and try again.`,returnToWorkspace:`Change Path`,recentWorkspacesLower:`recent workspaces`,start:`Start`,back:`Back`,backToAgent:`Back to Agent`,goBack:`Go Back`,goForward:`Go Forward`,backendConnecting:`Connecting to Farming backend...`,backendConnectionLost:`Farming backend disconnected. Reconnecting...`,backendHeartbeatLost:`No Farming backend heartbeat. Waiting for it to recover...`},OP={newAgent:`新建 Agent`,search:`搜索`,history:`历史`,codex:`Farming Code`,expandSidebar:`展开侧边栏`,collapseSidebar:`收起侧边栏`,enterFocusMode:`进入沉浸模式`,exitFocusMode:`退出沉浸模式`,appModeOpen:`应用模式与全屏`,appModeTitle:`隐藏浏览器控制`,appModeDescription:`浏览器支持时可安装为独立应用窗口,也可以临时进入全屏。`,appModeRecommended:`推荐`,appModeInstallTitle:`安装 Farming 2`,appModeInstallDescription:`以后从独立窗口打开,不显示标签栏、地址栏和浏览器扩展。`,appModeInstallAction:`安装 Farming 2`,appModeInstallStepOne:`打开 Chrome 右上角 ⋮,选择“投放、保存和分享”。`,appModeInstallStepTwo:`选择“将网页安装为应用”,以后从 Farming 2 应用图标打开。`,appModeInstallUnavailableTitle:`无法安装为浏览器应用`,appModeInstallUnavailableInsecure:`当前部署使用不安全的 HTTP 连接,浏览器无法将其安装为应用。`,appModeInstallUnavailableBrowser:`当前浏览器没有为此部署提供应用安装入口。`,appModeFullscreenTitle:`暂时全屏`,appModeFullscreenDescription:`只为当前窗口隐藏浏览器控制,按 Esc 即可退出。`,terminalView:`终端`,transcriptView:`对话`,switchToTerminal:`切换到终端`,switchToChat:`切换到对话`,collapseComposer:`收起输入框`,restoreComposer:`唤出输入框`,agentTranscriptSyncing:`正在同步聊天历史...`,agentTranscriptUnavailable:`无法加载此会话的 Chat 历史。`,agentTranscriptEmpty:`还没有对话。`,agentTranscriptWaiting:`Agent 仍在工作...`,agentTranscriptProcess:`执行过程`,agentTranscriptWorking:`处理中`,agentTranscriptThinking:`思考中`,agentTranscriptRunning:`运行命令中`,agentTranscriptReading:`读取文件中`,agentTranscriptSearching:`搜索中`,agentTranscriptEditing:`修改文件中`,agentTranscriptPlanActive:`执行计划中`,agentTranscriptPlanProgress:(e,t)=>`执行计划 ${e}/${t}`,agentTranscriptFetching:`获取信息中`,agentTranscriptUsingTool:`调用工具中`,agentTranscriptActionRunning:e=>`正在执行:${e}`,agentTranscriptActionFailed:e=>`失败:${e}`,agentTranscriptEarlierActions:e=>`更早的 ${e} 个操作`,agentTranscriptTerminalStatusUnavailable:`终端状态未能同步。`,agentTranscriptRetryTerminalStatus:`重试`,agentTranscriptWorkedFor:e=>`Worked for ${e}`,agentTranscriptProcessCount:e=>`${e} 个事件`,agentTranscriptCopyDetails:`复制详情`,agentTranscriptCopiedDetails:`已复制`,agentTranscriptCopyAnswer:`复制答复`,agentTranscriptCopiedAnswer:`已复制答复`,agentTranscriptFork:`分叉对话`,agentTranscriptForkedFromAgent:`从 Agent 分叉`,agentTranscriptReviewChanges:`Review`,agentTranscriptShowChanges:`展开文件改动`,agentTranscriptLoadingChanges:`正在加载准确改动…`,agentTranscriptKeepChange:`保留`,agentTranscriptRevertChange:`撤销`,agentTranscriptChangeKept:`已保留`,agentTranscriptChangeReverted:`已撤销`,agentTranscriptShowMoreFiles:e=>`显示另外 ${e} 个文件`,codexGoalTitle:`目标`,codexGoalEmpty:`没有活动目标`,codexGoalOpen:`打开目标控制`,codexGoalObjective:`目标内容`,codexGoalStatus:`状态`,codexGoalTokenBudget:`Token 预算`,codexGoalNoBudget:`不限制`,codexGoalUsage:(e,t)=>`${e.toLocaleString()} tokens · ${Math.round(t/60)} 分钟`,codexGoalStatusLabel:e=>({active:`进行中`,paused:`已暂停`,blocked:`已阻塞`,usageLimited:`用量受限`,budgetLimited:`预算受限`,complete:`已完成`})[e]??e,codexGoalEdit:`编辑`,codexGoalStart:`启动`,codexGoalStop:`停止`,codexGoalDelete:`删除`,codexGoalSave:`保存目标`,codexGoalClear:`清除`,codexGoalSaving:`保存中...`,searchProjectsOrAgents:`搜索项目或 Agent`,clearSearch:`清空搜索`,projectsAndAgents:`项目与 Agent`,noAgentsYet:`还没有 Agent。`,noMatchingProjectsOrAgents:`没有匹配的项目或 Agent。`,openNavigation:`打开导航`,closeNavigation:`关闭导航`,resizeNavigation:`调整导航宽度`,openOptions:`打开选项`,openSettings:`设置`,agentActions:`Agent 操作`,appearanceSystem:`外观:跟随系统`,appearanceLight:`外观:浅色`,appearanceDark:`外观:深色`,languageEnglish:`语言:English`,languageChinese:`语言:中文`,pinAgent:`置顶 Agent`,unpinAgent:`取消置顶`,pinProject:`置顶项目`,unpinProject:`取消置顶项目`,revealInFinder:`在访达中显示`,revealInFinderFailed:`无法在访达中显示项目`,createPermanentWorktree:`创建永久 worktree`,permanentWorktreeCreated:`已创建永久 worktree`,permanentWorktreeFailed:`创建永久 worktree 失败`,markAllAsRead:`全部标为已读`,renameAgent:`重命名 Agent`,renameProject:`重命名项目`,archiveAgent:`归档`,reorderAgentFailed:`调整 Agent 顺序失败`,markAsRead:`标为已读`,markAsUnread:`标为未读`,copyWorkingDirectory:`复制工作目录`,copiedWorkingDirectory:`已复制工作目录`,copyFailed:`复制失败`,sharePage:`分享页面`,scanToOpenOnPhone:`手机扫码打开`,copyFullShareLink:`复制完整链接`,copiedShareLink:`已复制完整链接`,shareLinkFailed:`分享链接不可用`,sharedLocationUnavailable:e=>`无法定位分享路径:${e}`,shareLinkExpired:`已过期`,refreshShareLink:`刷新`,brandStoryOrigin:`Farming Code 从一个简单的问题出发:当多个 Coding Agent 同时工作,人不该在终端、编辑器和浏览器标签页之间反复切换。`,brandStoryPurpose:`它把对话、终端、项目文件与进展放在一个安静的工作空间里,让注意力留在真正重要的事情上。`,brandGithub:`GitHub`,renameInstance:`重命名实例`,instanceNameTitle:`重命名 Farming 实例`,instanceNameDescription:`这个名称会显示在此机器的侧边栏和浏览器页签中。`,instanceNamePlaceholder:`机器名称`,instanceNameSaveFailed:`无法保存实例名称。`,mobileShareTitle:`分享页面`,mobileForwardTitle:`转发当前页面`,mobileForwardHint:`复制链接,发送给其他人。`,mobileShareCopyAction:`复制链接`,mobileShareCopied:`已复制`,mobileInstallTitle:`添加到主屏幕`,mobileInstallChromeHint:`确认已使用系统浏览器或 Chrome 打开当前页面。`,mobileInstallShareStep:`点浏览器工具栏里的“分享”。`,mobileInstallMoreStep:`没看到时,点 •••,再点“分享”。`,mobileInstallAddStep:`选择“添加到主屏幕”。`,mobileInstallOpenStep:`以后从主屏幕的 Farming 图标进入。`,mobileShareInstalled:`Farming 已经作为主屏幕 App 打开。`,forkSameWorktree:`在同一 worktree 分叉`,forkNewWorktree:`分叉到新 worktree`,newWorktreeFork:`已分叉到新 worktree`,scheduledTask:`周期任务`,killAgent:`停止 Agent`,killAgentQuestion:`停止 Agent?`,openSession:`打开会话`,pinChat:`置顶会话`,unpinChat:`取消置顶会话`,archiveChat:`归档`,archiveChats:`归档会话`,archiveProject:`归档项目`,removeProject:`移除项目`,deleteWorktree:`彻底删除 worktree`,deleteWorktreeQuestion:`彻底删除 worktree?`,deleteWorktreeDescription:`这会彻底删除该 worktree 及其中的所有文件。`,forceDelete:`彻底删除`,cancel:`取消`,retry:`重试`,save:`保存`,stopAgentDescription:e=>`停止 ${e} 并关闭它的终端。`,acknowledgeUnprovenAcpExit:`确认已退出并移除`,acknowledgeUnprovenAcpExitDescription:e=>`Farming 无法证明 ${e} 的旧版 ACP 进程在升级时已经退出。请先在操作系统层确认进程已退出;继续操作只会移除 Farming 元数据,不会停止未知进程。`,permissionModeLabel:(e,t)=>({ask:`请求批准`,approve:`自动批准`,full:`完全访问`,custom:`自定义`,default:`默认`,auto:`自动`,acceptEdits:`接受编辑`,dontAsk:`不询问`,plan:`计划`,bypassPermissions:`绕过权限`})[e]??t,permissionModeDescription:(e,t)=>({ask:`新 Codex 会话以 workspace-write 沙箱启动,并对不可信操作询问`,approve:`新 Codex 会话以 workspace-write 沙箱启动,并在 Codex 请求时询问`,full:`新 Codex 会话绕过批准和沙箱;仅用于可信沙箱`,custom:`新 Codex 会话使用 config.toml 中定义的权限`,default:`新 Claude Code 会话使用默认设置`,auto:`新 Claude Code 会话以 auto 权限模式启动`,acceptEdits:`新 Claude Code 会话允许文件编辑,其他高风险操作仍会询问`,dontAsk:`新 Claude Code 会话在支持时尽量避免交互式批准`,plan:`新 Claude Code 会话以计划权限模式启动`,bypassPermissions:`新 Claude Code 会话绕过权限检查;仅用于可信沙箱`})[e]??t,acpModeLabel:(e,t)=>({"read-only":`只读`,agent:`工作区`,"agent-full-access":`完全访问`,auto:`自动`,default:`手动批准`,acceptEdits:`接受编辑`,plan:`计划`,dontAsk:`不询问`,bypassPermissions:`绕过权限`,build:`执行`})[e]??t,acpModeDescription:(e,t)=>({"read-only":`默认只读和分析;写文件或运行需要更高权限的命令时会请求批准,网络默认关闭`,agent:`可在当前工作区内读写文件并运行沙箱命令;使用网络或访问工作区外内容时会请求批准`,"agent-full-access":`可访问工作区外文件并使用网络,且不再请求批准;仅用于可信环境`,auto:`由模型分类器自动批准或拒绝权限请求`,default:`需要权限的操作会先请求批准`,acceptEdits:`自动批准文件编辑;其他需要权限的操作仍会询问`,plan:`只进行规划和检查,不修改文件`,dontAsk:`不弹出权限询问;未经预先允许的操作会直接拒绝`,bypassPermissions:`绕过权限检查;仅用于可信环境`,build:`按照该 Agent 已配置的权限执行工具`})[e]??t,reasoningOptionLabel:(e,t)=>({config:`使用配置`,low:`低`,medium:`中`,high:`高`,xhigh:`超高`,max:`最高`})[e]??t,serviceTierLabel:(e,t)=>({default:`标准`,priority:`快`,flex:`弹性`})[e]??t,serviceTierDescription:(e,t)=>({default:`默认速度`,priority:`1.5 倍速度,用量增加`})[e]??t,messageMode:`消息`,goalMode:`目标`,planMode:`计划`,askFollowUpChanges:`输入后续修改要求`,shellCommandPlaceholder:`输入 Shell 命令`,describeAgentGoal:`描述这个 Agent 的目标`,describePlanFirst:`描述需要先规划的事情`,openAgentTerminalFirst:`先打开一个 Agent 终端`,queuedMessages:e=>`${e} 条排队消息`,sendQueuedMessage:`当前轮后发送`,discardQueuedMessage:`丢弃排队消息`,addContext:`添加上下文`,attachFile:`附加文件`,fileContext:`文件上下文`,acpSignOut:`退出登录`,acpSigningOut:`正在退出…`,acpSignOutDescription:`退出当前 ACP Agent 登录`,setObjective:`设置目标`,planFirst:`先做计划`,clearComposerMode:`清除输入模式`,agentPermissionMode:`Agent 权限模式`,permissionsPrompt:`启动权限 profile`,permissionProfileSavedForNextLaunch:`已保存给新 Agent。运行中的会话保留启动时的权限。`,permissionProfileRestarting:`正在切换 Agent 权限…`,runtimeModeRestarting:`正在重启 Agent…`,terminalProfileApplying:`正在应用 Codex Terminal 模型…`,terminalProfileApplied:`Codex Terminal 模型已更新。`,terminalProfileFailed:e=>`Codex Terminal 模型未修改:${e}`,agentRestartTimedOut:`Agent 重启超时。原 Agent 仍然可用,请重新切换。`,permissionRestartHint:`运行中的 Agent 会重启以应用权限;如果还没有可 resume 的 Session ID,则启动一个新会话。`,modelAndReasoning:`模型与推理`,reasoning:`推理`,speed:`速度`,startDictation:`开始语音输入`,stopDictation:`停止语音输入`,speechUnsupported:`当前浏览器不支持语音识别`,mobileDictationHint:`请点 iOS 键盘上的麦克风进行听写。`,sendMessage:`发送消息`,interruptAgent:`中止 Agent`,startOrSelectAgent:`启动或选择一个 Agent`,startOrSelectAgentDescription:`项目在左侧。打开任意 Agent 终端时,不会关闭其他工作区。`,emptyWorkspaceWelcome:`欢迎使用 Farming`,emptyWorkspaceWelcomeDescription:`继续之前的工作,或开始一个新的 Agent。`,emptyWorkspaceContinue:`继续之前的工作`,emptyWorkspaceContinueDescription:`从历史记录恢复 Codex、Claude 等 Agent 会话。`,emptyWorkspaceNewAgentDescription:`在当前项目开始一个新的编码任务。`,emptyWorkspaceSearchDescription:`查找项目、Agent 和历史。`,emptyWorkspaceShareDescription:`在手机或另一台设备打开。`,emptyWorkspaceFocus:`专注模式`,emptyWorkspaceFocusDescription:`隐藏干扰,专注当前任务。`,emptyWorkspaceCollapseDescription:`给工作区更多空间。`,historySummary:(e,t,n,r)=>`${n+r} 个 History Agents`,searchHistory:`搜索历史记录`,noHistoryYet:`还没有历史记录`,noHistoryDescription:`从主页面移出的 Agent 会出现在这里。`,historyAgents:`History Agents`,historyPagination:`历史记录分页`,historyPageStatus:(e,t,n,r)=>`第 ${e} / ${t}${r?`+`:``} 页 · 已载入 ${n} 条`,previousPage:`上一页`,nextPage:`下一页`,agentSessions:`Agent 会话`,recentWorkspaces:`最近工作区`,agentsSessionsSummary:(e,t)=>`${e} 个 Agent · ${t} 个会话`,restore:`恢复`,continueRun:`继续`,open:`打开`,archived:`已归档`,pinned:`已置顶`,unread:`未读`,showMore:`显示更多`,showLess:`收起`,showAgents:`展开 Agent`,hideAgents:`隐藏 Agent`,latest:`最新`,upgrade:`升级`,updating:`更新中`,retryUpdate:`重试`,checkForUpdates:`检查更新`,updateFailed:`更新失败`,upgradeToVersion:e=>e?`升级到 ${e}`:`升级 Farming Code`,sessionFallbackTitle:e=>`${e||`Agent`} 会话`,resumeSessionAria:e=>`恢复 ${e}`,resultsCount:e=>`${e} 个结果`,noMatchingAgents:`没有匹配的 Agent`,searchHint:`可按 Agent 标题、会话标题或项目搜索。`,searchEmptyTitle:`开始搜索`,searchEmptyDescription:`输入 Agent 标题、会话标题,或项目名称、路径。`,agents:`Agent`,files:`文件`,changes:`变更`,changedFiles:`变更文件`,trackedChanges:`已跟踪`,untrackedChanges:`未跟踪`,reviewChanges:`Review`,refreshChanges:`刷新变更`,worktrees:`工作树`,showWorktrees:`查看仓库工作树`,worktreeCurrent:`当前`,worktreeMain:`主工作树`,worktreeDetached:`游离`,worktreeLocked:`已锁定`,worktreePrunable:`可清理`,worktreeLoadFailed:`无法加载仓库工作树`,gitHistory:`历史`,gitHistoryEmpty:`还没有提交`,gitHistoryNotRepository:`当前项目不是 Git 仓库`,gitHistoryLoadMore:`加载更多`,gitHistoryView:`历史视图`,gitHistoryCurrentScope:`当前`,gitHistoryAllScope:`全部`,gitHistoryCurrentBranch:`当前分支`,gitHistoryAllBranches:`所有分支`,gitHistoryCommitMessage:`提交说明`,gitHistoryParent:`与父提交比较`,gitHistoryRootCommit:`根提交`,gitHistoryReviewCommit:`Review 提交`,gitHistoryCommitChanges:e=>`${e} 个文件有变化`,gitHistoryNoChanges:`没有文件变化`,gitHistoryChangesTruncated:`还有部分变更文件未展示`,searchOrPathLine:`搜索或路径:行号`,searchFilesOrJump:`搜索文件或跳转到路径行号`,openEditors:`打开的编辑器`,loading:`加载中...`,searching:`搜索中...`,noMatches:`无匹配`,searchIgnoredFolders:`同时在已忽略目录中搜索`,searchIncomplete:e=>`搜索提前停止(当前超时:${Math.round(e/1e3)} 秒)`,terminalSearchPlaceholder:`在终端中查找`,terminalSearchPrevious:`上一个匹配`,terminalSearchNext:`下一个匹配`,terminalSearchClose:`关闭终端搜索`,terminalSearchCaseSensitive:`区分大小写`,terminalSearchWholeWord:`全词匹配`,terminalSearchRegex:`使用正则表达式`,terminalSearchNoResults:`无结果`,terminalSearchResults:(e,t)=>`${e}/${t}`,terminalRecoveryRequesting:`正在获取终端状态…`,terminalRecoveryInstalling:`终端状态已获取,正在恢复画面…`,terminalRecoveryRetrying:e=>`终端状态获取失败,${e} 秒后重试…`,terminalRecoveryElapsed:e=>`已等待 ${e} 秒`,terminalRecoveryAttempt:e=>`第 ${e} 次尝试`,terminalSessionUnavailable:`终端会话不可用`,acpPermissionAllow:`允许`,acpPermissionTitle:`Agent 需要权限`,acpPermissionTool:`请求使用工具`,file:`文件`,folder:`文件夹`,go:`跳转`,moreMatchesOmitted:`更多匹配已省略`,stickyFolderPath:`固定文件夹路径`,containsUncommittedChanges:`包含未提交改动`,changedOnDisk:`磁盘上已变更`,unsavedChanges:`未保存改动`,gitStatus:e=>`Git 状态:${e}`,renameEntry:e=>`重命名 ${e}`,newFile:`新建文件`,newFolder:`新建文件夹`,refreshFiles:`刷新文件`,refreshingFiles:`正在刷新文件…`,filesRefreshed:`文件已刷新`,filesRefreshFailed:`文件刷新失败`,refresh:`刷新`,rename:`重命名`,copyRelativePath:`复制相对路径`,copyShareUrl:`拷贝分享 URL`,delete:`删除`,deleteFolderContents:e=>`删除文件夹及其所有内容:${e||``}`,deleteFile:e=>`删除文件:${e||``}`,saveFile:`保存文件`,savingFile:`正在保存文件`,reloadFile:`重新加载文件`,overwriteChangedFile:`覆盖已变更文件`,openFileDiff:`打开文件 Diff`,openFileDiffFor:e=>`打开 ${e} 的 Diff`,closeDiff:`关闭 Diff`,openFilePreview:`打开预览`,showFileSource:`显示源码`,enableWordWrap:`开启折行`,disableWordWrap:`关闭折行`,openMarkdownPreview:`打开 Markdown 预览`,showMarkdownSource:`显示 Markdown 源码`,openMarkdownSplitPreview:`打开 Markdown 侧边预览`,closeMarkdownSplitPreview:`关闭 Markdown 侧边预览`,markdownPreviewFor:e=>`${e} 的 Markdown 预览`,markdownFrontMatter:`Front matter`,markdownHeadingAnchor:`跳转到这个标题`,mermaidDiagram:`Mermaid 图表`,mermaidDiagramControls:`Mermaid 图表控制`,mermaidRendering:`正在渲染图表...`,mermaidRenderFailed:`无法渲染 Mermaid 图表`,mermaidZoomIn:`放大`,mermaidZoomOut:`缩小`,mermaidPanMode:`切换平移模式`,mermaidEnterFullscreen:`全屏查看图表`,mermaidExitFullscreen:`退出全屏查看`,mermaidResetView:`重置视图`,mermaidCopySource:`复制 Mermaid 源码`,mermaidCopiedSource:`已复制 Mermaid 源码`,fileDiff:`文件 Diff`,loadingDiff:`正在加载 Diff...`,noFileDiff:`文件没有变化。`,diffUnavailable:`这个文件没有可显示的 Diff 内容。`,binaryDiffUnavailable:`二进制文件不能显示 Diff。`,diffTooLarge:`Diff 过大,无法显示。`,deletedFileDiffOnly:`这个已删除文件只支持以 Diff 查看。`,showGitBlame:`显示 Git Blame`,hideGitBlame:`隐藏 Git Blame`,gitBlameAnnotations:`Git Blame 标注`,gitBlameDetails:`Git Blame 详情`,filePath:`文件路径`,editorFor:e=>`${e} 的编辑器`,revealInExplorer:e=>`在文件树中显示 ${e}`,previewFor:e=>`${e} 的预览`,author:`作者`,commit:`提交`,date:`日期`,line:`行`,unknown:`未知`,uncommitted:`未提交`,closeBlameDetails:`关闭 Blame 详情`,cut:`剪切`,copy:`复制`,paste:`粘贴`,selectAll:`全选`,annotateWithBlame:`用 Blame 标注`,hideBlame:`隐藏 Blame`,openLineChangesWithPreviousRevision:`打开与上一版的行变化`,openLineChangesWithWorkingFile:`打开与工作区文件的行变化`,lineChanges:`行变化`,loadingLineChanges:`正在加载行变化...`,noLineChanges:`这一行没有可显示的变化。`,closeLineChanges:`关闭行变化`,close:`关闭`,closeFile:e=>`关闭 ${e}`,closeOthers:`关闭其他`,closeToRight:`关闭右侧`,closeSaved:`关闭已保存`,closeAll:`全部关闭`,saveBeforeCloseTitle:e=>`是否保存对 ${e} 的更改?`,saveBeforeCloseDescription:`如果不保存,你的更改将丢失。`,dontSave:`不保存`,loadingBlame:`正在加载 Blame...`,notGitRepository:`不是 Git 仓库。`,noCommittedLines:`没有已提交行。`,cursorPosition:(e,t)=>`第 ${e} 行,第 ${t} 列`,startMainAgent:`启动 Main Agent`,startNewAgent:`启动新 Agent`,loadingAgents:`正在加载 Agent...`,agentListUnavailable:`Agent 列表不可用。`,noSupportedAgentsFound:`没有找到支持的 Agent。`,resumePreviousMainAgent:`恢复上一个 Main Agent`,codingAgents:`Coding Agent`,otherAgents:`Shell`,workspace:`工作区:`,workspacePathPlaceholder:`/工作区/路径`,chooseWorkspaceDirectory:`选择工作区目录`,workspaceDirectoryBrowserFailed:`无法读取这个目录。`,workspaceDirectoryBrowserHostHint:`浏览 Farming Host 上的目录。`,workspaceDirectoryBrowserGo:`转到目录`,workspaceDirectoryBrowserParent:`上级目录`,workspaceDirectoryBrowserEmpty:`没有子目录。`,workspaceDirectoryBrowserTruncated:`仅显示前 500 个目录,请输入更具体的路径继续浏览。`,workspaceDirectoryBrowserSelect:`选择此目录`,workspaceMissingTitle:`创建这个工作区?`,workspaceMissingDescription:`这个目录尚不存在。Farming 可以创建目录,并在其中启动 Agent。`,workspaceCreateAndStart:`创建并启动`,workspaceCreating:`正在创建…`,workspaceCreateFailedTitle:`无法创建工作区`,workspaceCreateForbiddenDescription:`Farming 没有权限创建这个目录。请选择其他位置,或调整父目录权限。`,workspaceCreateFailedDescription:`Farming 无法创建这个目录。请检查路径后重试。`,returnToWorkspace:`修改路径`,recentWorkspacesLower:`最近工作区`,start:`启动`,back:`返回`,backToAgent:`返回 Agent`,goBack:`后退`,goForward:`前进`,backendConnecting:`正在连接 Farming 后端...`,backendConnectionLost:`Farming 后端连接已断开,正在重连...`,backendHeartbeatLost:`没有收到 Farming 后端心跳,正在等待恢复...`};function kP(e){return e===`zh`?OP:DP}function AP(){return window}function jP(e,t={},n=AP()){let r=t.delays??[],i=[],a=t.animationFrame!==!1,o;return t.runNow!==!1&&e(),a&&(o=n.requestAnimationFrame(e)),r.forEach(t=>{i.push(n.setTimeout(e,t))}),()=>{o!==void 0&&n.cancelAnimationFrame(o),i.forEach(e=>n.clearTimeout(e))}}var MP={ask:`Ask for approval`,approve:`Approve for me`,full:`Full access`,custom:`Custom`},NP={ask:`Launch Codex with workspace-write sandbox and ask for untrusted actions`,approve:`Launch Codex with workspace-write sandbox and ask when Codex requests approval`,full:`Launch Codex with approvals and sandbox bypassed; use only in trusted sandboxes`,custom:`Launch Codex with permissions defined in config.toml`},PP=[`ask`,`approve`,`full`,`custom`].map(e=>({value:e,label:MP[e],description:NP[e],color:e===`approve`?`blue`:e===`full`?`orange`:`muted`})),FP={default:`Default`,auto:`Auto`,acceptEdits:`Accept edits`,dontAsk:`Don't ask`,plan:`Plan`,bypassPermissions:`Bypass permissions`},IP={default:`Launch Claude Code with its default settings`,auto:`Launch Claude Code in auto permission mode`,acceptEdits:`Launch Claude Code allowing file edits while still asking for other risky actions`,dontAsk:`Launch Claude Code avoiding interactive approval prompts where supported`,plan:`Launch Claude Code in plan permission mode`,bypassPermissions:`Launch Claude Code with permission checks bypassed; use only in trusted sandboxes`},LP=[`default`,`auto`,`acceptEdits`,`dontAsk`,`plan`,`bypassPermissions`].map(e=>({value:e,label:FP[e],description:IP[e],color:e===`bypassPermissions`?`orange`:[`auto`,`acceptEdits`,`plan`].includes(e)?`blue`:`muted`})),RP=[{value:`low`,effort:`low`,label:`Low`},{value:`medium`,effort:`medium`,label:`Medium`},{value:`high`,effort:`high`,label:`High`},{value:`xhigh`,effort:`xhigh`,label:`Extra High`},{value:`max`,effort:`max`,label:`Max`}],zP=`Claude settings`,BP={value:`config`,effort:`config`,label:zP},VP=[{value:`config`,label:zP,displayName:zP,defaultEffort:`config`,reasoningLevels:[BP,...RP],source:`settings`}],HP={available:!1,effectiveModel:``,effectiveEffort:``,modelOptions:[],effortOptions:RP};function UP(e){return!!(e&&e in MP)}function WP(e){return!!(e&&e in FP)}function GP(e,t,n){return e?UP(t)?t:`custom`:n}function KP(e,t,n){return e?WP(t)?t:`default`:n}function qP(e){if(typeof e!=`string`)return``;let t=e.trim();return!t||/[\s\x00-\x1f\x7f]/.test(t)||t.startsWith(`-`)?``:t}function JP(e){return e===`config`?e:qP(e)||`config`}function YP(e){return e&&RP.some(t=>t.value===e)?e:``}function XP(e){return e===`config`?e:YP(e)||`config`}function ZP(e){let t=[];return Array.isArray(e)&&e.forEach(e=>{let n=YP(e?.value);n&&t.push({value:n,effort:n,label:e.label||KD(n),description:e.description})}),t.length>0?t:RP}function QP(e){let t=ZP(e?.effortOptions),n=qP(e?.effectiveModel),r=YP(e?.effectiveEffort),i=[];return Array.isArray(e?.modelOptions)&&e.modelOptions.forEach(e=>{let n=qP(e?.value);n&&i.push({...e,value:n,label:e.label||n,displayName:e.displayName||n,defaultEffort:YP(e.defaultEffort)||r||`medium`,reasoningLevels:t,source:e.source||`settings`})}),n&&!i.some(e=>e.value===n)&&i.unshift({value:n,label:n,displayName:n,defaultEffort:r||`medium`,reasoningLevels:t,source:`settings`}),{available:e?.available===!0,effectiveModel:n,effectiveEffort:r,modelOptions:i,effortOptions:t}}function $P(e,t){let n=t.effortOptions?.length?t.effortOptions:RP,r=t.modelOptions?.length?t.modelOptions:VP.map(e=>({...e})),i=JP(e);return!i||i===`config`||r.some(e=>e.value===i)?r.map(e=>({...e,reasoningLevels:e.reasoningLevels?.length?e.reasoningLevels:n})):[...r.map(e=>({...e,reasoningLevels:e.reasoningLevels?.length?e.reasoningLevels:n})),{value:i,label:i,displayName:i,defaultEffort:t.effectiveEffort||`medium`,reasoningLevels:n,source:`settings`}]}function eF(e,t){return e===`config`?t.effectiveModel||t.modelOptions?.[0]?.value||`config`:JP(e)}function tF(e,t){return e===`config`?t.effectiveEffort||`config`:XP(e)}function nF(e,t){let n=t.effortOptions?.length?t.effortOptions:RP;return e===`config`?[BP,...n]:n.some(t=>t.value===e)?n:[...n,{value:e,effort:e,label:KD(e)}]}function rF(e,t,n,r){if(!e||r.some(t=>t.value===e))return r;let i=[{value:`default`,label:`Standard`,description:`Default speed`}];return n&&n!==`default`&&i.push({value:n,label:n===`priority`?`Fast`:n}),[...r,{value:e,label:JD(void 0,e),displayName:JD(void 0,e),defaultEffort:t,reasoningLevels:[{value:t,effort:t,label:KD(t)}],serviceTiers:i,source:`pending-catalog`}]}function iF(e){let t=e.agentLaunchProfiles?.codex??{},n=t.approvalMode??e.codexApprovalMode,r=qD(t.modelPreset??e.codexModelPreset),i=t.model||e.codexModel||r.model,a=t.reasoningEffort||e.codexReasoningEffort||r.effort,o=e.agentLaunchProfiles?.claude??{};return{codexApprovalMode:UP(n)?n:`approve`,codexModel:i,codexReasoningEffort:a,codexServiceTier:t.serviceTier||e.codexServiceTier||`default`,codexModelPreset:`${i}:${a}`,claudePermissionMode:WP(o.permissionMode)?o.permissionMode:`default`,claudeModel:JP(o.model),claudeEffort:XP(o.effort)}}function aF(e,t){return!e?.model||!e.reasoningEffort?t:{model:e.model,reasoningEffort:e.reasoningEffort,serviceTier:e.serviceTier||`default`}}function oF({agentKind:e,codexModel:t,codexReasoningEffort:n,codexServiceTier:r,codexModelPreset:i,codexModelOptions:a,codexApprovalMode:o,claudeModel:s,claudeEffort:c,claudeSettings:l,claudePermissionMode:u}){let d=eF(s,l),f=tF(c,l),p=e===`claude`?$P(s,l):e===`codex`?rF(t,n,r,a):a,m=e===`claude`?d:t,h=e===`claude`?f:n,g=e===`claude`?``:r,_=e===`claude`?`${m}:${h}`:i,v=p.find(e=>e.value===m)??p[0],y=e===`claude`?nF(h,l):v?.reasoningLevels?.length?v.reasoningLevels:h?[{value:h,effort:h,label:KD(h)}]:[],b=e===`claude`?[]:v?.serviceTiers?.length?v.serviceTiers:[{value:`default`,label:`Standard`,description:`Default speed`}],x=y.find(e=>e.value===h)??y[0],S=b.find(e=>e.value===g)??b[0],C=e===`claude`?LP:PP,w=e===`claude`?u:o,T=C.find(e=>e.value===w)??C[0];return{agentModelOptions:p,agentModel:m,agentReasoningEffort:h,agentServiceTier:g,agentModelPreset:_,currentModelOption:v,currentReasoningOptions:y,currentServiceTierOptions:b,currentReasoningOption:x,currentServiceTierOption:S,currentModelLabel:JD(v,m),currentReasoningLabel:x?.label??KD(h),currentSpeedLabel:S?.label??``,permissionModeOptions:C,currentPermissionMode:w,currentPermissionOption:T,currentPermissionLabel:T?.label??w,currentPermissionColor:T?.color??`muted`}}function sF(e){return!e.isMain&&e.archived!==!0&&e.status!==`dead`&&e.status!==`stopped`}function cF(e){return!e.isMain&&e.archived===!0}function lF(e,t=[]){let n=new Map;return e.forEach(e=>{if(!sF(e))return;let t=e.providerSessionKey||Ak(e.source);t&&n.set(e.id,t)}),n}function uF(e,t){return t.get(e.id)||`agent:${e.id}`}function dF(e){return e.providerSessionKey&&e.providerSessionTemporary!==!0?120:Ak(e.source)?100:e.providerSessionKey?40:0}function fF(e){return e.status===`running`?30:e.status===`pending`?20:0}function pF(e,t){return dF(e)+(t.has(e.id)?50:0)+fF(e)}function mF(e,t){let n=new Map;return e.forEach(e=>{let r=uF(e,t),i=n.get(r);if(!i){n.set(r,e);return}let a=pF(e,t),o=pF(i,t),s=Number(e.startedAt)||0,c=Number(i.startedAt)||0;(a>o||a===o&&s>c)&&n.set(r,e)}),e.filter(e=>n.get(uF(e,t))===e)}function hF(e,t){return e.filter(e=>!t.has(ZD(e)))}function gF(e,t,n){return e.filter(e=>{let r=ZD(e);return(e.archived||!t.has(r))&&!n.has(r)})}function _F({allAgents:e,liveAgents:t,sessions:n,mainPageSessionKeys:r}){let i=t.filter(sF),a=lF(i,n),o=new Set(a.values()),s=mF(i,a),c=n.filter(e=>!e.archived&&r.has(ZD(e))).sort(iO),l=hF(c,o),u=hF(n,o).sort(iO),d=gF(n,r,o).sort(iO);return{liveAgents:s,archivedAgents:e.filter(cF).sort((e,t)=>(t.archivedAt??0)-(e.archivedAt??0)),mainPageAgentSessions:c,sidebarAgentSessions:l,searchableAgentSessions:u,historyAgentSessions:d,claimedAgentSessionKeys:o,claimedAgentSessionKeyByAgentId:a}}var vF=`farming.workspaceDraftBackups.v1`,yF=32,bF=1024*1024,xF=2*1024*1024;function SF(e){if(!e||typeof e!=`object`)return!1;let t=e;return typeof t.key==`string`&&typeof t.agentId==`string`&&(t.workspaceRoot===void 0||typeof t.workspaceRoot==`string`)&&typeof t.filePath==`string`&&typeof t.baseSha1==`string`&&typeof t.draft==`string`&&typeof t.revision==`number`&&Number.isFinite(t.revision)&&typeof t.externalChanged==`boolean`&&typeof t.updatedAt==`number`&&Number.isFinite(t.updatedAt)}function CF(e,t=Date.now()){return{key:z(e),agentId:e.agentId,...e.workspaceRoot===void 0?{}:{workspaceRoot:e.workspaceRoot},filePath:e.file.path,baseSha1:e.file.sha1,draft:e.draft,revision:e.revision??0,externalChanged:e.externalChanged,updatedAt:t}}function wF(e,t){if(t.key!==z(e))return e;let n=t.draft!==e.file.content;return{...e,draft:n?t.draft:e.file.content,dirty:n,revision:Math.max(e.revision??0,t.revision),externalChanged:n&&(t.externalChanged||t.baseSha1!==e.file.sha1),saving:!1,saveRequestId:void 0,saveRevision:void 0,error:null,transient:!1}}function TF(e){let t=new Map;try{let n=JSON.parse(e.getItem(vF)||`null`);if(n?.version!==1||!Array.isArray(n.records))return t;n.records.forEach(e=>{SF(e)&&t.set(e.key,e)})}catch{try{e.removeItem(vF)}catch{}}return t}function EF(e,t){let n=Array.from(t.values()).filter(e=>e.draft.length<=bF).sort((e,t)=>t.updatedAt-e.updatedAt).slice(0,yF);for(;n.length>0;){let t=JSON.stringify({version:1,records:n});if(t.length>xF){n.pop();continue}try{e.setItem(vF,t);return}catch{n.pop()}}try{e.removeItem(vF)}catch{}}function DF(){return{activeFile:null,files:[],closedFileCache:new Map}}function OF(e){return{activeFile:e.activeFile,files:e.files,closedFileCache:e.closedFileCache}}function kF(){if(typeof window>`u`)return null;try{return window.localStorage}catch{return null}}function AF(e){return[...e.files,...e.closedFileCache.values()]}function jF(){let[e,t]=(0,G.useState)(()=>DF()),n=(0,G.useRef)(e),r=(0,G.useRef)(null),i=(0,G.useRef)(null);if(r.current===null){let e=kF();r.current=e?TF(e):new Map}let a=(0,G.useCallback)(()=>{i.current!==null&&(clearTimeout(i.current),i.current=null);let e=kF();e&&EF(e,r.current??new Map)},[]),o=(0,G.useCallback)(()=>{i.current!==null&&clearTimeout(i.current),i.current=setTimeout(()=>{i.current=null;let e=kF();e&&EF(e,r.current??new Map)},250)},[]),s=(0,G.useCallback)((e,t)=>{let n=r.current;if(!n)return;let i=AF(t),a=new Set(i.map(z));AF(e).forEach(e=>{let t=z(e);a.has(t)||n.delete(t)}),i.forEach(e=>{let t=z(e);e.dirty?n.set(t,CF(e)):n.delete(t)}),o()},[o]),c=(0,G.useCallback)(e=>{let r=n.current;return n.current=OF(e),s(r,n.current),t(n.current),n.current},[s]),l=(0,G.useCallback)((e,t,i)=>{let a=N(n.current,e,t,i),o=a.activeFile,s=o?r.current?.get(z(o)):null;return o&&s&&(a=R(a,wF(o,s))),c(a)},[c]),u=(0,G.useCallback)((e,t,r)=>{let i=D(n.current,e,t,r);return i?c(i):null},[c]),d=(0,G.useCallback)(e=>{let t=H(n.current,e);return t.closedFiles.length>0&&c(t),t},[c]),f=(0,G.useCallback)(e=>{let t=ne(n.current,{canReopen:e});return t?c(t):null},[c]),p=(0,G.useCallback)((e,t)=>{let r=te(n.current.files,e);if(!r)return null;let i=t(r);return i!==r&&c(R(n.current,i)),i},[c]),m=(0,G.useCallback)((e,t)=>c(P(n.current,e,t)),[c]),h=(0,G.useCallback)(e=>{let t=n.current.activeFile;if(!t)return null;let r=M(t,e);return c({...n.current,activeFile:r,files:fe(n.current.files,r)})},[c]),g=(0,G.useCallback)((e,t)=>{let r=j(n.current,e,t);return r!==n.current&&c(r),r},[c]),_=(0,G.useCallback)((e,t)=>{let r=ie(n.current,e,t);return t.length>0&&c(r),r},[c]),v=(0,G.useMemo)(()=>Array.from(e.closedFileCache.values()),[e.closedFileCache]);return(0,G.useEffect)(()=>{let e=()=>a();return window.addEventListener(`pagehide`,e),()=>{window.removeEventListener(`pagehide`,e),a()}},[a]),(0,G.useMemo)(()=>({activeFile:e.activeFile,files:e.files,closedFiles:v,openFromRead:l,select:u,close:d,reopenLastClosed:f,update:p,refreshFromReads:m,updateDraft:h,move:g,deleteEntries:_}),[v,d,_,g,l,m,f,u,e.activeFile,e.files,p,h])}function MF(){let[e,t]=(0,G.useState)(()=>Kn()),n=(0,G.useRef)(e),r=(0,G.useRef)(!1),i=(0,G.useRef)(null),a=(0,G.useCallback)(e=>(n.current=e,t(e),e),[]),o=(0,G.useCallback)(e=>{r.current||a(Zn(n.current,e))},[a]),s=(0,G.useCallback)(e=>{o(qn(e))},[o]),c=(0,G.useCallback)(e=>{o(Jn(e))},[o]),l=(0,G.useCallback)(e=>{r.current||(i.current!==null&&window.clearTimeout(i.current),i.current=window.setTimeout(()=>{i.current=null,o(Jn({...e,reason:`cursor`}))},650))},[o]),u=(0,G.useCallback)(e=>{let t=n.current,i=t.index+e,o=t.entries[i];return o?(r.current=!0,a({entries:t.entries,index:i}),o):null},[a]),d=(0,G.useCallback)(()=>{window.setTimeout(()=>{r.current=!1},120)},[]),f=(0,G.useCallback)(e=>{let t=n.current,r=t.entries.filter(e);if(r.length===t.entries.length)return;let i=t.entries[t.index],o=i?r.indexOf(i):-1;a({entries:r,index:o>=0?o:Math.min(t.index,r.length-1)})},[a]);return(0,G.useEffect)(()=>()=>{i.current!==null&&(window.clearTimeout(i.current),i.current=null)},[]),(0,G.useMemo)(()=>({canGoBack:e.index>0,canGoForward:e.index>=0&&e.index<e.entries.length-1,recordAgent:s,recordFile:c,recordFileCursor:l,beginNavigation:u,finishNavigation:d,pruneEntries:f}),[u,d,f,s,c,l,e.entries.length,e.index])}function NF({agents:e,permissionSwitchReplacement:t,onDiscardAttachment:n}){let[r,i]=(0,G.useState)({});(0,G.useLayoutEffect)(()=>{let r=new Set(e.filter(e=>!e.archived&&e.status!==`dead`&&e.status!==`stopped`).flatMap(e=>[$A(e),Aj(e)]).filter(Boolean));i(i=>{let a=i,o=!1,s=()=>(a===i&&(a={...i}),o=!0,a);if(t){let e=(e,t)=>{let n=a[e];if(!n)return;let r=s(),i=r[t];r[t]=i?ZA(i,n):n,delete r[e]};e(t.originalAgentId,t.replacementAgentId),e(`acp:${t.originalAgentId}`,`acp:${t.replacementAgentId}`)}return e.forEach(e=>{let t=$A(e);if(!t)return;ej(e).forEach(e=>{if(e===t)return;let n=a[e];if(!n)return;let r=s();r[t]=r[t]?ZA(r[t],n):n,delete r[e]});let n=Aj(e);jj(e).forEach(e=>{if(e===n)return;let t=a[e];if(!t)return;let r=s();r[n]=r[n]?ZA(r[n],t):t,delete r[e]})}),Object.entries(a).forEach(([e,t])=>{if(r.has(e))return;let i=s();t.attachments.forEach(n),delete i[e]}),o?a:i})},[e,n,t]);let a=(0,G.useCallback)(t=>{if(!t)return``;for(let n of e){let e=Mj(t),r=e?Aj(n):$A(n);if(!r)continue;let i=e?jj(n):ej(n);if(t===r||i.includes(t))return r}return t},[e]);return{composerByAgentKey:r,updateComposerStateForKey:(0,G.useCallback)((e,t)=>{i(n=>{let r=a(e);if(!r)return n;let i=n[r]??KA(),o=t(i);return o===i?n:{...n,[r]:o}})},[a]),updateExistingComposerStateForKey:(0,G.useCallback)((e,t)=>{i(n=>{let r=a(e);if(!r)return n;let i=n[r];if(!i)return n;let o=t(i);return o===i?n:{...n,[r]:o}})},[a])}}function PF(e,t=20){let n=[];for(let t of e){if(!t)continue;let e=n.indexOf(t);e>=0&&n.splice(e,1),n.push(t)}let r=Math.max(0,Math.floor(t));return r===0?[]:n.slice(-r)}function FF(e,t,n=20){let r=PF(t,n);return r.length===e.length&&r.every((t,n)=>t===e[n])?e:r}function IF(e,t,n=20){return FF(e,[...e,t],n)}function LF(){if(typeof window>`u`)return``;let e=window.location.hostname;return e?e===`localhost`||e===`127.0.0.1`||e===`::1`?`Local server`:`Remote server`:``}function RF(e){return e.replace(/^Language:\s*/i,``).replace(/^语言[::]\s*/,``)}function zF(e){if(!e||typeof e!=`object`||Array.isArray(e))return{};let t={};return Object.entries(e).forEach(([e,n])=>{let r=e.trim(),i=String(n??``).trim();!r||!i||(t[r]=i.slice(0,80))}),t}function BF(e){return e.replace(/^Appearance:\s*/i,``).replace(/^外观[::]\s*/,``)}function VF(e,t){return e.size===t.length?t.every(t=>e.has(t)):!1}function HF(e){return(e.ctrlKey||e.metaKey)&&e.shiftKey&&!e.altKey&&e.key.toLowerCase()===`t`}var UF=296,WF=220,GF=840,KF=360,qF=5*6e4,JF=52,YF=172,XF=900,ZF=12,QF=4,$F=15e3,eI=286,tI=60,nI=1e3,rI=150,iI=35e3,aI=15e3;async function oI(e,t){let n=new AbortController,r=window.setTimeout(()=>n.abort(),aI);try{return await fetch(e,{...t,signal:n.signal})}finally{window.clearTimeout(r)}}async function sI(e,t){let n=[],r=!0,i=0,a=Array.from({length:Math.min(QF,t.length)},async()=>{for(;i<t.length;){let a=t[i];i+=1;let o=new AbortController,s=window.setTimeout(()=>o.abort(),$F);try{n.push(await le(e,a,{signal:o.signal}))}catch{r=!1}finally{window.clearTimeout(s)}}});return await Promise.all(a),{files:n,successful:r}}function cI(){return typeof window>`u`?!1:re()&&ae()}function lI(e){let t=(e||``).trim().split(/\s+/).find(e=>e!==`env`&&!/^[A-Za-z_][A-Za-z0-9_]*=/.test(e))?.split(`/`).pop()||``;return t===`qoder`||t===`qodercli`||t===`opencode`}function uI(e){return!!(e&&TD(e.command)===`codex`&&e.runtimeBinding.kind===`terminal`)}function dI(e){return e instanceof HTMLElement?e.tagName===`INPUT`||e.tagName===`TEXTAREA`||e.isContentEditable:!1}function fI(e){return kk(e)}function pI(e){return e.kind===`agent-session`?ZD(e):VD(e)}function mI(){return ce()}function hI(e){return!mI()&&e>0&&e<XF}function gI(){return mI()?!0:typeof window<`u`&&hI(window.innerWidth)}function _I(e){e.preventDefault(),e.stopPropagation(),e.stopImmediatePropagation()}function vI(e){let t=(e||``).replace(/\/+$/,``);return t.split(`/`).filter(Boolean).pop()||t||`workspace`}function yI(e){if(e.lineNumber)return{lineNumber:e.lineNumber,column:e.column,endColumn:e.endColumn}}function bI(e){let t=new Map;for(let n of e)n.kind!==`path`||t.has(n.path)||t.set(n.path,n);return Array.from(t.values())}function xI(e){let t=new Map;for(let n of e)t.has(n.path)||t.set(n.path,n);return Array.from(t.values())}function SI(e,t){let n=new Set(e);return t.forEach(e=>{e.sessionKeys.forEach(t=>{e.operation===`add`?n.add(t):n.delete(t)})}),Array.from(n)}async function CI(e){try{if(navigator.clipboard?.writeText)return await navigator.clipboard.writeText(e),!0}catch{}let t=document.createElement(`textarea`);t.value=e,t.setAttribute(`readonly`,`true`),t.setAttribute(`autocomplete`,`off`),t.setAttribute(`autocorrect`,`off`),t.setAttribute(`autocapitalize`,`none`),t.setAttribute(`spellcheck`,`false`),t.setAttribute(`data-lpignore`,`true`),t.setAttribute(`data-1p-ignore`,`true`),t.setAttribute(`data-bwignore`,`true`),t.setAttribute(`data-form-type`,`other`),t.style.position=`fixed`,t.style.left=`-9999px`,t.style.top=`0`,document.body.appendChild(t),t.select();try{return document.execCommand(`copy`)}finally{t.remove()}}function wI({agents:e,taskHistory:t,mainPageSessionKeys:n,activeView:i,dialogOpen:a,usageSummary:o,contextWindowByAgentId:s={},activeTerminalId:c,permissionSwitchingAgentId:l,agentSwitchingKind:h,permissionSwitchReplacement:b,retainedAgentViewIds:S,terminalFocusRequest:w,remoteProjectWorkspaces:T,remotePinnedProjectWorkspaces:ee,keyMap:D,keyboardShortcutsEnabled:O,uiPreferences:k,onOpenTerminal:A,onOpenTerminalWhenReady:j,onNewAgent:M,onStartAgent:N,onRenameAgent:P,onUpdateAgentFlags:te,onOpenArchivedAgent:ne,onForkAgent:R,onDeleteForkWorktreeProject:B,onRestartMainAgent:ie,onWorkspaceViewChange:H,onKill:ae,onInterruptAgent:oe,sendComposerInput:se,onSessionOutput:ue,onUpdateUiPreferences:fe}){Rn(`codeWorkspace`);let pe=Jt(),{composerByAgentKey:me,updateComposerStateForKey:he,updateExistingComposerStateForKey:ge}=NF({agents:e,permissionSwitchReplacement:b,onDiscardAttachment:mj}),_e=(0,G.useRef)({}),ve=(0,G.useRef)({}),[,ye]=(0,G.useState)({}),[be,xe]=(0,G.useState)(`terminal`),[Se]=(0,G.useState)(()=>y().surface),Ce=(0,G.useRef)(!1),we=(0,G.useRef)(!Se),U=jF(),{canGoBack:Te,canGoForward:Ee,recordAgent:De,recordFile:Oe,recordFileCursor:ke,beginNavigation:Ae,finishNavigation:je,pruneEntries:Me}=MF(),W=U.activeFile,Ne=U.files,Pe=(0,G.useCallback)(async(e,t)=>{let n=Array.from(new Set(U.files.filter(e=>e.workspaceRoot===t).map(e=>e.file.path)));if(n.length===0)return!0;let r=await sI(e,n);return U.refreshFromReads(t,r.files),r.successful},[U]),[Fe,Ie]=(0,G.useState)(!1),[Le,Re]=(0,G.useState)(``),[ze,Be]=(0,G.useState)(0),[,Ve]=(0,G.useState)([]),[He,Ue]=(0,G.useState)([]),[We,Ge]=(0,G.useState)(!1),[Je,Xe]=(0,G.useState)([]),[Ze,Qe]=(0,G.useState)({}),[$e,et]=(0,G.useState)([]),[tt,nt]=(0,G.useState)(()=>new Set),[rt,it]=(0,G.useState)(`approve`),[,at]=(0,G.useState)(`gpt-5.5:xhigh`),[ot,st]=(0,G.useState)(`gpt-5.5`),[ct,lt]=(0,G.useState)(`xhigh`),[ut,dt]=(0,G.useState)(`default`),[ft,pt]=(0,G.useState)([]),[mt,ht]=(0,G.useState)(()=>new Set),[gt,_t]=(0,G.useState)(()=>new Map),vt=(0,G.useRef)(new Set),[yt,bt]=(0,G.useState)(`default`),[xt,St]=(0,G.useState)(`config`),[Ct,wt]=(0,G.useState)(`config`),[Tt,Et]=(0,G.useState)(HP),[Dt,Ot]=(0,G.useState)([]),[kt,At]=(0,G.useState)([]),[jt,Mt]=(0,G.useState)(``),[Nt,Pt]=(0,G.useState)(!1),[Ft,It]=(0,G.useState)([]),[Lt,zt]=(0,G.useState)(!1),Bt=(0,G.useRef)(!1),Vt=(0,G.useRef)(null),Ht=(0,G.useRef)(tI),[Ut,Wt]=(0,G.useState)(()=>wk().pinnedOverrides),[Gt,Kt]=(0,G.useState)(!1),[qt,Yt]=(0,G.useState)(!1),[Qt,$t]=(0,G.useState)(()=>new Set),[tn,nn]=(0,G.useState)(()=>new Set),[rn,an]=(0,G.useState)(UF),[on,cn]=(0,G.useState)(()=>gI()),[ln,un]=(0,G.useState)(null),[dn,pn]=(0,G.useState)(()=>typeof window>`u`?null:v(window.location.search)),[mn,hn]=(0,G.useState)(0),[gn,_n]=(0,G.useState)(void 0),[vn,yn]=(0,G.useState)(null),[bn,xn]=(0,G.useState)(null),[Sn,Cn]=(0,G.useState)(null),[wn,Tn]=(0,G.useState)(null),[En,Dn]=(0,G.useState)(!1),[On,kn]=(0,G.useState)(`Farming`),[An,jn]=(0,G.useState)(``),[Nn,Fn]=(0,G.useState)(null),[In,Ln]=(0,G.useState)(null),[zn,Bn]=(0,G.useState)(null),[Vn,Hn]=(0,G.useState)(null),[Kn,qn]=(0,G.useState)(null),[Jn,Yn]=(0,G.useState)(null),Xn=Nn?Nn.kind===`agent`?`agent:${Nn.agentId}`:`project:${Nn.projectId}`:``,[Zn,$n]=(0,G.useState)(Date.now()),er=(0,G.useRef)(null),tr=(0,G.useRef)(null),nr=(0,G.useRef)([]),rr=(0,G.useRef)(null),ir=(0,G.useRef)(null),ar=(0,G.useRef)(null),or=(0,G.useRef)(null),sr=(0,G.useRef)(null),cr=(0,G.useRef)(null),q=(0,G.useRef)(null),lr=(0,G.useRef)(null),ur=(0,G.useRef)(null),dr=(0,G.useRef)(null),fr=(0,G.useRef)(null),pr=(0,G.useRef)(null),mr=(0,G.useRef)(null),hr=(0,G.useRef)(!1),gr=(0,G.useRef)(0),_r=(0,G.useRef)(null),vr=(0,G.useRef)(0),yr=(0,G.useRef)(!1),br=(0,G.useRef)(()=>{}),xr=(0,G.useRef)(c),Sr=(0,G.useRef)(0),Cr=(0,G.useRef)(0),wr=(0,G.useRef)(0),Tr=(0,G.useRef)(0),Er=(0,G.useRef)(0),Dr=(0,G.useRef)(0),Or=(0,G.useRef)(null),kr=(0,G.useRef)(null),Ar=(0,G.useRef)(null),jr=(0,G.useRef)(0),Mr=(0,G.useRef)(Ek(n)),Nr=(0,G.useRef)(0),Pr=(0,G.useRef)([]),Fr=(0,G.useRef)(Promise.resolve()),Ir=(0,G.useRef)(new Set),Lr=(0,G.useRef)(!1),Rr=(0,G.useRef)(on),zr=(0,G.useRef)(mI()),Br=(0,G.useCallback)(()=>{Rr.current=!1,cn(!0)},[]),Vr=(0,G.useCallback)(()=>{cn(e=>(e||(Rr.current=!0),!0))},[]),Hr=(0,G.useCallback)(()=>{Rr.current=!1,cn(!1)},[]),Ur=(0,G.useCallback)(()=>{Rr.current=!1,cn(e=>!e)},[]),Wr=(0,G.useCallback)(e=>{un(t=>({kind:e,nonce:(t?.nonce||0)+1}))},[]);xr.current=c;let J=(0,G.useMemo)(()=>kP(k.language),[k.language]);(0,G.useEffect)(()=>{Tk({promotedKeys:[],pinnedOverrides:Ut,archivedOverrides:{}})},[Ut]);let Gr=(0,G.useMemo)(()=>e.filter(e=>!e.isMain),[e]),Kr=(0,G.useMemo)(()=>e.find(e=>e.isMain)??null,[e]),Y=(0,G.useMemo)(()=>Gr.filter(sF),[Gr]),qr=(0,G.useMemo)(()=>{let e=new Set(Y.map(e=>e.id));return Kr&&e.add(Kr.id),e},[Y,Kr]),Jr=(0,G.useMemo)(()=>{let e=new Set([Ye]);return He.forEach(t=>e.add(Un(t))),Y.forEach(t=>e.add(Un(UD(t)))),qr.forEach(t=>e.add(t)),e},[Y,He,qr]);(0,G.useEffect)(()=>{Me(e=>e.kind===`agent`?qr.has(e.agentId):Jr.has(e.agentId))},[Me,qr,Jr]);let Yr=(0,G.useCallback)((e,t)=>{let n=Kr?[...Y,Kr]:Y;if(Ke(e)){let e=n.find(e=>e.id===t);return{filesId:Ye,workspaceRoot:`/`,sourceAgentId:e?.id,sourceAgent:e}}let r=Wn(e);if(r){let e=Y.find(e=>e.id===t&&Un(UD(e))===Un(r));return{filesId:Un(r),workspaceRoot:r,sourceAgentId:e?.id,sourceAgent:e}}let i=n.find(t=>t.id===e);if(i&&!i.isMain){let e=UD(i),n=Y.find(n=>n.id===t&&Un(UD(n))===Un(e))??i;return{filesId:Un(e),workspaceRoot:e,sourceAgentId:n.id,sourceAgent:n}}return{filesId:e,workspaceRoot:i?UD(i):void 0,sourceAgentId:i?.id,sourceAgent:i}},[Y,Kr]);(0,G.useEffect)(()=>{W?.sourceAgentId&&(Yr(W.agentId,W.sourceAgentId).sourceAgentId||U.update({agentId:W.agentId,filePath:W.file.path,workspaceRoot:W.workspaceRoot},e=>({...e,sourceAgentId:void 0})))},[W,Yr,U]);let Xr=(0,G.useMemo)(()=>Dk(kt,Ut,{}),[Ut,kt]),Zr=(0,G.useMemo)(()=>_F({allAgents:Gr,liveAgents:Y,sessions:Xr,mainPageSessionKeys:tt}),[Y,Xr,tt,Gr]),Qr=Zr.mainPageAgentSessions,$r=Zr.sidebarAgentSessions,ei=Zr.searchableAgentSessions,ti=Zr.historyAgentSessions,ni=Zr.liveAgents,ri=Zr.archivedAgents,ii=t,ai=ti,oi=(0,G.useMemo)(()=>new Set(Ft.map(ZD)),[Ft]),si=(0,G.useMemo)(()=>new Set(Array.from(Zr.claimedAgentSessionKeyByAgentId.entries()).filter(([,e])=>oi.has(e)).map(([e])=>e)),[Zr.claimedAgentSessionKeyByAgentId,oi]),ci=(0,G.useMemo)(()=>{let e=new Map(ei.map(e=>[ZD(e),e]));return Ft.forEach(t=>e.set(ZD(t),t)),hF(Array.from(e.values()),Zr.claimedAgentSessionKeys)},[Zr.claimedAgentSessionKeys,Ft,ei]),li=(0,G.useMemo)(()=>TM(ni,$r,Ze,Ne,Gr,He,Je),[Ne,Je,Ze,He,$r,Gr,ni]),ui=(0,G.useMemo)(()=>jk(li,tn,!1),[tn,li]),di=(0,G.useMemo)(()=>TM(ni,ci,Ze,Ne,Gr,He,Je),[Ne,Je,Ze,He,ci,Gr,ni]),fi=Le.trim().toLowerCase(),pi=fi.length>0,mi=(0,G.useMemo)(()=>EM((i===`search`||Fe)&&pi?di:ui,fi,tn,oi,si),[i,tn,pi,fi,ui,di,si,oi,Fe]),hi=ui.some(e=>!!e.workspace),gi=(0,G.useMemo)(()=>pi?mi:[],[mi,pi]),_i=(0,G.useMemo)(()=>DM(mi,Qt,fi),[Qt,mi,fi]),vi=(0,G.useMemo)(()=>pi?_i:[],[pi,_i]),yi=(0,G.useMemo)(()=>{let e=new Map;return O&&D.forEach((t,n)=>{e.set(t,n)}),e},[D,O]),bi=(0,G.useMemo)(()=>c?IF(S,c):S,[c,S]),xi=(0,G.useMemo)(()=>bi.map(e=>Y.find(t=>t.id===e)??(Kr?.id===e?Kr:null)).filter(e=>!!e),[Y,Kr,bi]),Si=Rt((0,G.useMemo)(()=>xi.find(e=>e.id===c)??xi[0]??null,[c,xi])),Ci=(0,G.useMemo)(()=>xi.map(e=>e.id===Si?.id?Si:e),[Si,xi]),X=Rt((0,G.useMemo)(()=>Y.find(e=>e.id===c)??(Kr?.id===c?Kr:null),[Y,c,Kr])),wi=Mn(X)?X.runtimeBinding:null,Ti=!!(X&&X.id===l),Ei=!!(X&&mt.has(X.id)),Di=X?s[X.id]??null:null,Oi=wi?Aj(X):X?$A(X):``,ki=(0,G.useMemo)(()=>MD(X),[X]),Ai=Oi?me[Oi]??(X?(wi?jj(X):ej(X)).map(e=>me[e]).find(Boolean):void 0)??GA:GA,ji=Ai.draft,Mi=Ai.attachments,Ni=Ai.mode,{plusMenuOpen:Pi,approvalMenuOpen:Fi,modelMenuOpen:Ii,modelPickerPane:Li}=Ai.ui,Ri=!!(wi&&X&&ve.current[X.id]!==void 0),zi=(0,G.useMemo)(()=>Ri||wD(X),[Ri,X]),Bi=(0,G.useMemo)(()=>SD(X),[X]),Vi=ki.kind,Hi=(0,G.useMemo)(()=>GP(!!(X&&Vi===`codex`),X?.launchPermissionMode,rt),[X,rt,Vi]),Ui=(0,G.useMemo)(()=>KP(!!(X&&Vi===`claude`),X?.launchPermissionMode,yt),[X,yt,Vi]),Wi=X&>.get(X.id)||null,Gi=(0,G.useMemo)(()=>aF(Wi||X?.codexTerminalProfile,{model:ot,reasoningEffort:ct,serviceTier:ut}),[Wi?.model,Wi?.reasoningEffort,Wi?.serviceTier,X?.codexTerminalProfile?.model,X?.codexTerminalProfile?.reasoningEffort,X?.codexTerminalProfile?.serviceTier,ot,ct,ut]),Ki=Gi.model,qi=Gi.reasoningEffort,Ji=Gi.serviceTier,Yi=`${Ki}:${qi}`,Xi=(0,G.useMemo)(()=>zi||!!X&&X?.status===`running`&&Vi===`shell`&&Bi.terminalBusy,[X,Bi.terminalBusy,zi,Vi]),Zi=(0,G.useMemo)(()=>jD([...AD(Vi),...Dt]),[Vi,Dt]),Qi=Ai.pendingFollowUp;(0,G.useEffect)(()=>{!c||be!==`terminal`||i!==`projects`||De(c)},[c,i,be,De]),(0,G.useEffect)(()=>{!W||be!==`editor`||i!==`projects`||Oe({agentId:W.agentId,filePath:W.file.path,view:W.diffRequestId?`diff`:`editor`,lineNumber:W.cursor?.lineNumber,column:W.cursor?.column,endColumn:W.cursor?.endColumn,sourceAgentId:W.sourceAgentId})},[i,be,W?.agentId,W?.cursor?.column,W?.cursor?.endColumn,W?.cursor?.lineNumber,W?.cursor?.requestId,W?.diffRequestId,W?.file.path,W?.sourceAgentId,Oe]);let $i=hj(Mi).length>0,ea=Mi.some(e=>e.status===`uploading`),ta=Ei?`disabled`:X&&!ea&&(ji.trim()||$i)?`send`:Xi?`interrupt`:`disabled`,Z=Tj(X)?ta:`disabled`,na=(0,G.useCallback)(e=>{Oi&&he(Oi,e)},[Oi,he]),ra=(0,G.useCallback)(()=>{na(YA)},[na]),ia=(0,G.useMemo)(()=>Y.find(e=>e.id===vn?.agentId)??null,[Y,vn?.agentId]),aa=(0,G.useMemo)(()=>li.find(e=>e.id===bn?.projectId)??null,[li,bn?.projectId]),oa=(0,G.useMemo)(()=>mi.flatMap(e=>e.agentSessions).find(e=>e.provider===Sn?.provider&&ZD(e)===Sn?.sessionId)??null,[Sn?.provider,Sn?.sessionId,mi]),sa=Fe?vi[ze]??null:null,ca=sa?.kind===`agent`?sa.id:null,la=sa?.kind===`agent-session`?ZD(sa):null,ua=X?UD(X):void 0,da=(0,G.useMemo)(()=>{if(W&&!Ke(W.agentId))return W.agentId;if(X&&!X.isMain)return Un(UD(X));if(ua)return Un(ua);let e=Y.find(e=>!e.isMain);return e?Un(UD(e)):null},[X,Y,ua,W]),fa=(0,G.useCallback)(e=>{if(!(e instanceof Element))return null;let t=e.closest(`[data-testid="code-agent-row"][data-agent-id], [data-testid="code-project-agent-compact"][data-agent-id], [data-testid="code-pinned-agent-compact"][data-agent-id], [data-testid="code-agent-rail-item"][data-agent-id]`)?.dataset.agentId;if(t){let e=Y.find(e=>e.id===t&&!e.isMain);if(e)return Un(UD(e))}let n=e.closest(`[data-testid="code-project-group"]`)?.querySelector(`[data-testid="code-project-title"][data-project-id]`)?.dataset.projectId;return!n||n===`__farming_main_agent__`?null:Un(n)},[Y]),pa=X?.isMain?gn??ui[0]?.workspace:ua??gn??ui[0]?.workspace,ma=be===`editor`&&!!W,ha=(0,G.useMemo)(()=>{if(ma&&W){let e=W.workspaceRoot??Y.find(e=>e.id===W.agentId)?.projectWorkspace??Y.find(e=>e.id===W.agentId)?.cwd??``;return{kind:`file`,agentId:W.agentId,filePath:W.file.path,...e?{absolutePath:p(e,W.file.path)}:{},...e?{projectLabel:x(e)}:{},view:W.diffRequestId?`diff`:`editor`,lineNumber:W.cursor?.lineNumber,column:W.cursor?.column,endColumn:W.cursor?.endColumn}}return c&&qr.has(c)?{kind:`agent`,agentId:c,readingSurface:Pn(Y.find(e=>e.id===c))?`chat`:`terminal`}:null},[c,W?.agentId,W?.cursor?.column,W?.cursor?.endColumn,W?.cursor?.lineNumber,W?.diffRequestId,W?.file.path,W?.workspaceRoot,ma,Y,qr]),{agentModelOptions:ga,agentModel:_a,agentReasoningEffort:va,agentServiceTier:ya,agentModelPreset:ba,currentReasoningOptions:xa,currentServiceTierOptions:Sa,currentPermissionMode:Ca,currentPermissionLabel:wa,currentPermissionColor:Ta,currentModelLabel:Ea,currentReasoningLabel:Da,currentSpeedLabel:Oa,permissionModeOptions:ka}=(0,G.useMemo)(()=>oF({agentKind:Vi,codexModel:Ki,codexReasoningEffort:qi,codexServiceTier:Ji,codexModelPreset:Yi,codexModelOptions:ft,codexApprovalMode:Hi,claudeModel:xt,claudeEffort:Ct,claudeSettings:Tt,claudePermissionMode:Ui}),[Ct,xt,Tt,Ui,Hi,Ki,ft,Yi,qi,Ji,Vi]),Aa=LF(),ja=Fe||i===`search`?J.search:i===`history`?J.history:ma&&W?HD(W.file.path):X?u(X):J.codex,Ma=X?.isMain?`farming`:vI(X?UD(X):void 0),Na=X?`${Ma} · ${Aa}`:Aa,Pa=ma&&W?W.sourceAgentId:null,Fa=!!Pa,Ia=(0,G.useCallback)(()=>{let e=tr.current;if(!e)return;e.style.height=`auto`;let t=Math.min(e.scrollHeight,132);e.style.height=`${t}px`,e.style.overflowY=e.scrollHeight>132?`auto`:`hidden`},[]),La=(0,G.useCallback)(()=>{let e=!1;jP(()=>{if(document.querySelector(`.code-composer-menu`))return;let t=tr.current??document.querySelector(`[data-testid="code-composer-input"]`);e&&document.activeElement instanceof HTMLElement&&document.activeElement!==document.body&&document.activeElement!==t||(t?.focus({preventScroll:!0}),document.activeElement===t&&(e=!0))},{delays:[60]})},[]),Ra=(0,G.useCallback)(e=>{let t=iF(e);it(t.codexApprovalMode),st(t.codexModel),lt(t.codexReasoningEffort),dt(t.codexServiceTier),at(t.codexModelPreset),bt(t.claudePermissionMode),St(t.claudeModel),wt(t.claudeEffort)},[]),za=(0,G.useCallback)(()=>{let e=!1,t=jr.current;return fetch(r(`/api/settings`)).then(e=>e.json()).then(n=>{if(e)return;let r=n.settings??{};t===jr.current&&nt(new Set(Ek(r.mainPageSessionKeys??[]))),Qe(zF(r.projectNames)),typeof r.instanceName==`string`&&r.instanceName.trim()&&kn(r.instanceName),Ra(r)}).catch(()=>{}),()=>{e=!0}},[Ra]),Ba=(0,G.useCallback)(async e=>{try{let t=await fetch(r(`/api/settings`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({instanceName:e})});if(!t.ok)return!1;let n=(await t.json()).settings?.instanceName;return n?(kn(n),!0):!1}catch{return!1}},[]),Va=(0,G.useCallback)(()=>{let e=Date.now()-vr.current;if(yr.current||vr.current>0&&e<=qF)return()=>{};let t=!1;return yr.current=!0,fetch(r(`/api/codex/models`)).then(async e=>{let t=await e.json().catch(()=>({}));if(!e.ok)throw Error(t.error||`Failed to load Codex model catalog (${e.status})`);return t}).then(e=>{if(t)return;let n=XD(e);if(n.length===0)throw Error(`Codex model catalog did not contain any visible models`);vr.current=Date.now(),pt(n)}).catch(e=>{t||(vr.current=0,pt([]),Hn({id:Date.now(),kind:`error`,message:e instanceof Error?e.message:`Failed to load Codex model catalog`}))}).finally(()=>{yr.current=!1}),()=>{t=!0}},[]),Ha=(0,G.useCallback)(()=>{let e=!1;return fetch(r(`/api/claude/settings`)).then(e=>e.json()).then(t=>{e||Et(QP(t.settings))}).catch(()=>{e||Et(HP)}),()=>{e=!0}},[]),Ua=(0,G.useCallback)(async(e,t)=>{let n=new URLSearchParams({q:e,limit:String(nI),fresh:`1`}),i=await fetch(r(`/api/agent-sessions/search?${n.toString()}`),{signal:t,cache:`no-store`});if(!i.ok)throw Error(`Failed to search Agent sessions: ${i.status}`);let a=await i.json();return Array.isArray(a.sessions)?a.sessions:[]},[]),Wa=(0,G.useCallback)(async(e,t)=>gF(Dk(await Ua(e,t),Ut,{}),tt,Zr.claimedAgentSessionKeys),[Zr.claimedAgentSessionKeys,Ut,Ua,tt]),Ga=(0,G.useCallback)(async(e={})=>{let t=new URLSearchParams({limit:String(e.limit||tI)});e.cursor&&t.set(`cursor`,e.cursor),e.fresh&&t.set(`fresh`,`1`);let n=await(await fetch(r(`/api/agent-sessions?${t.toString()}`),{cache:e.fresh?`no-store`:`default`})).json();return{sessions:Array.isArray(n.sessions)?n.sessions:[],nextCursor:typeof n.nextCursor==`string`?n.nextCursor:``,hasMore:n.hasMore===!0}},[]),Ka=(0,G.useCallback)((e=!1)=>{let t=!1;return Ga({fresh:e}).then(e=>{t||(At(e.sessions),Mt(e.nextCursor),Pt(e.hasMore),Ht.current=Math.max(tI,e.sessions.length))}).catch(()=>{t||(At([]),Mt(``),Pt(!1))}),()=>{t=!0}},[Ga]),qa=(0,G.useCallback)(()=>{if(Vt.current)return Vt.current;let e=Ga({limit:Ht.current,fresh:!0}).then(e=>{At(e.sessions),Mt(e.nextCursor),Pt(e.hasMore)}).catch(()=>At([])).finally(()=>{Vt.current===e&&(Vt.current=null)});return Vt.current=e,e},[Ga]),Ja=(0,G.useCallback)(async()=>{if(!Nt||!jt||Bt.current)return!1;Bt.current=!0;try{let e=await Ga({cursor:jt});return At(t=>{let n=new Set(t.map(ZD)),r=[...t];return e.sessions.forEach(e=>{let t=ZD(e);n.has(t)||(n.add(t),r.push(e))}),Ht.current=Math.max(tI,r.length),r}),Mt(e.nextCursor),Pt(e.hasMore),e.sessions.length>0}catch{return!1}finally{Bt.current=!1}},[jt,Nt,Ga]);(0,G.useEffect)(()=>{if(!((i===`search`||Fe)&&pi)){It([]),zt(!1);return}let e=new AbortController;It([]),zt(!0);let t=window.setTimeout(()=>{Ua(fi,e.signal).then(It).catch(e=>{e instanceof DOMException&&e.name===`AbortError`||It([])}).finally(()=>{e.signal.aborted||zt(!1)})},rI);return()=>{window.clearTimeout(t),e.abort()}},[i,Ua,pi,fi,Fe]);let Ya=(0,G.useCallback)((e,t)=>{if(e!==`codex`&&e!==`claude`)return Ot([]),()=>{};let n=!1,i=new URLSearchParams({provider:e});return t&&i.set(`workspace`,t),fetch(r(`/api/slash-commands?${i.toString()}`)).then(e=>e.json()).then(e=>{n||Ot(Array.isArray(e.commands)?e.commands:[])}).catch(()=>{n||Ot([])}),()=>{n=!0}},[]),Xa=(0,G.useCallback)(()=>{Oi&&(na(e=>({...e,ui:{...e.ui,plusMenuOpen:!1}})),rr.current?.click())},[Oi,na]),Za=(0,G.useCallback)((e,t)=>{let n=fj(t),r=sj(t),i=oj(t,r?`pasted image`:`pasted audio`),a=r?pj(t):void 0,o={id:n,kind:r?`image`:`audio`,name:i,type:t.type||(r?`image/png`:`audio/wav`),size:t.size,status:`uploading`,previewUrl:a};he(e,e=>({...e,attachments:[...e.attachments,o]})),bj(t).then(t=>{ge(e,e=>({...e,attachments:e.attachments.map(e=>e.id===n?{...e,name:i,type:t.type||e.type,size:t.size||e.size,status:`ready`,path:t.path,messageBlock:r?uj({...t,name:i}):dj({...t,name:i}),error:void 0}:e)}))}).catch(()=>{ge(e,e=>({...e,attachments:e.attachments.map(e=>e.id===n?{...e,status:`error`,messageBlock:Sj(t),error:`Upload failed`}:e)}))})},[he,ge]),Qa=(0,G.useCallback)(async e=>{if(!Oi||e.length===0)return;e.filter(e=>sj(e)||cj(e)).forEach(e=>Za(Oi,e));let t=e.filter(e=>!sj(e)&&!cj(e));if(t.length===0){La();return}let n=[];for(let e of t)try{n.push(await xj(e))}catch{n.push(Sj(e))}he(Oi,e=>({...e,draft:aj(e.draft,n.join(`
|
|
208
|
+
`)).trimEnd()}function vj(e){return e.flatMap(e=>e.status===`ready`&&e.path?[{kind:e.kind,path:e.path,name:e.name,type:e.type,size:e.size}]:[])}function yj(e){return new Promise((t,n)=>{let r=new FileReader;r.onerror=()=>n(r.error??Error(`File read failed`)),r.onload=()=>t(typeof r.result==`string`?r.result:``),r.readAsText(e)})}async function bj(e){let t=cj(e)?`/api/attachments/audio`:`/api/attachments/image`,n=await fetch(ij(t),{method:`POST`,headers:{"Content-Type":e.type||(cj(e)?`audio/wav`:`image/png`)},body:e});if(!n.ok)throw Error(`Image upload failed: ${n.status}`);return n.json()}async function xj(e){if(sj(e))return uj(await bj(e));if(cj(e))return dj(await bj(e));try{return lj(e,await yj(e))}catch{return`Attached file: ${oj(e)}\n\n[Unable to read this file as text]`}}function Sj(e){return sj(e)?`Attached image: ${oj(e,`pasted image`)}\n\n[Unable to upload this image]`:cj(e)?`Attached audio: ${oj(e,`pasted audio`)}\n\n[Unable to upload this audio]`:`Attached file: ${oj(e)}\n\n[Unable to read this file as text]`}function Cj(e){if(!e)return[];let t=Array.from(e.files??[]).filter(e=>sj(e)||cj(e));return t.length>0?t:Array.from(e.items??[]).filter(e=>e.kind===`file`&&/^(image|audio)\//.test(e.type)).map(e=>e.getAsFile()).filter(e=>!!(e&&(sj(e)||cj(e))))}function wj(e,t){return e===`default`?t:`${nj[e]}\n\n${t}`}function Tj(e){return!!(e&&e.runtimeBinding.kind===`acp`&&e.status===`running`&&e.requiresProcessExitAcknowledgement!==!0)}function Ej({agent:e,composerKey:t,draft:n,attachments:r,composerMode:i,turnActive:a,supportsSteer:o,sendMessage:s,updateComposerState:c}){let l=vj(r),u=wj(i,_j(n,r).trim());if(!u&&l.length===0||!e||!Tj(e)||!t)return!1;let d=a&&o;return(!a||d)&&!s(e,u,l)?!1:(c(t,e=>({...e,draft:``,attachments:[],mode:`default`,history:VA(e.history,n),...a&&!d?{pendingFollowUp:{messages:[...e.pendingFollowUp?.messages||[],qA(u,l)],createdAt:e.pendingFollowUp?.createdAt||Date.now()}}:{}})),r.forEach(mj),!0)}function Dj(e,t,n,i=!1){return fetch(r(`/api/agents/${encodeURIComponent(e)}/acp-permission`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({requestId:t,optionId:n,cancelled:i})})}function Oj(e,t,n,i){return fetch(r(`/api/agents/${encodeURIComponent(e)}/acp-elicitation`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({requestId:t,action:n,content:i})})}var kj=`acp:`;function Aj(e){let t=$A(e);return t?`${kj}${t}`:``}function jj(e){return ej(e).map(e=>`${kj}${e}`)}function Mj(e){return e.startsWith(kj)}function Nj(){return typeof window>`u`?!1:navigator.standalone===!0||window.matchMedia(`(display-mode: standalone)`).matches}function Pj(){return(0,K.jsx)(`svg`,{viewBox:`0 0 20 20`,"aria-hidden":`true`,focusable:`false`,children:(0,K.jsx)(`path`,{d:`M10 13V3m0 0L6.5 6.5M10 3l3.5 3.5M4 9v6.5A1.5 1.5 0 0 0 5.5 17h9a1.5 1.5 0 0 0 1.5-1.5V9`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`,strokeLinejoin:`round`})})}function Fj(){return(0,K.jsxs)(`svg`,{viewBox:`0 0 20 20`,"aria-hidden":`true`,focusable:`false`,children:[(0,K.jsx)(`rect`,{x:`3`,y:`3`,width:`14`,height:`14`,rx:`3`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.4`}),(0,K.jsx)(`path`,{d:`M10 6.5v7M6.5 10h7`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.4`,strokeLinecap:`round`})]})}function Ij(){return(0,K.jsxs)(`svg`,{viewBox:`0 0 20 20`,"aria-hidden":`true`,focusable:`false`,children:[(0,K.jsx)(`rect`,{x:`6.5`,y:`6.5`,width:`9`,height:`9`,rx:`2`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`}),(0,K.jsx)(`path`,{d:`M13.5 6.5v-2A1.5 1.5 0 0 0 12 3H4.5A1.5 1.5 0 0 0 3 4.5V12A1.5 1.5 0 0 0 4.5 13.5h2`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`})]})}function Lj({copy:e,title:t,url:n,onClose:r}){let i=Nj(),[a,o]=(0,G.useState)(!1),[s,c]=(0,G.useState)(!1);(0,G.useEffect)(()=>{let e=e=>{e.key===`Escape`&&r()};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[r]),(0,G.useEffect)(()=>{if(!a&&!s)return;let e=window.setTimeout(()=>{o(!1),c(!1)},1800);return()=>window.clearTimeout(e)},[a,s]);let l=(0,G.useCallback)(async()=>{let e=await S(n);o(e),c(!e)},[n]);return(0,K.jsx)(`div`,{className:`code-mobile-share-backdrop`,"data-testid":`code-mobile-share-sheet`,role:`presentation`,onPointerDown:r,children:(0,K.jsxs)(`section`,{className:`code-mobile-share-sheet`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`code-mobile-share-title`,onPointerDown:e=>e.stopPropagation(),children:[(0,K.jsxs)(`header`,{className:`code-mobile-share-header`,children:[(0,K.jsx)(`h2`,{id:`code-mobile-share-title`,children:e.mobileShareTitle}),(0,K.jsx)(`button`,{type:`button`,"aria-label":e.cancel,onClick:r,children:`×`})]}),(0,K.jsxs)(`section`,{className:`code-mobile-share-choice code-mobile-share-forward`,children:[(0,K.jsxs)(`div`,{className:`code-mobile-share-choice-copy`,children:[(0,K.jsx)(`h3`,{children:e.mobileForwardTitle}),(0,K.jsx)(`p`,{children:e.mobileForwardHint})]}),(0,K.jsxs)(`div`,{className:`code-mobile-share-link-row`,children:[(0,K.jsx)(`span`,{className:`code-mobile-share-link`,title:t,children:n}),(0,K.jsxs)(`button`,{type:`button`,"data-testid":`code-mobile-share-copy-action`,onClick:()=>void l(),children:[(0,K.jsx)(Ij,{}),(0,K.jsx)(`span`,{children:a?e.mobileShareCopied:e.mobileShareCopyAction})]})]}),s&&(0,K.jsx)(`span`,{className:`code-mobile-share-status`,role:`status`,children:e.copyFailed})]}),(0,K.jsxs)(`section`,{className:`code-mobile-share-choice code-mobile-share-install-guide`,children:[(0,K.jsx)(`h3`,{children:e.mobileInstallTitle}),i?(0,K.jsx)(`p`,{className:`code-mobile-install-complete`,children:e.mobileShareInstalled}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`p`,{className:`code-mobile-install-hint`,children:e.mobileInstallChromeHint}),(0,K.jsxs)(`div`,{className:`code-mobile-install-steps`,children:[(0,K.jsxs)(`div`,{className:`code-mobile-install-step`,children:[(0,K.jsxs)(`span`,{className:`code-mobile-install-controls`,"aria-hidden":`true`,children:[(0,K.jsx)(`span`,{className:`code-mobile-install-control`,children:(0,K.jsx)(Pj,{})}),(0,K.jsx)(`span`,{className:`code-mobile-install-or`,children:`/`}),(0,K.jsx)(`span`,{className:`code-mobile-install-control code-mobile-install-more`,children:`•••`})]}),(0,K.jsxs)(`span`,{children:[e.mobileInstallShareStep,(0,K.jsx)(`small`,{children:e.mobileInstallMoreStep})]})]}),(0,K.jsxs)(`div`,{className:`code-mobile-install-step`,children:[(0,K.jsx)(`span`,{className:`code-mobile-install-controls`,"aria-hidden":`true`,children:(0,K.jsx)(`span`,{className:`code-mobile-install-control`,children:(0,K.jsx)(Fj,{})})}),(0,K.jsxs)(`span`,{children:[e.mobileInstallAddStep,(0,K.jsx)(`small`,{children:e.mobileInstallOpenStep})]})]})]})]})]})]})})}function Rj(e){let t=e.filter(e=>!e.hidden),n=[];for(t.forEach(e=>{e.type===`separator`&&(n.length===0||n[n.length-1]?.type===`separator`)||n.push(e)});n[n.length-1]?.type===`separator`;)n.pop();return n}function zj({contextMenuAgent:e,contextMenuAgentSession:t,contextMenuProject:n,agentMenu:r,projectMenu:i,agentSessionMenu:a,renameDialog:o,killDialog:s,deleteWorktreeDialog:c,copyNotice:l,contextMenuRef:u,renameDialogRef:d,renameInputRef:f,killDialogRef:p,killCancelButtonRef:m,deleteWorktreeDialogRef:h,deleteWorktreeCancelButtonRef:g,onContextMenuKeyDown:_,runtimeSwitchDisabled:v,onSwitchAgentRuntime:y,onUpdateAgentFlags:b,onRenameAgent:x,onRenameProject:S,onCopyAgentWorkingDirectory:C,onForkAgent:w,onKillAgent:T,onOpenSession:ee,onToggleSessionPinned:E,onArchiveSession:D,onCopySessionWorkingDirectory:O,onToggleProjectPinned:k,onRevealProject:A,onCreatePermanentWorktree:j,onMarkProjectRead:M,onArchiveProject:N,onRemoveProject:P,onDeleteWorktree:te,onCloseRenameDialog:F,onRenameDialogTitleChange:ne,onSubmitRenameDialog:I,onCloseKillDialog:L,onSubmitKillDialog:R,onCloseDeleteWorktreeDialog:z,onSubmitDeleteWorktreeDialog:B,copy:V}){let re=MD(e),ie=FD(n),H=ID(n),ae=!!n?.agents.some(e=>e.unread),oe=e?.runtimeBinding.kind!==`terminal`,se=Rj([{type:`item`,id:`switch-agent-runtime`,label:oe?V.switchToTerminal:V.switchToChat,hidden:!ND(e),disabled:v||wD(e),onSelect:()=>{e&&y(e.id,oe?`terminal`:`chat`)}},{type:`separator`,id:`agent-runtime-separator`},{type:`item`,id:`pin-agent`,label:e?.pinned?V.unpinAgent:V.pinAgent,hidden:!re.actions.pin,onSelect:()=>b({pinned:!e?.pinned})},{type:`item`,id:`rename-agent`,label:V.renameAgent,hidden:!re.actions.rename,onSelect:x},{type:`item`,id:`archive-agent`,label:V.archiveAgent,hidden:!re.actions.archive,onSelect:()=>b({archived:!0})},{type:`item`,id:`toggle-agent-unread`,label:e?.unread?V.markAsRead:V.markAsUnread,hidden:!re.actions.markUnread,onSelect:()=>b({unread:!e?.unread})},{type:`separator`,id:`agent-copy-separator`},{type:`item`,id:`copy-agent-working-directory`,label:V.copyWorkingDirectory,hidden:!re.actions.copyWorkingDirectory,onSelect:C},{type:`separator`,id:`agent-fork-separator`},{type:`item`,id:`fork-same-worktree`,label:V.forkSameWorktree,hidden:!re.actions.forkSameWorktree,onSelect:()=>w(`same-worktree`)},{type:`item`,id:`fork-new-worktree`,label:V.forkNewWorktree,hidden:!re.actions.forkNewWorktree,onSelect:()=>w(`new-worktree`)},{type:`item`,id:`kill-agent`,label:V.killAgent,danger:!0,hidden:!re.actions.kill,onSelect:T}]),ce=Rj([{type:`item`,id:`open-session`,label:V.openSession,onSelect:()=>{t&&ee(t.provider,t.id)}},{type:`item`,id:`toggle-session-pinned`,label:t?.pinned?V.unpinChat:V.pinChat,onSelect:E},{type:`item`,id:`archive-session`,label:V.archiveChat,onSelect:D},{type:`item`,id:`copy-session-working-directory`,label:V.copyWorkingDirectory,onSelect:O}]),le=Rj([{type:`item`,id:`pin-project`,label:n?.pinned?V.unpinProject:V.pinProject,icon:`pin`,hidden:!n?.workspace,onSelect:k},{type:`item`,id:`reveal-project`,label:V.revealInFinder,icon:`folder`,hidden:!n?.workspace||n.hasMain,onSelect:A},{type:`item`,id:`create-permanent-worktree`,label:V.createPermanentWorktree,icon:`worktree`,hidden:!n?.workspace||n.hasMain,onSelect:j},{type:`separator`,id:`project-primary-separator`},{type:`item`,id:`rename-project`,label:V.renameProject,icon:`rename`,hidden:!n?.workspace,onSelect:S},{type:`item`,id:`mark-project-read`,label:V.markAllAsRead,icon:`check`,disabled:!ae,onSelect:M},{type:`item`,id:`archive-project`,label:V.archiveChats,icon:`archive`,disabled:!ie,onSelect:N},{type:`separator`,id:`project-destructive-separator`},{type:`item`,id:`remove-project`,label:V.removeProject,removeIcon:!0,hidden:!n?.workspace||n.hasMain,disabled:!!(n&&(n.agents.length>0||n.agentSessions.length>0||n.hasOpenFile)),onSelect:P},{type:`item`,id:`delete-worktree`,label:V.deleteWorktree,icon:`trash`,danger:!0,hidden:!H,onSelect:te}]);return(0,K.jsxs)(K.Fragment,{children:[e&&(0,K.jsx)(`div`,{className:`code-context-menu`,"data-testid":`code-agent-context-menu`,style:{left:r?.x??0,top:r?.y??0},role:`menu`,ref:u,onKeyDownCapture:_,onKeyDown:_,children:(0,K.jsx)(Bj,{entries:se})}),t&&(0,K.jsx)(`div`,{className:`code-context-menu`,"data-testid":`code-session-context-menu`,style:{left:a?.x??0,top:a?.y??0},role:`menu`,ref:u,onKeyDownCapture:_,onKeyDown:_,children:(0,K.jsx)(Bj,{entries:ce})}),n&&(0,K.jsx)(`div`,{className:`code-context-menu code-project-context-menu`,"data-testid":`code-project-context-menu`,style:{left:i?.x??0,top:i?.y??0},role:`menu`,ref:u,onKeyDownCapture:_,onKeyDown:_,children:(0,K.jsx)(Bj,{entries:le})}),o&&(0,K.jsx)(`div`,{className:`code-rename-backdrop`,"data-testid":`code-rename-backdrop`,onMouseDown:F,children:(0,K.jsxs)(`form`,{className:`code-rename-dialog`,"data-testid":`code-rename-dialog`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`code-rename-title`,ref:d,onMouseDown:e=>e.stopPropagation(),onKeyDownCapture:e=>Uj(e,d.current),onKeyDown:e=>Uj(e,d.current),onSubmit:e=>{e.preventDefault(),I()},children:[(0,K.jsx)(`label`,{id:`code-rename-title`,htmlFor:`code-rename-input`,children:o.kind===`project`?V.renameProject:V.renameAgent}),(0,K.jsx)(`input`,{id:`code-rename-input`,ref:f,"data-testid":`code-rename-input`,type:`text`,name:`farming-rename-title`,inputMode:`text`,autoComplete:`off`,autoCorrect:`off`,autoCapitalize:`none`,spellCheck:!1,enterKeyHint:`done`,"data-lpignore":`true`,"data-1p-ignore":`true`,"data-bwignore":`true`,"data-form-type":`other`,value:o.title,onChange:e=>ne(e.target.value),onKeyDown:e=>{e.key===`Escape`&&(e.preventDefault(),F())}}),(0,K.jsxs)(`div`,{className:`code-rename-actions`,children:[(0,K.jsx)(`button`,{type:`button`,onClick:F,children:V.cancel}),(0,K.jsx)(`button`,{type:`submit`,className:`primary`,disabled:!o.title.trim(),children:V.save})]})]})}),s&&(0,K.jsx)(`div`,{className:`code-rename-backdrop`,"data-testid":`code-kill-backdrop`,onMouseDown:L,children:(0,K.jsxs)(`div`,{className:`code-rename-dialog code-kill-dialog`,"data-testid":`code-kill-dialog`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`code-kill-title`,ref:p,onMouseDown:e=>e.stopPropagation(),onKeyDownCapture:e=>Uj(e,p.current),onKeyDown:e=>Uj(e,p.current),children:[(0,K.jsx)(`h2`,{id:`code-kill-title`,children:V.killAgentQuestion}),(0,K.jsx)(`p`,{children:s.acknowledgeUnprovenAcpExit?V.acknowledgeUnprovenAcpExitDescription(s.title):V.stopAgentDescription(s.title)}),(0,K.jsxs)(`div`,{className:`code-rename-actions`,children:[(0,K.jsx)(`button`,{type:`button`,ref:m,onClick:L,autoFocus:!0,children:V.cancel}),(0,K.jsx)(`button`,{type:`button`,className:`danger`,onClick:R,children:s.acknowledgeUnprovenAcpExit?V.acknowledgeUnprovenAcpExit:V.killAgent})]})]})}),c&&(0,K.jsx)(`div`,{className:`code-rename-backdrop`,"data-testid":`code-delete-worktree-backdrop`,onMouseDown:z,children:(0,K.jsxs)(`div`,{className:`code-rename-dialog code-kill-dialog`,"data-testid":`code-delete-worktree-dialog`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`code-delete-worktree-title`,ref:h,onMouseDown:e=>e.stopPropagation(),onKeyDownCapture:e=>Uj(e,h.current),onKeyDown:e=>Uj(e,h.current),children:[(0,K.jsx)(`h2`,{id:`code-delete-worktree-title`,children:V.deleteWorktreeQuestion}),(0,K.jsx)(`p`,{children:V.deleteWorktreeDescription}),(0,K.jsxs)(`div`,{className:`code-rename-actions`,children:[(0,K.jsx)(`button`,{type:`button`,ref:g,onClick:z,autoFocus:!0,children:V.cancel}),(0,K.jsx)(`button`,{type:`button`,className:`danger`,onClick:B,children:V.forceDelete})]})]})}),l&&(0,K.jsx)(`div`,{className:`code-copy-toast ${l.kind}`,"data-testid":`code-copy-toast`,role:`status`,children:l.message})]})}function Bj({entries:e}){return(0,K.jsx)(K.Fragment,{children:e.map(e=>e.type===`separator`?(0,K.jsx)(`div`,{className:`code-context-menu-separator`,role:`separator`},e.id):(0,K.jsxs)(`button`,{type:`button`,role:`menuitem`,className:e.danger?`danger`:void 0,disabled:e.disabled,onClick:e.onSelect,children:[(e.icon||e.removeIcon)&&(0,K.jsx)(`span`,{className:`code-context-menu-icon`,"aria-hidden":`true`,children:e.removeIcon?(0,K.jsx)(Vj,{}):(0,K.jsx)(Hj,{kind:e.icon})}),(0,K.jsx)(`span`,{children:e.label})]},e.id))})}function Vj(){return(0,K.jsx)(`svg`,{width:`16`,height:`16`,viewBox:`0 0 16 16`,"aria-hidden":`true`,focusable:`false`,children:(0,K.jsx)(`path`,{fill:`currentColor`,d:`M4.354 3.646a.5.5 0 0 0-.708.708L7.293 8l-3.647 3.646a.5.5 0 0 0 .708.708L8 8.707l3.646 3.647a.5.5 0 0 0 .708-.708L8.707 8l3.647-3.646a.5.5 0 0 0-.708-.708L8 7.293 4.354 3.646Z`})})}function Hj({kind:e}){return e===`pin`?(0,K.jsx)(`svg`,{width:`16`,height:`16`,viewBox:`0 0 16 16`,fill:`currentColor`,"aria-hidden":`true`,focusable:`false`,children:(0,K.jsx)(`path`,{d:`M13.5 3C13.303 3 13.109 3.038 12.923 3.114L8.481 4.967L5.659 4.026C5.505 3.976 5.339 4.001 5.209 4.095C5.078 4.189 5.001 4.339 5.001 4.5V7H1.257L0.5 7.5L1.257 8H5V10.5C5 10.661 5.077 10.812 5.208 10.905C5.338 11 5.504 11.023 5.658 10.974L8.48 10.033L12.925 11.887C13.109 11.962 13.302 12 13.499 12C14.326 12 14.999 11.327 14.999 10.5V4.5C14.999 3.673 14.326 3 13.499 3H13.5ZM14 10.5C14 10.843 13.615 11.09 13.308 10.962L8.693 9.038C8.631 9.013 8.566 9 8.501 9C8.447 9 8.395 9.009 8.343 9.025L6.001 9.806V5.193L8.343 5.974C8.457 6.011 8.581 6.007 8.694 5.961L13.306 4.038C13.629 3.902 14.001 4.156 14.001 4.499V10.499L14 10.5Z`})}):e===`folder`?(0,K.jsx)(`svg`,{width:`16`,height:`16`,viewBox:`0 0 16 16`,fill:`currentColor`,"aria-hidden":`true`,focusable:`false`,children:(0,K.jsx)(`path`,{d:`M2 4.5V9.10022L2.92389 7.5C3.45979 6.5718 4.45017 6 5.52196 6L11.9146 6C11.7087 5.4174 11.1531 5 10.5 5H7C6.86739 5 6.74021 4.94732 6.64645 4.85355L4.93934 3.14645C4.84557 3.05268 4.71839 3 4.58579 3H3.5C2.67157 3 2 3.67157 2 4.5ZM7.06895 13.9953C7.04641 13.9984 7.02339 14 7 14H3.5C2.11929 14 1 12.8807 1 11.5V4.5C1 3.11929 2.11929 2 3.5 2H4.58579C4.98361 2 5.36514 2.15804 5.64645 2.43934L7.20711 4H10.5C11.724 4 12.7426 4.87965 12.958 6.04127C14.605 6.34148 15.5443 8.22106 14.6616 9.75L13.0766 12.4953C12.5407 13.4235 11.5503 13.9953 10.4785 13.9953H7.06895ZM5.52196 7C4.80743 7 4.14718 7.3812 3.78991 8L2.20492 10.7453C1.62757 11.7453 2.34926 12.9953 3.50396 12.9953L10.4785 12.9953C11.193 12.9953 11.8533 12.6141 12.2105 11.9953L13.7955 9.25C14.3729 8.25 13.6512 7 12.4965 7L5.52196 7Z`})}):e===`worktree`?(0,K.jsx)(`svg`,{width:`16`,height:`16`,viewBox:`0 0 16 16`,fill:`currentColor`,"aria-hidden":`true`,focusable:`false`,children:(0,K.jsx)(`path`,{d:`M14 5.5C14 4.121 12.879 3 11.5 3C10.121 3 9 4.121 9 5.5C9 6.682 9.826 7.669 10.93 7.928C10.744 8.546 10.177 9 9.5 9H6.5C5.935 9 5.419 9.195 5 9.512V4.949C6.14 4.717 7 3.707 7 2.5C7 1.121 5.879 0 4.5 0C3.121 0 2 1.121 2 2.5C2 3.708 2.86 4.717 4 4.949V11.05C2.86 11.282 2 12.292 2 13.499C2 14.878 3.121 15.999 4.5 15.999C5.879 15.999 7 14.878 7 13.499C7 12.317 6.174 11.33 5.07 11.071C5.256 10.453 5.823 9.999 6.5 9.999H9.5C10.723 9.999 11.74 9.115 11.954 7.953C13.116 7.738 14 6.723 14 5.5ZM3 2.5C3 1.673 3.673 1 4.5 1C5.327 1 6 1.673 6 2.5C6 3.327 5.327 4 4.5 4C3.673 4 3 3.327 3 2.5ZM6 13.5C6 14.327 5.327 15 4.5 15C3.673 15 3 14.327 3 13.5C3 12.673 3.673 12 4.5 12C5.327 12 6 12.673 6 13.5ZM11.5 7C10.673 7 10 6.327 10 5.5C10 4.673 10.673 4 11.5 4C12.327 4 13 4.673 13 5.5C13 6.327 12.327 7 11.5 7Z`})}):e===`check`?(0,K.jsx)(`svg`,{width:`16`,height:`16`,viewBox:`0 0 16 16`,fill:`currentColor`,"aria-hidden":`true`,focusable:`false`,children:(0,K.jsx)(`path`,{d:`M13.6572 3.13573C13.8583 2.9465 14.175 2.95614 14.3643 3.15722C14.5535 3.35831 14.5438 3.675 14.3428 3.86425L5.84277 11.8642C5.64597 12.0494 5.33756 12.0446 5.14648 11.8535L1.64648 8.35351C1.45121 8.15824 1.45121 7.84174 1.64648 7.64647C1.84174 7.45121 2.15825 7.45121 2.35351 7.64647L5.50976 10.8027L13.6572 3.13573Z`})}):e===`archive`?(0,K.jsx)(`svg`,{width:`16`,height:`16`,viewBox:`0 0 16 16`,"aria-hidden":`true`,focusable:`false`,children:(0,K.jsx)(`path`,{fill:`currentColor`,d:`M6.5 8C6.22386 8 6 8.22386 6 8.5C6 8.77614 6.22386 9 6.5 9H9.5C9.77614 9 10 8.77614 10 8.5C10 8.22386 9.77614 8 9.5 8H6.5ZM1 3.5C1 2.67157 1.67157 2 2.5 2H13.5C14.3284 2 15 2.67157 15 3.5V4.5C15 5.15311 14.5826 5.70873 14 5.91465V11.5C14 12.8807 12.8807 14 11.5 14H4.5C3.11929 14 2 12.8807 2 11.5V5.91465C1.4174 5.70873 1 5.15311 1 4.5V3.5ZM2.5 3C2.22386 3 2 3.22386 2 3.5V4.5C2 4.77614 2.22386 5 2.5 5H13.5C13.7761 5 14 4.77614 14 4.5V3.5C14 3.22386 13.7761 3 13.5 3H2.5ZM3 6V11.5C3 12.3284 3.67157 13 4.5 13H11.5C12.3284 13 13 12.3284 13 11.5V6H3Z`})}):e===`trash`?(0,K.jsx)(`svg`,{width:`16`,height:`16`,viewBox:`0 0 16 16`,"aria-hidden":`true`,focusable:`false`,children:(0,K.jsx)(`path`,{fill:`currentColor`,d:`M6.25 2h3.5l.5 1H13v1H3V3h2.75l.5-1ZM4.2 5h7.6l-.48 8.1A1 1 0 0 1 10.32 14H5.68a1 1 0 0 1-1-.9L4.2 5Zm2.05 1 .35 7h.95L7.2 6h-.95Zm2.2 0v7h.95V6h-.95Z`})}):(0,K.jsx)(`svg`,{width:`16`,height:`16`,viewBox:`0 0 16 16`,"aria-hidden":`true`,focusable:`false`,children:(0,K.jsx)(`path`,{fill:`currentColor`,d:`M11.3536 1.64645C10.963 1.25592 10.3299 1.25592 9.93934 1.64645L3.14645 8.43934C3.05268 8.53311 2.99999 8.66029 2.99999 8.79289V11.5C2.99999 11.7761 3.22385 12 3.49999 12H6.2071C6.33971 12 6.46689 11.9473 6.56066 11.8536L13.3536 5.06066C13.7441 4.67014 13.7441 4.037 13.3536 3.64645L11.3536 1.64645ZM3.99999 9L8.99999 4L11 6L6 11H3.99999V9ZM9.7071 3.29289L10.6464 2.35355L12.6464 4.35355L11.7071 5.29289L9.7071 3.29289ZM2.5 14C2.22386 14 2 14.2239 2 14.5C2 14.7761 2.22386 15 2.5 15H13.5C13.7761 15 14 14.7761 14 14.5C14 14.2239 13.7761 14 13.5 14H2.5Z`})})}function Uj(e,t){if(e.key!==`Tab`||!t)return;let n=Array.from(t.querySelectorAll(`button:not(:disabled), input:not(:disabled), select:not(:disabled), textarea:not(:disabled), [href], [tabindex]:not([tabindex="-1"])`)).filter(e=>e.offsetParent!==null);if(n.length===0){e.preventDefault();return}let r=n[0],i=n[n.length-1];!r||!i||(e.shiftKey&&document.activeElement===r?(e.preventDefault(),i.focus()):!e.shiftKey&&document.activeElement===i&&(e.preventDefault(),r.focus()))}var Wj=o();function Gj({canInstall:e,canFullscreen:t,fullscreenActive:n,installUnavailableReason:i,copy:a,onClose:o,onInstall:s,onToggleFullscreen:c}){let l=(0,G.useRef)(null);return(0,G.useEffect)(()=>{let e=document.activeElement instanceof HTMLElement?document.activeElement:null;l.current?.focus({preventScroll:!0});let t=e=>{e.key===`Escape`&&o()};return document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`keydown`,t),e?.focus({preventScroll:!0})}},[o]),(0,Wj.createPortal)((0,K.jsx)(`div`,{className:`code-app-mode-backdrop`,"data-testid":`code-app-mode-dialog`,role:`presentation`,onPointerDown:o,children:(0,K.jsxs)(`section`,{className:`code-app-mode-dialog`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`code-app-mode-title`,onPointerDown:e=>e.stopPropagation(),children:[(0,K.jsx)(`button`,{ref:l,type:`button`,className:`code-app-mode-close`,"aria-label":a.cancel,onClick:o,children:`×`}),(0,K.jsxs)(`header`,{className:`code-app-mode-heading`,children:[(0,K.jsx)(`img`,{src:r(`/farming-2/app-icon-v2-180.png`),alt:``,"aria-hidden":`true`}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h2`,{id:`code-app-mode-title`,children:a.appModeTitle}),(0,K.jsx)(`p`,{children:a.appModeDescription})]})]}),e?(0,K.jsxs)(`section`,{className:`code-app-mode-choice recommended`,children:[(0,K.jsx)(`span`,{className:`code-app-mode-recommended`,children:a.appModeRecommended}),(0,K.jsx)(`h3`,{children:a.appModeInstallTitle}),(0,K.jsx)(`p`,{children:a.appModeInstallDescription}),(0,K.jsx)(`button`,{type:`button`,className:`code-app-mode-install`,"data-testid":`code-app-mode-install`,onClick:s,children:a.appModeInstallAction}),(0,K.jsxs)(`ol`,{className:`code-app-mode-install-steps`,children:[(0,K.jsx)(`li`,{children:a.appModeInstallStepOne}),(0,K.jsx)(`li`,{children:a.appModeInstallStepTwo})]})]}):(0,K.jsxs)(`section`,{className:`code-app-mode-choice unavailable`,"data-testid":`code-app-mode-install-unavailable`,children:[(0,K.jsx)(`h3`,{children:a.appModeInstallUnavailableTitle}),(0,K.jsx)(`p`,{children:i})]}),t&&(0,K.jsxs)(`section`,{className:`code-app-mode-choice temporary`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h3`,{children:a.appModeFullscreenTitle}),(0,K.jsx)(`p`,{children:a.appModeFullscreenDescription})]}),(0,K.jsx)(`button`,{type:`button`,"data-testid":`code-app-mode-fullscreen`,onClick:c,children:n?a.exitFocusMode:a.enterFocusMode})]})]})}),document.body)}var Kj=`https://github.com/zhuwenzhuang/farming`;function qj({copy:e,version:t,onClose:n,returnFocusRef:i}){let a=(0,G.useRef)(null);return(0,G.useEffect)(()=>{a.current?.focus({preventScroll:!0});let e=e=>{e.key===`Escape`&&n()};return document.addEventListener(`keydown`,e),()=>{document.removeEventListener(`keydown`,e),i.current?.focus({preventScroll:!0})}},[n,i]),(0,Wj.createPortal)((0,K.jsx)(`div`,{className:`code-brand-backdrop`,"data-testid":`code-brand-dialog`,role:`presentation`,onPointerDown:n,children:(0,K.jsxs)(`section`,{className:`code-brand-dialog`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`code-brand-title`,onPointerDown:e=>e.stopPropagation(),children:[(0,K.jsx)(`button`,{ref:a,type:`button`,className:`code-brand-close`,"aria-label":e.cancel,onClick:n,children:`×`}),(0,K.jsx)(`img`,{className:`code-brand-logo`,src:r(`/farming-2/app-icon-v2-180.png`),alt:``,"aria-hidden":`true`}),(0,K.jsxs)(`div`,{className:`code-brand-heading`,children:[(0,K.jsx)(`h2`,{id:`code-brand-title`,children:`Farming Code`}),t&&(0,K.jsx)(`span`,{children:t})]}),(0,K.jsxs)(`div`,{className:`code-brand-story`,children:[(0,K.jsx)(`p`,{children:e.brandStoryOrigin}),(0,K.jsx)(`p`,{children:e.brandStoryPurpose})]}),(0,K.jsx)(`a`,{className:`code-brand-github`,href:Kj,target:`_blank`,rel:`noreferrer`,children:e.brandGithub})]})}),document.body)}var Jj=80;function Yj({copy:e,instanceName:t,onClose:n,onSave:r,returnFocusRef:i}){let[a,o]=(0,G.useState)(t),[s,c]=(0,G.useState)(!1),[l,u]=(0,G.useState)(!1),d=(0,G.useRef)(null),f=(0,G.useRef)(!1);return(0,G.useEffect)(()=>{f.current=s},[s]),(0,G.useEffect)(()=>{d.current?.focus({preventScroll:!0}),d.current?.select();let e=e=>{e.key===`Escape`&&!f.current&&n()};return document.addEventListener(`keydown`,e),()=>{document.removeEventListener(`keydown`,e),i.current?.focus({preventScroll:!0})}},[n,i]),(0,Wj.createPortal)((0,K.jsx)(`div`,{className:`code-brand-backdrop`,"data-testid":`code-instance-name-dialog`,role:`presentation`,onPointerDown:()=>!s&&n(),children:(0,K.jsxs)(`form`,{className:`code-brand-dialog code-instance-name-dialog`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`code-instance-name-title`,onPointerDown:e=>e.stopPropagation(),onSubmit:async e=>{if(e.preventDefault(),!s){if(c(!0),u(!1),await r(a)){n();return}c(!1),u(!0)}},children:[(0,K.jsx)(`h2`,{id:`code-instance-name-title`,children:e.instanceNameTitle}),(0,K.jsx)(`p`,{children:e.instanceNameDescription}),(0,K.jsx)(`input`,{ref:d,value:a,maxLength:Jj,placeholder:e.instanceNamePlaceholder,"aria-label":e.instanceNameTitle,onChange:e=>o(e.target.value)}),l&&(0,K.jsx)(`p`,{className:`code-instance-name-error`,role:`alert`,children:e.instanceNameSaveFailed}),(0,K.jsxs)(`div`,{className:`code-instance-name-actions`,children:[(0,K.jsx)(`button`,{type:`button`,onClick:n,disabled:s,children:e.cancel}),(0,K.jsx)(`button`,{type:`submit`,className:`primary`,disabled:s,children:e.save})]})]})}),document.body)}var Xj=8,Zj=26,Qj=11,$j=10;function eM(){return typeof window>`u`?{width:220+Xj*2,height:$j+Xj*2}:{width:window.innerWidth,height:window.innerHeight}}function tM(e,t=0){return $j+e*Zj+t*Qj}function nM(e,t,n,r=eM(),i=220){let a=Math.max(Xj,r.width-i-Xj),o=Math.max(Xj,r.height-n-Xj);return{x:Math.max(Xj,Math.min(e,a)),y:Math.max(Xj,Math.min(t,o))}}function rM(e,t,n=eM(),r=220){let i=e.right+Xj,a=e.left-r-Xj,o=i+r<=n.width-Xj?i:a>=Xj?a:nM(i,e.top,t,n,r).x;return{x:o,y:nM(o,e.top,t,n,r).y}}function iM(e,t,n=eM(),r=220){let i=Math.max(Xj,n.width-r-Xj),a=Math.max(Xj,Math.min(e.right-r,i)),o=e.bottom+6,s=Math.max(Xj,n.height-t-Xj),c=e.top-t-6;return{x:a,y:o<=s?o:Math.max(Xj,Math.min(c,s))}}function aM(e){let t=LD(e);return tM(t.itemCount,t.separatorCount)}var oM=140,sM=264,cM=340,lM=4,uM=null;function dM(e){if(typeof e==`function`)return e;if(typeof e.default==`function`)return e.default;if(typeof e.qrcode==`function`)return e.qrcode;throw Error(`QR renderer failed to load`)}function fM(){return uM||=s(()=>import(`./qrcode-DV-_rjU8.js`).then(e=>dM(e)),[]),uM}function pM(e){let t=Math.max(0,Math.ceil(e/1e3)),n=Math.floor(t/60),r=t%60;return`${n}:${String(r).padStart(2,`0`)}`}function mM(e,t){return!!(e&&e.expiresAt>t+1e3)}function hM(e){return e.split(`-`).map(e=>e.trim()).filter(Boolean)}async function gM(e){e?.code&&await fetch(r(`/api/share/qr-ticket/${encodeURIComponent(e.code)}`),{method:`DELETE`}).catch(()=>{})}function _M(e,t,n){let r=e<7,i=t<7,a=t>=n-7,o=e>=n-7;return r&&i||r&&a||o&&i}function vM(e,t,n,r){let i=Math.floor((n-r)/2),a=i+r;return e>=i&&e<a&&t>=i&&t<a}function yM(e,t){return(e+t)%11==0?`#6d8a63`:(e*3+t)%17==0?`#9b7a35`:`#263327`}function bM(e,t,n){return(0,K.jsxs)(`g`,{children:[(0,K.jsx)(`rect`,{x:e,y:t,width:`7`,height:`7`,rx:`1.45`,fill:`#263327`}),(0,K.jsx)(`rect`,{x:e+1,y:t+1,width:`5`,height:`5`,rx:`1`,fill:`#fbfaf2`}),(0,K.jsx)(`rect`,{x:e+2,y:t+2,width:`3`,height:`3`,rx:`0.72`,fill:`#263327`}),(0,K.jsx)(`rect`,{x:e+3.05,y:t+3.05,width:`0.9`,height:`0.9`,rx:`0.32`,fill:`#d9a735`})]},n)}function xM({value:e,badgeUrl:t,qrCodeFactory:n}){let r=(0,G.useId)().replace(/:/g,``),i=(0,G.useMemo)(()=>{let t=n(0,`H`);return t.addData(e),t.make(),t},[n,e]),a=i.getModuleCount(),o=a+lM*2,s=Math.max(7,Math.min(11,Math.floor(a*.26)|1)),c=s+1.4,l=lM+(a-c)/2,u=lM+(a-c)/2,d=`farming-qr-badge-${r}`,f=[];for(let e=0;e<a;e+=1)for(let t=0;t<a;t+=1)i.isDark(e,t)&&(_M(e,t,a)||vM(e,t,a,s)||f.push((0,K.jsx)(`rect`,{x:lM+t+.14,y:lM+e+.14,width:`0.72`,height:`0.72`,rx:`0.24`,fill:yM(e,t)},`${e}-${t}`)));return(0,K.jsxs)(`svg`,{className:`code-share-qr-svg`,viewBox:`0 0 ${o} ${o}`,role:`img`,"aria-label":`QR code`,shapeRendering:`geometricPrecision`,children:[(0,K.jsx)(`defs`,{children:(0,K.jsx)(`clipPath`,{id:d,children:(0,K.jsx)(`rect`,{x:l+.55,y:u+.55,width:c-1.1,height:c-1.1,rx:`2.1`})})}),(0,K.jsx)(`rect`,{x:`0`,y:`0`,width:o,height:o,rx:`4`,fill:`#fbfaf2`}),f,bM(lM,lM,`top-left`),bM(lM+a-7,lM,`top-right`),bM(lM,lM+a-7,`bottom-left`),(0,K.jsx)(`rect`,{x:l,y:u,width:c,height:c,rx:`2.6`,fill:`#fbfaf2`}),(0,K.jsx)(`rect`,{x:l+.35,y:u+.35,width:c-.7,height:c-.7,rx:`2.25`,fill:`#ffffff`}),(0,K.jsx)(`image`,{href:t,x:l+.55,y:u+.55,width:c-1.1,height:c-1.1,preserveAspectRatio:`xMidYMid slice`,clipPath:`url(#${d})`})]})}function SM({copy:e,sidebarCollapsed:t,shareTarget:n,openRequest:i=0}){let[a,o]=(0,G.useState)(!1),[s,c]=(0,G.useState)(!1),[l,u]=(0,G.useState)(null),[d,f]=(0,G.useState)(!1),[p,g]=(0,G.useState)(``),[_,v]=(0,G.useState)(!1),[y,b]=(0,G.useState)(()=>Date.now()),[x,C]=(0,G.useState)({x:0,y:0}),w=(0,G.useRef)(null),T=(0,G.useRef)(null),ee=(0,G.useRef)(null),E=(0,G.useRef)(null),D=(0,G.useRef)(null),O=(0,G.useRef)(0),k=(0,G.useRef)(null),A=(0,G.useRef)(null),j=(0,G.useRef)(0),[M,N]=(0,G.useState)(!0),[P,te]=(0,G.useState)(null),F=r(`/farming-2/app-icon-v2-180.png`),ne=h(n);(0,G.useEffect)(()=>{k.current=l},[l]);let I=(0,G.useCallback)(()=>{D.current!==null&&(window.clearTimeout(D.current),D.current=null)},[]),L=(0,G.useCallback)(()=>{let e=T.current?.getBoundingClientRect();if(!e)return;let t=e.right+8,n=e.left-sM-8;C({x:t+sM+10<=window.innerWidth?t:Math.max(8,n),y:Math.max(8,Math.min(e.top-4,window.innerHeight-cM-8))})},[]),R=(0,G.useCallback)(()=>{t||fM().then(e=>te(()=>e)).catch(()=>g(e.shareLinkFailed))},[e.shareLinkFailed,t]),z=(0,G.useCallback)(async(t=!1)=>{let i=k.current;if(!t&&mM(i,Date.now()))return i;let a=O.current+1;O.current=a,f(!0),g(``);try{let t=m(n),i=await fetch(r(`/api/share/qr-ticket`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t?{target:t}:{})}),o=await i.json();if(!i.ok||!(`shortUrl`in o))throw Error(`error`in o&&o.error?o.error:e.shareLinkFailed);return a===O.current?(u(o),b(Date.now()),v(!1),o):(await gM(o),null)}catch(t){return a===O.current&&g(t instanceof Error?t.message:e.shareLinkFailed),null}finally{a===O.current&&f(!1)}},[e.shareLinkFailed,n,ne]),B=(0,G.useCallback)(()=>{I(),O.current+=1,o(!1),c(!1),g(``),v(!1),f(!1);let e=k.current;k.current=null,u(null),gM(e)},[I]),V=(0,G.useCallback)((e,t=!1)=>{I(),L(),o(!0),c(e),R(),z(t)},[I,z,R,L]);(0,G.useEffect)(()=>{!i||j.current===i||(j.current=i,V(!0,!0))},[V,i]);let re=(0,G.useCallback)(()=>{!a||s||(I(),D.current=window.setTimeout(()=>{D.current=null,B()},oM))},[I,B,a,s]),ie=(0,G.useCallback)(()=>{if(a&&s){B();return}V(!0,!0)},[B,a,V,s]),H=(0,G.useCallback)(async()=>{let t=mM(k.current,Date.now())?k.current:await z(!0);if(t){if(!await S(t.longUrl)){g(e.copyFailed);return}v(!0),A.current!==null&&window.clearTimeout(A.current),A.current=window.setTimeout(()=>{v(!1),A.current=null},1800)}},[e.copyFailed,z]);(0,G.useLayoutEffect)(()=>{if(a)return L(),window.addEventListener(`resize`,L),()=>window.removeEventListener(`resize`,L)},[a,L]),(0,G.useEffect)(()=>{if(!a)return;let e=window.setInterval(()=>b(Date.now()),1e3);return()=>window.clearInterval(e)},[a]),(0,G.useEffect)(()=>{let e=k.current;e&&(k.current=null,u(null),v(!1),gM(e))},[ne]),(0,G.useLayoutEffect)(()=>{if(!a)return;let e=()=>{let e=ee.current,t=E.current;!e||!t||N(t.scrollWidth<=e.clientWidth+1)};e();let t=typeof ResizeObserver<`u`?new ResizeObserver(e):null;return t&&ee.current&&t.observe(ee.current),window.addEventListener(`resize`,e),()=>{t?.disconnect(),window.removeEventListener(`resize`,e)}},[a,l?.tokenLabel,l?.shortPath]),(0,G.useEffect)(()=>{if(!a)return;let e=e=>{let t=e.target;t instanceof Node&&w.current?.contains(t)||B()},t=e=>{e.key===`Escape`&&B()};return document.addEventListener(`pointerdown`,e,!0),document.addEventListener(`keydown`,t,!0),()=>{document.removeEventListener(`pointerdown`,e,!0),document.removeEventListener(`keydown`,t,!0)}},[B,a]),(0,G.useEffect)(()=>()=>{I(),A.current!==null&&window.clearTimeout(A.current),O.current+=1,gM(k.current)},[I]);let ae=!!(l&&l.expiresAt<=y),oe=l?pM(l.expiresAt-y):``,se=l?.tokenLabel||l?.shortPath||e.copyFullShareLink,ce=hM(se),le=M||ce.length<=1?[se]:ce;return(0,K.jsxs)(`div`,{ref:w,className:`code-share-root`,onMouseEnter:R,onMouseLeave:re,onFocus:()=>{I(),R()},onBlur:e=>{!e.currentTarget.contains(e.relatedTarget)&&!s&&B()},children:[(0,K.jsx)(`button`,{ref:T,type:`button`,className:`code-share-button`,"data-testid":`code-share-button`,"aria-label":e.sharePage,title:e.sharePage,"aria-haspopup":`dialog`,"aria-expanded":a,onClick:ie,children:(0,K.jsx)(be,{className:`code-share-icon`})}),a&&(0,K.jsxs)(`div`,{className:`code-share-popover`,"data-testid":`code-share-popover`,role:`dialog`,"aria-label":e.scanToOpenOnPhone,style:{left:x.x,top:x.y},onMouseEnter:()=>{I()},onMouseLeave:re,onKeyDown:e=>{e.key===`Escape`&&(B(),T.current?.focus())},children:[(0,K.jsxs)(`div`,{className:`code-share-qr-frame`,"data-expired":ae?`true`:`false`,children:[(0,K.jsx)(`div`,{className:`code-share-qr-canvas`,children:l&&!d&&P?(0,K.jsx)(xM,{value:l.shortUrl,badgeUrl:F,qrCodeFactory:P}):(0,K.jsx)(`div`,{className:`code-share-qr-loading`,children:d?e.loading:e.shareLinkFailed})}),l&&(0,K.jsx)(`div`,{className:`code-share-countdown`,children:ae?e.shareLinkExpired:oe}),ae&&(0,K.jsx)(`button`,{type:`button`,className:`code-share-refresh`,onClick:()=>void z(!0),children:e.refreshShareLink})]}),(0,K.jsxs)(`button`,{type:`button`,className:`code-share-copy-token`,"data-testid":`code-share-copy-link`,disabled:!l&&d,onClick:()=>void H(),children:[(0,K.jsxs)(`span`,{ref:ee,className:`code-share-token ${M?`single-line`:``}`,"aria-label":se,children:[(0,K.jsx)(`span`,{ref:E,className:`code-share-token-measure`,"aria-hidden":`true`,children:se}),le.map((e,t)=>(0,K.jsx)(`span`,{className:`code-share-token-line`,children:e},`${t}-${e}`))]}),(0,K.jsx)(`span`,{className:`code-share-copy-action`,children:_?e.copiedShareLink:e.copyFullShareLink})]}),p&&(0,K.jsx)(`div`,{className:`code-share-error`,role:`status`,children:p})]})]})}function CM(e,t){return e&&t.some(t=>!t.isMain&&t.id===e)?e:t.find(e=>!e.isMain)?.id??null}function wM(e){return e&&(e.projectWorkspace||e.cwd)||``}function TM(e,t,n={},r=[],i=e,a=[],o=[]){let s=aO(e,t),c=new Map(s.map(e=>[e.workspace,e]));r.forEach(e=>{let t=e.sourceAgentId?i.find(t=>t.id===e.sourceAgentId):i.find(t=>t.id===e.agentId),n=e.workspaceRoot||(t?UD(t):``);if(!n||n===`/`)return;let r=c.get(n);if(r){r.hasOpenFile=!0,!r.gitWorktree&&t?.gitWorktree?.workspace&&(r.gitWorktree=t.gitWorktree);return}let a={id:n,name:WD(n),workspace:n,agents:[],agentSessions:[],hasMain:!1,hasProjectAgent:!1,hasAgentSession:!1,hasOpenFile:!0,gitWorktree:t?.gitWorktree??null};s.push(a),c.set(n,a)}),a.forEach(e=>{if(!e||e===`/`||c.get(e))return;let t={id:e,name:WD(e),workspace:e,agents:[],agentSessions:[],hasMain:!1,hasProjectAgent:!1,hasAgentSession:!1,gitWorktree:null};s.push(t),c.set(e,t)});let l=new Map(o.map((e,t)=>[e,t]));return s.map((e,t)=>{let r=e.workspace?n[e.workspace]?.trim():``,i=r&&!e.hasMain?{...e,name:r}:e,a=l.get(e.workspace);return{project:{...i,pinned:a!==void 0},pinIndex:a,sourceIndex:t}}).sort((e,t)=>e.pinIndex!==void 0&&t.pinIndex!==void 0?e.pinIndex-t.pinIndex:e.pinIndex===void 0?t.pinIndex===void 0?e.sourceIndex-t.sourceIndex:1:-1).map(e=>e.project)}function EM(e,t,n,r=new Set,i=new Set){return t?jk(e.map(e=>{let n=[e.name,e.workspace].some(e=>e.toLowerCase().includes(t)),a=n?e.agents:e.agents.filter(e=>i.has(e.id)||ee(e).toLowerCase().includes(t)),o=n?e.agentSessions:e.agentSessions.filter(e=>r.has(ZD(e))||e.title.toLowerCase().includes(t));return a.length>0||o.length>0||e.workspace&&n?{...e,agents:a,agentSessions:o}:null}).filter(e=>!!e),n,!0):e}function DM(e,t,n){return e.flatMap(e=>t.has(e.id)&&!n?[]:[...e.agents.map(e=>({kind:`agent`,id:e.id})),...e.agentSessions.map(e=>({kind:`agent-session`,provider:e.provider,id:e.id,...e.providerHomeId?{providerHomeId:e.providerHomeId}:{}}))])}var OM=5,kM=5,AM=`__project_agent_drop_end__`;function jM(){return typeof window>`u`?!1:navigator.standalone===!0||window.matchMedia(`(display-mode: standalone)`).matches}function MM(e){let t=e?.trim().toLowerCase()||``;if(t===`claude-code`)return`claude`;if([`codex`,`claude`,`opencode`,`qoder`,`bash`,`zsh`].includes(t))return t}function NM(e){return MM(e.providerSessionProvider)||MM(e.command.trim().split(/\s+/).find(e=>e!==`env`&&!/^[A-Za-z_][A-Za-z0-9_]*=/.test(e))?.split(`/`).pop())}function PM(){return(0,K.jsxs)(`svg`,{width:`12`,height:`12`,viewBox:`0 0 16 16`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.4`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,K.jsx)(`circle`,{cx:`4`,cy:`3`,r:`1.5`}),(0,K.jsx)(`circle`,{cx:`4`,cy:`13`,r:`1.5`}),(0,K.jsx)(`circle`,{cx:`12`,cy:`5`,r:`1.5`}),(0,K.jsx)(`path`,{d:`M4 4.5v7M5.5 8h2.25A4.25 4.25 0 0 0 12 3.75`})]})}function FM(e){let t=e.trim().replace(/^v/i,``);if(!t)return``;let n=/^(\d+\.\d+\.\d+)-(\d+)-g[0-9a-f]+(?:-dirty)?$/i.exec(t);if(n)return`${n[1]}-${n[2]}`;let r=/^(\d+\.\d+\.\d+)-dirty$/i.exec(t);return r?`${r[1]}-1`:t.replace(/-dirty$/i,``)}var IM=(0,G.lazy)(()=>s(()=>import(`./ProjectFilesSection-C1RAJWOE.js`).then(e=>({default:e.ProjectFilesSection})),__vite__mapDeps([18,1,5,6,7,19,20,15,16])));function LM({sidebarCollapsed:e,emptyHomeActionRequest:t,activeView:n,searchOpen:i,displayedProjects:a,collapsedProjectIds:o,normalizedSearch:s,hasProjectListItems:c,hasDisplayedProjectListItems:l,activeTerminalId:u,selectedSearchAgentId:d,selectedSearchSessionHandle:f,claimedAgentSessionKeyByAgentId:p,agentShortcutKeys:m,keyboardShortcutsEnabled:h,now:g,mainAgent:_,usageSummary:v,instanceName:y,shareTarget:b,agentLaunchOptions:x,agentCreationWorkspace:S,openWorkspaceFile:C,openWorkspaceFiles:w,fileRevealRequest:T,fileSearchFocusRequest:ee,projectListRef:E,canLoadMoreAgentSessions:D,onLoadMoreAgentSessions:O,onNewAgent:k,onStartAgent:A,onToggleSidebar:j,onOpenSearch:M,onOpenWorkspaceView:N,onOpenMainAgent:P,onRestartMainAgent:te,onProjectListKeyDown:F,onToggleProject:ne,onToggleProjectSessions:I,onMountProject:L,onOpenProjectContextMenu:R,onOpenProjectKeyboardMenu:B,onOpenAgent:V,onUpdateAgentFlags:re,onReorderAgent:ie,onOpenAgentContextMenu:H,onOpenAgentKeyboardMenu:ae,onResumeAgentSession:oe,onOpenAgentSessionContextMenu:se,onOpenAgentSessionKeyboardMenu:ce,onOpenProjectFile:le,onSelectOpenWorkspaceFile:ue,onCloseOpenWorkspaceFile:de,onMoveWorkspaceEntries:fe,onDeleteWorkspaceEntries:pe,onRefreshProjectOpenFiles:me,onOpenOptionsMenu:he,onRenameInstance:_e,copy:ye}){let[be,xe]=(0,G.useState)(null),Se=(0,G.useRef)(null),we=(0,G.useRef)(!1),Te=(0,G.useRef)(new Map),[De,Oe]=(0,G.useState)(!0),[ke,je]=(0,G.useState)(!1),[W,Ne]=(0,G.useState)(!1),[Pe,Fe]=(0,G.useState)(!1),Ie=(0,G.useRef)(null),Le=(0,G.useRef)(null),Re=(0,G.useCallback)(()=>Ne(!1),[]),[Be,He]=(0,G.useState)(!1),[Ue,We]=(0,G.useState)(!1),[Ge,qe]=(0,G.useState)(jM),[Je,Xe]=(0,G.useState)(!1),[Ze,Qe]=(0,G.useState)(null),$e=(0,G.useRef)(0),[et,tt]=(0,G.useState)(!1),nt=(0,G.useCallback)(e=>{D&&e.scrollHeight-e.scrollTop-e.clientHeight<=240&&O()},[D,O]),rt=(0,G.useCallback)(()=>{Se.current!==null&&(window.clearTimeout(Se.current),Se.current=null)},[]),it=(0,G.useCallback)(()=>{rt(),xe(null)},[rt]),at=(0,G.useCallback)(()=>{we.current=!1,it()},[it]),ot=(0,G.useCallback)((e,t,n=!1)=>{rt();let i=e.currentTarget,a=we.current?0:n?450:1500;Se.current=window.setTimeout(()=>{if(Se.current=null,!i.matches(`:hover`))return;let e=i.getBoundingClientRect(),n=e.right+10,a=Math.min(320,window.innerWidth-n-12);if(a<200)return;let o=Math.max(8,Math.min(e.top-4,window.innerHeight-152)),s=t.workspaceRootId?Te.current.get(t.workspaceRootId):void 0,c=s&&s.expiresAt>Date.now()?s.branch:``;we.current=!0,xe({...t,x:n,y:o,width:a,branch:c}),!(!t.workspaceRootId||c)&&fetch(r(`/api/files/branch?rootId=${encodeURIComponent(t.workspaceRootId)}`)).then(e=>e.ok?e.json():null).then(e=>{let n=typeof e?.branch==`string`?e.branch.trim():``;Te.current.set(t.workspaceRootId,{branch:n,expiresAt:Date.now()+3e4}),xe(e=>e?.key===t.key?{...e,branch:n}:e)}).catch(()=>{Te.current.set(t.workspaceRootId,{branch:``,expiresAt:Date.now()+3e4})})},a)},[rt]);(0,G.useEffect)(()=>()=>rt(),[rt]),(0,G.useEffect)(()=>{We(!!(document.fullscreenEnabled&&document.documentElement.requestFullscreen));let e=()=>{He(!!document.fullscreenElement)};return document.addEventListener(`fullscreenchange`,e),e(),()=>{document.removeEventListener(`fullscreenchange`,e)}},[]),(0,G.useEffect)(()=>{let e=window.matchMedia(`(display-mode: standalone)`),t=()=>{let e=jM();qe(e),e&&Xe(!1)},n=e=>{e.preventDefault(),Qe(e)};return e.addEventListener(`change`,t),window.addEventListener(`beforeinstallprompt`,n),t(),()=>{e.removeEventListener(`change`,t),window.removeEventListener(`beforeinstallprompt`,n)}},[]);let st=(0,G.useCallback)(()=>{if(document.fullscreenElement){document.exitFullscreen().catch(()=>{});return}document.documentElement.requestFullscreen({navigationUI:`hide`}).catch(()=>{})},[]);(0,G.useEffect)(()=>{if(!(!t||$e.current===t.nonce)&&($e.current=t.nonce,t.kind===`focus`)){if(Ge){st();return}Xe(!0)}},[t,Ge,st]);let ct=(0,G.useCallback)(()=>{let e=Ze;e&&e.prompt().then(()=>e.userChoice).then(e=>{Qe(null),e.outcome===`accepted`&&Xe(!1)}).catch(()=>Qe(null))},[Ze]),lt=(0,G.useCallback)(()=>{Xe(!1),st()},[st]),ut=window.isSecureContext?ye.appModeInstallUnavailableBrowser:ye.appModeInstallUnavailableInsecure,dt=a.flatMap(e=>[...e.agents.filter(e=>e.pinned).map(e=>({kind:`agent`,agent:e})),...e.agentSessions.filter(e=>e.pinned).map(e=>({kind:`agent-session`,session:e}))]).sort((e,t)=>e.kind===`agent`&&t.kind===`agent`?(e.agent.pinnedOrder??0)-(t.agent.pinnedOrder??0)||(e.agent.startedAt??0)-(t.agent.startedAt??0):e.kind===t.kind?e.kind===`agent-session`&&t.kind===`agent-session`?rO(t.session)-rO(e.session):0:e.kind===`agent`?-1:1),ft=a.filter(e=>e.agents.some(e=>!e.pinned||!e.isMain)||e.agentSessions.some(e=>!e.pinned)||(e.hiddenAgentSessionCount??0)>0||e.hasOpenFile||!!e.workspace),pt=a.flatMap(e=>[...e.agents.filter(e=>!e.isMain).map(t=>({agent:t,projectName:e.name}))]),mt=w.filter(e=>Ke(e.agentId)),ht=C&&Ke(C.agentId)?C:null,gt=T?.agentId===Ye,_t=mt.length>0||gt;(0,G.useEffect)(()=>{_t||tt(!1)},[_t]),(0,G.useEffect)(()=>{gt&&tt(!1)},[gt]);let vt=FM(`2.2.23`),yt=vt?`v${vt}`:``,bt=e;return(0,K.jsxs)(`aside`,{className:`code-sidebar ${e?`collapsed`:``}`,"data-testid":`code-sidebar`,onMouseLeave:at,children:[(0,K.jsx)(`div`,{className:`code-nav`,children:(0,K.jsxs)(`div`,{className:`code-nav-top-row`,children:[(0,K.jsxs)(`button`,{type:`button`,className:`code-nav-item primary`,"data-testid":`code-new-agent`,onClick:e=>k(S,void 0,e.currentTarget),children:[(0,K.jsx)(`span`,{className:`code-nav-icon`,children:(0,K.jsx)(Ce,{})}),(0,K.jsx)(`span`,{children:ye.newAgent}),h&&(0,K.jsx)(`kbd`,{children:`N`})]}),(0,K.jsx)(SM,{copy:ye,sidebarCollapsed:e,shareTarget:b,openRequest:t?.kind===`share`?t.nonce:0}),!Ge&&!e&&(0,K.jsx)(`button`,{type:`button`,className:`code-sidebar-focus-toggle ${Be?`active`:``}`,"data-testid":`code-sidebar-focus-toggle`,"aria-label":ye.appModeOpen,title:ye.appModeOpen,"aria-haspopup":`dialog`,"aria-expanded":Je,onClick:()=>Xe(!0),children:(0,K.jsx)(`span`,{className:`code-sidebar-focus-icon`,children:(0,K.jsx)(U,{})})}),!e&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`button`,{type:`button`,className:`code-sidebar-search-toggle ${n===`search`||i?`active`:``}`,"data-testid":`code-nav-search`,"aria-label":ye.search,title:ye.search,"aria-pressed":n===`search`||i,onClick:M,children:(0,K.jsx)(`span`,{className:`code-sidebar-search-icon`,"aria-hidden":`true`,children:(0,K.jsx)(Ae,{})})}),(0,K.jsx)(`button`,{type:`button`,className:`code-sidebar-history-toggle ${n===`history`?`active`:``}`,"data-testid":`code-nav-history`,"aria-label":ye.history,title:ye.history,"aria-pressed":n===`history`,onClick:()=>N(`history`),children:(0,K.jsx)(`span`,{className:`code-sidebar-history-icon`,"aria-hidden":`true`,children:(0,K.jsx)(Ve,{})})})]}),(0,K.jsx)(`button`,{type:`button`,className:`code-sidebar-toggle`,"data-testid":`code-sidebar-toggle`,"aria-label":e?ye.expandSidebar:ye.collapseSidebar,title:e?ye.expandSidebar:ye.collapseSidebar,onClick:j,children:(0,K.jsx)(`span`,{className:`code-sidebar-toggle-icon ${e?`collapsed`:`expanded`}`,"aria-hidden":`true`,children:e?(0,K.jsx)(Ee,{}):(0,K.jsx)(ze,{})})})]})}),e&&pt.length>0&&(0,K.jsx)(PN,{items:pt,activeTerminalId:u,now:g,onOpenAgent:V,onShowPreview:ot,onHidePreview:it,copy:ye}),(0,K.jsxs)(`div`,{className:`code-project-list`,"data-testid":`code-project-list`,ref:E,tabIndex:0,onKeyDown:F,onScroll:e=>nt(e.currentTarget),"aria-label":ye.projectsAndAgents,children:[!c&&(0,K.jsx)(`div`,{className:`code-empty-project`,children:ye.noAgentsYet}),c&&!l&&(0,K.jsx)(`div`,{className:`code-empty-project`,"data-testid":`code-empty-search`,children:ye.noMatchingProjectsOrAgents}),dt.length>0&&(0,K.jsx)(RN,{items:dt,collapsed:ke,compressed:bt,activeTerminalId:u,selectedSearchAgentId:d,selectedSearchSessionHandle:f,claimedAgentSessionKeyByAgentId:p,agentShortcutKeys:m,keyboardShortcutsEnabled:h,now:g,onOpenAgent:V,onUpdateAgentFlags:re,onReorderAgent:ie,onOpenAgentContextMenu:H,onOpenAgentKeyboardMenu:ae,onResumeAgentSession:oe,onOpenAgentSessionContextMenu:se,onOpenAgentSessionKeyboardMenu:ce,onShowAgentPreview:ot,onHideAgentPreview:it,onToggleCollapsed:()=>je(e=>!e),copy:ye}),_t&&(0,K.jsxs)(`section`,{className:`code-project-group code-root-files-group`,"data-testid":`code-root-files-group`,children:[(0,K.jsx)(`div`,{className:`code-project-row code-root-files-row`,children:(0,K.jsxs)(`button`,{type:`button`,className:`code-project-title`,"data-testid":`code-root-files-title`,"aria-expanded":!et,onClick:()=>tt(e=>!e),children:[(0,K.jsx)(`span`,{className:`code-folder-icon ${et?`collapsed`:`expanded`}`,"aria-hidden":`true`,children:et?(0,K.jsx)(Ee,{}):(0,K.jsx)(Me,{})}),(0,K.jsx)(`span`,{children:`/`})]})}),!et&&(0,K.jsx)(`div`,{className:`code-project-expanded`,children:(0,K.jsx)(G.Suspense,{fallback:null,children:(0,K.jsx)(IM,{projectId:`__farming_global_files_project__`,projectWorkspace:`/`,agentId:`wroot_global`,agentLaunchOptions:[],activeFilePath:ht?.file.path,openFiles:mt.map(e=>({agentId:e.agentId,workspaceRoot:e.workspaceRoot,key:z(e),path:e.file.path,dirty:e.dirty,externalChanged:e.externalChanged})),revealRequest:T?.agentId===`wroot_global`?T:void 0,focusSearchRequest:ee?.agentId===`wroot_global`?ee:void 0,onOpenFile:le,onSelectOpenFile:ue,onCloseOpenFile:de,onMoveEntries:fe,onDeleteEntries:pe,onRefreshOpenFiles:me,readOnly:!0,copy:ye})})})]}),ft.map(e=>(0,K.jsx)(HN,{project:e,collapsed:o.has(e.id)&&!s,forceAgentsExpanded:!!s,compactAgents:bt,activeTerminalId:u,selectedSearchAgentId:d,selectedSearchSessionHandle:f,claimedAgentSessionKeyByAgentId:p,agentShortcutKeys:m,keyboardShortcutsEnabled:h,now:g,openWorkspaceFile:C,openWorkspaceFiles:w,agentLaunchOptions:x,fileRevealRequest:T,fileSearchFocusRequest:ee,onToggleProject:ne,onToggleProjectSessions:I,onMountProject:L,onNewAgent:k,onStartAgent:A,onOpenProjectContextMenu:R,onOpenProjectKeyboardMenu:B,onOpenAgent:V,onUpdateAgentFlags:re,onReorderAgent:ie,onOpenAgentContextMenu:H,onOpenAgentKeyboardMenu:ae,onResumeAgentSession:oe,onOpenAgentSessionContextMenu:se,onOpenAgentSessionKeyboardMenu:ce,onShowAgentPreview:ot,onHideAgentPreview:it,onOpenProjectFile:le,onSelectOpenWorkspaceFile:ue,onCloseOpenWorkspaceFile:de,onMoveWorkspaceEntries:fe,onDeleteWorkspaceEntries:pe,onRefreshProjectOpenFiles:me,copy:ye},e.id))]}),(0,K.jsxs)(`div`,{className:`code-sidebar-footer`,children:[!e&&(0,K.jsxs)(`button`,{ref:Le,type:`button`,className:`code-instance-name`,"data-testid":`code-instance-name-edit`,"aria-label":ye.renameInstance,title:y,onClick:()=>Fe(!0),children:[(0,K.jsx)(`span`,{className:`code-instance-name-copy`,children:y}),(0,K.jsx)(ge,{})]}),(0,K.jsxs)(`div`,{className:`code-product-row`,children:[(0,K.jsxs)(`button`,{ref:Ie,type:`button`,className:`code-product-mark`,"data-testid":`code-product-mark`,title:`Farming Code`,"aria-label":`Farming Code`,onClick:()=>Ne(!0),children:[(0,K.jsx)(`img`,{className:`code-product-logo`,src:r(`/farming-2/app-icon-v2-180.png`),alt:``,"aria-hidden":`true`}),(0,K.jsxs)(`span`,{className:`code-product-mark-copy`,children:[(0,K.jsxs)(`span`,{className:`code-product-mark-main-slot`,children:[(0,K.jsx)(`span`,{className:`code-product-mark-main code-product-mark-main-full`,children:`Farming Code`}),(0,K.jsx)(`span`,{className:`code-product-mark-main code-product-mark-main-short`,"aria-hidden":`true`,children:`Farming`})]}),yt&&(0,K.jsx)(`span`,{className:`code-product-mark-badge`,children:yt})]})]}),(0,K.jsx)(`button`,{type:`button`,className:`code-sidebar-options`,"data-testid":`code-sidebar-options`,"aria-label":ye.openSettings,title:ye.openSettings,onClick:he,children:(0,K.jsx)(ve,{})})]}),!e&&(0,K.jsx)(lN,{collapsed:De,mainAgent:_,now:g,usageSummary:v,onToggleCollapsed:()=>Oe(e=>!e),onOpenMainAgent:P,onRestartMainAgent:te})]}),be&&(0,K.jsx)(XN,{preview:be,now:g}),W&&(0,K.jsx)(qj,{copy:ye,version:yt,onClose:Re,returnFocusRef:Ie}),Pe&&(0,K.jsx)(Yj,{copy:ye,instanceName:y,onClose:()=>Fe(!1),onSave:_e,returnFocusRef:Le}),Je&&(0,K.jsx)(Gj,{canInstall:!!Ze,canFullscreen:Ue,fullscreenActive:Be,installUnavailableReason:ut,copy:ye,onClose:()=>Xe(!1),onInstall:ct,onToggleFullscreen:lt})]})}function RM(e){let t=Number(e);return!Number.isFinite(t)||t<=0?`Window`:t===10080?`Weekly`:t%1440==0?`${t/1440}d`:t%60==0?`${t/60}h`:`${t}m`}function zM(e){let t=Number(e);return Number.isFinite(t)?`${Math.round(t)}%`:`--`}function BM(e){let t=Number(e);if(!Number.isFinite(t))return`-- left`;let n=Math.max(0,Math.min(100,100-t));return`${Math.round(n)}% left`}function VM(e){let t=e.forecast?.remainingTokens,n=t==null?null:Number(t);return typeof n==`number`&&Number.isFinite(n)&&n>=0?`${GM(Math.round(n))} tok left`:BM(e.usedPercent)}function HM(e){return VM(e)}function UM(e,t){let n=[e],r=zM(t.usedPercent),i=VM(t);return r!==`--`&&n.push(`${r} used`),i!==`-- left`&&n.push(i),n.filter(Boolean).join(` / `)}function WM(e,t){let n=Number(e);if(!Number.isFinite(n)||n<=0)return null;let r=Math.max(0,Math.round((n-t)/6e4));return r===0?`reset now`:r>=1440?`reset ${Math.floor(r/1440)}d ${Math.floor(r%1440/60)}h`:r>=60?`reset ${Math.floor(r/60)}h ${r%60}m`:`reset ${r}m`}function GM(e){if(e>=1e9){let t=e/1e9;return`${t>=10?Math.round(t):Math.round(t*10)/10}B`}if(e>=1e6){let t=e/1e6;return`${t>=10?Math.round(t):Math.round(t*10)/10}M`}if(e>=1e3){let t=e/1e3;return`${t>=10?Math.round(t):Math.round(t*10)/10}k`}return`${e}`}function KM(e,t=!1){let n=Number(e);if(!Number.isFinite(n))return`-- tok/min`;let r=n<10?Math.round(n*10)/10:Math.round(n);return`${t?`~`:``}${GM(r)} tok/min`}function qM(e){let t=e.auth?.status||``;return e.auth?.available?/logged in/i.test(t)?`logged in`:t||`available`:`offline`}function JM(e){if(e.tokenUsage.available===!1)return!1;let t=Number(e.tokenUsage.eventCount),n=Number(e.tokenUsage.totalTokens),r=Number.isFinite(t)&&t>0||Number.isFinite(n)&&n>0;return e.auth.available||r}function YM(e){return e?.providers.filter(JM)??[]}function XM(e){let t=YM(e);return t.length?t.reduce((e,t)=>{let n=Number(t.tokenUsage.tokensPerMinute);return e+(Number.isFinite(n)?n:0)},0):null}function ZM(e){let t=e.forecast?.remainingPercent;if(typeof t==`number`&&Number.isFinite(t))return Math.max(0,Math.min(100,t));let n=Number(e.usedPercent);return Number.isFinite(n)?Math.max(0,Math.min(100,100-n)):null}function QM(e){let t=Number(e.windowMinutes);return Number.isFinite(t)&&t>=10020?0:Number.isFinite(t)&&t>=285&&t<=315?1:2}function $M(e){return[e.quota.primary,e.quota.secondary].filter(e=>!!e).map(e=>({label:RM(e.windowMinutes),limit:e,remaining:ZM(e),exhaustedAt:typeof e.forecast?.projectedExhaustedAt==`number`&&Number.isFinite(e.forecast.projectedExhaustedAt)?e.forecast.projectedExhaustedAt:null})).filter(e=>e.remaining!==null).sort((e,t)=>QM(e.limit)-QM(t.limit))}function eN(e){let t=Number(e.tokenUsage.tokensPerMinute);return Number.isFinite(t)&&t>0}function tN(e){let t=YM(e);return t.length?t.filter(e=>eN(e)&&e.quota.available).map(e=>{let t=$M(e),n=t.filter(e=>e.remaining!==null&&e.remaining<50);return n.length?{provider:e,limits:t,earliestExhaustedAt:n.reduce((e,t)=>t.exhaustedAt===null?e:e===null?t.exhaustedAt:Math.min(e,t.exhaustedAt),null),lowestRemaining:n.reduce((e,t)=>Math.min(e,t.remaining??100),100)}:null}).filter(e=>!!e).sort((e,t)=>e.earliestExhaustedAt!==null&&t.earliestExhaustedAt!==null?e.earliestExhaustedAt-t.earliestExhaustedAt:e.earliestExhaustedAt===null?t.earliestExhaustedAt===null?e.lowestRemaining-t.lowestRemaining:1:-1)[0]??null:null}function nN(e,t){let n=tN(e);if(!n)return null;let r=[n.provider.providerName];return n.limits.forEach(e=>{r.push(`${e.label} ${Math.round(e.remaining??0)}%`);let n=WM(e.limit.resetsAt,t);n&&r.push(n)}),r.join(` · `)}function rN(e,t){let n=[],r=XM(e);return r!==null&&n.push(KM(r)),t&&n.push(`CPU ${t.cpu}% / MEM ${t.memory.percentage}%`),n.join(` · `)||`5m`}function iN(e,t,n){return nN(e,n)||rN(e,t)}function aN(e){return e.status===`pending`?`starting`:e.status===`dead`?`offline`:e.status}function oN(e,t){return e??t?.systemStats??null}function sN({usageSummary:e,now:t}){let n=iN(e,oN(bt(),e),t);return(0,K.jsx)(`span`,{className:`code-usage-summary`,"data-testid":`code-usage-summary`,title:n,children:n})}function cN({usageSummary:e}){let t=oN(bt(),e);return t?(0,K.jsxs)(`div`,{className:`code-usage-row`,children:[(0,K.jsx)(`span`,{children:`System`}),(0,K.jsxs)(`strong`,{children:[`CPU `,t.cpu,`% / MEM `,t.memory.percentage,`%`]})]}):null}function lN(e){let t=xt();return!e.usageSummary&&!e.mainAgent&&!t?null:(0,K.jsx)(MN,{...e})}function uN(e){return new Date(e).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`})}function dN(e){return`${String(new Date(e).getHours()).padStart(2,`0`)}:00`}function fN(e){return Math.round(e).toLocaleString(`en-US`)}function pN(e){let t=e.map(e=>Math.max(0,Number(e)||0)).filter(e=>e>0).sort((e,t)=>e-t);if(!t.length)return[];let n=t[0],r=t[t.length-1];return n===r?[.2,.4,.6,.8].map(e=>r*e):[.2,.4,.6,.8].map(e=>{let n=(t.length-1)*e,r=Math.floor(n),i=Math.ceil(n),a=t[r];return a+(t[i]-a)*(n-r)})}function mN(e,t){let n=Math.max(0,Number(e)||0);return n<=0?0:Math.max(1,Math.min(5,1+t.filter(e=>n>e).length))}function hN(e){let t=e.timeline,n=Array.isArray(t?.points)?t.points:[];return n.length>0&&n.every((e,t)=>Number.isFinite(Number(e.startedAt))&&Number.isFinite(Number(e.endedAt))&&Number(e.endedAt)>Number(e.startedAt)&&Number.isFinite(Number(e.totalTokens))&&Number(e.totalTokens)>=0&&(t===0||Number(e.startedAt)>=Number(n[t-1].startedAt)))?n:null}function gN(e){let t=/^(\d{4})-(\d{2})-(\d{2})$/.exec(e);if(!t)return null;let n=Number(t[1]),r=Number(t[2]),i=Number(t[3]),a=new Date(n,r-1,i,12,0,0,0);return a.getFullYear()!==n||a.getMonth()!==r-1||a.getDate()!==i?null:a}function _N(e){let t=Array.isArray(e.daily?.points)?e.daily.points:[];return t.length>0&&t.every((e,n)=>!!gN(e.date)&&Number.isFinite(Number(e.totalTokens))&&Number(e.totalTokens)>=0&&(n===0||e.date>t[n-1].date))?t.slice(-364):null}var vN=200;function yN({usageSummary:e,points:t,onInspect:n}){let r=e.timeline,i=t.reduce((e,t)=>e+Number(t.totalTokens),0),a=RM(Number(r.windowMs)/6e4).toLowerCase(),o=pN(t.map(e=>e.totalTokens)),s=[0,.25,.5,.75,1].map(e=>r.startAt+(r.endAt-r.startAt)*e);return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`div`,{className:`code-usage-heatmap`,"data-testid":`code-usage-heatmap`,role:`img`,"aria-label":`Token activity over the last ${a}, ${GM(i)} tokens`,title:`Local token activity · last ${a}`,children:t.map((e,t)=>{let r=Number(e.totalTokens),i=`${uN(e.startedAt)}–${uN(e.endedAt)}`,a=`${i} · ${fN(r)} tokens`;return(0,K.jsx)(`span`,{className:`code-usage-heatmap-cell`,"data-level":mN(r,o),"data-start":e.startedAt,title:a,"aria-label":a,onMouseEnter:()=>n({label:i,tokens:r})},`${e.startedAt}-${t}`)})}),(0,K.jsx)(`div`,{className:`code-usage-time-axis`,"data-testid":`code-usage-time-axis`,"aria-hidden":`true`,children:s.map((e,t)=>(0,K.jsx)(`span`,{children:dN(e)},`${e}-${t}`))})]})}function bN({points:e,onInspect:t,inspection:n=null,showDayHighlight:r=!1}){let i=(0,G.useRef)(null),a=(0,G.useCallback)(()=>{i.current!==null&&(window.clearTimeout(i.current),i.current=null)},[]),o=(0,G.useCallback)(e=>{a(),i.current=window.setTimeout(()=>{i.current=null,t(e)},vN)},[a,t]);(0,G.useEffect)(()=>a,[a]);let s=(gN(e[0].date).getDay()+6)%7,c=Math.max(1,Math.ceil((s+e.length)/7)),l=c*7-s-e.length,u=pN(e.map(e=>e.totalTokens)),d=e.filter(e=>e.totalTokens>0).length,f=Math.max(0,e.length-7),p=e.slice(f).reduce((e,t)=>e+t.totalTokens,0),m=e.reduce((e,t)=>!e||t.totalTokens>e.totalTokens?t:e,null),h=m&&m.totalTokens>0?m:null,g=n?e.find(e=>e.date===n.label)??null:null,_=e[e.length-1]??null,v=g??_,y=!!(v&&v.date===h?.date);return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{className:`code-usage-activity-heading`,children:[(0,K.jsx)(`span`,{children:`52w · daily`}),r&&v?(0,K.jsxs)(`div`,{className:`code-usage-detail-day-highlight`,"data-state":g?`selected`:`today`,"data-testid":`code-usage-detail-day-highlight`,children:[(0,K.jsxs)(`span`,{children:[g&&y?`Top · `:``,CN(v.date)]}),(0,K.jsx)(`strong`,{children:GM(v.totalTokens)}),(0,K.jsx)(`small`,{children:`tokens`})]}):(0,K.jsxs)(`span`,{children:[`7d `,GM(p)]})]}),(0,K.jsxs)(`div`,{className:`code-usage-daily-heatmap`,"data-testid":`code-usage-daily-heatmap`,role:`img`,"aria-label":`Daily token activity over 52 weeks, ${d} active days`,style:{gridTemplateColumns:`repeat(${c}, minmax(2px, 1fr))`},children:[Array.from({length:s},(e,t)=>(0,K.jsx)(`span`,{className:`code-usage-daily-spacer`,"aria-hidden":`true`},`leading-${t}`)),e.map((e,n)=>{let i=Number(e.totalTokens),s=e.date===h?.date,c=i>1e9,l=s?`Token king`:c?`Over 1B tokens`:``,d=`${e.date} · ${fN(i)} tokens${l?` · ${l}`:``}`,p=e.date===g?.date,m={label:e.date,tokens:i},_=()=>{a(),t(m)};return(0,K.jsx)(`span`,{className:`code-usage-heatmap-cell code-usage-daily-heatmap-cell`,"data-date":e.date,"data-level":mN(i,u),"data-peak":s?`true`:void 0,"data-billion":c?`true`:void 0,"data-shape":r?s?`crown`:c?`flame`:void 0:void 0,"data-recent":n>=f?`true`:void 0,"data-selected":p?`true`:void 0,title:d,"aria-label":d,role:r?`button`:void 0,tabIndex:r?0:void 0,onClick:r?_:void 0,onFocus:r?_:void 0,onKeyDown:r?e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),_())}:void 0,onMouseEnter:r?void 0:_,onPointerMove:r?()=>o(m):void 0,onPointerLeave:r?a:void 0},e.date)}),Array.from({length:l},(e,t)=>(0,K.jsx)(`span`,{className:`code-usage-daily-spacer`,"aria-hidden":`true`},`trailing-${t}`))]}),r&&v&&(0,K.jsxs)(`label`,{className:`code-usage-mobile-date-picker`,children:[(0,K.jsx)(`span`,{children:`Selected day`}),(0,K.jsx)(`input`,{type:`date`,min:e[0].date,max:_?.date,value:v.date,"data-testid":`code-usage-mobile-date-picker`,onChange:n=>{let r=e.find(e=>e.date===n.currentTarget.value);r&&t({label:r.date,tokens:r.totalTokens})}})]})]})}function xN(e){return e.reduce((e,t)=>e+Number(t.totalTokens),0)}function SN(e,t){if(t<=0)return e>0?`New`:`0%`;let n=Math.round((e-t)/t*100);return`${n>0?`+`:``}${n}%`}function CN(e){let t=gN(e);return t?t.toLocaleDateString([],{month:`short`,day:`numeric`}):e}function wN(e,t){if(!e||typeof e!=`object`)return!1;let n=e;return n.date===t&&Array.isArray(n.hours)&&n.hours.length===24&&n.hours.every((e,t)=>e.hour===t&&Number.isFinite(Number(e.totalTokens))&&e.totalTokens>=0&&!!(e.agents&&typeof e.agents==`object`))&&Array.isArray(n.agents)&&n.agents.every(e=>!!(e.key&&e.label)&&Number.isFinite(Number(e.totalTokens))&&e.totalTokens>=0)}function TN(e,t){let[n,i]=(0,G.useState)(0),[a,o]=(0,G.useState)({date:``,detail:null,error:``,loading:!1});return(0,G.useEffect)(()=>{if(!e){o({date:``,detail:null,error:``,loading:!1});return}let n=new AbortController;o({date:e,detail:null,error:``,loading:!0});let i=new URLSearchParams({date:e});return t&&i.set(`live`,`1`),fetch(r(`/api/usage/day?${i.toString()}`),{signal:n.signal}).then(async t=>{let n=await t.json();if(!t.ok)throw Error(n.error||`Failed to load day activity`);if(!wN(n.detail,e))throw Error(`Day activity response was incomplete`);return n.detail}).then(t=>{n.signal.aborted||o({date:e,detail:t,error:``,loading:!1})}).catch(t=>{n.signal.aborted||o({date:e,detail:null,error:t instanceof Error?t.message:`Failed to load day activity`,loading:!1})}),()=>n.abort()},[e,t,n]),{...a,retry:()=>i(e=>e+1)}}var EN=[`#245f1d`,`#3b782f`,`#548f47`,`#70a766`,`#8dbc86`,`#aacda5`,`#486d42`,`#789473`];function DN(e){let t=0;for(let n of e)t=(t<<5)-t+n.charCodeAt(0)|0;return EN[Math.abs(t)%EN.length]}function ON({date:e,detail:t,error:n,loading:r,onRetry:i}){let[a,o]=(0,G.useState)(null);if((0,G.useEffect)(()=>o(null),[e]),r)return(0,K.jsx)(`div`,{className:`code-usage-day-breakdown loading`,"data-testid":`code-usage-day-histogram-loading`,children:(0,K.jsx)(`div`,{className:`code-usage-day-breakdown-status`,children:`Loading hourly Agent activity…`})});if(n)return(0,K.jsxs)(`div`,{className:`code-usage-day-breakdown error`,"data-testid":`code-usage-day-histogram-error`,children:[(0,K.jsx)(`span`,{children:n}),(0,K.jsx)(`button`,{type:`button`,onClick:i,children:`Retry`})]});if(!t)return null;let s=Math.max(0,...t.hours.map(e=>e.totalTokens)),c=Array.from(t.agents.reduce((e,t)=>{let n=e.get(t.provider);return n?n.totalTokens+=t.totalTokens:e.set(t.provider,{key:t.provider,label:w(t.provider),totalTokens:t.totalTokens}),e},new Map).values()).sort((e,t)=>t.totalTokens-e.totalTokens||e.label.localeCompare(t.label)),l=a?`${a.label} · ${GM(a.tokens)} tokens`:`${CN(t.date)} · ${GM(t.total.totalTokens)} tokens`;return(0,K.jsxs)(`div`,{className:`code-usage-day-breakdown`,"data-testid":`code-usage-day-histogram`,onMouseLeave:()=>o(null),children:[(0,K.jsxs)(`div`,{className:`code-usage-day-breakdown-heading`,children:[(0,K.jsx)(`span`,{children:`Hourly by Agent type`}),(0,K.jsx)(`strong`,{"data-testid":`code-usage-day-histogram-readout`,children:l})]}),(0,K.jsxs)(`div`,{className:`code-usage-day-histogram-chart`,role:`img`,"aria-label":`Hourly token activity for ${t.date}, split across ${c.length} Agent types`,children:[(0,K.jsxs)(`div`,{className:`code-usage-day-histogram-scale`,"aria-hidden":`true`,children:[(0,K.jsx)(`span`,{children:GM(s)}),(0,K.jsx)(`span`,{children:`0`})]}),(0,K.jsxs)(`div`,{className:`code-usage-day-histogram-plot`,children:[(0,K.jsx)(`div`,{className:`code-usage-day-histogram-bars`,children:t.hours.map(e=>{let n=s>0?e.totalTokens/s*100:0;return(0,K.jsx)(`div`,{className:`code-usage-day-histogram-column`,"data-hour":e.hour,title:`${e.label}:00 · ${fN(e.totalTokens)} tokens`,children:(0,K.jsx)(`div`,{className:`code-usage-day-histogram-stack`,style:{height:`${n}%`},children:c.map(n=>{let r=t.agents.reduce((t,r)=>r.provider===n.key?t+(Number(e.agents[r.key]?.totalTokens)||0):t,0);if(r<=0||e.totalTokens<=0)return null;let i=`${e.label}:00 · ${n.label}`,a=`${i} · ${fN(r)} tokens`;return(0,K.jsx)(`span`,{className:`code-usage-day-histogram-segment`,"data-agent-type":n.key,style:{backgroundColor:DN(n.key),height:`${r/e.totalTokens*100}%`},title:a,onMouseEnter:()=>o({label:i,tokens:r})},n.key)})})},e.hour)})}),(0,K.jsxs)(`div`,{className:`code-usage-day-histogram-axis`,"aria-hidden":`true`,children:[(0,K.jsx)(`span`,{children:`00:00`}),(0,K.jsx)(`span`,{children:`06:00`}),(0,K.jsx)(`span`,{children:`12:00`}),(0,K.jsx)(`span`,{children:`18:00`}),(0,K.jsx)(`span`,{children:`23:00`})]})]})]}),c.length>0&&(0,K.jsx)(`div`,{className:`code-usage-day-agent-legend`,"data-testid":`code-usage-day-agent-legend`,children:c.map(e=>(0,K.jsxs)(`span`,{title:`${e.label} · ${fN(e.totalTokens)} tokens`,children:[(0,K.jsx)(`i`,{style:{backgroundColor:DN(e.key)},"aria-hidden":`true`}),(0,K.jsx)(`b`,{children:e.label}),(0,K.jsx)(`small`,{children:GM(e.totalTokens)})]},e.key))})]})}function kN({label:e,value:t,detail:n}){return(0,K.jsxs)(`div`,{className:`code-usage-detail-stat`,children:[(0,K.jsx)(`span`,{children:e}),(0,K.jsx)(`strong`,{children:t}),n&&(0,K.jsx)(`small`,{children:n})]})}function AN({initialRange:e,usageSummary:t,onClose:n}){let[r,i]=(0,G.useState)(e),[a,o]=(0,G.useState)(null),s=hN(t),c=_N(t),l=c?.reduce((e,t)=>!e||t.totalTokens>e.totalTokens?t:e,null)??null,u=c?.[c.length-1]??null,d=c?.find(e=>e.date===a?.label)??null,f=r===`year`&&(d??u)?.date||``,p=TN(f,!!(f&&c&&f===c[c.length-1]?.date));if((0,G.useEffect)(()=>{let e=e=>{e.key===`Escape`&&n()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[n]),typeof document>`u`)return null;let m=s?.reduce((e,t)=>e+t.totalTokens,0)??0,h=s?.filter(e=>e.totalTokens>0).length??0,g=s?.reduce((e,t)=>!e||t.totalTokens>e.totalTokens?t:e,null)??null,_=c?.slice(-7)??[],v=c?.slice(-14,-7)??[],y=xN(_),b=xN(v),x=c?xN(c):0,S=c?.filter(e=>e.totalTokens>0).length??0,C=_.reduce((e,t)=>e+(Number(t.cacheReadTokens)||0)+(Number(t.cacheWriteTokens)||0),0),w=y>0?Math.min(100,Math.round(C/y*100)):0,T=a?`${a.label} · ${fN(a.tokens)} tokens`:`Last 24 hours · ${fN(m)} tokens`,ee=a?`${a.label} · ${fN(a.tokens)} tokens`:`Last 52 weeks · ${fN(x)} tokens`;return(0,Wj.createPortal)((0,K.jsx)(`div`,{className:`code-usage-detail-backdrop`,"data-testid":`code-usage-detail-backdrop`,onMouseDown:e=>{e.target===e.currentTarget&&n()},children:(0,K.jsxs)(`section`,{className:`code-usage-detail-dialog`,"data-testid":`code-usage-detail-dialog`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`code-usage-detail-title`,children:[(0,K.jsxs)(`header`,{className:`code-usage-detail-header`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`span`,{className:`code-usage-detail-eyebrow`,children:`Local provider tokens`}),(0,K.jsx)(`h2`,{id:`code-usage-detail-title`,children:`Usage activity`})]}),(0,K.jsx)(`button`,{type:`button`,className:`code-usage-detail-close`,"aria-label":`Close usage activity`,onClick:n,children:(0,K.jsx)(Fe,{})})]}),(0,K.jsxs)(`div`,{className:`code-usage-detail-tabs`,role:`tablist`,"aria-label":`Usage activity range`,children:[(0,K.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":r===`day`,"data-testid":`code-usage-detail-day-tab`,onClick:()=>{o(null),i(`day`)},children:`1 Day`}),(0,K.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":r===`year`,"data-testid":`code-usage-detail-year-tab`,onClick:()=>{o(null),i(`year`)},children:`52 Weeks`})]}),(0,K.jsxs)(`div`,{className:`code-usage-detail-chart`,onBlur:e=>{e.currentTarget.contains(e.relatedTarget)||o(null)},onMouseLeave:()=>o(null),children:[r===`day`&&s&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{className:`code-usage-detail-chart-heading`,children:[(0,K.jsx)(`span`,{children:`Hourly activity`}),(0,K.jsxs)(`strong`,{children:[GM(m),` tokens`]})]}),(0,K.jsx)(yN,{usageSummary:t,points:s,onInspect:o})]}),r===`year`&&c&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(bN,{points:c,inspection:a,showDayHighlight:!0,onInspect:o}),(0,K.jsx)(ON,{date:f,detail:p.date===f?p.detail:null,error:p.date===f?p.error:``,loading:p.date===f?p.loading:!0,onRetry:p.retry})]}),(0,K.jsx)(`div`,{className:`code-usage-detail-readout`,"data-testid":`code-usage-detail-readout`,children:r===`day`?T:ee})]}),(0,K.jsx)(`div`,{className:`code-usage-detail-analysis`,"data-testid":`code-usage-detail-analysis`,children:r===`day`?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(kN,{label:`24-hour tokens`,value:GM(m)}),(0,K.jsx)(kN,{label:`Active hours`,value:`${h}`,detail:`hours with token activity`}),(0,K.jsx)(kN,{label:`Peak hour`,value:g?dN(g.startedAt):`--`,detail:g?`${GM(g.totalTokens)} tokens`:`no activity`})]}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(kN,{label:`Last 7 days`,value:GM(y)}),(0,K.jsx)(kN,{label:`Previous 7 days`,value:GM(b),detail:`${SN(y,b)} change`}),(0,K.jsx)(kN,{label:`Peak day`,value:l?CN(l.date):`--`,detail:l?`${GM(l.totalTokens)} tokens`:`no activity`}),(0,K.jsx)(kN,{label:`Active days`,value:`${S}`,detail:`within 52 weeks`}),(0,K.jsx)(kN,{label:`7-day cache share`,value:`${w}%`,detail:`read and write tokens`}),(0,K.jsx)(kN,{label:`52-week tokens`,value:GM(x)})]})})]})}),document.body)}function jN({usageSummary:e}){let t=hN(e),n=_N(e),[r,i]=(0,G.useState)(null),[a,o]=(0,G.useState)(null);if(!t&&!n)return null;let s=t?.reduce((e,t)=>e+t.totalTokens,0)??0,c=RM(Number(e.timeline?.windowMs)/6e4).toLowerCase(),l=n?.slice(-7).reduce((e,t)=>e+t.totalTokens,0)??0,u=n?.reduce((e,t)=>e+t.totalTokens,0)??0,d=`${r?`${r.label} · ${fN(r.tokens)} tokens`:`${t?`${c} ${GM(s)}`:``}${t&&n?` · `:``}${n?`7d ${GM(l)} · 52w ${GM(u)}`:``}`}${e.daily?.syncing===!0?` · syncing history`:``}`;return(0,K.jsxs)(`div`,{className:`code-usage-activity`,onMouseLeave:()=>i(null),children:[t&&(0,K.jsxs)(`button`,{type:`button`,className:`code-usage-chart-trigger`,"data-testid":`code-usage-open-day`,title:`Open 1-day usage details`,onClick:()=>o(`day`),children:[(0,K.jsxs)(`div`,{className:`code-usage-activity-heading`,children:[(0,K.jsxs)(`span`,{children:[c,` · activity`]}),(0,K.jsxs)(`span`,{children:[RM(e.timeline.bucketMs/6e4).toLowerCase(),` buckets`]})]}),(0,K.jsx)(yN,{usageSummary:e,points:t,onInspect:i})]}),n&&(0,K.jsx)(`button`,{type:`button`,className:`code-usage-chart-trigger`,"data-testid":`code-usage-open-year`,title:`Open 52-week usage details`,onClick:()=>o(`year`),children:(0,K.jsx)(bN,{points:n,onInspect:i})}),(0,K.jsx)(`div`,{className:`code-usage-activity-readout`,"data-testid":`code-usage-activity-readout`,title:d,children:d}),a&&(0,K.jsx)(AN,{initialRange:a,usageSummary:e,onClose:()=>o(null)})]})}function MN({collapsed:e,mainAgent:t,now:n,usageSummary:r,onToggleCollapsed:i,onOpenMainAgent:a,onRestartMainAgent:o}){let s=YM(r),c=XM(r),[l,d]=(0,G.useState)(!1),[f,p]=(0,G.useState)(!1),m=r&&_N(r)?`year`:r&&hN(r)?`day`:null;return(0,K.jsxs)(`div`,{className:`code-usage-panel ${e?`collapsed`:``} ${m?``:`mobile-unavailable`}`,"data-testid":`code-usage-panel`,children:[m&&(0,K.jsxs)(`button`,{type:`button`,className:`code-usage-mobile-open`,"data-testid":`code-mobile-usage-open`,onClick:()=>p(!0),children:[(0,K.jsx)(`span`,{children:`Usage activity`}),(0,K.jsxs)(`span`,{children:[m===`year`?`52 Weeks`:`1 Day`,(0,K.jsx)(Ee,{})]})]}),(0,K.jsxs)(`button`,{type:`button`,className:`code-usage-header`,"data-testid":`code-usage-toggle`,"aria-expanded":!e,title:`Provider local token usage refreshes periodically.`,onClick:i,children:[(0,K.jsxs)(`span`,{className:`code-usage-title`,children:[(0,K.jsx)(`span`,{className:`code-usage-chevron ${e?`collapsed`:`expanded`}`,"aria-hidden":`true`,children:e?(0,K.jsx)(Ee,{}):(0,K.jsx)(Me,{})}),(0,K.jsx)(`span`,{children:`Usage`})]}),(0,K.jsx)(`span`,{className:`code-usage-header-meta`,children:e?(0,K.jsx)(sN,{usageSummary:r,now:n}):(0,K.jsx)(`span`,{className:`code-usage-summary`,"data-testid":`code-usage-summary`,title:`5-minute rate · hourly and daily activity`,children:`5m rate · activity`})})]}),!e&&(0,K.jsxs)(K.Fragment,{children:[s.length>0&&r?.timeline&&(0,K.jsx)(jN,{usageSummary:r}),t&&(0,K.jsxs)(`div`,{className:`code-usage-main-agent-block`,children:[(0,K.jsxs)(`div`,{className:`code-usage-row code-usage-main-agent`,title:`${u(t)} · ${t.command} · ${t.cwd}`,"data-testid":`code-main-agent-usage-row`,children:[(0,K.jsxs)(`button`,{type:`button`,className:`code-usage-main-agent-open`,"data-testid":`code-main-agent-open`,onClick:a,children:[(0,K.jsx)(`span`,{children:`Main Agent`}),(0,K.jsx)(`strong`,{children:aN(t)})]}),(0,K.jsx)(`button`,{type:`button`,className:`code-usage-main-agent-restart`,"data-testid":`code-main-agent-restart`,"aria-expanded":l,onClick:()=>d(e=>!e),children:`Restart`})]}),l&&(0,K.jsx)(`div`,{className:`code-main-agent-restart-menu`,"data-testid":`code-main-agent-restart-menu`,role:`menu`,children:[[`codex`,`Codex`],[`claude`,`Claude Code`],[`opencode`,`OpenCode`],[`qoder`,`Qoder`],[`bash`,`bash`],[`zsh`,`zsh`]].map(([e,t])=>(0,K.jsx)(`button`,{type:`button`,role:`menuitem`,"data-testid":`code-main-agent-restart-${e}`,onClick:()=>{d(!1),o(e)},children:t},e))})]}),s.map(e=>(0,K.jsx)(NN,{provider:e},e.provider)),s.length>1&&c!==null&&(0,K.jsxs)(`div`,{className:`code-usage-row`,title:`Sum of local token usage reported by providers.`,children:[(0,K.jsx)(`span`,{children:`Total local tokens`}),(0,K.jsx)(`strong`,{children:KM(c)})]}),(0,K.jsx)(cN,{usageSummary:r})]}),f&&m&&r&&(0,K.jsx)(AN,{initialRange:m,usageSummary:r,onClose:()=>p(!1)})]})}function NN({provider:e}){let t=e.quota.primary??null,n=e.quota.secondary??null,r=e.quota.available?e.quota.source:e.quota.reason||e.quota.source;return(0,K.jsxs)(`div`,{className:`code-usage-provider`,children:[(0,K.jsxs)(`div`,{className:`code-usage-row`,children:[(0,K.jsx)(`span`,{children:e.providerName}),(0,K.jsx)(`strong`,{title:e.auth?.status,children:qM(e)})]}),e.quota.available&&(0,K.jsxs)(K.Fragment,{children:[t&&(0,K.jsxs)(`div`,{className:`code-usage-row code-usage-subrow`,title:UM(r,t),children:[(0,K.jsx)(`span`,{children:RM(t.windowMinutes)}),(0,K.jsx)(`strong`,{children:HM(t)})]}),n&&(0,K.jsxs)(`div`,{className:`code-usage-row code-usage-subrow`,title:UM(r,n),children:[(0,K.jsx)(`span`,{children:RM(n.windowMinutes)}),(0,K.jsx)(`strong`,{children:HM(n)})]})]}),(0,K.jsxs)(`div`,{className:`code-usage-row code-usage-subrow`,title:e.tokenUsage.source,children:[(0,K.jsx)(`span`,{children:`Local tokens`}),(0,K.jsx)(`strong`,{children:KM(e.tokenUsage.tokensPerMinute)})]})]})}function PN({items:e,activeTerminalId:t,now:n,onOpenAgent:r,onShowPreview:i,onHidePreview:a,copy:o}){return(0,K.jsx)(`div`,{className:`code-agent-rail`,"data-testid":`code-agent-rail`,"aria-label":o.projectsAndAgents,children:e.map((e,o)=>(0,K.jsx)(FN,{item:e,index:o,activeTerminalId:t,now:n,onOpenAgent:r,onShowPreview:i,onHidePreview:a},oA({kind:`agent`,agent:e.agent})))})}function FN({item:e,index:t,activeTerminalId:n,now:r,onOpenAgent:i,onShowPreview:a,onHidePreview:o}){let s=_A({kind:`agent`,agent:e.agent},r),c=e.agent.id===n,l=[s.title,s.commandTitle,e.projectName].filter(Boolean).join(` · `);return(0,K.jsxs)(`button`,{type:`button`,className:`code-agent-rail-button ${c?`active`:``} ${s.unread?`unread`:``}`,"data-testid":`code-agent-rail-item`,"data-agent-id":e.agent.id,"aria-label":l,onClick:()=>{i(e.agent.id)},onMouseEnter:t=>a(t,JN(e.agent,s,e.projectName),!0),onMouseLeave:o,children:[(0,K.jsx)(`span`,{className:`code-agent-rail-label`,children:t+1}),s.statusIndicatorVisible&&(0,K.jsx)(`span`,{className:`code-agent-rail-status ${s.lifecycleStatus} ${s.turnActive?`turn-active`:``}`,"aria-hidden":`true`}),s.unread&&(0,K.jsx)(`span`,{className:`code-agent-rail-unread`,"aria-hidden":`true`})]})}function IN({agents:e,activeTerminalId:t,selectedSearchAgentId:n,claimedAgentSessionKeyByAgentId:r,now:i,onOpenAgent:a,onOpenAgentContextMenu:o,onOpenAgentKeyboardMenu:s,onShowPreview:c,onHidePreview:l}){return(0,K.jsx)(`div`,{className:`code-project-agent-strip`,"data-testid":`code-project-agent-strip`,"aria-label":`Project agents`,children:e.map((e,u)=>{let d=_A({kind:`agent`,agent:e},i),f=e.id===t,p=e.id===n,m=d.rowTitle||d.title;return(0,K.jsxs)(`button`,{type:`button`,className:`code-project-agent-compact ${f?`active`:``} ${p?`search-selected`:``} ${d.unread?`unread`:``}`,"data-testid":`code-project-agent-compact`,"data-agent-id":e.id,"aria-label":m,onClick:()=>a(e.id),onMouseEnter:t=>c(t,JN(e,d),!0),onMouseLeave:l,onContextMenu:t=>o(t,e.id),onKeyDown:t=>{s(t,e.id),!t.defaultPrevented&&(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),a(e.id))},children:[(0,K.jsx)(`span`,{className:`code-project-agent-compact-label`,children:u+1}),d.statusIndicatorVisible&&(0,K.jsx)(`span`,{className:`code-project-agent-compact-status ${d.lifecycleStatus} ${d.turnActive?`turn-active`:``}`,"aria-hidden":`true`}),d.unread&&(0,K.jsx)(`span`,{className:`code-project-agent-compact-unread`,"aria-hidden":`true`})]},oA({kind:`agent`,agent:e,claimedSessionKey:r.get(e.id)}))})})}function LN({items:e,activeTerminalId:t,selectedSearchAgentId:n,selectedSearchSessionHandle:r,claimedAgentSessionKeyByAgentId:i,now:a,onOpenAgent:o,onOpenAgentContextMenu:s,onOpenAgentKeyboardMenu:c,onResumeAgentSession:l,onOpenAgentSessionContextMenu:u,onOpenAgentSessionKeyboardMenu:d,onShowPreview:f,onHidePreview:p}){return(0,K.jsx)(`div`,{className:`code-project-agent-strip code-pinned-agent-strip`,"data-testid":`code-pinned-agent-strip`,"aria-label":`Pinned agents`,children:e.map((e,m)=>{let h=e.kind===`agent`?_A({kind:`agent`,agent:e.agent},a):_A({kind:`history`,session:e.session,fallbackTitle:e.session.providerName||e.session.provider||`Agent`},a),g=e.kind===`agent`?e.agent:null,_=e.kind===`agent`?null:e.session,v=_?ZD(_):null,y=g?g.id===t:!1,b=g?g.id===n:v===r,x=h.rowTitle||h.title;return(0,K.jsxs)(`button`,{type:`button`,className:`code-project-agent-compact ${y?`active`:``} ${b?`search-selected`:``} ${h.unread?`unread`:``}`,"data-testid":`code-pinned-agent-compact`,"data-agent-id":g?.id,"data-session-id":v??void 0,"aria-label":x,onClick:()=>{if(g){o(g.id);return}_&&l(_.provider,_.id,_.providerHomeId)},onMouseEnter:e=>f(e,g?JN(g,h):YN(_,h),!0),onMouseLeave:p,onContextMenu:e=>{if(g){s(e,g.id);return}_&&u(e,_.provider,ZD(_))},onKeyDown:e=>{g?c(e,g.id):_&&d(e,_.provider,ZD(_)),!e.defaultPrevented&&(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),g?o(g.id):_&&l(_.provider,_.id,_.providerHomeId))},children:[(0,K.jsx)(`span`,{className:`code-project-agent-compact-label`,children:m+1}),h.statusIndicatorVisible&&(0,K.jsx)(`span`,{className:`code-project-agent-compact-status ${h.lifecycleStatus} ${h.turnActive?`turn-active`:``}`,"aria-hidden":`true`}),h.unread&&(0,K.jsx)(`span`,{className:`code-project-agent-compact-unread`,"aria-hidden":`true`})]},e.kind===`agent`?oA({kind:`agent`,agent:e.agent,claimedSessionKey:i.get(e.agent.id)}):oA({kind:`history`,session:e.session}))})})}function RN({items:e,collapsed:t,compressed:n,activeTerminalId:r,selectedSearchAgentId:i,selectedSearchSessionHandle:a,claimedAgentSessionKeyByAgentId:o,agentShortcutKeys:s,keyboardShortcutsEnabled:c,now:l,onOpenAgent:u,onUpdateAgentFlags:d,onReorderAgent:f,onOpenAgentContextMenu:p,onOpenAgentKeyboardMenu:m,onResumeAgentSession:h,onOpenAgentSessionContextMenu:g,onOpenAgentSessionKeyboardMenu:_,onShowAgentPreview:v,onHideAgentPreview:y,onToggleCollapsed:b,copy:x}){let S=e.flatMap(e=>e.kind===`agent`?[e.agent]:[]),[C,w]=(0,G.useState)(null),T=(e,t)=>{e.dataTransfer.effectAllowed=`move`,e.dataTransfer.setData(`text/plain`,t),y(),w({agentId:t,targetAgentId:``,position:`before`})},ee=(e,t)=>{if(!C||C.agentId===t)return;e.preventDefault(),e.dataTransfer.dropEffect=`move`;let n=e.currentTarget.getBoundingClientRect(),r=e.clientY<n.top+n.height/2?`before`:`after`;C.targetAgentId===t&&C.position===r||w(e=>e?{...e,targetAgentId:t,position:r}:null)},E=()=>w(null),D=(e,t)=>{if(e.preventDefault(),!C||C.agentId===t){E();return}let n=S.filter(e=>e.id!==C.agentId),r=n.findIndex(e=>e.id===t);if(r<0){E();return}let i=C.position===`before`?r:r+1;f(C.agentId,i>0?n[i-1]?.id??``:``,i<n.length?n[i]?.id??``:``),E()};return(0,K.jsxs)(`section`,{className:`code-pinned-section ${t?`collapsed`:``}`,"data-testid":`code-pinned-section`,children:[(0,K.jsxs)(`button`,{type:`button`,className:`code-pinned-title`,"data-testid":`code-pinned-title`,"aria-expanded":!t,onClick:b,children:[(0,K.jsx)(`span`,{className:`code-folder-icon ${t?`collapsed`:`expanded`}`,"aria-hidden":`true`,children:t?(0,K.jsx)(Ee,{}):(0,K.jsx)(Me,{})}),(0,K.jsx)(`span`,{children:x.pinned})]}),!t&&(0,K.jsx)(`div`,{className:`code-agent-list code-pinned-list`,children:n?(0,K.jsx)(LN,{items:e,activeTerminalId:r,selectedSearchAgentId:i,selectedSearchSessionHandle:a,claimedAgentSessionKeyByAgentId:o,now:l,onOpenAgent:u,onOpenAgentContextMenu:p,onOpenAgentKeyboardMenu:m,onResumeAgentSession:h,onOpenAgentSessionContextMenu:g,onOpenAgentSessionKeyboardMenu:_,onShowPreview:v,onHidePreview:y}):e.map(e=>{if(e.kind===`agent`){let t=e.agent;return(0,K.jsx)(rP,{agent:t,shortcutHint:c?s.get(t.id):void 0,active:t.id===r,searchSelected:t.id===i,now:l,onOpenAgent:u,onUpdateAgentFlags:d,reorderable:!0,dragging:C?.agentId===t.id,dropPosition:C?.targetAgentId===t.id?C.position:void 0,onAgentDragStart:T,onAgentDragEnd:E,onAgentDragOver:ee,onAgentDrop:D,onOpenAgentContextMenu:p,onOpenAgentKeyboardMenu:m,onShowPreview:v,onHidePreview:y,copy:x},oA({kind:`agent`,agent:t,claimedSessionKey:o.get(t.id)}))}return(0,K.jsx)(rP,{session:e.session,searchSelected:ZD(e.session)===a,now:l,onResume:h,onOpenSessionContextMenu:g,onOpenSessionKeyboardMenu:_,onShowPreview:v,onHidePreview:y,copy:x},oA({kind:`history`,session:e.session}))})})]})}function zN(e,t){return e.branch?e.branch:e.detached?`${t.worktreeDetached}@${e.head.slice(0,7)}`:e.bare?`bare`:e.head.slice(0,7)}function BN({agentId:e,anchorRef:t,copy:n,fallback:r,point:i,onClose:a,onMountProject:o}){let s=(0,G.useRef)(null),c=(0,G.useRef)(null),[l,u]=(0,G.useState)(r),[d,f]=(0,G.useState)(!1),[p,m]=(0,G.useState)(``),h=(0,G.useCallback)(()=>{c.current?.abort();let t=new AbortController;c.current=t,f(!0),m(``),se(e,{signal:t.signal}).then(e=>{t.signal.aborted||u(e)}).catch(e=>{t.signal.aborted||e?.name===`AbortError`||m(n.worktreeLoadFailed)}).finally(()=>{t.signal.aborted||f(!1)})},[e,n.worktreeLoadFailed]);return(0,G.useEffect)(()=>(h(),()=>c.current?.abort()),[h]),(0,G.useEffect)(()=>{let e=e=>{let n=e.target;n&&(s.current?.contains(n)||t.current?.contains(n))||a()},n=e=>{e.key===`Escape`&&(e.preventDefault(),a(),t.current?.focus())};return window.addEventListener(`pointerdown`,e,!0),window.addEventListener(`keydown`,n,!0),()=>{window.removeEventListener(`pointerdown`,e,!0),window.removeEventListener(`keydown`,n,!0)}},[t,a]),(0,K.jsxs)(`div`,{ref:s,className:`code-worktree-popover`,"data-testid":`code-project-worktree-menu`,role:`dialog`,"aria-label":n.worktrees,style:{left:i.x,top:i.y},children:[(0,K.jsxs)(`div`,{className:`code-worktree-popover-header`,children:[(0,K.jsx)(`span`,{children:n.worktrees}),(0,K.jsx)(`span`,{className:`code-worktree-popover-count`,children:l.items.length}),(0,K.jsx)(`button`,{type:`button`,className:d?`loading`:``,disabled:d,onClick:h,children:n.refresh})]}),p&&(0,K.jsx)(`div`,{className:`code-worktree-popover-status error`,children:p}),!p&&!l.isGitRepo&&(0,K.jsx)(`div`,{className:`code-worktree-popover-status`,children:n.gitHistoryNotRepository}),(0,K.jsx)(`div`,{className:`code-worktree-list`,children:l.items.map(e=>(0,K.jsxs)(`button`,{type:`button`,className:`code-worktree-row ${e.current?`current`:``}`,"data-current":e.current?`true`:void 0,"data-main":e.main?`true`:void 0,title:e.workspace,onClick:()=>{o(e.workspace),a()},children:[(0,K.jsx)(`span`,{className:`code-worktree-row-marker`,"aria-hidden":`true`}),(0,K.jsxs)(`span`,{className:`code-worktree-row-content`,children:[(0,K.jsxs)(`span`,{className:`code-worktree-row-heading`,children:[(0,K.jsx)(`strong`,{children:zN(e,n)}),(0,K.jsxs)(`span`,{className:`code-worktree-row-badges`,children:[e.current&&(0,K.jsx)(`span`,{children:n.worktreeCurrent}),e.main&&(0,K.jsx)(`span`,{children:n.worktreeMain}),e.locked&&(0,K.jsx)(`span`,{title:e.lockReason,children:n.worktreeLocked}),e.prunable&&(0,K.jsx)(`span`,{title:e.pruneReason,children:n.worktreePrunable})]}),e.head&&(0,K.jsx)(`code`,{children:e.head.slice(0,7)})]}),(0,K.jsx)(`span`,{className:`code-worktree-row-path`,children:e.workspace})]})]},e.workspace))})]})}function VN(e){return e?.workspace?{isGitRepo:!0,commonDir:e.commonDir,currentWorkspace:e.workspace,mainWorkspace:e.mainWorkspace,items:Array.isArray(e.worktrees)?e.worktrees:[]}:null}function HN({project:e,collapsed:t,forceAgentsExpanded:n,compactAgents:r,activeTerminalId:i,selectedSearchAgentId:a,selectedSearchSessionHandle:o,claimedAgentSessionKeyByAgentId:s,agentShortcutKeys:l,keyboardShortcutsEnabled:u,now:d,openWorkspaceFile:f,openWorkspaceFiles:p,agentLaunchOptions:m,fileRevealRequest:h,fileSearchFocusRequest:g,onToggleProject:_,onToggleProjectSessions:v,onMountProject:y,onNewAgent:b,onStartAgent:x,onOpenProjectContextMenu:S,onOpenProjectKeyboardMenu:C,onOpenAgent:T,onUpdateAgentFlags:ee,onReorderAgent:E,onOpenAgentContextMenu:D,onOpenAgentKeyboardMenu:O,onResumeAgentSession:k,onOpenAgentSessionContextMenu:A,onOpenAgentSessionKeyboardMenu:j,onShowAgentPreview:M,onHideAgentPreview:N,onOpenProjectFile:P,onSelectOpenWorkspaceFile:te,onCloseOpenWorkspaceFile:F,onMoveWorkspaceEntries:ne,onDeleteWorkspaceEntries:I,onRefreshProjectOpenFiles:L,copy:R}){let B=(0,G.useRef)(null),V=(0,G.useRef)(null),re=(0,G.useRef)(null),ie=(0,G.useRef)(null),H=(0,G.useRef)(null),ae=(0,G.useRef)(null),[oe,le]=(0,G.useState)(null),[ue,de]=(0,G.useState)(null),[fe,pe]=(0,G.useState)(()=>VN(e.gitWorktree)),[me,he]=(0,G.useState)(!1),[ge,_e]=(0,G.useState)(!1),[ve,ye]=(0,G.useState)(!1),[be,xe]=(0,G.useState)(null),[Se,Ce]=(0,G.useState)(()=>CM(null,e.agents)),we=CM((i&&e.agents.some(e=>!e.isMain&&e.id===i)?i:null)??Se,e.agents),U=e.agents.find(e=>!e.isMain&&e.id===we)??null,Te=e.workspace?Un(e.workspace):``,De=e.id!==`__farming_main_agent__`&&!!Te,Oe=new Set([Te,...e.agents.filter(e=>!e.isMain).map(e=>e.id),...U&&!U.isMain?[U.id]:[]]),ke=t=>t.workspaceRoot===e.workspace||Oe.has(t.agentId),Ae=f&&ke(f)?f:null,je=p.filter(ke),W=new Set(je.filter(e=>e.dirty).map(e=>e.file.path)),Ne=new Set(je.filter(e=>e.externalChanged).map(e=>e.file.path)),Pe=e.agents.filter(e=>!e.pinned),Fe=e.agentSessions.filter(e=>!e.pinned),Ie=Pe.length>0||Fe.length>0||(e.hiddenAgentSessionCount??0)>0,Le=ve&&ce()&&Pe.length>1,Re=(r||Le)&&Pe.length>0,ze=Re||me?Pe:KN(Pe,kM,[i,a]),Be=Math.max(0,Pe.length-ze.length),Ve=ge&&!n;(0,G.useEffect)(()=>{Se!==we&&Ce(we)},[we,Se]),(0,G.useEffect)(()=>{let t=VN(e.gitWorktree);t&&pe(t)},[e.gitWorktree]),(0,G.useEffect)(()=>{if(!Te)return;let e=new AbortController;return se(Te,{signal:e.signal}).then(pe).catch(()=>{}),()=>e.abort()},[Te]);let He=(0,G.useCallback)(e=>!U?.id||e?.sourceAgentId?e:{...e,sourceAgentId:U.id},[U?.id]),Ue=(0,G.useCallback)((e,t,n)=>{P(e,t,He(n))},[P,He]),We=(0,G.useCallback)((e,t,n)=>te(e,t,He(n)),[te,He]),Ge=(0,G.useCallback)(e=>{ye(!e)},[]),Ke=(e,t)=>{e.dataTransfer.effectAllowed=`move`,e.dataTransfer.setData(`text/plain`,t),N(),xe({agentId:t,targetAgentId:``,position:`before`})},qe=(e,t)=>{if(!be||be.agentId===t)return;e.preventDefault(),e.dataTransfer.dropEffect=`move`;let n=e.currentTarget.getBoundingClientRect(),r=e.clientY<n.top+n.height/2?`before`:`after`;be.targetAgentId===t&&be.position===r||xe(e=>e?{...e,targetAgentId:t,position:r}:null)},Je=()=>xe(null),Ye=(e,t)=>{if(e.preventDefault(),!be||be.agentId===t){Je();return}let n=Pe.filter(e=>e.id!==be.agentId),r=n.findIndex(e=>e.id===t);if(r<0){Je();return}let i=be.position===`before`?r:r+1;E(be.agentId,i>0?n[i-1]?.id??``:``,i<n.length?n[i]?.id??``:``),Je()},Xe=e=>{if(e.preventDefault(),!be)return;let t=Pe.filter(e=>e.id!==be.agentId);E(be.agentId,t[t.length-1]?.id??``,``),Je()},Ze=e=>{be&&(e.preventDefault(),e.dataTransfer.dropEffect=`move`,be.targetAgentId!==AM&&xe(e=>e?{...e,targetAgentId:AM,position:`after`}:null))};(0,G.useEffect)(()=>{Pe.length<=kM&&me&&he(!1)},[me,Pe.length]),(0,G.useLayoutEffect)(()=>{let e=B.current;if(!e)return;let t=()=>{let t=V.current;e.style.setProperty(`--code-project-sticky-height`,t?`${Math.ceil(t.getBoundingClientRect().height)}px`:``);let n=re.current;e.style.setProperty(`--code-agents-sticky-height`,n?`${Math.ceil(n.getBoundingClientRect().height)}px`:`0px`)};t();let n=V.current,r=re.current,i=typeof ResizeObserver<`u`?new ResizeObserver(t):null;return n&&i?.observe(n),r&&i?.observe(r),window.addEventListener(`resize`,t),()=>{i?.disconnect(),window.removeEventListener(`resize`,t)}},[t,e.id,Ie]),(0,G.useEffect)(()=>{if(!oe)return;let e=e=>{let t=e.target;t&&(H.current?.contains(t)||ie.current?.contains(t))||le(null)},t=e=>{e.key===`Escape`&&(e.preventDefault(),le(null),ie.current?.focus())};return window.addEventListener(`pointerdown`,e,!0),window.addEventListener(`keydown`,t,!0),()=>{window.removeEventListener(`pointerdown`,e,!0),window.removeEventListener(`keydown`,t,!0)}},[oe]);let Qe=t=>{if(t.preventDefault(),t.stopPropagation(),m.length===0){b(e.workspace,void 0,t.currentTarget);return}let n=t.currentTarget.getBoundingClientRect(),r=Math.min(260,m.length*34+12);le(ce()?iM(n,r,void 0,160):rM(n,r,void 0,160))},$e=t=>{le(null),x(t,e.workspace)},et=fe?.items.find(e=>e.current),tt=fe?.isGitRepo&&et&&et?et.branch||`detached@${et.head.slice(0,7)}`:``,nt=fe?.items.length||0;return(0,K.jsxs)(`section`,{ref:B,className:`code-project-group`,"data-testid":`code-project-group`,children:[(0,K.jsxs)(`div`,{ref:V,className:`code-project-row`,children:[(0,K.jsxs)(`span`,{className:`code-project-title-content`,children:[(0,K.jsxs)(`button`,{type:`button`,className:`code-project-title`,"data-testid":`code-project-title`,"data-project-id":e.id,"aria-expanded":!t,onClick:()=>_(e.id),onContextMenu:t=>S(t,e.id),onKeyDown:t=>C(t,e.id),children:[(0,K.jsx)(`span`,{className:`code-folder-icon ${t?`collapsed`:`expanded`}`,"aria-hidden":`true`,children:t?(0,K.jsx)(Ee,{}):(0,K.jsx)(Me,{})}),(0,K.jsx)(`span`,{className:`code-project-title-name`,children:e.name})]}),tt&&fe&&(0,K.jsxs)(`button`,{ref:ae,type:`button`,className:`code-project-worktree`,"data-testid":`code-project-worktree`,title:`${tt} · ${nt} ${R.worktrees.toLocaleLowerCase()} · ${R.showWorktrees}`,"aria-label":`${tt} · ${nt} ${R.worktrees}`,"aria-haspopup":`dialog`,"aria-expanded":ue?!0:void 0,onClick:e=>{e.preventDefault(),e.stopPropagation();let t=e.currentTarget.getBoundingClientRect(),n=Math.min(440,Math.max(320,window.innerWidth-24)),r=Math.min(420,Math.max(132,(fe?.items.length||2)*58+54));de(ce()?iM(t,r,void 0,n):rM(t,r,void 0,n))},children:[(0,K.jsx)(`span`,{className:`code-project-worktree-icon`,"aria-hidden":`true`,children:(0,K.jsx)(PM,{})}),(0,K.jsx)(`span`,{className:`code-project-worktree-name`,children:tt}),nt>1&&(0,K.jsx)(`span`,{className:`code-project-worktree-count`,"aria-hidden":`true`,children:nt})]})]}),(0,K.jsxs)(`span`,{className:`code-project-title-actions`,"aria-hidden":!1,children:[Ie&&!n&&(0,K.jsx)(`button`,{type:`button`,className:`code-project-title-action`,"data-testid":`code-project-agent-visibility`,"data-collapsed":Ve?`true`:`false`,"aria-expanded":!Ve,"aria-label":Ve?R.showAgents:R.hideAgents,title:Ve?R.showAgents:R.hideAgents,onClick:()=>_e(e=>!e),children:Ve?(0,K.jsx)(WN,{}):(0,K.jsx)(GN,{})}),(0,K.jsx)(`button`,{type:`button`,className:`code-project-title-action`,"data-testid":`code-project-actions`,"aria-label":R.openOptions,title:R.openOptions,onClick:t=>S(t,e.id),children:(0,K.jsx)(qN,{})}),(0,K.jsx)(`button`,{ref:ie,type:`button`,className:`code-project-title-action`,"data-testid":`code-project-new-agent`,"aria-label":R.newAgent,title:R.newAgent,"aria-haspopup":`menu`,"aria-expanded":oe?!0:void 0,onClick:Qe,children:(0,K.jsx)(UN,{})})]}),oe&&typeof document<`u`&&(0,Wj.createPortal)((0,K.jsx)(`div`,{ref:H,className:`code-context-menu code-project-launch-menu`,"data-testid":`code-project-new-agent-menu`,role:`menu`,style:{left:oe.x,top:oe.y},children:m.map(e=>(0,K.jsxs)(`button`,{type:`button`,role:`menuitem`,"data-testid":`code-project-agent-launch-${e.name}`,onClick:()=>$e(e.command||e.name),children:[(0,K.jsx)(c,{name:e.name}),(0,K.jsx)(`span`,{children:w(e.name)})]},e.name))}),document.body),ue&&fe&&typeof document<`u`&&(0,Wj.createPortal)((0,K.jsx)(BN,{agentId:Te,anchorRef:ae,copy:R,fallback:fe,point:ue,onClose:()=>de(null),onMountProject:y}),document.body)]}),!t&&(0,K.jsxs)(`div`,{className:`code-project-expanded`,children:[Ie&&(0,K.jsx)(`div`,{ref:re,className:`code-agents-section`,"data-testid":`code-agents-section`,"data-project-id":e.id,children:(0,K.jsxs)(`div`,{className:`code-agent-list`,children:[!Ve&&(0,K.jsxs)(K.Fragment,{children:[Re?(0,K.jsx)(IN,{agents:Pe,activeTerminalId:i,selectedSearchAgentId:a,claimedAgentSessionKeyByAgentId:s,now:d,onOpenAgent:T,onOpenAgentContextMenu:D,onOpenAgentKeyboardMenu:O,onShowPreview:M,onHidePreview:N}):ze.map(e=>(0,K.jsx)(rP,{agent:e,shortcutHint:u?l.get(e.id):void 0,active:e.id===i,searchSelected:e.id===a,now:d,onOpenAgent:T,onUpdateAgentFlags:ee,reorderable:!0,dragging:be?.agentId===e.id,dropPosition:be?.targetAgentId===e.id?be.position:void 0,onAgentDragStart:Ke,onAgentDragEnd:Je,onAgentDragOver:qe,onAgentDrop:Ye,onOpenAgentContextMenu:D,onOpenAgentKeyboardMenu:O,onShowPreview:M,onHidePreview:N,copy:R},oA({kind:`agent`,agent:e,claimedSessionKey:s.get(e.id)}))),Fe.map(e=>(0,K.jsx)(rP,{session:e,searchSelected:ZD(e)===o,now:d,onResume:k,onOpenSessionContextMenu:A,onOpenSessionKeyboardMenu:j,onShowPreview:M,onHidePreview:N,copy:R},oA({kind:`history`,session:e}))),(e.hiddenAgentSessionCount??0)>0&&(0,K.jsxs)(`button`,{type:`button`,className:`code-agent-row code-session-show-more`,"data-testid":`code-session-show-more`,onClick:()=>v(e.id),children:[(0,K.jsx)(`span`,{className:`code-agent-row-copy`,children:(0,K.jsx)(`span`,{className:`code-agent-name`,children:R.showMore})}),(0,K.jsx)(`span`,{className:`code-agent-row-trailing`,children:(0,K.jsx)(`span`,{className:`code-agent-age`,children:e.hiddenAgentSessionCount})})]}),e.agentSessionsExpanded&&e.agentSessions.length>OM&&(0,K.jsx)(`button`,{type:`button`,className:`code-agent-row code-session-show-more`,"data-testid":`code-session-show-less`,onClick:()=>v(e.id),children:(0,K.jsx)(`span`,{className:`code-agent-row-copy`,children:(0,K.jsx)(`span`,{className:`code-agent-name`,children:R.showLess})})})]}),!n&&!Ve&&!Re&&Pe.length>kM&&(0,K.jsxs)(`div`,{className:`code-agent-list-controls`,"data-testid":`code-agent-list-controls`,children:[Be>0&&(0,K.jsxs)(`button`,{type:`button`,className:`code-agent-row code-session-show-more ${be?.targetAgentId===AM?`drop-after`:``}`,"data-testid":`code-agent-show-more`,onClick:()=>he(!0),onDragOver:Ze,onDrop:Xe,children:[(0,K.jsx)(`span`,{className:`code-agent-row-copy`,children:(0,K.jsx)(`span`,{className:`code-agent-name`,children:R.showMore})}),(0,K.jsx)(`span`,{className:`code-agent-row-trailing`,children:(0,K.jsx)(`span`,{className:`code-agent-age`,children:Be})})]}),me&&(0,K.jsx)(`button`,{type:`button`,className:`code-agent-row code-session-show-more`,"data-testid":`code-agent-show-less`,onClick:()=>he(!1),children:(0,K.jsx)(`span`,{className:`code-agent-row-copy`,children:(0,K.jsx)(`span`,{className:`code-agent-name`,children:R.showLess})})})]})]})}),De&&(0,K.jsx)(G.Suspense,{fallback:null,children:(0,K.jsx)(IM,{projectId:e.id,projectWorkspace:e.workspace,agentId:Te,agentLaunchOptions:m,activeFilePath:Ae?.file.path,openFiles:je.map(e=>({agentId:e.agentId,workspaceRoot:e.workspaceRoot,key:z(e),path:e.file.path,dirty:e.dirty,externalChanged:e.externalChanged})),revealRequest:h&&Oe.has(h.agentId)?h:void 0,focusSearchRequest:g&&Oe.has(g.agentId)?g:void 0,editorDirtyFilePaths:W,editorExternalChangedFilePaths:Ne,onOpenFile:Ue,onSelectOpenFile:We,onCloseOpenFile:F,onNewAgent:b,onStartAgent:x,onMoveEntries:ne,onDeleteEntries:I,onRefreshOpenFiles:L,onFilesCollapsedChange:Ge,copy:R})})]})]})}function UN(){return(0,K.jsx)(`svg`,{width:`16`,height:`16`,viewBox:`0 0 16 16`,"aria-hidden":`true`,focusable:`false`,children:(0,K.jsx)(`path`,{fill:`currentColor`,d:`M7.5 3C7.77614 3 8 3.22386 8 3.5V7H11.5C11.7761 7 12 7.22386 12 7.5C12 7.77614 11.7761 8 11.5 8H8V11.5C8 11.7761 7.77614 12 7.5 12C7.22386 12 7 11.7761 7 11.5V8H3.5C3.22386 8 3 7.77614 3 7.5C3 7.22386 3.22386 7 3.5 7H7V3.5C7 3.22386 7.22386 3 7.5 3Z`})})}function WN(){return(0,K.jsx)(`svg`,{width:`16`,height:`16`,viewBox:`0 0 16 16`,fill:`currentColor`,"aria-hidden":`true`,focusable:`false`,children:(0,K.jsx)(`path`,{d:`M2.98444 8.62471L2.98346 8.62815C2.91251 8.8948 2.63879 9.05404 2.37202 8.9833C1.94098 8.86907 2.01687 8.37186 2.01687 8.37186L2.03453 8.31047C2.03453 8.31047 2.06063 8.22636 2.08166 8.1653C2.12369 8.04329 2.18795 7.87274 2.27931 7.66977C2.46154 7.26493 2.75443 6.72477 3.19877 6.18295C4.09629 5.08851 5.60509 4 8.00017 4C10.3952 4 11.904 5.08851 12.8016 6.18295C13.2459 6.72477 13.5388 7.26493 13.721 7.66977C13.8124 7.87274 13.8766 8.04329 13.9187 8.1653C13.9397 8.22636 13.9552 8.27541 13.9658 8.31047C13.9711 8.328 13.9752 8.34204 13.9781 8.35236L13.9816 8.365L13.9827 8.36916L13.9832 8.37069L13.9835 8.37186C14.0542 8.63878 13.8952 8.91253 13.6283 8.9833C13.3618 9.05397 13.0885 8.89556 13.0172 8.62937L13.0169 8.62815L13.0159 8.62471L13.0085 8.5997C13.0014 8.57616 12.9898 8.53927 12.9732 8.49095C12.9399 8.39422 12.8866 8.25227 12.8091 8.08023C12.6538 7.73508 12.4041 7.27523 12.0283 6.81706C11.2857 5.9115 10.0445 5 8.00017 5C5.95584 5 4.71464 5.9115 3.97201 6.81706C3.59627 7.27523 3.34655 7.73508 3.19119 8.08023C3.11375 8.25227 3.06047 8.39422 3.02715 8.49095C3.01051 8.53927 2.9989 8.57616 2.99179 8.5997L2.98444 8.62471ZM8.00024 7C6.61953 7 5.50024 8.11929 5.50024 9.5C5.50024 10.8807 6.61953 12 8.00024 12C9.38096 12 10.5002 10.8807 10.5002 9.5C10.5002 8.11929 9.38096 7 8.00024 7ZM6.50024 9.5C6.50024 8.67157 7.17182 8 8.00024 8C8.82867 8 9.50024 8.67157 9.50024 9.5C9.50024 10.3284 8.82867 11 8.00024 11C7.17182 11 6.50024 10.3284 6.50024 9.5Z`})})}function GN(){return(0,K.jsx)(`svg`,{width:`16`,height:`16`,viewBox:`0 0 16 16`,fill:`currentColor`,"aria-hidden":`true`,focusable:`false`,children:(0,K.jsx)(`path`,{d:`M10.1196 10.8267L14.1464 14.8536C14.3417 15.0488 14.6583 15.0488 14.8536 14.8536C15.0488 14.6583 15.0488 14.3417 14.8536 14.1464L1.85355 1.14645C1.65829 0.951184 1.34171 0.951184 1.14645 1.14645C0.951184 1.34171 0.951184 1.65829 1.14645 1.85355L4.37624 5.08334C3.90117 5.4183 3.5126 5.80026 3.19877 6.18295C2.75443 6.72477 2.46154 7.26493 2.27931 7.66977C2.18795 7.87274 2.12369 8.04329 2.08166 8.1653C2.06063 8.22636 2.03453 8.31047 2.03453 8.31047L2.01687 8.37186C2.01687 8.37186 1.94098 8.86907 2.37202 8.9833C2.63879 9.05404 2.91251 8.8948 2.98346 8.62815L2.98444 8.62471L2.99179 8.5997C2.9989 8.57616 3.01051 8.53927 3.02715 8.49095C3.06047 8.39421 3.11375 8.25227 3.19119 8.08023C3.34655 7.73507 3.59627 7.27523 3.97201 6.81706C4.26363 6.46146 4.63213 6.10494 5.09595 5.80306L6.67356 7.38067C5.9688 7.82277 5.50024 8.60667 5.50024 9.5C5.50024 10.8807 6.61953 12 8.00024 12C8.89358 12 9.67747 11.5314 10.1196 10.8267ZM9.3807 10.0878C9.15205 10.6241 8.62005 11 8.00024 11C7.17182 11 6.50024 10.3284 6.50024 9.5C6.50024 8.88019 6.87616 8.34819 7.41244 8.11955L9.3807 10.0878ZM6.31962 4.19853L7.174 5.05291C7.43366 5.01852 7.70875 5 8.00017 5C10.0445 5 11.2857 5.9115 12.0283 6.81706C12.4041 7.27523 12.6538 7.73507 12.8091 8.08023C12.8866 8.25227 12.9399 8.39421 12.9732 8.49095C12.9898 8.53927 13.0014 8.57616 13.0085 8.5997L13.0159 8.62471L13.0169 8.62815L13.0172 8.62937C13.0885 8.89555 13.3618 9.05397 13.6283 8.9833C13.8952 8.91253 14.0542 8.63878 13.9835 8.37186L13.9832 8.37069L13.9827 8.36916L13.9816 8.365L13.9781 8.35236C13.9752 8.34204 13.9711 8.328 13.9658 8.31047C13.9552 8.27541 13.9397 8.22636 13.9187 8.1653C13.8766 8.04329 13.8124 7.87274 13.721 7.66977C13.5388 7.26493 13.2459 6.72477 12.8016 6.18295C11.904 5.0885 10.3952 4 8.00017 4C7.38264 4 6.82403 4.07236 6.31962 4.19853Z`})})}function KN(e,t,n){if(e.length<=t)return e;let r=e.slice(0,t),i=new Set(r.map(e=>e.id)),a=new Set(n.filter(e=>!!e));for(let n of e)if(!(!a.has(n.id)||i.has(n.id))){if(r.length>=t&&r.length>0){let e=r[r.length-1];i.delete(e.id),r[r.length-1]=n}else r.push(n);i.add(n.id)}return r}function qN(){return(0,K.jsx)(`svg`,{width:`16`,height:`16`,viewBox:`0 0 16 16`,"aria-hidden":`true`,focusable:`false`,children:(0,K.jsx)(`path`,{fill:`currentColor`,d:`M4 8C4 8.55228 3.55228 9 3 9C2.44772 9 2 8.55228 2 8C2 7.44772 2.44772 7 3 7C3.55228 7 4 7.44772 4 8ZM9 8C9 8.55228 8.55228 9 8 9C7.44772 9 7 8.55228 7 8C7 7.44772 7.44772 7 8 7C8.55228 7 9 7.44772 9 8ZM13 9C13.5523 9 14 8.55228 14 8C14 7.44772 13.5523 7 13 7C12.4477 7 12 7.44772 12 8C12 8.55228 12.4477 9 13 9Z`})})}function JN(e,t,n){return{key:`agent:${e.id}`,title:t.title,project:n||WD(e.projectWorkspace||e.cwd),lastActive:e.lastActivity||e.startedAt||0,provider:NM(e),workspaceRootId:e.workspaceRootId}}function YN(e,t){return{key:`session:${ZD(e)}`,title:t.title,project:nO(e),lastActive:rO(e),provider:MM(e.provider)}}function XN({preview:e,now:t}){return(0,K.jsxs)(`div`,{className:`code-agent-hover-preview`,"data-testid":`code-agent-hover-preview`,style:{left:e.x,top:e.y,width:e.width},"aria-hidden":`true`,children:[(0,K.jsxs)(`div`,{className:`code-agent-hover-preview-header`,children:[(0,K.jsx)(`strong`,{children:e.title}),(0,K.jsx)(`span`,{children:T(e.lastActive,t)})]}),(0,K.jsxs)(`div`,{className:`code-agent-hover-preview-line`,children:[(0,K.jsx)(`span`,{className:`code-agent-hover-preview-icon`,children:(0,K.jsx)(ZN,{})}),(0,K.jsxs)(`div`,{className:`code-agent-hover-preview-project`,children:[(0,K.jsx)(`span`,{className:`code-agent-hover-preview-project-name`,children:e.project}),e.provider&&(0,K.jsx)(c,{name:e.provider,variant:`color`,className:`code-agent-hover-preview-provider-icon`})]})]}),(0,K.jsxs)(`div`,{className:`code-agent-hover-preview-line`,children:[(0,K.jsx)(`span`,{className:`code-agent-hover-preview-icon`,children:(0,K.jsx)(QN,{})}),(0,K.jsx)(`span`,{children:e.branch||`—`})]})]})}function ZN(){return(0,K.jsx)(`svg`,{width:`16`,height:`16`,viewBox:`0 0 16 16`,"aria-hidden":`true`,focusable:`false`,children:(0,K.jsx)(`path`,{fill:`currentColor`,d:`M1.5 3.75C1.5 2.784 2.284 2 3.25 2h3.104c.464 0 .91.184 1.237.513l.841.842c.14.14.33.22.528.22h3.79c.966 0 1.75.784 1.75 1.75v6.925c0 .966-.784 1.75-1.75 1.75H3.25a1.75 1.75 0 0 1-1.75-1.75V3.75Zm1.75-.75a.75.75 0 0 0-.75.75v8.5c0 .414.336.75.75.75h9.5a.75.75 0 0 0 .75-.75V5.325a.75.75 0 0 0-.75-.75H8.96a1.75 1.75 0 0 1-1.235-.512l-.841-.842A.75.75 0 0 0 6.354 3H3.25Z`})})}function QN(){return(0,K.jsx)(`svg`,{width:`24`,height:`24`,viewBox:`0 0 24 24`,fill:`currentColor`,"aria-hidden":`true`,focusable:`false`,children:(0,K.jsx)(`path`,{d:`M21 8.25C21 6.1815 19.3185 4.5 17.25 4.5C15.1815 4.5 13.5 6.1815 13.5 8.25C13.5 10.023 14.739 11.5035 16.395 11.892C16.116 12.819 15.2655 13.5 14.25 13.5H9.75C8.9025 13.5 8.1285 13.7925 7.5 14.268V7.4235C9.21 7.0755 10.5 5.5605 10.5 3.75C10.5 1.6815 8.8185 0 6.75 0C4.6815 0 3 1.6815 3 3.75C3 5.562 4.29 7.0755 6 7.4235V16.575C4.29 16.923 3 18.438 3 20.2485C3 22.317 4.6815 23.9985 6.75 23.9985C8.8185 23.9985 10.5 22.317 10.5 20.2485C10.5 18.4755 9.261 16.995 7.605 16.6065C7.884 15.6795 8.7345 14.9985 9.75 14.9985H14.25C16.0845 14.9985 17.61 13.6725 17.931 11.9295C19.674 11.607 21 10.0845 21 8.25ZM4.5 3.75C4.5 2.5095 5.5095 1.5 6.75 1.5C7.9905 1.5 9 2.5095 9 3.75C9 4.9905 7.9905 6 6.75 6C5.5095 6 4.5 4.9905 4.5 3.75ZM9 20.25C9 21.4905 7.9905 22.5 6.75 22.5C5.5095 22.5 4.5 21.4905 4.5 20.25C4.5 19.0095 5.5095 18 6.75 18C7.9905 18 9 19.0095 9 20.25ZM17.25 10.5C16.0095 10.5 15 9.4905 15 8.25C15 7.0095 16.0095 6 17.25 6C18.4905 6 19.5 7.0095 19.5 8.25C19.5 9.4905 18.4905 10.5 17.25 10.5Z`})})}function $N(){return(0,K.jsx)(`svg`,{width:`16`,height:`16`,viewBox:`0 0 16 16`,"aria-hidden":`true`,focusable:`false`,children:(0,K.jsx)(`path`,{fill:`currentColor`,d:`M10.0589 2.44511C9.34701 1.73063 8.14697 1.90829 7.67261 2.79839L5.6526 6.58878L2.8419 7.52568C2.6775 7.58048 2.5532 7.71649 2.51339 7.88514C2.47357 8.0538 2.52392 8.23104 2.64646 8.35357L4.79291 10.5L2.14645 13.1465L2 14L2.85356 13.8536L5.50002 11.2071L7.64646 13.3536C7.76899 13.4761 7.94623 13.5265 8.11489 13.4866C8.28354 13.4468 8.41955 13.3225 8.47435 13.1581L9.41143 10.3469L13.1897 8.32423C14.0759 7.84982 14.2538 6.6551 13.5443 5.94305L10.0589 2.44511ZM8.55511 3.2687C8.71323 2.972 9.11324 2.91278 9.35055 3.15094L12.836 6.64889C13.0725 6.88624 13.0131 7.28448 12.7178 7.44262L8.76403 9.55921C8.65137 9.61952 8.56608 9.72068 8.52567 9.84191L7.7815 12.0744L3.92562 8.21853L6.15812 7.47436C6.27966 7.43385 6.38101 7.34823 6.44126 7.23518L8.55511 3.2687Z`})})}function eP(){return(0,K.jsx)(`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,K.jsx)(`path`,{d:`M9.56016 10.2673L14.1464 14.8536C14.3417 15.0488 14.6583 15.0488 14.8536 14.8536C15.0488 14.6583 15.0488 14.3417 14.8536 14.1464L1.85355 1.14645C1.65829 0.951184 1.34171 0.951184 1.14645 1.14645C0.951184 1.34171 0.951184 1.65829 1.14645 1.85355L5.73223 6.43934L5.6526 6.58876L2.8419 7.52566C2.6775 7.58046 2.5532 7.71648 2.51339 7.88513C2.47357 8.05378 2.52392 8.23102 2.64646 8.35356L4.79291 10.5L2.14645 13.1465L2 14L2.85356 13.8536L5.50002 11.2071L7.64646 13.3536C7.76899 13.4761 7.94623 13.5264 8.11489 13.4866C8.28354 13.4468 8.41955 13.3225 8.47435 13.1581L9.41143 10.3469L9.56016 10.2673ZM8.82138 9.52849L8.76403 9.5592C8.65137 9.61951 8.56608 9.72066 8.52567 9.84189L7.7815 12.0744L3.92562 8.21851L6.15812 7.47435C6.27966 7.43383 6.38101 7.34822 6.44126 7.23516L6.47143 7.17854L8.82138 9.52849ZM12.7178 7.4426L10.6636 8.54227L11.4024 9.28105L13.1897 8.32422C14.0759 7.84981 14.2538 6.65509 13.5443 5.94304L10.0589 2.44509C9.34701 1.73062 8.14697 1.90828 7.67261 2.79838L6.71556 4.59421L7.45476 5.33341L8.55511 3.26869C8.71323 2.97199 9.11324 2.91277 9.35055 3.15093L12.836 6.64888C13.0725 6.88623 13.0131 7.28446 12.7178 7.4426Z`})})}function tP(){return(0,K.jsx)(`svg`,{width:`16`,height:`16`,viewBox:`0 0 16 16`,"aria-hidden":`true`,focusable:`false`,children:(0,K.jsx)(`path`,{fill:`currentColor`,d:`M6.5 8C6.22386 8 6 8.22386 6 8.5C6 8.77614 6.22386 9 6.5 9H9.5C9.77614 9 10 8.77614 10 8.5C10 8.22386 9.77614 8 9.5 8H6.5ZM1 3.5C1 2.67157 1.67157 2 2.5 2H13.5C14.3284 2 15 2.67157 15 3.5V4.5C15 5.15311 14.5826 5.70873 14 5.91465V11.5C14 12.8807 12.8807 14 11.5 14H4.5C3.11929 14 2 12.8807 2 11.5V5.91465C1.4174 5.70873 1 5.15311 1 4.5V3.5ZM2.5 3C2.22386 3 2 3.22386 2 3.5V4.5C2 4.77614 2.22386 5 2.5 5H13.5C13.7761 5 14 4.77614 14 4.5V3.5C14 3.22386 13.7761 3 13.5 3H2.5ZM3 6V11.5C3 12.3284 3.67157 13 4.5 13H11.5C12.3284 13 13 12.3284 13 11.5V6H3Z`})})}function nP(){return(0,K.jsx)(`svg`,{width:`16`,height:`16`,viewBox:`0 0 16 16`,"aria-hidden":`true`,focusable:`false`,children:(0,K.jsx)(`path`,{fill:`currentColor`,d:`M12.854 14.8542L14.854 12.8542C15.049 12.6592 15.049 12.3422 14.854 12.1472L12.854 10.1472C12.659 9.95223 12.342 9.95223 12.147 10.1472C11.952 10.3422 11.952 10.6592 12.147 10.8542L13.293 12.0002H8.5C8.225 12.0002 8 11.7752 8 11.5002V5.50023C8 5.22523 8.225 5.00023 8.5 5.00023H13.293L12.147 6.14623C12.049 6.24423 12.001 6.37223 12.001 6.50023C12.001 6.62823 12.05 6.75623 12.147 6.85423C12.342 7.04923 12.659 7.04923 12.854 6.85423L14.854 4.85423C15.049 4.65923 15.049 4.34223 14.854 4.14723L12.854 2.14723C12.659 1.95223 12.342 1.95223 12.147 2.14723C11.952 2.34223 11.952 2.65923 12.147 2.85423L13.293 4.00023H8.5C7.673 4.00023 7 4.67323 7 5.50023V8.00023H1.5C1.224 8.00023 1 8.22423 1 8.50023C1 8.77623 1.224 9.00023 1.5 9.00023H7V11.5002C7 12.3272 7.673 13.0002 8.5 13.0002H13.293L12.147 14.1462C12.049 14.2442 12.001 14.3722 12.001 14.5002C12.001 14.6282 12.05 14.7562 12.147 14.8542C12.342 15.0492 12.659 15.0492 12.854 14.8542Z`})})}function rP({agent:e,session:t,shortcutHint:n,active:r=!1,searchSelected:i,now:a,onOpenAgent:o,onUpdateAgentFlags:s,reorderable:l=!1,dragging:u=!1,dropPosition:d,onAgentDragStart:f,onAgentDragEnd:p,onAgentDragOver:m,onAgentDrop:h,onOpenAgentContextMenu:g,onOpenAgentKeyboardMenu:_,onResume:v,onOpenSessionContextMenu:y,onOpenSessionKeyboardMenu:b,onShowPreview:x,onHidePreview:S,copy:C}){let w=(0,G.useRef)(!1),T=Lt(e),ee=T?{kind:`agent`,agent:T}:t?{kind:`history`,session:t,fallbackTitle:C.sessionFallbackTitle(t.providerName)}:null;if(!ee)return null;let E=_A(ee,a),D=E.requiresResume,O=T?.id??``,k=t?.provider??``,A=t?.id??``,j=D?`code-active-session-row`:`code-agent-row`,M=T?NM(T):MM(t?.provider),N=()=>{if(D){S?.(),k&&A&&v?.(k,A,t?.providerHomeId);return}O&&o?.(O)};return(0,K.jsxs)(`div`,{tabIndex:0,className:`code-agent-row ${M?`has-provider`:``} ${D?`requires-resume`:``} ${r?`active`:``} ${i?`search-selected`:``} ${E.pinned?`pinned`:``} ${E.unread?`unread`:``} ${u?`dragging`:``} ${d?`drop-${d}`:``}`,draggable:l||void 0,"data-testid":j,"data-agent-id":T?.id,"data-activity-level":T?.activityLevel,"data-provider":t?.provider,"data-session-id":t?ZD(t):void 0,"aria-label":E.rowTitle||E.title,onDragStart:e=>{!O||!l||(w.current=!0,f?.(e,O))},onDragEnd:()=>{p?.(),window.setTimeout(()=>{w.current=!1},0)},onDragOver:e=>O&&m?.(e,O),onDrop:e=>O&&h?.(e,O),onClick:e=>{if(w.current){e.preventDefault(),e.stopPropagation();return}N()},onMouseEnter:e=>{T?x?.(e,JN(T,E)):t&&x?.(e,YN(t,E))},onMouseLeave:S,onContextMenu:e=>{if(D){S?.(),k&&t&&y?.(e,k,ZD(t));return}O&&g?.(e,O)},onKeyDown:e=>{D?k&&t&&b?.(e,k,ZD(t)):O&&_?.(e,O),!e.defaultPrevented&&(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),N())},children:[M&&(0,K.jsx)(`span`,{className:`code-agent-row-provider-icon`,"aria-hidden":`true`,children:(0,K.jsx)(c,{name:M,variant:`color`})}),(0,K.jsxs)(`span`,{className:`code-agent-row-copy ${E.detailLabel?`has-details`:``}`,children:[(0,K.jsx)(`span`,{className:`code-agent-name`,children:E.title}),E.detailLabel&&(0,K.jsx)(`span`,{className:`code-agent-meta`,"data-testid":`code-agent-row-detail`,title:E.detailLabel,children:E.detailLabel})]}),(0,K.jsxs)(`span`,{className:`code-agent-row-trailing`,children:[E.statusIndicatorVisible&&(0,K.jsx)(`span`,{className:`code-agent-dot ${E.lifecycleStatus} ${E.turnActive?`turn-active`:``}`,title:E.commandTitle||E.lifecycleStatus}),E.forkedToNewWorktree&&(0,K.jsx)(`span`,{className:`code-agent-fork-new-worktree`,"data-testid":`code-agent-new-worktree-fork`,title:C.newWorktreeFork,"aria-label":C.newWorktreeFork,role:`img`,children:(0,K.jsx)(nP,{})}),E.scheduled&&(0,K.jsx)(`span`,{className:`code-agent-schedule-clock`,"data-testid":`code-agent-schedule-clock`,title:E.scheduleTitle,"aria-label":E.scheduleTitle||C.scheduledTask}),E.unread&&(0,K.jsx)(`span`,{className:`code-agent-unread`,title:C.unread}),E.ageVisible&&(0,K.jsx)(`span`,{className:`code-agent-age code-agent-relative-age`,"data-testid":`code-agent-row-age`,title:E.ageTitle,children:E.ageLabel}),e&&(0,K.jsxs)(`span`,{className:`code-agent-row-actions`,"aria-hidden":!1,children:[(0,K.jsx)(`button`,{type:`button`,className:`code-agent-row-action pin ${E.pinned?`active`:``}`,"data-testid":`code-agent-row-pin`,"aria-label":E.pinned?C.unpinAgent:C.pinAgent,title:E.pinned?C.unpinAgent:C.pinAgent,onClick:e=>{e.preventDefault(),e.stopPropagation(),T&&s?.(T,{pinned:!E.pinned})},children:E.pinned?(0,K.jsx)(eP,{}):(0,K.jsx)($N,{})}),(0,K.jsx)(`button`,{type:`button`,className:`code-agent-row-action archive`,"data-testid":`code-agent-row-archive`,"aria-label":C.archiveAgent,title:C.archiveAgent,onClick:e=>{e.preventDefault(),e.stopPropagation(),T&&s?.(T,{archived:!0})},children:(0,K.jsx)(tP,{})})]}),(e||t)&&(0,K.jsx)(`button`,{type:`button`,className:`code-agent-row-more`,"data-testid":`code-agent-row-more`,"aria-label":C.openOptions,title:C.openOptions,onClick:e=>{if(e.preventDefault(),e.stopPropagation(),D){S?.(),k&&t&&y?.(e,k,ZD(t));return}O&&g?.(e,O)},children:(0,K.jsx)(qN,{})}),n&&(0,K.jsx)(`kbd`,{children:n})]})]})}var iP=[`codex`,`claude`,`opencode`,`qoder`],aP=new Set([`bash`,`zsh`]),oP=/^[A-Za-z0-9._-]+$/,sP=[3,5,10,15,30,60,180],cP=15e3;async function lP(e,t){let n=new AbortController,r=window.setTimeout(()=>n.abort(),cP);try{return await fetch(e,{...t,signal:n.signal})}finally{window.clearTimeout(r)}}function uP(e){let t=e/1e3;return sP.reduce((e,n)=>Math.abs(n-t)<Math.abs(e-t)?n:e)}function dP(e){let t=Number(e?.receivedBytes),n=Number(e?.totalBytes);return!Number.isFinite(t)||!Number.isFinite(n)||n<=0?null:Math.max(0,Math.min(100,Math.floor(t/n*100)))}function fP(e,t=Date.now()){let n=Date.parse(String(e?.startedAt||``)),r=e?.completedAt?Date.parse(e.completedAt):e?.preparedAt?Date.parse(e.preparedAt):t;return!Number.isFinite(n)||!Number.isFinite(r)||r<n?null:Math.floor((r-n)/1e3)}function pP(e){let t=e===`zh`;return{title:t?`设置`:`Settings`,subtitle:t?`管理 Farming 的本地元数据。`:`Manage local Farming metadata.`,close:t?`关闭`:`Close`,back:t?`返回导航`:`Back to navigation`,general:t?`通用`:`General`,appearance:t?`外观`:`Appearance`,system:t?`跟随系统`:`System`,light:t?`浅色`:`Light`,dark:t?`深色`:`Dark`,interface:t?`界面`:`Interface`,interfaceSkin:t?`界面皮肤`:`Interface skin`,farmingCode:`Farming Code`,farmingCrt:`Farming CRT`,language:t?`语言`:`Language`,english:`English`,chinese:`中文`,search:t?`搜索`:`Search`,agentPermissions:t?`Agent 权限`:`Agent Permissions`,dangerousSkipLabel:t?`默认跳过所有 agent 权限检查`:`Skip all agent permission checks by default`,dangerousSkipHint:t?`开启后,新启动的 Codex、Claude、OpenCode、Qoder、Qwen、Aider、GitHub Copilot CLI、Amazon Q 等会使用各自的危险跳过权限 flag。只在可信沙箱中使用。`:`When enabled, new Codex, Claude, OpenCode, Qoder, Qwen, Aider, GitHub Copilot CLI, Amazon Q, and similar agents launch with their provider-specific dangerous skip flags. Use only in trusted sandboxes.`,searchTimeout:t?`搜索超时`:`Search timeout`,searchTimeoutValue:e=>t?e>=60?`${e/60} 分钟`:`${e} 秒`:e>=60?`${e/60} min`:`${e} sec`,updates:t?`更新`:`Updates`,updateUrl:t?`更新 URL`:`Update URL`,updateUrlPlaceholder:`https://github.com/zhuwenzhuang/farming/releases/latest`,updateUrlEmpty:t?`等待检查更新`:`Waiting for update check`,saveUpdateUrl:t?`保存更新 URL`:`Save Update URL`,refreshUpdates:t?`刷新`:`Refresh`,updateAction:t?`准备更新`:`Prepare update`,updateToVersion:e=>t?`准备 ${e}`:`Prepare ${e}`,updating:t?`准备中…`:`Preparing…`,restartToUpdate:t?`重启并应用`:`Restart to update`,checkingUpdates:t?`正在检查更新…`:`Checking for updates…`,currentVersion:t?`当前版本`:`Current`,latestVersion:t?`最新版本`:`Latest`,targetVersion:t?`升级版本`:`Target`,updateSource:t?`更新源`:`Update source`,updateMethodLabel:e=>({npm:`npm`,"app-bundle":t?`兼容包`:`App bundle`,"source-deploy":t?`源码部署`:`Source deployment`,source:t?`源码检出`:`Source checkout`,"standalone-cli":t?`单文件 CLI`:`Standalone CLI`})[e]||e||`-`,upToDate:t?`已是最新版本`:`Up to date`,updateAvailable:t?`有新版本可用`:`Update available`,updateNotInstallable:t?`当前更新不可安装`:`Update is not installable`,updateDownloading:e=>e===null?t?`正在下载更新包…`:`Downloading update package…`:t?`正在下载更新包 ${e}%`:`Downloading update package ${e}%`,updateExtracting:t?`正在解压更新包…`:`Extracting update package…`,updateInstalling:t?`正在准备更新…`:`Preparing update…`,updateReady:t?`更新已准备好,重启后应用。`:`Update ready. Restart to apply it.`,updateRestarting:t?`新版本已安装,正在重启 Farming。`:`The new version is installed. Restarting Farming.`,updateRollingBack:t?`正在回退到旧版本…`:`Rolling back to the previous version…`,updateSucceeded:t?`更新成功。`:`Update completed.`,updateRolledBack:t?`新版本启动失败,已回退到旧版本。`:`The new version failed to start and Farming rolled back.`,updateElapsed:e=>{let n=Math.floor(e/60),r=e%60;return t?`已用时 ${n>0?`${n} 分 `:``}${r} 秒`:`Elapsed ${n>0?`${n}m `:``}${r}s`},agentHomes:`Agent Homes`,agentHomesHint:t?`为不同 Agent 配置独立的主目录。`:`Configure a separate home directory for each agent.`,addHome:e=>t?`添加 ${e} home`:`Add ${e} home`,edit:t?`编辑`:`Edit`,remove:t?`删除`:`Remove`,save:t?`保存`:`Save`,cancel:t?`取消`:`Cancel`,homeName:t?`Home 名称(可选)`:`Home name (optional)`,homePath:t?`Home 路径`:`Home path`,homeNameHint:t?`留空时将根据路径自动生成。允许字母、数字、点、下划线和短横线。`:`Leave empty to generate it from the path. Use letters, numbers, dots, underscores, and hyphens.`,homeNamePlaceholder:t?`例如:work`:`e.g. work`,pathPlaceholder:`~/.codex.local`,loading:t?`加载中…`:`Loading…`,saving:t?`保存中…`:`Saving…`,saved:t?`已保存`:`Saved`,loadFailed:t?`加载设置失败`:`Failed to load settings`,saveFailed:t?`保存失败`:`Failed to save`,invalidId:t?`Home 名称只能包含字母、数字、点、下划线和短横线。`:`Home name can only contain letters, numbers, dots, underscores, and hyphens.`,duplicateId:t?`同一个 provider 下 Home 名称不能重复。`:`Home name must be unique under the same provider.`,missingPath:t?`Home 路径不能为空。`:`Home path is required.`,removeLastHint:t?`至少保留一个 home。`:`Keep at least one home.`,removeDefaultHint:t?`default home 不能删除。`:`The default home cannot be removed.`,editDisabledHint:t?`home 不支持编辑;请删除后重新添加。`:`Homes cannot be edited. Remove and add again.`,confirmRemove:e=>t?`删除 home ${e}?`:`Remove home ${e}?`,empty:t?`还没有配置 home。`:`No homes configured.`,noAgents:t?`当前机器没有识别到可配置的 coding agent。`:`No configurable coding agents were detected on this machine.`,unavailable:t?`未安装`:`Not installed`}}function mP(e){return e.trim().toLowerCase()}function hP(e){let t=e&&typeof e==`object`&&!Array.isArray(e)?e:{},n={};return Object.entries(t).forEach(([e,t])=>{let r=mP(e);if(!r||!/^[a-z0-9._-]+$/.test(r)||!Array.isArray(t))return;let i=new Set,a=[];t.forEach(e=>{if(!e||typeof e!=`object`)return;let t=e,n=String(t.id??``).trim(),r=String(t.path??``).trim();if(!n||!r||!oP.test(n))return;let o=n.toLowerCase();i.has(o)||(i.add(o),a.push({id:n,path:r}))}),a.length>0&&(n[r]=a)}),n}function gP(e){return e===`codex`?`Codex`:e===`claude`?`Claude`:e===`opencode`?`OpenCode`:e===`qoder`?`Qoder`:e}function _P(e){return{codex:`~/.codex`,claude:`~/.claude`,opencode:`~/.opencode`,qoder:`~/.qoder`}[e]??`~/.${e}`}function vP(e){return!!e?.some(e=>e.id.toLowerCase()!==`default`)}function yP(e){return e.filter(e=>e.supported!==!1&&e.interactive!==!1).filter(e=>!aP.has(e.name)).filter(e=>iP.includes(e.name)).map(e=>mP(e.name)).filter(Boolean)}function bP(e,t){let n=new Set(yP(t)),r=Object.keys(e).filter(t=>vP(e[t])),i=new Set([...n,...r]);return Array.from(i).sort((e,t)=>{let n=iP.indexOf(e),r=iP.indexOf(t),i=n===-1?iP.length:n,a=r===-1?iP.length:r;return i===a?e.localeCompare(t):i-a})}function xP(e,t){let n=e[t]??[];return n.some(e=>e.id.toLowerCase()===`default`)?n:[{id:`default`,path:_P(t)},...n]}function SP(e,t){let n=e.trim().replace(/\/+$/,``).split(`/`).filter(Boolean),r=(n[n.length-1]??``).replace(/^\.+/,``).replace(/[^A-Za-z0-9._-]+/g,`-`).replace(/^[.-]+|[.-]+$/g,``).slice(0,64)||`home`,i=new Set(t.map(e=>e.id.toLowerCase())),a=1,o=r;for(;i.has(o.toLowerCase());)a+=1,o=`${r}-${a}`;return{id:o}}function CP(e){return{provider:e,id:``,path:``}}function wP({open:e,activeAgentId:t=null,language:n,uiPreferences:i,agentLaunchOptions:a,onClose:o,onUpdateUiPreferences:s}){let c=(0,G.useMemo)(()=>pP(n),[n]),l=(0,G.useRef)(null),u=(0,G.useRef)(null),d=(0,G.useRef)(``),f=(0,G.useRef)({open:e,generation:0}),p=(0,G.useRef)(0),m=(0,G.useRef)(null),h=(0,G.useRef)(0),[g,_]=(0,G.useState)(!1),[v,y]=(0,G.useState)(``),[b,x]=(0,G.useState)(15),[S,C]=(0,G.useState)(null),[w,T]=(0,G.useState)(``),[ee,E]=(0,G.useState)(!1),[D,O]=(0,G.useState)(!1),[k,A]=(0,G.useState)(()=>hP({codex:[{id:`default`,path:`~/.codex`}],claude:[{id:`default`,path:`~/.claude`}],opencode:[{id:`default`,path:`~/.opencode`}],qoder:[{id:`default`,path:`~/.qoder`}]})),[j,M]=(0,G.useState)(!1),[N,P]=(0,G.useState)(!1),[te,F]=(0,G.useState)(``),[ne,I]=(0,G.useState)(``),[L,R]=(0,G.useState)(null);f.current.open!==e&&(f.current={open:e,generation:f.current.generation+1});let z=(0,G.useCallback)(()=>{if(!f.current.open||m.current)return;let e=f.current.generation,t=p.current+1;p.current=t,M(!0),I(``),lP(r(`/api/settings`)).then(e=>e.json()).then(n=>{p.current!==t||f.current.generation!==e||!f.current.open||m.current||(A(hP(n.settings?.agentHomes)),_(n.settings?.dangerouslySkipAgentPermissionsByDefault===!0),y(String(n.settings?.updateUrl??``)),x(uP(Number(n.settings?.searchTimeoutMs??15e3))))}).catch(()=>{p.current===t&&f.current.generation===e&&f.current.open&&!m.current&&I(c.loadFailed)}).finally(()=>{p.current===t&&f.current.generation===e&&f.current.open&&!m.current&&M(!1)})},[c.loadFailed]);(0,G.useEffect)(()=>(f.current.open=e,()=>{f.current={open:!1,generation:f.current.generation+1},p.current+=1,u.current!==null&&window.clearTimeout(u.current)}),[]),(0,G.useEffect)(()=>{e&&(m.current||P(!1),z(),window.requestAnimationFrame(()=>l.current?.focus({preventScroll:!0})))},[z,e]),(0,G.useEffect)(()=>{if(!e)return;let t=e=>{e.key===`Escape`&&(e.preventDefault(),o())};return window.addEventListener(`keydown`,t),()=>window.removeEventListener(`keydown`,t)},[o,e]);let B=(0,G.useCallback)(e=>{if(!f.current.open||m.current)return;let t=f.current.generation,n=h.current+1;h.current=n,m.current=n,p.current+=1,M(!1),P(!0),I(``),F(``);let i=!1;lP(r(`/api/settings`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({agentHomes:e})}).then(async r=>{let i=await r.json().catch(()=>null);if(!r.ok)throw Error(i?.error||c.saveFailed);m.current!==n||f.current.generation!==t||!f.current.open||(A(hP(i?.settings?.agentHomes??e)),R(null),F(c.saved),window.dispatchEvent(new CustomEvent(`farming-agent-homes-saved`)))}).catch(e=>{i=!0,m.current===n&&f.current.generation===t&&f.current.open&&I(e instanceof Error?e.message:c.saveFailed)}).finally(()=>{m.current===n&&(m.current=null,f.current.open&&(P(!1),(i||f.current.generation!==t)&&z()))})},[c.saveFailed,c.saved,z]),V=(0,G.useCallback)((e=!0,t=!1)=>{t||(E(!0),I(``)),fetch(r(`/api/update${e?`?force=1`:``}`)).then(async e=>{let t=await e.json().catch(()=>null);if(!e.ok)throw Error(t?.error||c.loadFailed);let n=t?.update??null;C(n);let r=n?.versions??[];T(e=>{if(n?.state?.phase===`ready-to-restart`){let e=n.state.version,t=r.find(t=>t.version===e);if(t?.assetName)return t.assetName}return e&&r.some(t=>t.assetName===e)?e:r[0]?.assetName||``})}).catch(e=>{t||I(e instanceof Error?e.message:c.loadFailed)}).finally(()=>{t||E(!1)})},[c.loadFailed]),re=(0,G.useCallback)(()=>{O(!0),I(``),F(``),fetch(r(`/api/settings`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({updateUrl:v})}).then(async e=>{let t=await e.json().catch(()=>null);if(!e.ok)throw Error(t?.error||c.saveFailed);y(String(t?.settings?.updateUrl??``)),F(c.saved),V(!0)}).catch(e=>I(e instanceof Error?e.message:c.saveFailed)).finally(()=>O(!1))},[c.saveFailed,c.saved,V,v]),ie=(0,G.useCallback)(e=>{x(e),I(``),u.current!==null&&window.clearTimeout(u.current),u.current=window.setTimeout(()=>{fetch(r(`/api/settings`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({searchTimeoutMs:e*1e3})}).then(async t=>{let n=await t.json().catch(()=>null);if(!t.ok)throw Error(n?.error||c.saveFailed);x(uP(Number(n?.settings?.searchTimeoutMs??e*1e3)))}).catch(e=>I(e instanceof Error?e.message:c.saveFailed))},120)},[c.saveFailed]),H=(0,G.useCallback)(()=>{let e=S?.state?.phase===`ready-to-restart`,t=S?.versions?.find(e=>e.assetName===w);if(!e&&!t?.available){V(!0);return}E(!0),I(``),F(``),d.current=e?S?.state?.version||``:t?.version||t?.assetName||``,fetch(r(e?`/api/update/restart`:`/api/update/install`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e?{}:{assetName:w})}).then(async e=>{let t=await e.json().catch(()=>null);if(!e.ok){let e=t?.blockingAgents||[],n=e.length?`: ${e.map(e=>e.command).join(`, `)}`:``;throw Error(`${t?.error||c.saveFailed}${n}`)}C(e=>({...e??{},state:t?.update?.state??e?.state,blockingAgents:t?.update?.blockingAgents??e?.blockingAgents}))}).catch(e=>{d.current=``,I(e instanceof Error?e.message:c.saveFailed)}).finally(()=>E(!1))},[c,V,w,S]);(0,G.useEffect)(()=>{e&&V(!1)},[e,V]);let ae=(0,G.useCallback)(e=>{_(e),P(!0),I(``),F(``),fetch(r(`/api/settings`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({dangerouslySkipAgentPermissionsByDefault:e})}).then(async e=>{let t=await e.json().catch(()=>null);if(!e.ok)throw Error(t?.error||c.saveFailed);_(t?.settings?.dangerouslySkipAgentPermissionsByDefault===!0),F(c.saved)}).catch(t=>{_(!e),I(t instanceof Error?t.message:c.saveFailed)}).finally(()=>P(!1))},[c.saveFailed,c.saved]),oe=(0,G.useCallback)(()=>{if(!L)return;let e=mP(L.provider),t=L.path.trim();if(!t){I(c.missingPath);return}let n=k[e]??[],r=L.id.trim()||SP(t,n).id;if(!oP.test(r)){I(c.invalidId);return}if(n.some(e=>e.id.toLowerCase()===r.toLowerCase())){I(c.duplicateId);return}B({...k,[e]:[...n,{id:r,path:t}]})},[c.duplicateId,c.invalidId,c.missingPath,L,k,B]),se=(0,G.useCallback)((e,t)=>{if(t.toLowerCase()===`default`)return;let n=k[e]??[];window.confirm(c.confirmRemove(t))&&B({...k,[e]:n.filter(e=>e.id!==t)})},[c,k,B]),ce=S?.state?.phase||``;if((0,G.useEffect)(()=>{if(!e||![`downloading`,`extracting`,`installing`,`restarting`,`rolling-back`].includes(ce))return;let t=window.setInterval(()=>V(!1,!0),1500);return()=>window.clearInterval(t)},[e,V,ce]),(0,G.useEffect)(()=>{!e||ce!==`succeeded`||!d.current||(S?.state?.version||S?.current?.releaseVersion||S?.current?.packageVersion||``)===d.current&&(d.current=``,window.location.reload())},[e,ce,S]),!e)return null;let le=bP(k,a),ue=S?.versions??[],de=ue.find(e=>e.assetName===w),fe=[`downloading`,`extracting`,`installing`,`restarting`,`rolling-back`].includes(ce),pe=ce===`ready-to-restart`,me=ee||D||fe,ge=S?.method||S?.current?.type||``,_e=c.updateMethodLabel(ge),ve=ge===`app-bundle`||ge===`source-deploy`,ye=S?.current?.releaseVersion||S?.current?.packageVersion||S?.state?.previousVersion||`-`,be=S?.latest?.version||`-`,xe=pe?S?.state?.version||de?.version||S?.selected?.version||be:de?.version||S?.selected?.version||be,Se=ye!==`-`&&xe!==`-`&&ye!==xe&&(S?.available===!0||me||pe),Ce=dP(S?.state),we=S?ce===`rolled-back`?c.updateRolledBack:ce===`failed`&&S?.state?.error?S.state.error:ce===`downloading`?c.updateDownloading(Ce):pe?c.updateReady:ce===`extracting`?c.updateExtracting:ce===`installing`?c.updateInstalling:ce===`restarting`?c.updateRestarting:ce===`rolling-back`?c.updateRollingBack:S.available?c.updateAvailable:ce===`succeeded`?c.updateSucceeded:S.latest?.blockedReason||c.upToDate:c.checkingUpdates,U=fe||pe||[`succeeded`,`failed`,`rolled-back`].includes(ce)?fP(S?.state):null,Ee=U===null?``:c.updateElapsed(U),De=fe?c.updating:pe?c.restartToUpdate:de?.available&&xe!==`-`?c.updateToVersion(xe):c.updateAction;return(0,K.jsx)(`div`,{className:`code-settings-panel-overlay`,"data-testid":`code-settings-panel`,onPointerDown:e=>{e.target===e.currentTarget&&o()},children:(0,K.jsxs)(`aside`,{className:`code-settings-panel`,"aria-modal":`true`,role:`dialog`,"aria-labelledby":`code-settings-panel-title`,children:[(0,K.jsxs)(`header`,{className:`code-settings-panel-header`,children:[(0,K.jsx)(`button`,{type:`button`,className:`code-settings-panel-back`,onClick:o,"aria-label":c.back,children:(0,K.jsx)(ze,{})}),(0,K.jsx)(`div`,{children:(0,K.jsx)(`h2`,{id:`code-settings-panel-title`,children:c.title})}),(0,K.jsx)(`button`,{ref:l,type:`button`,className:`code-settings-panel-close`,onClick:o,"aria-label":c.close,children:(0,K.jsx)(Fe,{})})]}),(0,K.jsxs)(`div`,{className:`code-settings-panel-body`,children:[(0,K.jsx)(`section`,{className:`code-settings-section compact`,children:(0,K.jsxs)(`div`,{className:`code-settings-inline-preferences`,children:[(0,K.jsxs)(`div`,{className:`code-settings-inline-choice`,children:[(0,K.jsx)(W,{"aria-hidden":`true`}),(0,K.jsxs)(`div`,{className:`code-settings-segmented`,role:`group`,"aria-label":c.appearance,children:[(0,K.jsx)(`button`,{type:`button`,className:i.appearance===`system`?`active`:``,onClick:()=>s({appearance:`system`}),children:c.system}),(0,K.jsx)(`button`,{type:`button`,className:i.appearance===`light`?`active`:``,onClick:()=>s({appearance:`light`}),children:c.light}),(0,K.jsx)(`button`,{type:`button`,className:i.appearance===`dark`?`active`:``,onClick:()=>s({appearance:`dark`}),children:c.dark})]})]}),(0,K.jsx)(`div`,{className:`code-settings-inline-choice code-settings-language-choice`,children:(0,K.jsxs)(`div`,{className:`code-settings-segmented`,role:`group`,"aria-label":c.language,children:[(0,K.jsx)(`button`,{type:`button`,className:i.language===`en`?`active`:``,onClick:()=>s({language:`en`}),children:c.english}),(0,K.jsx)(`button`,{type:`button`,className:i.language===`zh`?`active`:``,onClick:()=>s({language:`zh`}),children:c.chinese})]})})]})}),(0,K.jsxs)(`section`,{className:`code-settings-section code-settings-group`,children:[(0,K.jsx)(`div`,{className:`code-settings-section-heading`,children:(0,K.jsx)(`div`,{children:(0,K.jsx)(`h3`,{children:c.interface})})}),(0,K.jsx)(`div`,{className:`code-settings-card`,children:(0,K.jsxs)(`div`,{className:`code-settings-choice-row code-settings-runtime-row`,children:[(0,K.jsx)(`div`,{className:`code-settings-row-copy`,children:(0,K.jsx)(`strong`,{children:c.interfaceSkin})}),(0,K.jsxs)(`div`,{className:`code-settings-segmented`,role:`group`,"aria-label":c.interfaceSkin,children:[(0,K.jsx)(`button`,{type:`button`,className:`active`,"data-testid":`code-settings-skin-code`,"aria-pressed":`true`,children:c.farmingCode}),(0,K.jsx)(`button`,{type:`button`,"data-testid":`code-settings-skin-crt`,"aria-pressed":`false`,onClick:()=>window.location.assign(`${r(`/crt/`)}${t?`?agent=${encodeURIComponent(t)}`:``}`),children:c.farmingCrt})]})]})})]}),(0,K.jsxs)(`section`,{className:`code-settings-section code-settings-group`,children:[(0,K.jsx)(`div`,{className:`code-settings-section-heading`,children:(0,K.jsx)(`div`,{children:(0,K.jsx)(`h3`,{children:c.search})})}),(0,K.jsx)(`div`,{className:`code-settings-card`,children:(0,K.jsxs)(`div`,{className:`code-settings-choice-row code-settings-search-timeout-row`,children:[(0,K.jsx)(`div`,{className:`code-settings-row-copy`,children:(0,K.jsx)(`strong`,{children:c.searchTimeout})}),(0,K.jsx)(`input`,{type:`range`,min:`0`,max:String(sP.length-1),step:`1`,value:sP.indexOf(b),"aria-label":c.searchTimeout,onChange:e=>ie(sP[Number(e.target.value)]??15)}),(0,K.jsx)(`output`,{children:c.searchTimeoutValue(b)})]})})]}),(0,K.jsxs)(`section`,{className:`code-settings-section`,children:[(0,K.jsx)(`div`,{className:`code-settings-section-heading`,children:(0,K.jsx)(`div`,{children:(0,K.jsx)(`h3`,{children:c.updates})})}),(0,K.jsxs)(`div`,{className:`code-settings-update-card ${S?.available?`available`:``}`,"data-testid":`code-settings-update-card`,children:[(0,K.jsxs)(`div`,{className:`code-settings-update-overview`,children:[(0,K.jsxs)(`div`,{className:`code-settings-update-versions`,"aria-label":`${c.currentVersion} ${ye}; ${c.latestVersion} ${be}`,children:[(0,K.jsx)(`span`,{children:ye}),Se&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`span`,{className:`code-settings-update-arrow`,"aria-hidden":`true`,children:`→`}),(0,K.jsx)(`strong`,{children:xe})]})]}),(0,K.jsxs)(`div`,{className:`code-settings-update-summary ${S?.available?`available`:``} ${ce?`phase-${ce}`:``}`,role:`status`,"aria-live":`polite`,children:[(0,K.jsxs)(`span`,{className:`code-settings-update-summary-text`,children:[ge&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`span`,{children:_e}),(0,K.jsx)(`span`,{"aria-hidden":`true`,children:` · `})]}),(0,K.jsx)(`span`,{children:we})]}),Ee&&(0,K.jsx)(`span`,{className:`code-settings-update-elapsed`,"aria-hidden":`true`,children:Ee})]})]}),(0,K.jsxs)(`div`,{className:`code-settings-update-actions`,children:[(0,K.jsx)(`button`,{type:`button`,className:`code-settings-update-refresh`,onClick:()=>V(!0),disabled:me,"aria-label":c.refreshUpdates,title:c.refreshUpdates,children:`↻`}),(0,K.jsx)(`button`,{type:`button`,className:`primary`,"data-testid":`code-settings-update-action`,onClick:H,disabled:me||!pe&&!de?.available,children:De})]}),ve&&(0,K.jsxs)(`label`,{className:`code-settings-update-url`,children:[(0,K.jsx)(`span`,{children:c.updateSource}),(0,K.jsx)(`input`,{type:`url`,name:`farming-update-url`,inputMode:`url`,autoComplete:`off`,autoCorrect:`off`,autoCapitalize:`none`,spellCheck:!1,enterKeyHint:`done`,"data-lpignore":`true`,"data-1p-ignore":`true`,"data-bwignore":`true`,"data-form-type":`other`,value:v,placeholder:c.updateUrlPlaceholder,"aria-label":c.updateUrl,onChange:e=>y(e.target.value),disabled:me})]}),ve&&(0,K.jsx)(`button`,{type:`button`,className:`code-settings-update-save`,onClick:re,disabled:me,children:c.saveUpdateUrl}),ue.length>1&&(0,K.jsx)(`label`,{className:`code-settings-update-version`,children:(0,K.jsx)(`select`,{value:w,"aria-label":c.targetVersion,onChange:e=>T(e.target.value),disabled:me||pe||ue.length===0,children:ue.map(e=>(0,K.jsxs)(`option`,{value:e.assetName||``,children:[e.version||e.assetName||`-`,e.assetName&&e.assetName!==e.version?` · ${e.assetName}`:``]},e.assetName||e.version))})})]})]}),(0,K.jsxs)(`section`,{className:`code-settings-section`,children:[(0,K.jsx)(`div`,{className:`code-settings-section-heading`,children:(0,K.jsx)(`div`,{children:(0,K.jsx)(`h3`,{children:c.agentPermissions})})}),(0,K.jsxs)(`div`,{className:`code-settings-choice-row dangerous`,children:[(0,K.jsx)(`span`,{children:c.dangerousSkipLabel}),(0,K.jsx)(`button`,{type:`button`,className:`code-settings-permission-toggle ${g?`active`:``}`,role:`checkbox`,"aria-label":c.dangerousSkipLabel,"aria-pressed":g,disabled:N,onClick:()=>ae(!g),children:(0,K.jsx)(Te,{})})]})]}),(0,K.jsxs)(`section`,{className:`code-settings-section`,children:[(0,K.jsxs)(`div`,{className:`code-settings-section-heading`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h3`,{children:c.agentHomes}),(0,K.jsx)(`p`,{children:c.agentHomesHint})]}),(j||N||te)&&(0,K.jsx)(`span`,{className:`code-settings-status`,children:j?c.loading:N?c.saving:te})]}),ne&&(0,K.jsx)(`div`,{className:`code-settings-error`,role:`alert`,children:ne}),le.length===0&&(0,K.jsx)(`div`,{className:`code-agent-home-empty`,children:c.noAgents}),(0,K.jsx)(`div`,{className:`code-agent-homes-list`,children:le.map(e=>{let t=xP(k,e),n=yP(a).includes(e),r=t.find(e=>e.id.toLowerCase()===`default`),i=t.filter(e=>e.id.toLowerCase()!==`default`);return(0,K.jsxs)(`div`,{className:`code-agent-home-provider`,children:[(0,K.jsxs)(`div`,{className:`code-agent-home-provider-header`,children:[(0,K.jsxs)(`div`,{className:`code-agent-home-provider-title`,children:[(0,K.jsxs)(`strong`,{children:[gP(e),n?``:` · ${c.unavailable}`]}),r&&(0,K.jsxs)(`span`,{title:r.path,children:[r.path,` default`]})]}),(0,K.jsx)(`button`,{type:`button`,className:`code-agent-home-add`,disabled:j||N,onClick:()=>{I(``),F(``),R(CP(e))},"aria-label":c.addHome(gP(e)),title:c.addHome(gP(e)),children:(0,K.jsx)(he,{})})]}),i.map(t=>(0,K.jsxs)(`div`,{className:`code-agent-home-row`,children:[(0,K.jsx)(`div`,{className:`code-agent-home-path`,title:t.path,children:t.path}),(0,K.jsx)(`div`,{className:`code-agent-home-id`,children:t.id}),(0,K.jsx)(`div`,{className:`code-agent-home-actions`,children:(0,K.jsx)(`button`,{type:`button`,disabled:j||N,onClick:()=>se(e,t.id),"aria-label":c.remove,title:c.remove,children:(0,K.jsx)(Fe,{})})})]},t.id)),L&&L.provider===e&&(0,K.jsxs)(`div`,{className:`code-agent-home-form`,children:[(0,K.jsxs)(`label`,{children:[(0,K.jsx)(`span`,{children:c.homePath}),(0,K.jsx)(`input`,{type:`text`,name:`farming-agent-home-${e}-path`,inputMode:`text`,autoComplete:`off`,autoCorrect:`off`,autoCapitalize:`none`,spellCheck:!1,enterKeyHint:`next`,"data-lpignore":`true`,"data-1p-ignore":`true`,"data-bwignore":`true`,"data-form-type":`other`,value:L.path,placeholder:c.pathPlaceholder,"aria-label":c.homePath,onChange:e=>R(t=>t&&{...t,path:e.target.value})})]}),(0,K.jsxs)(`label`,{children:[(0,K.jsx)(`span`,{children:c.homeName}),(0,K.jsx)(`input`,{type:`text`,name:`farming-agent-home-${e}-name`,inputMode:`text`,autoComplete:`off`,autoCorrect:`off`,autoCapitalize:`none`,spellCheck:!1,enterKeyHint:`done`,"data-lpignore":`true`,"data-1p-ignore":`true`,"data-bwignore":`true`,"data-form-type":`other`,value:L.id,placeholder:c.homeNamePlaceholder,"aria-label":c.homeName,onChange:e=>R(t=>t&&{...t,id:e.target.value})}),(0,K.jsx)(`span`,{children:c.homeNameHint})]}),(0,K.jsxs)(`div`,{className:`code-agent-home-form-actions`,children:[(0,K.jsx)(`button`,{type:`button`,onClick:()=>R(null),"aria-label":c.cancel,title:c.cancel,children:(0,K.jsx)(Fe,{})}),(0,K.jsx)(`button`,{type:`button`,className:`primary`,disabled:j||N,onClick:oe,"aria-label":c.save,title:c.save,children:(0,K.jsx)(Te,{})})]})]})]},e)})})]})]})]})})}var TP=`\r`;function EP(e){return[{type:`paste`,text:e},TP]}var DP={newAgent:`New Agent`,search:`Search`,history:`History`,codex:`Farming Code`,expandSidebar:`Expand sidebar`,collapseSidebar:`Collapse sidebar`,enterFocusMode:`Enter focus mode`,exitFocusMode:`Exit focus mode`,appModeOpen:`App mode and fullscreen`,appModeTitle:`Use Farming without browser controls`,appModeDescription:`Use a clean app window where the browser supports it, or fullscreen temporarily.`,appModeRecommended:`Recommended`,appModeInstallTitle:`Install Farming 2`,appModeInstallDescription:`Opens as its own window without tabs, the address bar, or browser extensions.`,appModeInstallAction:`Install Farming 2`,appModeInstallStepOne:`Open Chrome’s ⋮ menu, then choose “Cast, save and share”.`,appModeInstallStepTwo:`Choose “Install page as app”, then open Farming 2 from its app icon.`,appModeInstallUnavailableTitle:`Browser app installation is unavailable`,appModeInstallUnavailableInsecure:`This deployment uses an insecure HTTP connection, so the browser cannot install it as an app.`,appModeInstallUnavailableBrowser:`This browser has not provided an app-install prompt for this deployment.`,appModeFullscreenTitle:`Fullscreen for now`,appModeFullscreenDescription:`Hide browser controls for this window. Press Esc to leave fullscreen.`,terminalView:`Terminal`,transcriptView:`Chat`,switchToTerminal:`Switch to Terminal`,switchToChat:`Switch to Chat`,collapseComposer:`Hide input`,restoreComposer:`Show input`,agentTranscriptSyncing:`Syncing chat history...`,agentTranscriptUnavailable:`This session’s Chat history could not be loaded.`,agentTranscriptEmpty:`No conversation yet.`,agentTranscriptWaiting:`Agent is still working...`,agentTranscriptProcess:`Process`,agentTranscriptWorking:`Processing`,agentTranscriptThinking:`Thinking`,agentTranscriptRunning:`Running`,agentTranscriptReading:`Reading`,agentTranscriptSearching:`Searching`,agentTranscriptEditing:`Editing`,agentTranscriptPlanActive:`On plan`,agentTranscriptPlanProgress:(e,t)=>`Plan ${e}/${t}`,agentTranscriptFetching:`Fetching`,agentTranscriptUsingTool:`Using tool`,agentTranscriptActionRunning:e=>`Running: ${e}`,agentTranscriptActionFailed:e=>`Failed: ${e}`,agentTranscriptEarlierActions:e=>`${e} earlier ${e===1?`action`:`actions`}`,agentTranscriptTerminalStatusUnavailable:`Terminal status could not be synchronized.`,agentTranscriptRetryTerminalStatus:`Retry`,agentTranscriptWorkedFor:e=>`Worked for ${e}`,agentTranscriptProcessCount:e=>`${e} ${e===1?`event`:`events`}`,agentTranscriptCopyDetails:`Copy details`,agentTranscriptCopiedDetails:`Copied`,agentTranscriptCopyAnswer:`Copy answer`,agentTranscriptCopiedAnswer:`Copied answer`,agentTranscriptFork:`Fork conversation`,agentTranscriptForkedFromAgent:`Forked from agent`,agentTranscriptReviewChanges:`Review`,agentTranscriptShowChanges:`Show file changes`,agentTranscriptLoadingChanges:`Loading exact changes…`,agentTranscriptKeepChange:`Keep`,agentTranscriptRevertChange:`Revert`,agentTranscriptChangeKept:`Kept`,agentTranscriptChangeReverted:`Reverted`,agentTranscriptShowMoreFiles:e=>`Show ${e} more file${e===1?``:`s`}`,codexGoalTitle:`Goal`,codexGoalEmpty:`No active goal`,codexGoalOpen:`Open goal controls`,codexGoalObjective:`Objective`,codexGoalStatus:`Status`,codexGoalTokenBudget:`Token budget`,codexGoalNoBudget:`No budget`,codexGoalUsage:(e,t)=>`${e.toLocaleString()} tokens · ${Math.round(t/60)}m`,codexGoalStatusLabel:e=>({active:`Active`,paused:`Paused`,blocked:`Blocked`,usageLimited:`Usage limited`,budgetLimited:`Budget limited`,complete:`Complete`})[e]??e,codexGoalEdit:`Edit`,codexGoalStart:`Start`,codexGoalStop:`Stop`,codexGoalDelete:`Delete`,codexGoalSave:`Save goal`,codexGoalClear:`Clear`,codexGoalSaving:`Saving...`,searchProjectsOrAgents:`Search projects or agents`,clearSearch:`Clear search`,projectsAndAgents:`Projects and agents`,noAgentsYet:`No agents yet.`,noMatchingProjectsOrAgents:`No matching projects or agents.`,openNavigation:`Open navigation`,closeNavigation:`Close navigation`,resizeNavigation:`Resize navigation`,openOptions:`Open options`,openSettings:`Settings`,agentActions:`Agent actions`,appearanceSystem:`Appearance: System`,appearanceLight:`Appearance: Light`,appearanceDark:`Appearance: Dark`,languageEnglish:`Language: English`,languageChinese:`Language: 中文`,pinAgent:`Pin Agent`,unpinAgent:`Unpin Agent`,pinProject:`Pin project`,unpinProject:`Unpin project`,revealInFinder:`Reveal in Finder`,revealInFinderFailed:`Failed to reveal project in Finder`,createPermanentWorktree:`Create permanent worktree`,permanentWorktreeCreated:`Permanent worktree created`,permanentWorktreeFailed:`Failed to create permanent worktree`,markAllAsRead:`Mark all as read`,renameAgent:`Rename Agent`,renameProject:`Rename project`,archiveAgent:`Archive`,reorderAgentFailed:`Failed to reorder Agent`,markAsRead:`Mark as read`,markAsUnread:`Mark as unread`,copyWorkingDirectory:`Copy working directory`,copiedWorkingDirectory:`Copied working directory`,copyFailed:`Copy failed`,sharePage:`Share page`,scanToOpenOnPhone:`Scan to open on phone`,copyFullShareLink:`Copy full link`,copiedShareLink:`Copied full link`,shareLinkFailed:`Share link unavailable`,sharedLocationUnavailable:e=>`Unable to locate shared path: ${e}`,shareLinkExpired:`Expired`,refreshShareLink:`Refresh`,brandStoryOrigin:`Farming Code began with a simple idea: when several coding agents work at once, people should not have to bounce between terminals, editors, and browser tabs.`,brandStoryPurpose:`It brings conversations, terminals, project files, and progress into one calm workspace, so attention stays on what matters.`,brandGithub:`GitHub`,renameInstance:`Rename instance`,instanceNameTitle:`Rename Farming instance`,instanceNameDescription:`This name appears in the sidebar and browser tab for this Farming machine.`,instanceNamePlaceholder:`Machine name`,instanceNameSaveFailed:`Could not save the instance name.`,mobileShareTitle:`Share page`,mobileForwardTitle:`Send this page`,mobileForwardHint:`Copy the link to send the current view to someone else.`,mobileShareCopyAction:`Copy link`,mobileShareCopied:`Copied`,mobileInstallTitle:`Add to Home Screen`,mobileInstallChromeHint:`Make sure this page is open in your system browser or Chrome.`,mobileInstallShareStep:`Tap Share in the browser toolbar.`,mobileInstallMoreStep:`If it is hidden, tap •••, then Share.`,mobileInstallAddStep:`Choose “Add to Home Screen”.`,mobileInstallOpenStep:`Open Farming from its Home Screen icon next time.`,mobileShareInstalled:`Farming is already open as a Home Screen app.`,forkSameWorktree:`Fork into same worktree`,forkNewWorktree:`Fork into new worktree`,newWorktreeFork:`Forked to new worktree`,scheduledTask:`Scheduled task`,killAgent:`Kill Agent`,killAgentQuestion:`Kill Agent?`,openSession:`Open Session`,pinChat:`Pin chat`,unpinChat:`Unpin chat`,archiveChat:`Archive`,archiveChats:`Archive chats`,archiveProject:`Archive Project`,removeProject:`Remove Project`,deleteWorktree:`Permanently Delete Worktree`,deleteWorktreeQuestion:`Permanently delete worktree?`,deleteWorktreeDescription:`This permanently deletes the worktree and all of its files.`,forceDelete:`Permanently Delete`,cancel:`Cancel`,retry:`Retry`,save:`Save`,stopAgentDescription:e=>`Stop ${e} and close its terminal.`,acknowledgeUnprovenAcpExit:`Confirm Exit and Remove`,acknowledgeUnprovenAcpExitDescription:e=>`Farming cannot prove that ${e}'s legacy ACP process exited during the upgrade. Continue only after verifying it has exited at the operating-system level. This removes Farming metadata and does not stop an unknown process.`,permissionModeLabel:(e,t)=>t,permissionModeDescription:(e,t)=>t,acpModeLabel:(e,t)=>({"read-only":`Read-only`,agent:`Workspace`,"agent-full-access":`Full access`,auto:`Auto`,default:`Manual`,acceptEdits:`Accept edits`,plan:`Plan`,dontAsk:`Don't ask`,bypassPermissions:`Bypass permissions`,build:`Build`})[e]??t,acpModeDescription:(e,t)=>({"read-only":`Read and analyze by default. File writes and commands that need more access require approval. Network access is off.`,agent:`Read and write inside this workspace and run sandboxed commands. Network and out-of-workspace access require approval.`,"agent-full-access":`Access files outside this workspace and use the network without approval prompts. Use only in a trusted environment.`,auto:`Use the model classifier to approve or deny permission requests.`,default:`Prompt before operations that require approval.`,acceptEdits:`Approve file edits automatically; ask about other operations that need permission.`,plan:`Plan and inspect without modifying files.`,dontAsk:`Do not show permission prompts; deny operations that were not already allowed.`,bypassPermissions:`Bypass permission checks. Use only in a trusted environment.`,build:`Run tools according to the permissions configured for this Agent.`})[e]??t,reasoningOptionLabel:(e,t)=>t,serviceTierLabel:(e,t)=>t,serviceTierDescription:(e,t)=>t,messageMode:`Message`,goalMode:`Goal`,planMode:`Plan`,askFollowUpChanges:`Ask for follow-up changes`,shellCommandPlaceholder:`Type a shell command`,describeAgentGoal:`Describe the goal for this agent`,describePlanFirst:`Describe what should be planned first`,openAgentTerminalFirst:`Open an agent terminal first`,queuedMessages:e=>`${e} queued messages`,sendQueuedMessage:`Send next`,discardQueuedMessage:`Discard queued message`,addContext:`Add context`,attachFile:`Attach file`,fileContext:`File context`,acpSignOut:`Sign out`,acpSigningOut:`Signing out…`,acpSignOutDescription:`Sign out of this ACP Agent`,setObjective:`Set objective`,planFirst:`Plan first`,clearComposerMode:`Clear composer mode`,agentPermissionMode:`Agent permission mode`,permissionsPrompt:`Launch permission profile`,permissionProfileSavedForNextLaunch:`Saved for new agents. Running sessions keep the permissions they launched with.`,permissionProfileRestarting:`Switching agent permissions…`,runtimeModeRestarting:`Restarting Agent…`,terminalProfileApplying:`Applying model to Codex Terminal…`,terminalProfileApplied:`Codex Terminal model updated.`,terminalProfileFailed:e=>`Codex Terminal model was not changed: ${e}`,agentRestartTimedOut:`Agent restart timed out. The previous Agent remains available; try switching again.`,permissionRestartHint:`The running agent restarts to apply these permissions. If it has no resumable session id yet, a fresh session starts.`,modelAndReasoning:`Model and reasoning`,reasoning:`Reasoning`,speed:`Speed`,startDictation:`Start dictation`,stopDictation:`Stop dictation`,speechUnsupported:`Speech recognition is not supported in this browser`,mobileDictationHint:`Use the microphone key on the iOS keyboard to dictate.`,sendMessage:`Send message`,interruptAgent:`Interrupt agent`,startOrSelectAgent:`Start or select an agent`,startOrSelectAgentDescription:`Projects live on the left. Open any agent terminal without closing the rest of the workspace.`,emptyWorkspaceWelcome:`Welcome to Farming`,emptyWorkspaceWelcomeDescription:`Continue earlier work, or start a new Agent.`,emptyWorkspaceContinue:`Continue earlier work`,emptyWorkspaceContinueDescription:`Resume Codex, Claude, and other Agent sessions from History.`,emptyWorkspaceNewAgentDescription:`Start a new coding task in the current project.`,emptyWorkspaceSearchDescription:`Find projects, Agents, and history.`,emptyWorkspaceShareDescription:`Open Farming on your phone or another device.`,emptyWorkspaceFocus:`Focus mode`,emptyWorkspaceFocusDescription:`Hide distractions and focus on the current task.`,emptyWorkspaceCollapseDescription:`Give the workspace more room.`,historySummary:(e,t,n,r)=>`${n+r} history agents`,searchHistory:`Search history`,noHistoryYet:`No history yet`,noHistoryDescription:`Agents moved off the main page will appear here.`,historyAgents:`History Agents`,historyPagination:`History pages`,historyPageStatus:(e,t,n,r)=>`${e} / ${t}${r?`+`:``} · ${n} loaded`,previousPage:`Previous page`,nextPage:`Next page`,agentSessions:`Agent Sessions`,recentWorkspaces:`Recent Workspaces`,agentsSessionsSummary:(e,t)=>`${e} agents · ${t} sessions`,restore:`Restore`,continueRun:`Continue`,open:`Open`,archived:`Archived`,pinned:`Pinned`,unread:`Unread`,showMore:`Show more`,showLess:`Show less`,showAgents:`Show agents`,hideAgents:`Hide agents`,latest:`Latest`,upgrade:`UPGRADE`,updating:`UPDATING`,retryUpdate:`RETRY`,checkForUpdates:`Check for updates`,updateFailed:`Update failed`,upgradeToVersion:e=>e?`Upgrade to ${e}`:`Upgrade Farming Code`,sessionFallbackTitle:e=>`${e||`Agent`} session`,resumeSessionAria:e=>`Resume ${e}`,resultsCount:e=>`${e} results`,noMatchingAgents:`No matching agents`,searchHint:`Search by Agent title, session title, or project.`,searchEmptyTitle:`Start a search`,searchEmptyDescription:`Type an Agent title, session title, or project name or path.`,agents:`Agents`,files:`Files`,changes:`Changes`,changedFiles:`Changed files`,trackedChanges:`Tracked`,untrackedChanges:`Untracked`,reviewChanges:`Review`,refreshChanges:`Refresh changes`,worktrees:`Worktrees`,showWorktrees:`Show repository worktrees`,worktreeCurrent:`current`,worktreeMain:`main`,worktreeDetached:`detached`,worktreeLocked:`locked`,worktreePrunable:`prunable`,worktreeLoadFailed:`Unable to load repository worktrees`,gitHistory:`History`,gitHistoryEmpty:`No commits yet`,gitHistoryNotRepository:`This project is not a Git repository`,gitHistoryLoadMore:`Load more`,gitHistoryView:`History view`,gitHistoryCurrentScope:`Current`,gitHistoryAllScope:`All`,gitHistoryCurrentBranch:`Current branch`,gitHistoryAllBranches:`All branches`,gitHistoryCommitMessage:`Message`,gitHistoryParent:`Compare with parent`,gitHistoryRootCommit:`Root commit`,gitHistoryReviewCommit:`Review commit`,gitHistoryCommitChanges:e=>`${e} file${e===1?``:`s`} changed`,gitHistoryNoChanges:`No file changes`,gitHistoryChangesTruncated:`More changed files were omitted`,searchOrPathLine:`Search or path:line`,searchFilesOrJump:`Search files or jump to path line`,openEditors:`OPEN EDITORS`,loading:`Loading...`,searching:`Searching...`,noMatches:`No matches`,searchIgnoredFolders:`Also search ignored folders`,searchIncomplete:e=>`Search stopped early. Current timeout: ${Math.round(e/1e3)}s.`,terminalSearchPlaceholder:`Find in terminal`,terminalSearchPrevious:`Previous match`,terminalSearchNext:`Next match`,terminalSearchClose:`Close terminal search`,terminalSearchCaseSensitive:`Match case`,terminalSearchWholeWord:`Match whole word`,terminalSearchRegex:`Use regular expression`,terminalSearchNoResults:`No results`,terminalSearchResults:(e,t)=>`${e}/${t}`,terminalRecoveryRequesting:`Loading terminal state…`,terminalRecoveryInstalling:`Terminal state received. Restoring screen…`,terminalRecoveryRetrying:e=>`Terminal state unavailable. Retrying in ${e}s…`,terminalRecoveryElapsed:e=>`Waiting ${e}s`,terminalRecoveryAttempt:e=>`Attempt ${e}`,terminalSessionUnavailable:`Terminal session unavailable`,acpPermissionAllow:`Allow`,acpPermissionTitle:`Agent needs permission`,acpPermissionTool:`Requested tool`,file:`File`,folder:`Folder`,go:`Go`,moreMatchesOmitted:`More matches omitted`,stickyFolderPath:`Sticky folder path`,containsUncommittedChanges:`Contains uncommitted changes`,changedOnDisk:`Changed on disk`,unsavedChanges:`Unsaved changes`,gitStatus:e=>`Git status: ${e}`,renameEntry:e=>`Rename ${e}`,newFile:`New File`,newFolder:`New Folder`,refreshFiles:`Refresh files`,refreshingFiles:`Refreshing files…`,filesRefreshed:`Files refreshed`,filesRefreshFailed:`Files refresh failed`,refresh:`Refresh`,rename:`Rename`,copyRelativePath:`Copy Relative Path`,copyShareUrl:`Copy Share URL`,delete:`Delete`,deleteFolderContents:e=>`Delete folder and all contents: ${e||``}`,deleteFile:e=>`Delete file: ${e||``}`,saveFile:`Save file`,savingFile:`Saving file`,reloadFile:`Reload file`,overwriteChangedFile:`Overwrite changed file`,openFileDiff:`Open File Diff`,openFileDiffFor:e=>`Open diff for ${e}`,closeDiff:`Close diff`,openFilePreview:`Open preview`,showFileSource:`Show source`,enableWordWrap:`Enable word wrap`,disableWordWrap:`Disable word wrap`,openMarkdownPreview:`Open Markdown preview`,showMarkdownSource:`Show Markdown source`,openMarkdownSplitPreview:`Open Markdown preview to side`,closeMarkdownSplitPreview:`Close Markdown side preview`,markdownPreviewFor:e=>`Markdown preview for ${e}`,markdownFrontMatter:`Front matter`,markdownHeadingAnchor:`Link to heading`,mermaidDiagram:`Mermaid diagram`,mermaidDiagramControls:`Mermaid diagram controls`,mermaidRendering:`Rendering diagram...`,mermaidRenderFailed:`Unable to render Mermaid diagram`,mermaidZoomIn:`Zoom in`,mermaidZoomOut:`Zoom out`,mermaidPanMode:`Toggle pan mode`,mermaidEnterFullscreen:`Open fullscreen diagram`,mermaidExitFullscreen:`Close fullscreen diagram`,mermaidResetView:`Reset view`,mermaidCopySource:`Copy Mermaid source`,mermaidCopiedSource:`Copied Mermaid source`,fileDiff:`File Diff`,loadingDiff:`Loading diff...`,noFileDiff:`No file changes.`,diffUnavailable:`Diff content is unavailable for this file.`,binaryDiffUnavailable:`Binary file diff is unavailable.`,diffTooLarge:`Diff is too large to display.`,deletedFileDiffOnly:`This deleted file is only available as a diff.`,showGitBlame:`Show git blame`,hideGitBlame:`Hide git blame`,gitBlameAnnotations:`Git blame annotations`,gitBlameDetails:`Git blame details`,filePath:`File path`,editorFor:e=>`Editor for ${e}`,revealInExplorer:e=>`Reveal ${e} in Explorer`,previewFor:e=>`Preview for ${e}`,author:`Author`,commit:`Commit`,date:`Date`,line:`Line`,unknown:`Unknown`,uncommitted:`Uncommitted`,closeBlameDetails:`Close blame details`,cut:`Cut`,copy:`Copy`,paste:`Paste`,selectAll:`Select All`,annotateWithBlame:`Annotate with Blame`,hideBlame:`Hide Blame`,openLineChangesWithPreviousRevision:`Open Line Changes with Previous Revision`,openLineChangesWithWorkingFile:`Open Line Changes with Working File`,lineChanges:`Line changes`,loadingLineChanges:`Loading line changes...`,noLineChanges:`No line changes for this line.`,closeLineChanges:`Close line changes`,close:`Close`,closeFile:e=>`Close ${e}`,closeOthers:`Close Others`,closeToRight:`Close to the Right`,closeSaved:`Close Saved`,closeAll:`Close All`,saveBeforeCloseTitle:e=>`Save changes to ${e}?`,saveBeforeCloseDescription:`If you do not save, your changes will be lost.`,dontSave:`Don't Save`,loadingBlame:`Loading blame...`,notGitRepository:`Not a git repository.`,noCommittedLines:`No committed lines.`,cursorPosition:(e,t)=>`Ln ${e}, Col ${t}`,startMainAgent:`Start Main Agent`,startNewAgent:`Start New Agent`,loadingAgents:`Loading agents...`,agentListUnavailable:`Agent list unavailable.`,noSupportedAgentsFound:`No supported agents found.`,resumePreviousMainAgent:`Resume previous Main Agent`,codingAgents:`coding agents`,otherAgents:`Shell`,workspace:`Workspace:`,workspacePathPlaceholder:`/path/to/workspace`,chooseWorkspaceDirectory:`Choose workspace folder`,workspaceDirectoryBrowserFailed:`Couldn’t read this directory.`,workspaceDirectoryBrowserHostHint:`Browse folders on the Farming host.`,workspaceDirectoryBrowserGo:`Go to directory`,workspaceDirectoryBrowserParent:`Parent directory`,workspaceDirectoryBrowserEmpty:`No subdirectories.`,workspaceDirectoryBrowserTruncated:`Only the first 500 folders are shown. Enter a more specific path to continue.`,workspaceDirectoryBrowserSelect:`Select this folder`,workspaceMissingTitle:`Create this workspace?`,workspaceMissingDescription:`This directory does not exist yet. Farming can create it and start the Agent there.`,workspaceCreateAndStart:`Create & Start`,workspaceCreating:`Creating...`,workspaceCreateFailedTitle:`Couldn’t create workspace`,workspaceCreateForbiddenDescription:`Farming does not have permission to create this directory. Choose another location or update the parent directory permissions.`,workspaceCreateFailedDescription:`Farming couldn’t create this directory. Check the path and try again.`,returnToWorkspace:`Change Path`,recentWorkspacesLower:`recent workspaces`,start:`Start`,back:`Back`,backToAgent:`Back to Agent`,goBack:`Go Back`,goForward:`Go Forward`,backendConnecting:`Connecting to Farming backend...`,backendConnectionLost:`Farming backend disconnected. Reconnecting...`,backendHeartbeatLost:`No Farming backend heartbeat. Waiting for it to recover...`},OP={newAgent:`新建 Agent`,search:`搜索`,history:`历史`,codex:`Farming Code`,expandSidebar:`展开侧边栏`,collapseSidebar:`收起侧边栏`,enterFocusMode:`进入沉浸模式`,exitFocusMode:`退出沉浸模式`,appModeOpen:`应用模式与全屏`,appModeTitle:`隐藏浏览器控制`,appModeDescription:`浏览器支持时可安装为独立应用窗口,也可以临时进入全屏。`,appModeRecommended:`推荐`,appModeInstallTitle:`安装 Farming 2`,appModeInstallDescription:`以后从独立窗口打开,不显示标签栏、地址栏和浏览器扩展。`,appModeInstallAction:`安装 Farming 2`,appModeInstallStepOne:`打开 Chrome 右上角 ⋮,选择“投放、保存和分享”。`,appModeInstallStepTwo:`选择“将网页安装为应用”,以后从 Farming 2 应用图标打开。`,appModeInstallUnavailableTitle:`无法安装为浏览器应用`,appModeInstallUnavailableInsecure:`当前部署使用不安全的 HTTP 连接,浏览器无法将其安装为应用。`,appModeInstallUnavailableBrowser:`当前浏览器没有为此部署提供应用安装入口。`,appModeFullscreenTitle:`暂时全屏`,appModeFullscreenDescription:`只为当前窗口隐藏浏览器控制,按 Esc 即可退出。`,terminalView:`终端`,transcriptView:`对话`,switchToTerminal:`切换到终端`,switchToChat:`切换到对话`,collapseComposer:`收起输入框`,restoreComposer:`唤出输入框`,agentTranscriptSyncing:`正在同步聊天历史...`,agentTranscriptUnavailable:`无法加载此会话的 Chat 历史。`,agentTranscriptEmpty:`还没有对话。`,agentTranscriptWaiting:`Agent 仍在工作...`,agentTranscriptProcess:`执行过程`,agentTranscriptWorking:`处理中`,agentTranscriptThinking:`思考中`,agentTranscriptRunning:`运行命令中`,agentTranscriptReading:`读取文件中`,agentTranscriptSearching:`搜索中`,agentTranscriptEditing:`修改文件中`,agentTranscriptPlanActive:`执行计划中`,agentTranscriptPlanProgress:(e,t)=>`执行计划 ${e}/${t}`,agentTranscriptFetching:`获取信息中`,agentTranscriptUsingTool:`调用工具中`,agentTranscriptActionRunning:e=>`正在执行:${e}`,agentTranscriptActionFailed:e=>`失败:${e}`,agentTranscriptEarlierActions:e=>`更早的 ${e} 个操作`,agentTranscriptTerminalStatusUnavailable:`终端状态未能同步。`,agentTranscriptRetryTerminalStatus:`重试`,agentTranscriptWorkedFor:e=>`Worked for ${e}`,agentTranscriptProcessCount:e=>`${e} 个事件`,agentTranscriptCopyDetails:`复制详情`,agentTranscriptCopiedDetails:`已复制`,agentTranscriptCopyAnswer:`复制答复`,agentTranscriptCopiedAnswer:`已复制答复`,agentTranscriptFork:`分叉对话`,agentTranscriptForkedFromAgent:`从 Agent 分叉`,agentTranscriptReviewChanges:`Review`,agentTranscriptShowChanges:`展开文件改动`,agentTranscriptLoadingChanges:`正在加载准确改动…`,agentTranscriptKeepChange:`保留`,agentTranscriptRevertChange:`撤销`,agentTranscriptChangeKept:`已保留`,agentTranscriptChangeReverted:`已撤销`,agentTranscriptShowMoreFiles:e=>`显示另外 ${e} 个文件`,codexGoalTitle:`目标`,codexGoalEmpty:`没有活动目标`,codexGoalOpen:`打开目标控制`,codexGoalObjective:`目标内容`,codexGoalStatus:`状态`,codexGoalTokenBudget:`Token 预算`,codexGoalNoBudget:`不限制`,codexGoalUsage:(e,t)=>`${e.toLocaleString()} tokens · ${Math.round(t/60)} 分钟`,codexGoalStatusLabel:e=>({active:`进行中`,paused:`已暂停`,blocked:`已阻塞`,usageLimited:`用量受限`,budgetLimited:`预算受限`,complete:`已完成`})[e]??e,codexGoalEdit:`编辑`,codexGoalStart:`启动`,codexGoalStop:`停止`,codexGoalDelete:`删除`,codexGoalSave:`保存目标`,codexGoalClear:`清除`,codexGoalSaving:`保存中...`,searchProjectsOrAgents:`搜索项目或 Agent`,clearSearch:`清空搜索`,projectsAndAgents:`项目与 Agent`,noAgentsYet:`还没有 Agent。`,noMatchingProjectsOrAgents:`没有匹配的项目或 Agent。`,openNavigation:`打开导航`,closeNavigation:`关闭导航`,resizeNavigation:`调整导航宽度`,openOptions:`打开选项`,openSettings:`设置`,agentActions:`Agent 操作`,appearanceSystem:`外观:跟随系统`,appearanceLight:`外观:浅色`,appearanceDark:`外观:深色`,languageEnglish:`语言:English`,languageChinese:`语言:中文`,pinAgent:`置顶 Agent`,unpinAgent:`取消置顶`,pinProject:`置顶项目`,unpinProject:`取消置顶项目`,revealInFinder:`在访达中显示`,revealInFinderFailed:`无法在访达中显示项目`,createPermanentWorktree:`创建永久 worktree`,permanentWorktreeCreated:`已创建永久 worktree`,permanentWorktreeFailed:`创建永久 worktree 失败`,markAllAsRead:`全部标为已读`,renameAgent:`重命名 Agent`,renameProject:`重命名项目`,archiveAgent:`归档`,reorderAgentFailed:`调整 Agent 顺序失败`,markAsRead:`标为已读`,markAsUnread:`标为未读`,copyWorkingDirectory:`复制工作目录`,copiedWorkingDirectory:`已复制工作目录`,copyFailed:`复制失败`,sharePage:`分享页面`,scanToOpenOnPhone:`手机扫码打开`,copyFullShareLink:`复制完整链接`,copiedShareLink:`已复制完整链接`,shareLinkFailed:`分享链接不可用`,sharedLocationUnavailable:e=>`无法定位分享路径:${e}`,shareLinkExpired:`已过期`,refreshShareLink:`刷新`,brandStoryOrigin:`Farming Code 从一个简单的问题出发:当多个 Coding Agent 同时工作,人不该在终端、编辑器和浏览器标签页之间反复切换。`,brandStoryPurpose:`它把对话、终端、项目文件与进展放在一个安静的工作空间里,让注意力留在真正重要的事情上。`,brandGithub:`GitHub`,renameInstance:`重命名实例`,instanceNameTitle:`重命名 Farming 实例`,instanceNameDescription:`这个名称会显示在此机器的侧边栏和浏览器页签中。`,instanceNamePlaceholder:`机器名称`,instanceNameSaveFailed:`无法保存实例名称。`,mobileShareTitle:`分享页面`,mobileForwardTitle:`转发当前页面`,mobileForwardHint:`复制链接,发送给其他人。`,mobileShareCopyAction:`复制链接`,mobileShareCopied:`已复制`,mobileInstallTitle:`添加到主屏幕`,mobileInstallChromeHint:`确认已使用系统浏览器或 Chrome 打开当前页面。`,mobileInstallShareStep:`点浏览器工具栏里的“分享”。`,mobileInstallMoreStep:`没看到时,点 •••,再点“分享”。`,mobileInstallAddStep:`选择“添加到主屏幕”。`,mobileInstallOpenStep:`以后从主屏幕的 Farming 图标进入。`,mobileShareInstalled:`Farming 已经作为主屏幕 App 打开。`,forkSameWorktree:`在同一 worktree 分叉`,forkNewWorktree:`分叉到新 worktree`,newWorktreeFork:`已分叉到新 worktree`,scheduledTask:`周期任务`,killAgent:`停止 Agent`,killAgentQuestion:`停止 Agent?`,openSession:`打开会话`,pinChat:`置顶会话`,unpinChat:`取消置顶会话`,archiveChat:`归档`,archiveChats:`归档会话`,archiveProject:`归档项目`,removeProject:`移除项目`,deleteWorktree:`彻底删除 worktree`,deleteWorktreeQuestion:`彻底删除 worktree?`,deleteWorktreeDescription:`这会彻底删除该 worktree 及其中的所有文件。`,forceDelete:`彻底删除`,cancel:`取消`,retry:`重试`,save:`保存`,stopAgentDescription:e=>`停止 ${e} 并关闭它的终端。`,acknowledgeUnprovenAcpExit:`确认已退出并移除`,acknowledgeUnprovenAcpExitDescription:e=>`Farming 无法证明 ${e} 的旧版 ACP 进程在升级时已经退出。请先在操作系统层确认进程已退出;继续操作只会移除 Farming 元数据,不会停止未知进程。`,permissionModeLabel:(e,t)=>({ask:`请求批准`,approve:`自动批准`,full:`完全访问`,custom:`自定义`,default:`默认`,auto:`自动`,acceptEdits:`接受编辑`,dontAsk:`不询问`,plan:`计划`,bypassPermissions:`绕过权限`})[e]??t,permissionModeDescription:(e,t)=>({ask:`新 Codex 会话以 workspace-write 沙箱启动,并对不可信操作询问`,approve:`新 Codex 会话以 workspace-write 沙箱启动,并在 Codex 请求时询问`,full:`新 Codex 会话绕过批准和沙箱;仅用于可信沙箱`,custom:`新 Codex 会话使用 config.toml 中定义的权限`,default:`新 Claude Code 会话使用默认设置`,auto:`新 Claude Code 会话以 auto 权限模式启动`,acceptEdits:`新 Claude Code 会话允许文件编辑,其他高风险操作仍会询问`,dontAsk:`新 Claude Code 会话在支持时尽量避免交互式批准`,plan:`新 Claude Code 会话以计划权限模式启动`,bypassPermissions:`新 Claude Code 会话绕过权限检查;仅用于可信沙箱`})[e]??t,acpModeLabel:(e,t)=>({"read-only":`只读`,agent:`工作区`,"agent-full-access":`完全访问`,auto:`自动`,default:`手动批准`,acceptEdits:`接受编辑`,plan:`计划`,dontAsk:`不询问`,bypassPermissions:`绕过权限`,build:`执行`})[e]??t,acpModeDescription:(e,t)=>({"read-only":`默认只读和分析;写文件或运行需要更高权限的命令时会请求批准,网络默认关闭`,agent:`可在当前工作区内读写文件并运行沙箱命令;使用网络或访问工作区外内容时会请求批准`,"agent-full-access":`可访问工作区外文件并使用网络,且不再请求批准;仅用于可信环境`,auto:`由模型分类器自动批准或拒绝权限请求`,default:`需要权限的操作会先请求批准`,acceptEdits:`自动批准文件编辑;其他需要权限的操作仍会询问`,plan:`只进行规划和检查,不修改文件`,dontAsk:`不弹出权限询问;未经预先允许的操作会直接拒绝`,bypassPermissions:`绕过权限检查;仅用于可信环境`,build:`按照该 Agent 已配置的权限执行工具`})[e]??t,reasoningOptionLabel:(e,t)=>({config:`使用配置`,low:`低`,medium:`中`,high:`高`,xhigh:`超高`,max:`最高`})[e]??t,serviceTierLabel:(e,t)=>({default:`标准`,priority:`快`,flex:`弹性`})[e]??t,serviceTierDescription:(e,t)=>({default:`默认速度`,priority:`1.5 倍速度,用量增加`})[e]??t,messageMode:`消息`,goalMode:`目标`,planMode:`计划`,askFollowUpChanges:`输入后续修改要求`,shellCommandPlaceholder:`输入 Shell 命令`,describeAgentGoal:`描述这个 Agent 的目标`,describePlanFirst:`描述需要先规划的事情`,openAgentTerminalFirst:`先打开一个 Agent 终端`,queuedMessages:e=>`${e} 条排队消息`,sendQueuedMessage:`当前轮后发送`,discardQueuedMessage:`丢弃排队消息`,addContext:`添加上下文`,attachFile:`附加文件`,fileContext:`文件上下文`,acpSignOut:`退出登录`,acpSigningOut:`正在退出…`,acpSignOutDescription:`退出当前 ACP Agent 登录`,setObjective:`设置目标`,planFirst:`先做计划`,clearComposerMode:`清除输入模式`,agentPermissionMode:`Agent 权限模式`,permissionsPrompt:`启动权限 profile`,permissionProfileSavedForNextLaunch:`已保存给新 Agent。运行中的会话保留启动时的权限。`,permissionProfileRestarting:`正在切换 Agent 权限…`,runtimeModeRestarting:`正在重启 Agent…`,terminalProfileApplying:`正在应用 Codex Terminal 模型…`,terminalProfileApplied:`Codex Terminal 模型已更新。`,terminalProfileFailed:e=>`Codex Terminal 模型未修改:${e}`,agentRestartTimedOut:`Agent 重启超时。原 Agent 仍然可用,请重新切换。`,permissionRestartHint:`运行中的 Agent 会重启以应用权限;如果还没有可 resume 的 Session ID,则启动一个新会话。`,modelAndReasoning:`模型与推理`,reasoning:`推理`,speed:`速度`,startDictation:`开始语音输入`,stopDictation:`停止语音输入`,speechUnsupported:`当前浏览器不支持语音识别`,mobileDictationHint:`请点 iOS 键盘上的麦克风进行听写。`,sendMessage:`发送消息`,interruptAgent:`中止 Agent`,startOrSelectAgent:`启动或选择一个 Agent`,startOrSelectAgentDescription:`项目在左侧。打开任意 Agent 终端时,不会关闭其他工作区。`,emptyWorkspaceWelcome:`欢迎使用 Farming`,emptyWorkspaceWelcomeDescription:`继续之前的工作,或开始一个新的 Agent。`,emptyWorkspaceContinue:`继续之前的工作`,emptyWorkspaceContinueDescription:`从历史记录恢复 Codex、Claude 等 Agent 会话。`,emptyWorkspaceNewAgentDescription:`在当前项目开始一个新的编码任务。`,emptyWorkspaceSearchDescription:`查找项目、Agent 和历史。`,emptyWorkspaceShareDescription:`在手机或另一台设备打开。`,emptyWorkspaceFocus:`专注模式`,emptyWorkspaceFocusDescription:`隐藏干扰,专注当前任务。`,emptyWorkspaceCollapseDescription:`给工作区更多空间。`,historySummary:(e,t,n,r)=>`${n+r} 个 History Agents`,searchHistory:`搜索历史记录`,noHistoryYet:`还没有历史记录`,noHistoryDescription:`从主页面移出的 Agent 会出现在这里。`,historyAgents:`History Agents`,historyPagination:`历史记录分页`,historyPageStatus:(e,t,n,r)=>`第 ${e} / ${t}${r?`+`:``} 页 · 已载入 ${n} 条`,previousPage:`上一页`,nextPage:`下一页`,agentSessions:`Agent 会话`,recentWorkspaces:`最近工作区`,agentsSessionsSummary:(e,t)=>`${e} 个 Agent · ${t} 个会话`,restore:`恢复`,continueRun:`继续`,open:`打开`,archived:`已归档`,pinned:`已置顶`,unread:`未读`,showMore:`显示更多`,showLess:`收起`,showAgents:`展开 Agent`,hideAgents:`隐藏 Agent`,latest:`最新`,upgrade:`升级`,updating:`更新中`,retryUpdate:`重试`,checkForUpdates:`检查更新`,updateFailed:`更新失败`,upgradeToVersion:e=>e?`升级到 ${e}`:`升级 Farming Code`,sessionFallbackTitle:e=>`${e||`Agent`} 会话`,resumeSessionAria:e=>`恢复 ${e}`,resultsCount:e=>`${e} 个结果`,noMatchingAgents:`没有匹配的 Agent`,searchHint:`可按 Agent 标题、会话标题或项目搜索。`,searchEmptyTitle:`开始搜索`,searchEmptyDescription:`输入 Agent 标题、会话标题,或项目名称、路径。`,agents:`Agent`,files:`文件`,changes:`变更`,changedFiles:`变更文件`,trackedChanges:`已跟踪`,untrackedChanges:`未跟踪`,reviewChanges:`Review`,refreshChanges:`刷新变更`,worktrees:`工作树`,showWorktrees:`查看仓库工作树`,worktreeCurrent:`当前`,worktreeMain:`主工作树`,worktreeDetached:`游离`,worktreeLocked:`已锁定`,worktreePrunable:`可清理`,worktreeLoadFailed:`无法加载仓库工作树`,gitHistory:`历史`,gitHistoryEmpty:`还没有提交`,gitHistoryNotRepository:`当前项目不是 Git 仓库`,gitHistoryLoadMore:`加载更多`,gitHistoryView:`历史视图`,gitHistoryCurrentScope:`当前`,gitHistoryAllScope:`全部`,gitHistoryCurrentBranch:`当前分支`,gitHistoryAllBranches:`所有分支`,gitHistoryCommitMessage:`提交说明`,gitHistoryParent:`与父提交比较`,gitHistoryRootCommit:`根提交`,gitHistoryReviewCommit:`Review 提交`,gitHistoryCommitChanges:e=>`${e} 个文件有变化`,gitHistoryNoChanges:`没有文件变化`,gitHistoryChangesTruncated:`还有部分变更文件未展示`,searchOrPathLine:`搜索或路径:行号`,searchFilesOrJump:`搜索文件或跳转到路径行号`,openEditors:`打开的编辑器`,loading:`加载中...`,searching:`搜索中...`,noMatches:`无匹配`,searchIgnoredFolders:`同时在已忽略目录中搜索`,searchIncomplete:e=>`搜索提前停止(当前超时:${Math.round(e/1e3)} 秒)`,terminalSearchPlaceholder:`在终端中查找`,terminalSearchPrevious:`上一个匹配`,terminalSearchNext:`下一个匹配`,terminalSearchClose:`关闭终端搜索`,terminalSearchCaseSensitive:`区分大小写`,terminalSearchWholeWord:`全词匹配`,terminalSearchRegex:`使用正则表达式`,terminalSearchNoResults:`无结果`,terminalSearchResults:(e,t)=>`${e}/${t}`,terminalRecoveryRequesting:`正在获取终端状态…`,terminalRecoveryInstalling:`终端状态已获取,正在恢复画面…`,terminalRecoveryRetrying:e=>`终端状态获取失败,${e} 秒后重试…`,terminalRecoveryElapsed:e=>`已等待 ${e} 秒`,terminalRecoveryAttempt:e=>`第 ${e} 次尝试`,terminalSessionUnavailable:`终端会话不可用`,acpPermissionAllow:`允许`,acpPermissionTitle:`Agent 需要权限`,acpPermissionTool:`请求使用工具`,file:`文件`,folder:`文件夹`,go:`跳转`,moreMatchesOmitted:`更多匹配已省略`,stickyFolderPath:`固定文件夹路径`,containsUncommittedChanges:`包含未提交改动`,changedOnDisk:`磁盘上已变更`,unsavedChanges:`未保存改动`,gitStatus:e=>`Git 状态:${e}`,renameEntry:e=>`重命名 ${e}`,newFile:`新建文件`,newFolder:`新建文件夹`,refreshFiles:`刷新文件`,refreshingFiles:`正在刷新文件…`,filesRefreshed:`文件已刷新`,filesRefreshFailed:`文件刷新失败`,refresh:`刷新`,rename:`重命名`,copyRelativePath:`复制相对路径`,copyShareUrl:`拷贝分享 URL`,delete:`删除`,deleteFolderContents:e=>`删除文件夹及其所有内容:${e||``}`,deleteFile:e=>`删除文件:${e||``}`,saveFile:`保存文件`,savingFile:`正在保存文件`,reloadFile:`重新加载文件`,overwriteChangedFile:`覆盖已变更文件`,openFileDiff:`打开文件 Diff`,openFileDiffFor:e=>`打开 ${e} 的 Diff`,closeDiff:`关闭 Diff`,openFilePreview:`打开预览`,showFileSource:`显示源码`,enableWordWrap:`开启折行`,disableWordWrap:`关闭折行`,openMarkdownPreview:`打开 Markdown 预览`,showMarkdownSource:`显示 Markdown 源码`,openMarkdownSplitPreview:`打开 Markdown 侧边预览`,closeMarkdownSplitPreview:`关闭 Markdown 侧边预览`,markdownPreviewFor:e=>`${e} 的 Markdown 预览`,markdownFrontMatter:`Front matter`,markdownHeadingAnchor:`跳转到这个标题`,mermaidDiagram:`Mermaid 图表`,mermaidDiagramControls:`Mermaid 图表控制`,mermaidRendering:`正在渲染图表...`,mermaidRenderFailed:`无法渲染 Mermaid 图表`,mermaidZoomIn:`放大`,mermaidZoomOut:`缩小`,mermaidPanMode:`切换平移模式`,mermaidEnterFullscreen:`全屏查看图表`,mermaidExitFullscreen:`退出全屏查看`,mermaidResetView:`重置视图`,mermaidCopySource:`复制 Mermaid 源码`,mermaidCopiedSource:`已复制 Mermaid 源码`,fileDiff:`文件 Diff`,loadingDiff:`正在加载 Diff...`,noFileDiff:`文件没有变化。`,diffUnavailable:`这个文件没有可显示的 Diff 内容。`,binaryDiffUnavailable:`二进制文件不能显示 Diff。`,diffTooLarge:`Diff 过大,无法显示。`,deletedFileDiffOnly:`这个已删除文件只支持以 Diff 查看。`,showGitBlame:`显示 Git Blame`,hideGitBlame:`隐藏 Git Blame`,gitBlameAnnotations:`Git Blame 标注`,gitBlameDetails:`Git Blame 详情`,filePath:`文件路径`,editorFor:e=>`${e} 的编辑器`,revealInExplorer:e=>`在文件树中显示 ${e}`,previewFor:e=>`${e} 的预览`,author:`作者`,commit:`提交`,date:`日期`,line:`行`,unknown:`未知`,uncommitted:`未提交`,closeBlameDetails:`关闭 Blame 详情`,cut:`剪切`,copy:`复制`,paste:`粘贴`,selectAll:`全选`,annotateWithBlame:`用 Blame 标注`,hideBlame:`隐藏 Blame`,openLineChangesWithPreviousRevision:`打开与上一版的行变化`,openLineChangesWithWorkingFile:`打开与工作区文件的行变化`,lineChanges:`行变化`,loadingLineChanges:`正在加载行变化...`,noLineChanges:`这一行没有可显示的变化。`,closeLineChanges:`关闭行变化`,close:`关闭`,closeFile:e=>`关闭 ${e}`,closeOthers:`关闭其他`,closeToRight:`关闭右侧`,closeSaved:`关闭已保存`,closeAll:`全部关闭`,saveBeforeCloseTitle:e=>`是否保存对 ${e} 的更改?`,saveBeforeCloseDescription:`如果不保存,你的更改将丢失。`,dontSave:`不保存`,loadingBlame:`正在加载 Blame...`,notGitRepository:`不是 Git 仓库。`,noCommittedLines:`没有已提交行。`,cursorPosition:(e,t)=>`第 ${e} 行,第 ${t} 列`,startMainAgent:`启动 Main Agent`,startNewAgent:`启动新 Agent`,loadingAgents:`正在加载 Agent...`,agentListUnavailable:`Agent 列表不可用。`,noSupportedAgentsFound:`没有找到支持的 Agent。`,resumePreviousMainAgent:`恢复上一个 Main Agent`,codingAgents:`Coding Agent`,otherAgents:`Shell`,workspace:`工作区:`,workspacePathPlaceholder:`/工作区/路径`,chooseWorkspaceDirectory:`选择工作区目录`,workspaceDirectoryBrowserFailed:`无法读取这个目录。`,workspaceDirectoryBrowserHostHint:`浏览 Farming Host 上的目录。`,workspaceDirectoryBrowserGo:`转到目录`,workspaceDirectoryBrowserParent:`上级目录`,workspaceDirectoryBrowserEmpty:`没有子目录。`,workspaceDirectoryBrowserTruncated:`仅显示前 500 个目录,请输入更具体的路径继续浏览。`,workspaceDirectoryBrowserSelect:`选择此目录`,workspaceMissingTitle:`创建这个工作区?`,workspaceMissingDescription:`这个目录尚不存在。Farming 可以创建目录,并在其中启动 Agent。`,workspaceCreateAndStart:`创建并启动`,workspaceCreating:`正在创建…`,workspaceCreateFailedTitle:`无法创建工作区`,workspaceCreateForbiddenDescription:`Farming 没有权限创建这个目录。请选择其他位置,或调整父目录权限。`,workspaceCreateFailedDescription:`Farming 无法创建这个目录。请检查路径后重试。`,returnToWorkspace:`修改路径`,recentWorkspacesLower:`最近工作区`,start:`启动`,back:`返回`,backToAgent:`返回 Agent`,goBack:`后退`,goForward:`前进`,backendConnecting:`正在连接 Farming 后端...`,backendConnectionLost:`Farming 后端连接已断开,正在重连...`,backendHeartbeatLost:`没有收到 Farming 后端心跳,正在等待恢复...`};function kP(e){return e===`zh`?OP:DP}function AP(){return window}function jP(e,t={},n=AP()){let r=t.delays??[],i=[],a=t.animationFrame!==!1,o;return t.runNow!==!1&&e(),a&&(o=n.requestAnimationFrame(e)),r.forEach(t=>{i.push(n.setTimeout(e,t))}),()=>{o!==void 0&&n.cancelAnimationFrame(o),i.forEach(e=>n.clearTimeout(e))}}var MP={ask:`Ask for approval`,approve:`Approve for me`,full:`Full access`,custom:`Custom`},NP={ask:`Launch Codex with workspace-write sandbox and ask for untrusted actions`,approve:`Launch Codex with workspace-write sandbox and ask when Codex requests approval`,full:`Launch Codex with approvals and sandbox bypassed; use only in trusted sandboxes`,custom:`Launch Codex with permissions defined in config.toml`},PP=[`ask`,`approve`,`full`,`custom`].map(e=>({value:e,label:MP[e],description:NP[e],color:e===`approve`?`blue`:e===`full`?`orange`:`muted`})),FP={default:`Default`,auto:`Auto`,acceptEdits:`Accept edits`,dontAsk:`Don't ask`,plan:`Plan`,bypassPermissions:`Bypass permissions`},IP={default:`Launch Claude Code with its default settings`,auto:`Launch Claude Code in auto permission mode`,acceptEdits:`Launch Claude Code allowing file edits while still asking for other risky actions`,dontAsk:`Launch Claude Code avoiding interactive approval prompts where supported`,plan:`Launch Claude Code in plan permission mode`,bypassPermissions:`Launch Claude Code with permission checks bypassed; use only in trusted sandboxes`},LP=[`default`,`auto`,`acceptEdits`,`dontAsk`,`plan`,`bypassPermissions`].map(e=>({value:e,label:FP[e],description:IP[e],color:e===`bypassPermissions`?`orange`:[`auto`,`acceptEdits`,`plan`].includes(e)?`blue`:`muted`})),RP=[{value:`low`,effort:`low`,label:`Low`},{value:`medium`,effort:`medium`,label:`Medium`},{value:`high`,effort:`high`,label:`High`},{value:`xhigh`,effort:`xhigh`,label:`Extra High`},{value:`max`,effort:`max`,label:`Max`}],zP=`Claude settings`,BP={value:`config`,effort:`config`,label:zP},VP=[{value:`config`,label:zP,displayName:zP,defaultEffort:`config`,reasoningLevels:[BP,...RP],source:`settings`}],HP={available:!1,effectiveModel:``,effectiveEffort:``,modelOptions:[],effortOptions:RP};function UP(e){return!!(e&&e in MP)}function WP(e){return!!(e&&e in FP)}function GP(e,t,n){return e?UP(t)?t:`custom`:n}function KP(e,t,n){return e?WP(t)?t:`default`:n}function qP(e){if(typeof e!=`string`)return``;let t=e.trim();return!t||/[\s\x00-\x1f\x7f]/.test(t)||t.startsWith(`-`)?``:t}function JP(e){return e===`config`?e:qP(e)||`config`}function YP(e){return e&&RP.some(t=>t.value===e)?e:``}function XP(e){return e===`config`?e:YP(e)||`config`}function ZP(e){let t=[];return Array.isArray(e)&&e.forEach(e=>{let n=YP(e?.value);n&&t.push({value:n,effort:n,label:e.label||KD(n),description:e.description})}),t.length>0?t:RP}function QP(e){let t=ZP(e?.effortOptions),n=qP(e?.effectiveModel),r=YP(e?.effectiveEffort),i=[];return Array.isArray(e?.modelOptions)&&e.modelOptions.forEach(e=>{let n=qP(e?.value);n&&i.push({...e,value:n,label:e.label||n,displayName:e.displayName||n,defaultEffort:YP(e.defaultEffort)||r||`medium`,reasoningLevels:t,source:e.source||`settings`})}),n&&!i.some(e=>e.value===n)&&i.unshift({value:n,label:n,displayName:n,defaultEffort:r||`medium`,reasoningLevels:t,source:`settings`}),{available:e?.available===!0,effectiveModel:n,effectiveEffort:r,modelOptions:i,effortOptions:t}}function $P(e,t){let n=t.effortOptions?.length?t.effortOptions:RP,r=t.modelOptions?.length?t.modelOptions:VP.map(e=>({...e})),i=JP(e);return!i||i===`config`||r.some(e=>e.value===i)?r.map(e=>({...e,reasoningLevels:e.reasoningLevels?.length?e.reasoningLevels:n})):[...r.map(e=>({...e,reasoningLevels:e.reasoningLevels?.length?e.reasoningLevels:n})),{value:i,label:i,displayName:i,defaultEffort:t.effectiveEffort||`medium`,reasoningLevels:n,source:`settings`}]}function eF(e,t){return e===`config`?t.effectiveModel||t.modelOptions?.[0]?.value||`config`:JP(e)}function tF(e,t){return e===`config`?t.effectiveEffort||`config`:XP(e)}function nF(e,t){let n=t.effortOptions?.length?t.effortOptions:RP;return e===`config`?[BP,...n]:n.some(t=>t.value===e)?n:[...n,{value:e,effort:e,label:KD(e)}]}function rF(e,t,n,r){if(!e||r.some(t=>t.value===e))return r;let i=[{value:`default`,label:`Standard`,description:`Default speed`}];return n&&n!==`default`&&i.push({value:n,label:n===`priority`?`Fast`:n}),[...r,{value:e,label:JD(void 0,e),displayName:JD(void 0,e),defaultEffort:t,reasoningLevels:[{value:t,effort:t,label:KD(t)}],serviceTiers:i,source:`pending-catalog`}]}function iF(e){let t=e.agentLaunchProfiles?.codex??{},n=t.approvalMode??e.codexApprovalMode,r=qD(t.modelPreset??e.codexModelPreset),i=t.model||e.codexModel||r.model,a=t.reasoningEffort||e.codexReasoningEffort||r.effort,o=e.agentLaunchProfiles?.claude??{};return{codexApprovalMode:UP(n)?n:`approve`,codexModel:i,codexReasoningEffort:a,codexServiceTier:t.serviceTier||e.codexServiceTier||`default`,codexModelPreset:`${i}:${a}`,claudePermissionMode:WP(o.permissionMode)?o.permissionMode:`default`,claudeModel:JP(o.model),claudeEffort:XP(o.effort)}}function aF(e,t){return!e?.model||!e.reasoningEffort?t:{model:e.model,reasoningEffort:e.reasoningEffort,serviceTier:e.serviceTier||`default`}}function oF({agentKind:e,codexModel:t,codexReasoningEffort:n,codexServiceTier:r,codexModelPreset:i,codexModelOptions:a,codexApprovalMode:o,claudeModel:s,claudeEffort:c,claudeSettings:l,claudePermissionMode:u}){let d=eF(s,l),f=tF(c,l),p=e===`claude`?$P(s,l):e===`codex`?rF(t,n,r,a):a,m=e===`claude`?d:t,h=e===`claude`?f:n,g=e===`claude`?``:r,_=e===`claude`?`${m}:${h}`:i,v=p.find(e=>e.value===m)??p[0],y=e===`claude`?nF(h,l):v?.reasoningLevels?.length?v.reasoningLevels:h?[{value:h,effort:h,label:KD(h)}]:[],b=e===`claude`?[]:v?.serviceTiers?.length?v.serviceTiers:[{value:`default`,label:`Standard`,description:`Default speed`}],x=y.find(e=>e.value===h)??y[0],S=b.find(e=>e.value===g)??b[0],C=e===`claude`?LP:PP,w=e===`claude`?u:o,T=C.find(e=>e.value===w)??C[0];return{agentModelOptions:p,agentModel:m,agentReasoningEffort:h,agentServiceTier:g,agentModelPreset:_,currentModelOption:v,currentReasoningOptions:y,currentServiceTierOptions:b,currentReasoningOption:x,currentServiceTierOption:S,currentModelLabel:JD(v,m),currentReasoningLabel:x?.label??KD(h),currentSpeedLabel:S?.label??``,permissionModeOptions:C,currentPermissionMode:w,currentPermissionOption:T,currentPermissionLabel:T?.label??w,currentPermissionColor:T?.color??`muted`}}function sF(e){return!e.isMain&&e.archived!==!0&&e.status!==`dead`&&e.status!==`stopped`}function cF(e){return!e.isMain&&e.archived===!0}function lF(e,t=[]){let n=new Map;return e.forEach(e=>{if(!sF(e))return;let t=e.providerSessionKey||Ak(e.source);t&&n.set(e.id,t)}),n}function uF(e,t){return t.get(e.id)||`agent:${e.id}`}function dF(e){return e.providerSessionKey&&e.providerSessionTemporary!==!0?120:Ak(e.source)?100:e.providerSessionKey?40:0}function fF(e){return e.status===`running`?30:e.status===`pending`?20:0}function pF(e,t){return dF(e)+(t.has(e.id)?50:0)+fF(e)}function mF(e,t){let n=new Map;return e.forEach(e=>{let r=uF(e,t),i=n.get(r);if(!i){n.set(r,e);return}let a=pF(e,t),o=pF(i,t),s=Number(e.startedAt)||0,c=Number(i.startedAt)||0;(a>o||a===o&&s>c)&&n.set(r,e)}),e.filter(e=>n.get(uF(e,t))===e)}function hF(e,t){return e.filter(e=>!t.has(ZD(e)))}function gF(e,t,n){return e.filter(e=>{let r=ZD(e);return(e.archived||!t.has(r))&&!n.has(r)})}function _F({allAgents:e,liveAgents:t,sessions:n,mainPageSessionKeys:r}){let i=t.filter(sF),a=lF(i,n),o=new Set(a.values()),s=mF(i,a),c=n.filter(e=>!e.archived&&r.has(ZD(e))).sort(iO),l=hF(c,o),u=hF(n,o).sort(iO),d=gF(n,r,o).sort(iO);return{liveAgents:s,archivedAgents:e.filter(cF).sort((e,t)=>(t.archivedAt??0)-(e.archivedAt??0)),mainPageAgentSessions:c,sidebarAgentSessions:l,searchableAgentSessions:u,historyAgentSessions:d,claimedAgentSessionKeys:o,claimedAgentSessionKeyByAgentId:a}}var vF=`farming.workspaceDraftBackups.v1`,yF=32,bF=1024*1024,xF=2*1024*1024;function SF(e){if(!e||typeof e!=`object`)return!1;let t=e;return typeof t.key==`string`&&typeof t.agentId==`string`&&(t.workspaceRoot===void 0||typeof t.workspaceRoot==`string`)&&typeof t.filePath==`string`&&typeof t.baseSha1==`string`&&typeof t.draft==`string`&&typeof t.revision==`number`&&Number.isFinite(t.revision)&&typeof t.externalChanged==`boolean`&&typeof t.updatedAt==`number`&&Number.isFinite(t.updatedAt)}function CF(e,t=Date.now()){return{key:z(e),agentId:e.agentId,...e.workspaceRoot===void 0?{}:{workspaceRoot:e.workspaceRoot},filePath:e.file.path,baseSha1:e.file.sha1,draft:e.draft,revision:e.revision??0,externalChanged:e.externalChanged,updatedAt:t}}function wF(e,t){if(t.key!==z(e))return e;let n=t.draft!==e.file.content;return{...e,draft:n?t.draft:e.file.content,dirty:n,revision:Math.max(e.revision??0,t.revision),externalChanged:n&&(t.externalChanged||t.baseSha1!==e.file.sha1),saving:!1,saveRequestId:void 0,saveRevision:void 0,error:null,transient:!1}}function TF(e){let t=new Map;try{let n=JSON.parse(e.getItem(vF)||`null`);if(n?.version!==1||!Array.isArray(n.records))return t;n.records.forEach(e=>{SF(e)&&t.set(e.key,e)})}catch{try{e.removeItem(vF)}catch{}}return t}function EF(e,t){let n=Array.from(t.values()).filter(e=>e.draft.length<=bF).sort((e,t)=>t.updatedAt-e.updatedAt).slice(0,yF);for(;n.length>0;){let t=JSON.stringify({version:1,records:n});if(t.length>xF){n.pop();continue}try{e.setItem(vF,t);return}catch{n.pop()}}try{e.removeItem(vF)}catch{}}function DF(){return{activeFile:null,files:[],closedFileCache:new Map}}function OF(e){return{activeFile:e.activeFile,files:e.files,closedFileCache:e.closedFileCache}}function kF(){if(typeof window>`u`)return null;try{return window.localStorage}catch{return null}}function AF(e){return[...e.files,...e.closedFileCache.values()]}function jF(){let[e,t]=(0,G.useState)(()=>DF()),n=(0,G.useRef)(e),r=(0,G.useRef)(null),i=(0,G.useRef)(null);if(r.current===null){let e=kF();r.current=e?TF(e):new Map}let a=(0,G.useCallback)(()=>{i.current!==null&&(clearTimeout(i.current),i.current=null);let e=kF();e&&EF(e,r.current??new Map)},[]),o=(0,G.useCallback)(()=>{i.current!==null&&clearTimeout(i.current),i.current=setTimeout(()=>{i.current=null;let e=kF();e&&EF(e,r.current??new Map)},250)},[]),s=(0,G.useCallback)((e,t)=>{let n=r.current;if(!n)return;let i=AF(t),a=new Set(i.map(z));AF(e).forEach(e=>{let t=z(e);a.has(t)||n.delete(t)}),i.forEach(e=>{let t=z(e);e.dirty?n.set(t,CF(e)):n.delete(t)}),o()},[o]),c=(0,G.useCallback)(e=>{let r=n.current;return n.current=OF(e),s(r,n.current),t(n.current),n.current},[s]),l=(0,G.useCallback)((e,t,i)=>{let a=N(n.current,e,t,i),o=a.activeFile,s=o?r.current?.get(z(o)):null;return o&&s&&(a=R(a,wF(o,s))),c(a)},[c]),u=(0,G.useCallback)((e,t,r)=>{let i=D(n.current,e,t,r);return i?c(i):null},[c]),d=(0,G.useCallback)(e=>{let t=H(n.current,e);return t.closedFiles.length>0&&c(t),t},[c]),f=(0,G.useCallback)(e=>{let t=ne(n.current,{canReopen:e});return t?c(t):null},[c]),p=(0,G.useCallback)((e,t)=>{let r=te(n.current.files,e);if(!r)return null;let i=t(r);return i!==r&&c(R(n.current,i)),i},[c]),m=(0,G.useCallback)((e,t)=>c(P(n.current,e,t)),[c]),h=(0,G.useCallback)(e=>{let t=n.current.activeFile;if(!t)return null;let r=M(t,e);return c({...n.current,activeFile:r,files:fe(n.current.files,r)})},[c]),g=(0,G.useCallback)((e,t)=>{let r=j(n.current,e,t);return r!==n.current&&c(r),r},[c]),_=(0,G.useCallback)((e,t)=>{let r=ie(n.current,e,t);return t.length>0&&c(r),r},[c]),v=(0,G.useMemo)(()=>Array.from(e.closedFileCache.values()),[e.closedFileCache]);return(0,G.useEffect)(()=>{let e=()=>a();return window.addEventListener(`pagehide`,e),()=>{window.removeEventListener(`pagehide`,e),a()}},[a]),(0,G.useMemo)(()=>({activeFile:e.activeFile,files:e.files,closedFiles:v,openFromRead:l,select:u,close:d,reopenLastClosed:f,update:p,refreshFromReads:m,updateDraft:h,move:g,deleteEntries:_}),[v,d,_,g,l,m,f,u,e.activeFile,e.files,p,h])}function MF(){let[e,t]=(0,G.useState)(()=>Kn()),n=(0,G.useRef)(e),r=(0,G.useRef)(!1),i=(0,G.useRef)(null),a=(0,G.useCallback)(e=>(n.current=e,t(e),e),[]),o=(0,G.useCallback)(e=>{r.current||a(Zn(n.current,e))},[a]),s=(0,G.useCallback)(e=>{o(qn(e))},[o]),c=(0,G.useCallback)(e=>{o(Jn(e))},[o]),l=(0,G.useCallback)(e=>{r.current||(i.current!==null&&window.clearTimeout(i.current),i.current=window.setTimeout(()=>{i.current=null,o(Jn({...e,reason:`cursor`}))},650))},[o]),u=(0,G.useCallback)(e=>{let t=n.current,i=t.index+e,o=t.entries[i];return o?(r.current=!0,a({entries:t.entries,index:i}),o):null},[a]),d=(0,G.useCallback)(()=>{window.setTimeout(()=>{r.current=!1},120)},[]),f=(0,G.useCallback)(e=>{let t=n.current,r=t.entries.filter(e);if(r.length===t.entries.length)return;let i=t.entries[t.index],o=i?r.indexOf(i):-1;a({entries:r,index:o>=0?o:Math.min(t.index,r.length-1)})},[a]);return(0,G.useEffect)(()=>()=>{i.current!==null&&(window.clearTimeout(i.current),i.current=null)},[]),(0,G.useMemo)(()=>({canGoBack:e.index>0,canGoForward:e.index>=0&&e.index<e.entries.length-1,recordAgent:s,recordFile:c,recordFileCursor:l,beginNavigation:u,finishNavigation:d,pruneEntries:f}),[u,d,f,s,c,l,e.entries.length,e.index])}function NF({agents:e,permissionSwitchReplacement:t,onDiscardAttachment:n}){let[r,i]=(0,G.useState)({});(0,G.useLayoutEffect)(()=>{let r=new Set(e.filter(e=>!e.archived&&e.status!==`dead`&&e.status!==`stopped`).flatMap(e=>[$A(e),Aj(e)]).filter(Boolean));i(i=>{let a=i,o=!1,s=()=>(a===i&&(a={...i}),o=!0,a);if(t){let e=(e,t)=>{let n=a[e];if(!n)return;let r=s(),i=r[t];r[t]=i?ZA(i,n):n,delete r[e]};e(t.originalAgentId,t.replacementAgentId),e(`acp:${t.originalAgentId}`,`acp:${t.replacementAgentId}`)}return e.forEach(e=>{let t=$A(e);if(!t)return;ej(e).forEach(e=>{if(e===t)return;let n=a[e];if(!n)return;let r=s();r[t]=r[t]?ZA(r[t],n):n,delete r[e]});let n=Aj(e);jj(e).forEach(e=>{if(e===n)return;let t=a[e];if(!t)return;let r=s();r[n]=r[n]?ZA(r[n],t):t,delete r[e]})}),Object.entries(a).forEach(([e,t])=>{if(r.has(e))return;let i=s();t.attachments.forEach(n),delete i[e]}),o?a:i})},[e,n,t]);let a=(0,G.useCallback)(t=>{if(!t)return``;for(let n of e){let e=Mj(t),r=e?Aj(n):$A(n);if(!r)continue;let i=e?jj(n):ej(n);if(t===r||i.includes(t))return r}return t},[e]);return{composerByAgentKey:r,updateComposerStateForKey:(0,G.useCallback)((e,t)=>{i(n=>{let r=a(e);if(!r)return n;let i=n[r]??KA(),o=t(i);return o===i?n:{...n,[r]:o}})},[a]),updateExistingComposerStateForKey:(0,G.useCallback)((e,t)=>{i(n=>{let r=a(e);if(!r)return n;let i=n[r];if(!i)return n;let o=t(i);return o===i?n:{...n,[r]:o}})},[a])}}function PF(e,t=20){let n=[];for(let t of e){if(!t)continue;let e=n.indexOf(t);e>=0&&n.splice(e,1),n.push(t)}let r=Math.max(0,Math.floor(t));return r===0?[]:n.slice(-r)}function FF(e,t,n=20){let r=PF(t,n);return r.length===e.length&&r.every((t,n)=>t===e[n])?e:r}function IF(e,t,n=20){return FF(e,[...e,t],n)}function LF(){if(typeof window>`u`)return``;let e=window.location.hostname;return e?e===`localhost`||e===`127.0.0.1`||e===`::1`?`Local server`:`Remote server`:``}function RF(e){return e.replace(/^Language:\s*/i,``).replace(/^语言[::]\s*/,``)}function zF(e){if(!e||typeof e!=`object`||Array.isArray(e))return{};let t={};return Object.entries(e).forEach(([e,n])=>{let r=e.trim(),i=String(n??``).trim();!r||!i||(t[r]=i.slice(0,80))}),t}function BF(e){return e.replace(/^Appearance:\s*/i,``).replace(/^外观[::]\s*/,``)}function VF(e,t){return e.size===t.length?t.every(t=>e.has(t)):!1}function HF(e){return(e.ctrlKey||e.metaKey)&&e.shiftKey&&!e.altKey&&e.key.toLowerCase()===`t`}var UF=296,WF=220,GF=840,KF=360,qF=5*6e4,JF=52,YF=172,XF=900,ZF=12,QF=4,$F=15e3,eI=286,tI=60,nI=1e3,rI=150,iI=35e3,aI=15e3;async function oI(e,t){let n=new AbortController,r=window.setTimeout(()=>n.abort(),aI);try{return await fetch(e,{...t,signal:n.signal})}finally{window.clearTimeout(r)}}async function sI(e,t){let n=[],r=!0,i=0,a=Array.from({length:Math.min(QF,t.length)},async()=>{for(;i<t.length;){let a=t[i];i+=1;let o=new AbortController,s=window.setTimeout(()=>o.abort(),$F);try{n.push(await le(e,a,{signal:o.signal}))}catch{r=!1}finally{window.clearTimeout(s)}}});return await Promise.all(a),{files:n,successful:r}}function cI(){return typeof window>`u`?!1:re()&&ae()}function lI(e){let t=(e||``).trim().split(/\s+/).find(e=>e!==`env`&&!/^[A-Za-z_][A-Za-z0-9_]*=/.test(e))?.split(`/`).pop()||``;return t===`qoder`||t===`qodercli`||t===`opencode`}function uI(e){return!!(e&&TD(e.command)===`codex`&&e.runtimeBinding.kind===`terminal`)}function dI(e){return e instanceof HTMLElement?e.tagName===`INPUT`||e.tagName===`TEXTAREA`||e.isContentEditable:!1}function fI(e){return kk(e)}function pI(e){return e.kind===`agent-session`?ZD(e):VD(e)}function mI(){return ce()}function hI(e){return!mI()&&e>0&&e<XF}function gI(){return mI()?!0:typeof window<`u`&&hI(window.innerWidth)}function _I(e){e.preventDefault(),e.stopPropagation(),e.stopImmediatePropagation()}function vI(e){let t=(e||``).replace(/\/+$/,``);return t.split(`/`).filter(Boolean).pop()||t||`workspace`}function yI(e){if(e.lineNumber)return{lineNumber:e.lineNumber,column:e.column,endColumn:e.endColumn}}function bI(e){let t=new Map;for(let n of e)n.kind!==`path`||t.has(n.path)||t.set(n.path,n);return Array.from(t.values())}function xI(e){let t=new Map;for(let n of e)t.has(n.path)||t.set(n.path,n);return Array.from(t.values())}function SI(e,t){let n=new Set(e);return t.forEach(e=>{e.sessionKeys.forEach(t=>{e.operation===`add`?n.add(t):n.delete(t)})}),Array.from(n)}async function CI(e){try{if(navigator.clipboard?.writeText)return await navigator.clipboard.writeText(e),!0}catch{}let t=document.createElement(`textarea`);t.value=e,t.setAttribute(`readonly`,`true`),t.setAttribute(`autocomplete`,`off`),t.setAttribute(`autocorrect`,`off`),t.setAttribute(`autocapitalize`,`none`),t.setAttribute(`spellcheck`,`false`),t.setAttribute(`data-lpignore`,`true`),t.setAttribute(`data-1p-ignore`,`true`),t.setAttribute(`data-bwignore`,`true`),t.setAttribute(`data-form-type`,`other`),t.style.position=`fixed`,t.style.left=`-9999px`,t.style.top=`0`,document.body.appendChild(t),t.select();try{return document.execCommand(`copy`)}finally{t.remove()}}function wI({agents:e,taskHistory:t,mainPageSessionKeys:n,activeView:i,dialogOpen:a,usageSummary:o,contextWindowByAgentId:s={},activeTerminalId:c,permissionSwitchingAgentId:l,agentSwitchingKind:h,permissionSwitchReplacement:b,retainedAgentViewIds:S,terminalFocusRequest:w,remoteProjectWorkspaces:T,remotePinnedProjectWorkspaces:ee,keyMap:D,keyboardShortcutsEnabled:O,uiPreferences:k,onOpenTerminal:A,onOpenTerminalWhenReady:j,onNewAgent:M,onStartAgent:N,onRenameAgent:P,onUpdateAgentFlags:te,onOpenArchivedAgent:ne,onForkAgent:R,onDeleteForkWorktreeProject:B,onRestartMainAgent:ie,onWorkspaceViewChange:H,onKill:ae,onInterruptAgent:oe,sendComposerInput:se,onSessionOutput:ue,onUpdateUiPreferences:fe}){Rn(`codeWorkspace`);let pe=Jt(),{composerByAgentKey:me,updateComposerStateForKey:he,updateExistingComposerStateForKey:ge}=NF({agents:e,permissionSwitchReplacement:b,onDiscardAttachment:mj}),_e=(0,G.useRef)({}),ve=(0,G.useRef)({}),[,ye]=(0,G.useState)({}),[be,xe]=(0,G.useState)(`terminal`),[Se]=(0,G.useState)(()=>y().surface),Ce=(0,G.useRef)(!1),we=(0,G.useRef)(!Se),U=jF(),{canGoBack:Te,canGoForward:Ee,recordAgent:De,recordFile:Oe,recordFileCursor:ke,beginNavigation:Ae,finishNavigation:je,pruneEntries:Me}=MF(),W=U.activeFile,Ne=U.files,Pe=(0,G.useCallback)(async(e,t)=>{let n=Array.from(new Set(U.files.filter(e=>e.workspaceRoot===t).map(e=>e.file.path)));if(n.length===0)return!0;let r=await sI(e,n);return U.refreshFromReads(t,r.files),r.successful},[U]),[Fe,Ie]=(0,G.useState)(!1),[Le,Re]=(0,G.useState)(``),[ze,Be]=(0,G.useState)(0),[,Ve]=(0,G.useState)([]),[He,Ue]=(0,G.useState)([]),[We,Ge]=(0,G.useState)(!1),[Je,Xe]=(0,G.useState)([]),[Ze,Qe]=(0,G.useState)({}),[$e,et]=(0,G.useState)([]),[tt,nt]=(0,G.useState)(()=>new Set),[rt,it]=(0,G.useState)(`approve`),[,at]=(0,G.useState)(`gpt-5.5:xhigh`),[ot,st]=(0,G.useState)(`gpt-5.5`),[ct,lt]=(0,G.useState)(`xhigh`),[ut,dt]=(0,G.useState)(`default`),[ft,pt]=(0,G.useState)([]),[mt,ht]=(0,G.useState)(()=>new Set),[gt,_t]=(0,G.useState)(()=>new Map),vt=(0,G.useRef)(new Set),[yt,bt]=(0,G.useState)(`default`),[xt,St]=(0,G.useState)(`config`),[Ct,wt]=(0,G.useState)(`config`),[Tt,Et]=(0,G.useState)(HP),[Dt,Ot]=(0,G.useState)([]),[kt,At]=(0,G.useState)([]),[jt,Mt]=(0,G.useState)(``),[Nt,Pt]=(0,G.useState)(!1),[Ft,It]=(0,G.useState)([]),[Lt,zt]=(0,G.useState)(!1),Bt=(0,G.useRef)(!1),Vt=(0,G.useRef)(null),Ht=(0,G.useRef)(tI),[Ut,Wt]=(0,G.useState)(()=>wk().pinnedOverrides),[Gt,Kt]=(0,G.useState)(!1),[qt,Yt]=(0,G.useState)(!1),[Qt,$t]=(0,G.useState)(()=>new Set),[tn,nn]=(0,G.useState)(()=>new Set),[rn,an]=(0,G.useState)(UF),[on,cn]=(0,G.useState)(()=>gI()),[ln,un]=(0,G.useState)(null),[dn,pn]=(0,G.useState)(()=>typeof window>`u`?null:v(window.location.search)),[mn,hn]=(0,G.useState)(0),[gn,_n]=(0,G.useState)(void 0),[vn,yn]=(0,G.useState)(null),[bn,xn]=(0,G.useState)(null),[Sn,Cn]=(0,G.useState)(null),[wn,Tn]=(0,G.useState)(null),[En,Dn]=(0,G.useState)(!1),[On,kn]=(0,G.useState)(`Farming`),[An,jn]=(0,G.useState)(``),[Nn,Fn]=(0,G.useState)(null),[In,Ln]=(0,G.useState)(null),[zn,Bn]=(0,G.useState)(null),[Vn,Hn]=(0,G.useState)(null),[Kn,qn]=(0,G.useState)(null),[Jn,Yn]=(0,G.useState)(null),Xn=Nn?Nn.kind===`agent`?`agent:${Nn.agentId}`:`project:${Nn.projectId}`:``,[Zn,$n]=(0,G.useState)(Date.now()),er=(0,G.useRef)(null),tr=(0,G.useRef)(null),nr=(0,G.useRef)([]),rr=(0,G.useRef)(null),ir=(0,G.useRef)(null),ar=(0,G.useRef)(null),or=(0,G.useRef)(null),sr=(0,G.useRef)(null),cr=(0,G.useRef)(null),q=(0,G.useRef)(null),lr=(0,G.useRef)(null),ur=(0,G.useRef)(null),dr=(0,G.useRef)(null),fr=(0,G.useRef)(null),pr=(0,G.useRef)(null),mr=(0,G.useRef)(null),hr=(0,G.useRef)(!1),gr=(0,G.useRef)(0),_r=(0,G.useRef)(null),vr=(0,G.useRef)(0),yr=(0,G.useRef)(!1),br=(0,G.useRef)(()=>{}),xr=(0,G.useRef)(c),Sr=(0,G.useRef)(0),Cr=(0,G.useRef)(0),wr=(0,G.useRef)(0),Tr=(0,G.useRef)(0),Er=(0,G.useRef)(0),Dr=(0,G.useRef)(0),Or=(0,G.useRef)(null),kr=(0,G.useRef)(null),Ar=(0,G.useRef)(null),jr=(0,G.useRef)(0),Mr=(0,G.useRef)(Ek(n)),Nr=(0,G.useRef)(0),Pr=(0,G.useRef)([]),Fr=(0,G.useRef)(Promise.resolve()),Ir=(0,G.useRef)(new Set),Lr=(0,G.useRef)(!1),Rr=(0,G.useRef)(on),zr=(0,G.useRef)(mI()),Br=(0,G.useCallback)(()=>{Rr.current=!1,cn(!0)},[]),Vr=(0,G.useCallback)(()=>{cn(e=>(e||(Rr.current=!0),!0))},[]),Hr=(0,G.useCallback)(()=>{Rr.current=!1,cn(!1)},[]),Ur=(0,G.useCallback)(()=>{Rr.current=!1,cn(e=>!e)},[]),Wr=(0,G.useCallback)(e=>{un(t=>({kind:e,nonce:(t?.nonce||0)+1}))},[]);xr.current=c;let J=(0,G.useMemo)(()=>kP(k.language),[k.language]);(0,G.useEffect)(()=>{Tk({promotedKeys:[],pinnedOverrides:Ut,archivedOverrides:{}})},[Ut]);let Gr=(0,G.useMemo)(()=>e.filter(e=>!e.isMain),[e]),Kr=(0,G.useMemo)(()=>e.find(e=>e.isMain)??null,[e]),Y=(0,G.useMemo)(()=>Gr.filter(sF),[Gr]),qr=(0,G.useMemo)(()=>{let e=new Set(Y.map(e=>e.id));return Kr&&e.add(Kr.id),e},[Y,Kr]),Jr=(0,G.useMemo)(()=>{let e=new Set([Ye]);return He.forEach(t=>e.add(Un(t))),Y.forEach(t=>e.add(Un(UD(t)))),qr.forEach(t=>e.add(t)),e},[Y,He,qr]);(0,G.useEffect)(()=>{Me(e=>e.kind===`agent`?qr.has(e.agentId):Jr.has(e.agentId))},[Me,qr,Jr]);let Yr=(0,G.useCallback)((e,t)=>{let n=Kr?[...Y,Kr]:Y;if(Ke(e)){let e=n.find(e=>e.id===t);return{filesId:Ye,workspaceRoot:`/`,sourceAgentId:e?.id,sourceAgent:e}}let r=Wn(e);if(r){let e=Y.find(e=>e.id===t&&Un(UD(e))===Un(r));return{filesId:Un(r),workspaceRoot:r,sourceAgentId:e?.id,sourceAgent:e}}let i=n.find(t=>t.id===e);if(i&&!i.isMain){let e=UD(i),n=Y.find(n=>n.id===t&&Un(UD(n))===Un(e))??i;return{filesId:Un(e),workspaceRoot:e,sourceAgentId:n.id,sourceAgent:n}}return{filesId:e,workspaceRoot:i?UD(i):void 0,sourceAgentId:i?.id,sourceAgent:i}},[Y,Kr]);(0,G.useEffect)(()=>{W?.sourceAgentId&&(Yr(W.agentId,W.sourceAgentId).sourceAgentId||U.update({agentId:W.agentId,filePath:W.file.path,workspaceRoot:W.workspaceRoot},e=>({...e,sourceAgentId:void 0})))},[W,Yr,U]);let Xr=(0,G.useMemo)(()=>Dk(kt,Ut,{}),[Ut,kt]),Zr=(0,G.useMemo)(()=>_F({allAgents:Gr,liveAgents:Y,sessions:Xr,mainPageSessionKeys:tt}),[Y,Xr,tt,Gr]),Qr=Zr.mainPageAgentSessions,$r=Zr.sidebarAgentSessions,ei=Zr.searchableAgentSessions,ti=Zr.historyAgentSessions,ni=Zr.liveAgents,ri=Zr.archivedAgents,ii=t,ai=ti,oi=(0,G.useMemo)(()=>new Set(Ft.map(ZD)),[Ft]),si=(0,G.useMemo)(()=>new Set(Array.from(Zr.claimedAgentSessionKeyByAgentId.entries()).filter(([,e])=>oi.has(e)).map(([e])=>e)),[Zr.claimedAgentSessionKeyByAgentId,oi]),ci=(0,G.useMemo)(()=>{let e=new Map(ei.map(e=>[ZD(e),e]));return Ft.forEach(t=>e.set(ZD(t),t)),hF(Array.from(e.values()),Zr.claimedAgentSessionKeys)},[Zr.claimedAgentSessionKeys,Ft,ei]),li=(0,G.useMemo)(()=>TM(ni,$r,Ze,Ne,Gr,He,Je),[Ne,Je,Ze,He,$r,Gr,ni]),ui=(0,G.useMemo)(()=>jk(li,tn,!1),[tn,li]),di=(0,G.useMemo)(()=>TM(ni,ci,Ze,Ne,Gr,He,Je),[Ne,Je,Ze,He,ci,Gr,ni]),fi=Le.trim().toLowerCase(),pi=fi.length>0,mi=(0,G.useMemo)(()=>EM((i===`search`||Fe)&&pi?di:ui,fi,tn,oi,si),[i,tn,pi,fi,ui,di,si,oi,Fe]),hi=ui.some(e=>!!e.workspace),gi=(0,G.useMemo)(()=>pi?mi:[],[mi,pi]),_i=(0,G.useMemo)(()=>DM(mi,Qt,fi),[Qt,mi,fi]),vi=(0,G.useMemo)(()=>pi?_i:[],[pi,_i]),yi=(0,G.useMemo)(()=>{let e=new Map;return O&&D.forEach((t,n)=>{e.set(t,n)}),e},[D,O]),bi=(0,G.useMemo)(()=>c?IF(S,c):S,[c,S]),xi=(0,G.useMemo)(()=>bi.map(e=>Y.find(t=>t.id===e)??(Kr?.id===e?Kr:null)).filter(e=>!!e),[Y,Kr,bi]),Si=Rt((0,G.useMemo)(()=>xi.find(e=>e.id===c)??xi[0]??null,[c,xi])),Ci=(0,G.useMemo)(()=>xi.map(e=>e.id===Si?.id?Si:e),[Si,xi]),X=Rt((0,G.useMemo)(()=>Y.find(e=>e.id===c)??(Kr?.id===c?Kr:null),[Y,c,Kr])),wi=Mn(X)?X.runtimeBinding:null,Ti=!!(X&&X.id===l),Ei=!!(X&&mt.has(X.id)),Di=X?s[X.id]??null:null,Oi=wi?Aj(X):X?$A(X):``,ki=(0,G.useMemo)(()=>MD(X),[X]),Ai=Oi?me[Oi]??(X?(wi?jj(X):ej(X)).map(e=>me[e]).find(Boolean):void 0)??GA:GA,ji=Ai.draft,Mi=Ai.attachments,Ni=Ai.mode,{plusMenuOpen:Pi,approvalMenuOpen:Fi,modelMenuOpen:Ii,modelPickerPane:Li}=Ai.ui,Ri=!!(wi&&X&&ve.current[X.id]!==void 0),zi=(0,G.useMemo)(()=>Ri||wD(X),[Ri,X]),Bi=(0,G.useMemo)(()=>SD(X),[X]),Vi=ki.kind,Hi=(0,G.useMemo)(()=>GP(!!(X&&Vi===`codex`),X?.launchPermissionMode,rt),[X,rt,Vi]),Ui=(0,G.useMemo)(()=>KP(!!(X&&Vi===`claude`),X?.launchPermissionMode,yt),[X,yt,Vi]),Wi=X&>.get(X.id)||null,Gi=(0,G.useMemo)(()=>aF(Wi||X?.codexTerminalProfile,{model:ot,reasoningEffort:ct,serviceTier:ut}),[Wi?.model,Wi?.reasoningEffort,Wi?.serviceTier,X?.codexTerminalProfile?.model,X?.codexTerminalProfile?.reasoningEffort,X?.codexTerminalProfile?.serviceTier,ot,ct,ut]),Ki=Gi.model,qi=Gi.reasoningEffort,Ji=Gi.serviceTier,Yi=`${Ki}:${qi}`,Xi=(0,G.useMemo)(()=>zi||!!X&&X?.status===`running`&&Vi===`shell`&&Bi.terminalBusy,[X,Bi.terminalBusy,zi,Vi]),Zi=(0,G.useMemo)(()=>jD([...AD(Vi),...Dt]),[Vi,Dt]),Qi=Ai.pendingFollowUp;(0,G.useEffect)(()=>{!c||be!==`terminal`||i!==`projects`||De(c)},[c,i,be,De]),(0,G.useEffect)(()=>{!W||be!==`editor`||i!==`projects`||Oe({agentId:W.agentId,filePath:W.file.path,view:W.diffRequestId?`diff`:`editor`,lineNumber:W.cursor?.lineNumber,column:W.cursor?.column,endColumn:W.cursor?.endColumn,sourceAgentId:W.sourceAgentId})},[i,be,W?.agentId,W?.cursor?.column,W?.cursor?.endColumn,W?.cursor?.lineNumber,W?.cursor?.requestId,W?.diffRequestId,W?.file.path,W?.sourceAgentId,Oe]);let $i=hj(Mi).length>0,ea=Mi.some(e=>e.status===`uploading`),ta=Ei?`disabled`:X&&!ea&&(ji.trim()||$i)?`send`:Xi?`interrupt`:`disabled`,Z=Tj(X)?ta:`disabled`,na=(0,G.useCallback)(e=>{Oi&&he(Oi,e)},[Oi,he]),ra=(0,G.useCallback)(()=>{na(YA)},[na]),ia=(0,G.useMemo)(()=>Y.find(e=>e.id===vn?.agentId)??null,[Y,vn?.agentId]),aa=(0,G.useMemo)(()=>li.find(e=>e.id===bn?.projectId)??null,[li,bn?.projectId]),oa=(0,G.useMemo)(()=>mi.flatMap(e=>e.agentSessions).find(e=>e.provider===Sn?.provider&&ZD(e)===Sn?.sessionId)??null,[Sn?.provider,Sn?.sessionId,mi]),sa=Fe?vi[ze]??null:null,ca=sa?.kind===`agent`?sa.id:null,la=sa?.kind===`agent-session`?ZD(sa):null,ua=X?UD(X):void 0,da=(0,G.useMemo)(()=>{if(W&&!Ke(W.agentId))return W.agentId;if(X&&!X.isMain)return Un(UD(X));if(ua)return Un(ua);let e=Y.find(e=>!e.isMain);return e?Un(UD(e)):null},[X,Y,ua,W]),fa=(0,G.useCallback)(e=>{if(!(e instanceof Element))return null;let t=e.closest(`[data-testid="code-agent-row"][data-agent-id], [data-testid="code-project-agent-compact"][data-agent-id], [data-testid="code-pinned-agent-compact"][data-agent-id], [data-testid="code-agent-rail-item"][data-agent-id]`)?.dataset.agentId;if(t){let e=Y.find(e=>e.id===t&&!e.isMain);if(e)return Un(UD(e))}let n=e.closest(`[data-testid="code-project-group"]`)?.querySelector(`[data-testid="code-project-title"][data-project-id]`)?.dataset.projectId;return!n||n===`__farming_main_agent__`?null:Un(n)},[Y]),pa=X?.isMain?gn??ui[0]?.workspace:ua??gn??ui[0]?.workspace,ma=be===`editor`&&!!W,ha=(0,G.useMemo)(()=>{if(ma&&W){let e=W.workspaceRoot??Y.find(e=>e.id===W.agentId)?.projectWorkspace??Y.find(e=>e.id===W.agentId)?.cwd??``;return{kind:`file`,agentId:W.agentId,filePath:W.file.path,...e?{absolutePath:p(e,W.file.path)}:{},...e?{projectLabel:x(e)}:{},view:W.diffRequestId?`diff`:`editor`,lineNumber:W.cursor?.lineNumber,column:W.cursor?.column,endColumn:W.cursor?.endColumn}}return c&&qr.has(c)?{kind:`agent`,agentId:c,readingSurface:Pn(Y.find(e=>e.id===c))?`chat`:`terminal`}:null},[c,W?.agentId,W?.cursor?.column,W?.cursor?.endColumn,W?.cursor?.lineNumber,W?.diffRequestId,W?.file.path,W?.workspaceRoot,ma,Y,qr]),{agentModelOptions:ga,agentModel:_a,agentReasoningEffort:va,agentServiceTier:ya,agentModelPreset:ba,currentReasoningOptions:xa,currentServiceTierOptions:Sa,currentPermissionMode:Ca,currentPermissionLabel:wa,currentPermissionColor:Ta,currentModelLabel:Ea,currentReasoningLabel:Da,currentSpeedLabel:Oa,permissionModeOptions:ka}=(0,G.useMemo)(()=>oF({agentKind:Vi,codexModel:Ki,codexReasoningEffort:qi,codexServiceTier:Ji,codexModelPreset:Yi,codexModelOptions:ft,codexApprovalMode:Hi,claudeModel:xt,claudeEffort:Ct,claudeSettings:Tt,claudePermissionMode:Ui}),[Ct,xt,Tt,Ui,Hi,Ki,ft,Yi,qi,Ji,Vi]),Aa=LF(),ja=Fe||i===`search`?J.search:i===`history`?J.history:ma&&W?HD(W.file.path):X?u(X):J.codex,Ma=X?.isMain?`farming`:vI(X?UD(X):void 0),Na=X?`${Ma} · ${Aa}`:Aa,Pa=ma&&W?W.sourceAgentId:null,Fa=!!Pa,Ia=(0,G.useCallback)(()=>{let e=tr.current;if(!e)return;e.style.height=`auto`;let t=Math.min(e.scrollHeight,132);e.style.height=`${t}px`,e.style.overflowY=e.scrollHeight>132?`auto`:`hidden`},[]),La=(0,G.useCallback)(()=>{let e=!1;jP(()=>{if(document.querySelector(`.code-composer-menu`))return;let t=tr.current??document.querySelector(`[data-testid="code-composer-input"]`);e&&document.activeElement instanceof HTMLElement&&document.activeElement!==document.body&&document.activeElement!==t||(t?.focus({preventScroll:!0}),document.activeElement===t&&(e=!0))},{delays:[60]})},[]),Ra=(0,G.useCallback)(e=>{let t=iF(e);it(t.codexApprovalMode),st(t.codexModel),lt(t.codexReasoningEffort),dt(t.codexServiceTier),at(t.codexModelPreset),bt(t.claudePermissionMode),St(t.claudeModel),wt(t.claudeEffort)},[]),za=(0,G.useCallback)(()=>{let e=!1,t=jr.current;return fetch(r(`/api/settings`)).then(e=>e.json()).then(n=>{if(e)return;let r=n.settings??{};t===jr.current&&nt(new Set(Ek(r.mainPageSessionKeys??[]))),Qe(zF(r.projectNames)),typeof r.instanceName==`string`&&r.instanceName.trim()&&kn(r.instanceName),Ra(r)}).catch(()=>{}),()=>{e=!0}},[Ra]),Ba=(0,G.useCallback)(async e=>{try{let t=await fetch(r(`/api/settings`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({instanceName:e})});if(!t.ok)return!1;let n=(await t.json()).settings?.instanceName;return n?(kn(n),!0):!1}catch{return!1}},[]),Va=(0,G.useCallback)(()=>{let e=Date.now()-vr.current;if(yr.current||vr.current>0&&e<=qF)return()=>{};let t=!1;return yr.current=!0,fetch(r(`/api/codex/models`)).then(async e=>{let t=await e.json().catch(()=>({}));if(!e.ok)throw Error(t.error||`Failed to load Codex model catalog (${e.status})`);return t}).then(e=>{if(t)return;let n=XD(e);if(n.length===0)throw Error(`Codex model catalog did not contain any visible models`);vr.current=Date.now(),pt(n)}).catch(e=>{t||(vr.current=0,pt([]),Hn({id:Date.now(),kind:`error`,message:e instanceof Error?e.message:`Failed to load Codex model catalog`}))}).finally(()=>{yr.current=!1}),()=>{t=!0}},[]),Ha=(0,G.useCallback)(()=>{let e=!1;return fetch(r(`/api/claude/settings`)).then(e=>e.json()).then(t=>{e||Et(QP(t.settings))}).catch(()=>{e||Et(HP)}),()=>{e=!0}},[]),Ua=(0,G.useCallback)(async(e,t)=>{let n=new URLSearchParams({q:e,limit:String(nI),fresh:`1`}),i=await fetch(r(`/api/agent-sessions/search?${n.toString()}`),{signal:t,cache:`no-store`});if(!i.ok)throw Error(`Failed to search Agent sessions: ${i.status}`);let a=await i.json();return Array.isArray(a.sessions)?a.sessions:[]},[]),Wa=(0,G.useCallback)(async(e,t)=>gF(Dk(await Ua(e,t),Ut,{}),tt,Zr.claimedAgentSessionKeys),[Zr.claimedAgentSessionKeys,Ut,Ua,tt]),Ga=(0,G.useCallback)(async(e={})=>{let t=new URLSearchParams({limit:String(e.limit||tI)});e.cursor&&t.set(`cursor`,e.cursor),e.fresh&&t.set(`fresh`,`1`);let n=await(await fetch(r(`/api/agent-sessions?${t.toString()}`),{cache:e.fresh?`no-store`:`default`})).json();return{sessions:Array.isArray(n.sessions)?n.sessions:[],nextCursor:typeof n.nextCursor==`string`?n.nextCursor:``,hasMore:n.hasMore===!0}},[]),Ka=(0,G.useCallback)((e=!1)=>{let t=!1;return Ga({fresh:e}).then(e=>{t||(At(e.sessions),Mt(e.nextCursor),Pt(e.hasMore),Ht.current=Math.max(tI,e.sessions.length))}).catch(()=>{t||(At([]),Mt(``),Pt(!1))}),()=>{t=!0}},[Ga]),qa=(0,G.useCallback)(()=>{if(Vt.current)return Vt.current;let e=Ga({limit:Ht.current,fresh:!0}).then(e=>{At(e.sessions),Mt(e.nextCursor),Pt(e.hasMore)}).catch(()=>At([])).finally(()=>{Vt.current===e&&(Vt.current=null)});return Vt.current=e,e},[Ga]),Ja=(0,G.useCallback)(async()=>{if(!Nt||!jt||Bt.current)return!1;Bt.current=!0;try{let e=await Ga({cursor:jt});return At(t=>{let n=new Set(t.map(ZD)),r=[...t];return e.sessions.forEach(e=>{let t=ZD(e);n.has(t)||(n.add(t),r.push(e))}),Ht.current=Math.max(tI,r.length),r}),Mt(e.nextCursor),Pt(e.hasMore),e.sessions.length>0}catch{return!1}finally{Bt.current=!1}},[jt,Nt,Ga]);(0,G.useEffect)(()=>{if(!((i===`search`||Fe)&&pi)){It([]),zt(!1);return}let e=new AbortController;It([]),zt(!0);let t=window.setTimeout(()=>{Ua(fi,e.signal).then(It).catch(e=>{e instanceof DOMException&&e.name===`AbortError`||It([])}).finally(()=>{e.signal.aborted||zt(!1)})},rI);return()=>{window.clearTimeout(t),e.abort()}},[i,Ua,pi,fi,Fe]);let Ya=(0,G.useCallback)((e,t)=>{if(e!==`codex`&&e!==`claude`)return Ot([]),()=>{};let n=!1,i=new URLSearchParams({provider:e});return t&&i.set(`workspace`,t),fetch(r(`/api/slash-commands?${i.toString()}`)).then(e=>e.json()).then(e=>{n||Ot(Array.isArray(e.commands)?e.commands:[])}).catch(()=>{n||Ot([])}),()=>{n=!0}},[]),Xa=(0,G.useCallback)(()=>{Oi&&(na(e=>({...e,ui:{...e.ui,plusMenuOpen:!1}})),rr.current?.click())},[Oi,na]),Za=(0,G.useCallback)((e,t)=>{let n=fj(t),r=sj(t),i=oj(t,r?`pasted image`:`pasted audio`),a=r?pj(t):void 0,o={id:n,kind:r?`image`:`audio`,name:i,type:t.type||(r?`image/png`:`audio/wav`),size:t.size,status:`uploading`,previewUrl:a};he(e,e=>({...e,attachments:[...e.attachments,o]})),bj(t).then(t=>{ge(e,e=>({...e,attachments:e.attachments.map(e=>e.id===n?{...e,name:i,type:t.type||e.type,size:t.size||e.size,status:`ready`,path:t.path,messageBlock:r?uj({...t,name:i}):dj({...t,name:i}),error:void 0}:e)}))}).catch(()=>{ge(e,e=>({...e,attachments:e.attachments.map(e=>e.id===n?{...e,status:`error`,messageBlock:Sj(t),error:`Upload failed`}:e)}))})},[he,ge]),Qa=(0,G.useCallback)(async e=>{if(!Oi||e.length===0)return;e.filter(e=>sj(e)||cj(e)).forEach(e=>Za(Oi,e));let t=e.filter(e=>!sj(e)&&!cj(e));if(t.length===0){La();return}let n=[];for(let e of t)try{n.push(await xj(e))}catch{n.push(Sj(e))}he(Oi,e=>({...e,draft:aj(e.draft,n.join(`
|
|
209
209
|
|
|
210
210
|
`))})),La()},[Oi,Za,La,he]),$a=(0,G.useCallback)(e=>{na(t=>{let n=t.attachments.find(t=>t.id===e);return n&&mj(n),{...t,attachments:t.attachments.filter(t=>t.id!==e)}}),La()},[La,na]),eo=(0,G.useCallback)(e=>{let t=Array.from(e.target.files??[]);e.target.value=``,Qa(t)},[Qa]),to=(0,G.useCallback)(e=>{let t=Cj(e.clipboardData);t.length!==0&&(e.preventDefault(),Qa(t))},[Qa]);(0,G.useEffect)(()=>{let e=rr.current;if(e)return e.addEventListener(`cancel`,La),()=>e.removeEventListener(`cancel`,La)},[La]),(0,G.useEffect)(()=>{nr.current=Object.values(me).flatMap(e=>e.attachments)},[me]),(0,G.useEffect)(()=>()=>{nr.current.forEach(mj)},[]);let no=(0,G.useCallback)(e=>{na(t=>({...t,mode:e,ui:{...t.ui,plusMenuOpen:!1}})),La()},[La,na]),ro=(0,G.useCallback)((e,t=!1,n=null)=>{let r=Y.find(t=>t.id===e);if(!r)return;let i=Number.isFinite(r.attentionSeq)?Math.max(0,Number(r.attentionSeq)):0,a=Number.isFinite(r.readAttentionSeq)?Math.max(0,Number(r.readAttentionSeq)):0;!t&&i<=a&&!r.unread||te(e,{unread:!1,...n?{readOutputEpoch:n.runtimeEpoch,readOutputSeq:n.outputSeq}:{}})},[Y,te]),io=(0,G.useCallback)((e,t=null)=>{ro(e,!0,t)},[ro]),ao=(0,G.useCallback)((e,t)=>{ye(n=>{let r=n[e];return r?.following===t.following&&r?.hasUnreadOutput===t.hasUnreadOutput?n:{...n,[e]:t}})},[]),oo=(0,G.useCallback)(e=>{na(t=>({...t,draft:e,history:{...t.history,cursor:null}}))},[na]),so=(0,G.useCallback)((e,t)=>{if(!X||!Oi||!HA(t))return null;let n=UA(Ai.history,e,t.value);return n.changed?(he(Oi,e=>({...e,draft:n.value,history:n.history})),n.value):null},[X,Oi,Ai.history,he]),co=(0,G.useCallback)(async(e,t,n,i)=>{if(!uI(e))return!0;if(vt.current.has(e.id))return!1;vt.current.add(e.id);let a={model:t,reasoningEffort:n,serviceTier:i,source:`pending-terminal-command`};_t(t=>{let n=new Map(t);return n.set(e.id,a),n}),ht(t=>new Set(t).add(e.id)),Hn({id:Date.now(),kind:`success`,message:J.terminalProfileApplying});let o=new AbortController,s=window.setTimeout(()=>{o.abort(new DOMException(`Timed out applying the Codex Terminal profile`,`TimeoutError`))},iI);try{let a=await fetch(r(`/api/agents/${encodeURIComponent(e.id)}/codex-terminal-profile`),{method:`POST`,headers:{"Content-Type":`application/json`},signal:o.signal,body:JSON.stringify({model:t,effort:n,serviceTier:i})}),s=await a.json().catch(()=>({}));if(!a.ok)throw Error(s.error||`Failed to update Codex Terminal (${a.status})`);return Hn({id:Date.now(),kind:`success`,message:J.terminalProfileApplied}),!0}catch(t){_t(t=>{let n=new Map(t);return n.delete(e.id),n});let n=t instanceof Error?t.message:`Failed to update Codex Terminal`;return Hn({id:Date.now(),kind:`error`,message:J.terminalProfileFailed(n)}),!1}finally{window.clearTimeout(s),vt.current.delete(e.id),ht(t=>{let n=new Set(t);return n.delete(e.id),n})}},[J.terminalProfileApplied,J.terminalProfileApplying,J.terminalProfileFailed]);(0,G.useEffect)(()=>{let e=X?.codexTerminalProfile;!X||!e||_t(t=>{let n=t.get(X.id);if(!n||e.model!==n.model||e.reasoningEffort!==n.reasoningEffort||e.serviceTier!==n.serviceTier)return t;let r=new Map(t);return r.delete(X.id),r})},[X?.id,X?.codexTerminalProfile?.model,X?.codexTerminalProfile?.reasoningEffort,X?.codexTerminalProfile?.serviceTier]);let lo=(0,G.useCallback)((e,t,n=[])=>Pn(e)?se(t,e.id,n,{awaitResult:!1}):TD(e.command)===`shell`||MD(e).kind===`shell`||lI(e.command)?EC(e.id,`${t}\r`):EC(e.id,EP(t)),[se]),uo=(0,G.useCallback)(e=>{let t=e??tr.current?.value??ji;if(!X||!Oi||Mi.some(e=>e.status===`uploading`))return;let n=Pn(X)?vj(Mi):[],r=n.length>0?_j(t,Mi):gj(t,Mi);if(!r&&n.length===0)return;let i=wj(Ni,r),a=!0;CD(X)&&X.runtimeBinding.kind===`terminal`?he(Oi,e=>{let t=e.pendingFollowUp;return{...e,pendingFollowUp:{messages:[...t?.messages||[],qA(i)],createdAt:t?.createdAt||Date.now()}}}):a=lo(X,i,n);let o=()=>{he(Oi,e=>e.draft===t?(e.attachments.forEach(mj),{...e,draft:``,attachments:[],mode:`default`,history:VA(e.history,t)}):e),La()};if(typeof a==`boolean`){a&&o();return}a.then(e=>{e&&o()})},[X,Oi,Mi,Ni,ji,La,lo,he]),fo=(0,G.useCallback)(e=>{let t=e??tr.current?.value??ji,n=!!(wi&&X&&ve.current[X.id]!==void 0),r=Ej({agent:X,composerKey:Oi,draft:t,attachments:Mi,composerMode:Ni,turnActive:zi||n,supportsSteer:X?.providerCapabilities.supportsSteer===!0,sendMessage:(e,t,n)=>{let r=lo(e,t,n);return typeof r==`boolean`?r:!1},updateComposerState:he});r&&X&&wi&&!zi&&!n&&(ve.current[X.id]=Number(wi.sessionRevision)||0),r&&La()},[wi,X,zi,Oi,Mi,Ni,ji,La,lo,he]),po=(0,G.useCallback)(()=>{!X||!Xi||(oe(X.id),La())},[X,Xi,La,oe]),mo=(0,G.useCallback)((e,t,n)=>{X&&Dj(X.id,e,t,n===!0)},[X]),ho=(0,G.useCallback)((e,t,n)=>{X&&Oj(X.id,e,t,n)},[X]),go=(0,G.useCallback)(e=>{if(!X||!Oi)return;let t=me[Oi]?.pendingFollowUp;if(!t||t.messages.length===0)return;let n=t.messages.find(t=>t.id===e);if(!n)return;let r=()=>he(Oi,t=>t.pendingFollowUp?{...t,pendingFollowUp:JA(t.pendingFollowUp,e)}:t),i=lo(X,n.text,n.attachments);if(typeof i==`boolean`){if(!i)return;_e.current[Oi]=n.id,r(),La();return}i.then(e=>{e&&(_e.current[Oi]=n.id,r(),La())})},[X,Oi,me,La,lo,he]),_o=(0,G.useCallback)(e=>{!X||!Oi||(he(Oi,t=>t.pendingFollowUp?{...t,pendingFollowUp:JA(t.pendingFollowUp,e)}:t),La())},[X,Oi,La,he]);(0,G.useEffect)(()=>{let e=new Set(Y.map(e=>e.id));Object.keys(ve.current).forEach(t=>{e.has(t)||delete ve.current[t]}),Y.forEach(e=>{let t=ve.current[e.id];if(t===void 0)return;let n=Mn(e)?e.runtimeBinding:null,r=wD(e)||(Number(n?.sessionRevision)||0)>t;(!n||r||n.state===`error`||e.archived||e.status===`dead`||e.status===`stopped`)&&delete ve.current[e.id]})},[Y]),(0,G.useEffect)(()=>{let e=[];Y.forEach(t=>{let n=Mn(t),r=n?Aj(t):$A(t);if(!r)return;let i=me[r]?.pendingFollowUp;if(!i||i.messages.length===0){delete _e.current[r];return}if(t.archived||t.status===`dead`||t.status===`stopped`||n&&ve.current[t.id]!==void 0)return;if(n?wD(t):CD(t)){delete _e.current[r];return}if(_e.current[r])return;let a=i.messages[0];a&&e.push({agent:t,composerKey:r,message:a})}),e.length!==0&&e.forEach(({agent:e,composerKey:t,message:n})=>{let r=()=>ge(t,e=>e.pendingFollowUp?{...e,pendingFollowUp:JA(e.pendingFollowUp,n.id)}:e),i=lo(e,n.text,n.attachments);if(typeof i==`boolean`){if(!i)return;_e.current[t]=n.id,r();return}i.then(e=>{e&&(_e.current[t]=n.id,r())})})},[Y,me,lo,ge]);let vo=(0,G.useCallback)(()=>{yn(null),xn(null),Cn(null),Tn(null),ra(),Hr(),H(`search`),Ie(!0),requestAnimationFrame(()=>sr.current?.focus())},[ra,Hr,H]),yo=(0,G.useCallback)(()=>{mI()&&Vr()},[Vr]),bo=(0,G.useCallback)(()=>{Hr()},[Hr]),xo=(0,G.useCallback)((e,t,n)=>{M(e,t,n),yo()},[yo,M]),So=(0,G.useCallback)((e,t,n)=>{if(Re(``),Ie(!1),Be(0),xe(`terminal`),H(`projects`),TD(e)!==`codex`){N(e,t,n);return}let r=n?.codexApprovalMode||rt;N(e,t,{...n,codexApprovalMode:r,...r===`full`?{dangerouslySkipPermissions:!0}:{}})},[rt,N,H]);(0,G.useEffect)(()=>{let e=!1;return fetch(r(`/api/executables`)).then(e=>{if(!e.ok)throw Error(`Failed to load executables: ${e.status}`);return e.json()}).then(t=>{e||et(sn(Array.isArray(t)?t:t.agents??[]))}).catch(()=>{e||et([])}),()=>{e=!0}},[]);let Co=(0,G.useCallback)(e=>{nt(t=>{let n=Ek(e(t));return VF(t,n)?t:new Set(n)})},[]),wo=(0,G.useCallback)(e=>{e&&(Mr.current=Ek(e));let t=SI(Mr.current,Pr.current);nt(e=>VF(e,t)?e:new Set(t))},[]),To=(0,G.useCallback)((e,t)=>{let n=Ek(t);if(n.length===0)return;let i=++jr.current;Pr.current.push({version:i,operation:e,sessionKeys:n}),Fr.current=Fr.current.catch(()=>{}).then(async()=>{let t=Nr.current,a=null;try{let t=await oI(r(`/api/main-page-agent-sessions`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({operation:e,sessionKeys:n})}),i=await t.json().catch(()=>null);if(!t.ok||!Array.isArray(i?.mainPageSessionKeys))throw Error(`Failed to update main-page sessions: ${t.status}`);a=i.mainPageSessionKeys}catch{try{let e=await oI(r(`/api/settings`));if(!e.ok)throw Error(`Failed to reconcile main-page sessions: ${e.status}`);let t=await e.json();if(!Array.isArray(t.settings?.mainPageSessionKeys))throw Error(`Failed to reconcile main-page sessions: invalid response`);a=t.settings.mainPageSessionKeys}catch{}}finally{Pr.current=Pr.current.filter(e=>e.version!==i),wo(a!==null&&Nr.current===t&&a?a:void 0)}})},[wo]);(0,G.useEffect)(()=>{Nr.current+=1,wo(Ek(n))},[wo,n]);let Eo=(0,G.useCallback)((e,t,n=``)=>{let r=ZD({provider:e,id:t,providerHomeId:n});Co(e=>[...e,r]),To(`add`,[r])},[To,Co]),Do=(0,G.useCallback)(e=>{Co(t=>Array.from(t).filter(t=>t!==e)),To(`remove`,[e])},[To,Co]),Oo=(0,G.useCallback)(e=>{let t=new Set(e);Co(e=>Array.from(e).filter(e=>!t.has(e))),To(`remove`,e)},[To,Co]),ko=(0,G.useCallback)(e=>{Promise.resolve(e).then(e=>{if(!e||typeof e!=`object`)return;let t=Array.isArray(e.removedMainPageSessionKeys)?e.removedMainPageSessionKeys:[];t.length>0&&Oo(t)}).catch(()=>{})},[Oo]);(0,G.useEffect)(()=>{let e=!1;Y.forEach(t=>{if(t.providerSessionTemporary===!0)return;let n=t.providerSessionKey||Ak(t.source);if(!n)return;let r=`${t.id}:${n}`;Ir.current.has(r)||(Ir.current.add(r),Co(e=>[...e,n]),e=!0)}),e&&qa()},[Y,qa,Co]),(0,G.useEffect)(()=>{if(!pe||!Y.some(e=>e.providerSessionTemporary===!0))return;qa();let e=window.setInterval(qa,5e3);return()=>window.clearInterval(e)},[Y,pe,qa]);let Ao=(0,G.useCallback)(()=>{let e=xr.current,t=Array.from(er.current?.querySelectorAll(`[data-testid="code-agent-row"], [data-testid="code-project-agent-compact"], [data-testid="code-pinned-agent-compact"], [data-testid="code-agent-rail-item"], [data-testid="code-active-session-row"]`)??[]),n=(e?t.find(t=>t.dataset.agentId===e):null)??t[0]??pr.current;return n?(n.focus({preventScroll:!0}),document.activeElement===n):!1},[]),jo=(0,G.useCallback)(e=>{let t=Array.from(er.current?.querySelectorAll(`[data-testid="code-agent-row"], [data-testid="code-project-agent-compact"], [data-testid="code-pinned-agent-compact"], [data-testid="code-agent-rail-item"], [data-testid="code-active-session-row"]`)??[]).find(t=>e.kind===`agent`?t.dataset.agentId===e.id:t.dataset.provider===e.provider&&t.dataset.sessionId===pI(e));return t?(t.focus({preventScroll:!0}),document.activeElement===t):!1},[]),Mo=(0,G.useCallback)(()=>{if(a||document.querySelector(`.code-context-menu`)||document.querySelector(`.code-composer.menu-open, .code-composer-menu`))return!0;let e=document.activeElement;return e instanceof HTMLElement?e.closest(`.code-context-menu`)?!0:e===document.body||e===document.documentElement||pr.current?.contains(e)||e.closest(`.code-sidebar`)?!1:!!e.closest(`.code-composer`):!1},[a]),No=(0,G.useCallback)(e=>{window.requestAnimationFrame(()=>{e?.skipIfFocusMoved&&Mo()||Ao()})},[Ao,Mo]),Po=(0,G.useCallback)(()=>{Re(``),Ie(!1),Be(0)},[]),Fo=(0,G.useCallback)(()=>{Po(),H(`projects`),Or.current=`active-force`},[Po,H]);(0,G.useEffect)(()=>{if(!Fe||i!==`search`)return;let e=e=>{let t=e.target;t instanceof Element&&(t.closest(`.code-search-panel, [data-testid="code-nav-search"], [data-testid="code-mobile-menu"]`)||Fo())};return document.addEventListener(`pointerdown`,e,!0),()=>{document.removeEventListener(`pointerdown`,e,!0)}},[i,Fo,Fe]);let Io=(0,G.useCallback)(e=>{yn(null),xn(null),Cn(null),Tn(null),e===`projects`?(Hr(),Po()):e!==`search`&&Po(),H(e)},[Po,Hr,H]),Lo=(0,G.useCallback)(()=>{vo(),yo()},[yo,vo]),Ro=(0,G.useCallback)(e=>{Io(e),yo()},[yo,Io]),zo=(0,G.useCallback)(e=>{$t(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),Bo=(0,G.useCallback)(e=>{Array.isArray(e.projectWorkspaces)&&(Ue(Gn(e.projectWorkspaces)),Ge(!0)),Array.isArray(e.pinnedProjectWorkspaces)&&Xe(Gn(e.pinnedProjectWorkspaces))},[]);(0,G.useEffect)(()=>{T&&Bo({projectWorkspaces:T})},[Bo,T]),(0,G.useEffect)(()=>{ee&&Bo({pinnedProjectWorkspaces:ee})},[Bo,ee]);let Vo=(0,G.useCallback)(async e=>{let t=e.trim().replace(/[\\/]+$/,``);if(!t)return;let n=await fetch(r(`/api/projects/mount`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({workspace:t})}),i=await n.json().catch(()=>null);if(!n.ok)throw Error(i?.error||`Project request failed (${n.status})`);let a=i?.workspace||t;$t(e=>{if(!e.has(a))return e;let t=new Set(e);return t.delete(a),t})},[]),Ho=(0,G.useCallback)(e=>{nn(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),Uo=(0,G.useCallback)((e,t)=>{xe(`terminal`),H(`projects`),e.kind===`agent`?A(e.id,{focusTerminal:t?.focusTerminal}):br.current(e.provider,e.id,e.providerHomeId)},[A,H]),Wo=(0,G.useCallback)(()=>{let e=document.activeElement;if(e instanceof HTMLElement){let t=e.closest(`[data-testid="code-agent-row"], [data-testid="code-project-agent-compact"], [data-testid="code-pinned-agent-compact"], [data-testid="code-agent-rail-item"], [data-testid="code-active-session-row"]`);if(t?.dataset.agentId)return VD({kind:`agent`,id:t.dataset.agentId});if(t?.dataset.sessionId&&t.dataset.provider)return t.dataset.sessionId}let t=xr.current;return t?VD({kind:`agent`,id:t}):``},[]),Go=(0,G.useCallback)(e=>{if(_i.length===0)return;let t=Wo(),n=_i.findIndex(e=>pI(e)===t),r=_i[((n===-1?e>0?-1:0:n)+e+_i.length)%_i.length];r&&(Uo(r,{focusTerminal:!1}),r.kind===`agent`&&(Mo()||jo(r),window.requestAnimationFrame(()=>{Mo()||jo(r)})),Or.current=`active`)},[Wo,jo,Uo,Mo,_i]),Ko=(0,G.useCallback)(e=>{if(!(e.ctrlKey||e.metaKey||e.altKey)){if(e.key===`/`&&!e.shiftKey){e.preventDefault(),vo();return}if(e.key===`ArrowDown`){e.preventDefault(),Go(1);return}e.key===`ArrowUp`&&(e.preventDefault(),Go(-1))}},[Go,vo]),qo=(0,G.useCallback)(e=>{vi.length!==0&&Be(t=>(t+e+vi.length)%vi.length)},[vi.length]),Jo=(0,G.useCallback)(()=>{sa&&(Uo(sa),Po())},[Po,Uo,sa]),Yo=(0,G.useCallback)(e=>{if(e.key===`Escape`){e.preventDefault(),Fo();return}if(e.key===`ArrowDown`){e.preventDefault(),qo(1);return}if(e.key===`ArrowUp`){e.preventDefault(),qo(-1);return}e.key===`Enter`&&(e.preventDefault(),Jo())},[Fo,qo,Jo]),Xo=(0,G.useCallback)(e=>{let t=er.current?.getBoundingClientRect(),n=e-(t?.left??0);if(n<=YF){Br();return}let r=t?.width??window.innerWidth,i=Math.max(WF,Math.min(GF,r-KF)),a=Math.max(WF,Math.min(i,n));Hr(),an(a)},[Br,Hr]),Zo=(0,G.useCallback)(e=>{let t=Array.from(er.current?.querySelectorAll(`[data-testid="code-agent-row"], [data-testid="code-project-agent-compact"], [data-testid="code-pinned-agent-compact"], [data-testid="code-agent-rail-item"]`)??[]).find(t=>t.dataset.agentId===e);return t?(t.focus({preventScroll:!0}),document.activeElement===t):!1},[]),Qo=(0,G.useCallback)(e=>{jP(()=>{Zo(e)},{delays:[80,180]})},[Zo]),$o=(0,G.useCallback)((e,t)=>{window.requestAnimationFrame(()=>{Array.from(er.current?.querySelectorAll(`[data-testid="code-active-session-row"]`)??[]).find(n=>n.dataset.provider===e&&n.dataset.sessionId===t)?.focus({preventScroll:!0})})},[]),es=(0,G.useCallback)(e=>{window.requestAnimationFrame(()=>{Array.from(er.current?.querySelectorAll(`[data-testid="code-project-title"]`)??[]).find(t=>t.dataset.projectId===e)?.focus()})},[]),ts=(0,G.useCallback)(async()=>{if(!oa)return;let e=ZD(oa),t=oa.pinned!==!0;Wt(n=>({...n,[e]:t})),Cn(null),Tn(null),tt.has(e)?$o(oa.provider,e):window.requestAnimationFrame(()=>pr.current?.focus({preventScroll:!0}));try{if(!(await fetch(r(`/api/agent-sessions/${encodeURIComponent(oa.provider)}/${encodeURIComponent(oa.id)}`),{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify({pinned:t,providerHomeId:oa.providerHomeId||`default`})})).ok)throw Error(J.updateFailed);let n=await Ga({limit:Ht.current});At(n.sessions),Mt(n.nextCursor),Pt(n.hasMore),Wt(t=>{let n={...t};return delete n[e],n})}catch(n){Wt(n=>({...n,[e]:!t})),Hn({id:Date.now(),kind:`error`,message:n instanceof Error?n.message:J.updateFailed})}},[oa,J.updateFailed,Ga,$o,tt]),ns=(0,G.useCallback)(()=>{if(!oa)return;let e=ZD(oa);Wt(t=>({...t,[e]:!1})),Do(e),Cn(null),Tn(null),window.requestAnimationFrame(()=>pr.current?.focus({preventScroll:!0}))},[oa,Do]),rs=(0,G.useCallback)(e=>{e.preventDefault(),Hr(),Lr.current=!0,document.body.classList.add(`code-resizing-sidebar`),Xo(e.clientX)},[Hr,Xo]),is=(0,G.useCallback)((e,t)=>{yn(null),xn(null),Cn(null),Tn(null),Po(),xe(`terminal`),H(`projects`),A(e,t)},[Po,A,H]),as=(0,G.useCallback)(e=>{is(e),yo()},[yo,is]),os=(0,G.useCallback)(e=>F(e,{cursorRequestId:e?.lineNumber?Sr.current+=1:Sr.current,diffRequestId:e?.view===`diff`?Cr.current+=1:Cr.current}),[]),ss=(0,G.useCallback)(async(e,t,n)=>{let r=Yr(e,n?.sourceAgentId),i=Ke(r.filesId),a=Wn(r.filesId);if(!i&&r.workspaceRoot)try{await Vo(r.workspaceRoot)}catch(e){throw Hn({id:Date.now(),kind:`error`,message:e instanceof Error?e.message:`Failed to create Project`}),e}if(!i&&(a||r.sourceAgent)){let e=a||(r.sourceAgent?.isMain?`__farming_main_agent__`:UD(r.sourceAgent));$t(t=>{if(!t.has(e))return t;let n=new Set(t);return n.delete(e),n})}yn(null),xn(null),Cn(null),Tn(null),Po(),H(`projects`),xe(`editor`);let o={...os(n),workspaceRoot:r.workspaceRoot,sourceAgentId:r.sourceAgentId};U.openFromRead(r.filesId,t,o),L(n)&&qn({agentId:r.filesId,path:t.path,kind:`file`,requestId:wr.current+=1}),r.sourceAgent&&r.sourceAgentId&&A(r.sourceAgentId,{focusTerminal:!1}),yo()},[Po,yo,os,Vo,A,H,Yr,U]);(0,G.useEffect)(()=>{if(we.current||Ce.current)return;let e=Se;if(!e){we.current=!0;return}if(e.kind===`agent`){if(Y.length===0)return;Ce.current=!0;let t=Y.find(t=>t.id===e.agentId)??Y.find(t=>!!e.providerSessionKey&&t.providerSessionKey===e.providerSessionKey)??Y.find(t=>!!e.workspace&&UD(t)===e.workspace);t?is(t.id,{focusTerminal:!1}):g({surface:void 0}),we.current=!0;return}if(!We)return;Ce.current=!0;let t=Y.find(t=>t.id===e.sourceAgentId&&(e.workspace===`/`||Un(UD(t))===Un(e.workspace)))??Y.find(t=>Un(UD(t))===Un(e.workspace)),n=e.workspace===`/`?Ye:Un(e.workspace);if(!(e.workspace===`/`||He.some(e=>Un(e)===n)||t)){g({surface:void 0}),we.current=!0;return}let r=Yr(n,t?.id);le(r.filesId,e.filePath).then(t=>ss(r.filesId,t,{view:e.view??`editor`,lineNumber:e.lineNumber,column:e.column,endColumn:e.endColumn,revealInTree:!0,sourceAgentId:r.sourceAgentId})).catch(()=>{g({surface:void 0})}).finally(()=>{we.current=!0})},[Y,Se,ss,is,He,We,Yr]),(0,G.useEffect)(()=>{if(!we.current||i!==`projects`)return;if(be===`terminal`){let e=Y.find(e=>e.id===c);if(!e)return;g({surface:{kind:`agent`,agentId:e.id,providerSessionKey:e.providerSessionKey||void 0,workspace:UD(e)}});return}if(!W)return;let e=W.workspaceRoot??Y.find(e=>e.id===W.agentId)?.projectWorkspace??Y.find(e=>e.id===W.agentId)?.cwd??``;e&&g({surface:{kind:`file`,workspace:e,filePath:W.file.path,view:W.diffRequestId?`diff`:`editor`,lineNumber:W.cursor?.lineNumber,column:W.cursor?.column,endColumn:W.cursor?.endColumn,sourceAgentId:W.sourceAgentId}})},[Y,c,i,be,W]);let cs=(0,G.useCallback)((e,t)=>{let n=Yr(e),r=Wn(n.filesId);if(!Ke(n.filesId)&&(r||n.sourceAgent)){let e=r||(n.sourceAgent?.isMain?`__farming_main_agent__`:UD(n.sourceAgent));$t(t=>{if(!t.has(e))return t;let n=new Set(t);return n.delete(e),n})}yn(null),xn(null),Cn(null),Tn(null),Po(),Hr(),H(`projects`),Yn({agentId:n.filesId,...t?{query:t}:{},requestId:Tr.current+=1})},[Po,Hr,H,Yr]),ls=(0,G.useCallback)((e,t,n)=>{let r=Yr(e),i=Wn(r.filesId);if(!Ke(r.filesId)&&(i||r.sourceAgent)){let e=i||(r.sourceAgent?.isMain?`__farming_main_agent__`:UD(r.sourceAgent));$t(t=>{if(!t.has(e))return t;let n=new Set(t);return n.delete(e),n})}yn(null),xn(null),Cn(null),Tn(null),Po(),Hr(),H(`projects`),qn({agentId:r.filesId,path:t,kind:n,requestId:wr.current+=1})},[Po,Hr,H,Yr]),us=(0,G.useCallback)(async(e,t)=>{let n=Yr(e,e),r=wT(t.path,n.workspaceRoot??``);if(!r)return null;try{let e=bI((await de(n.filesId,r,{limit:ZF})).matches),i=e.find(e=>e.path===r)?.path??(e.length===1?e[0]?.path:``);return i?{...t,path:i}:null}catch{return null}},[Yr]),ds=(0,G.useCallback)((e,t)=>{let n=Yr(e,e),r=wT(t.path,n.workspaceRoot??``);if(!r)return;let i=Er.current+1;Er.current=i;let a=yI(t),o={...a??{},sourceAgentId:n.sourceAgentId},s=async(e,t=o)=>{let r=await le(n.filesId,e);Er.current===i&&await ss(n.filesId,r,t)},c=e=>{Er.current===i&&ls(n.filesId,e,`directory`)},l=async e=>{if(e.entryType===`directory`){c(e.path);return}await s(e.path)},u=()=>{Er.current===i&&cs(n.filesId,r)};(async()=>{try{await V(n.filesId,r),c(r);return}catch{}try{await s(r);return}catch{}try{let e=await de(n.filesId,r,{limit:ZF});if(Er.current!==i)return;let t=bI(e.matches);if(t.length===1){let e=t[0];if(!e)return;await l(e);return}let c=xI(e.matches);if(t.length===0&&c.length===1){let e=c[0];if(!e)return;await s(e.path,!a&&e.kind===`content`?{lineNumber:e.lineNumber,column:e.ranges[0]?e.ranges[0].start+1:void 0,endColumn:e.ranges[0]?Math.max(e.ranges[0].start+1,e.ranges[0].end+1):void 0,sourceAgentId:n.sourceAgentId}:o);return}}catch{}u()})()},[cs,ss,Yr,ls]),fs=(0,G.useCallback)((e,t,n)=>{let r=Yr(e,n?.sourceAgentId),i=Ke(r.filesId),a=Wn(r.filesId);if(!i&&(a||r.sourceAgent)){let e=a||(r.sourceAgent?.isMain?`__farming_main_agent__`:UD(r.sourceAgent));$t(t=>{if(!t.has(e))return t;let n=new Set(t);return n.delete(e),n})}let o=E({agentId:r.filesId,workspaceRoot:r.workspaceRoot,filePath:t});if(!Ne.some(e=>z(e)===o))return!1;let s={...os(n),workspaceRoot:r.workspaceRoot,sourceAgentId:r.sourceAgentId};return U.select(r.filesId,t,s)?(yn(null),xn(null),Cn(null),Tn(null),Po(),H(`projects`),xe(`editor`),L(n)&&qn({agentId:r.filesId,path:t,kind:`file`,requestId:wr.current+=1}),r.sourceAgent&&r.sourceAgentId&&A(r.sourceAgentId,{focusTerminal:!1}),yo(),!0):!1},[Po,yo,os,A,H,Ne,Yr,U]),ps=(0,G.useCallback)(async(e,t,n)=>{let r=Yr(n?.globalRoot?Ye:e,n?.sourceAgentId??(n?.globalRoot?e:void 0)),i=r.filesId,a=n?.globalRoot?qe(t):t,o=n?{...n,sourceAgentId:r.sourceAgentId}:r.sourceAgentId?{sourceAgentId:r.sourceAgentId}:void 0;if(fs(i,a,o))return;let s=async(e,t=o)=>{await ss(i,await le(i,e),t)};try{await s(a,o)}catch{try{await V(i,a),ls(i,a,`directory`)}catch{try{let e=await de(i,a,{limit:ZF}),t=bI(e.matches),c=xI(e.matches);if(t.length===1){let e=t[0];if(e?.entryType===`directory`){ls(i,e.path,`directory`);return}if(e?.path){await s(e.path,o);return}}if(t.length===0&&c.length===1){let e=c[0];if(e?.path){await s(e.path,!n&&e.kind===`content`?{lineNumber:e.lineNumber,column:e.ranges[0]?e.ranges[0].start+1:void 0,endColumn:e.ranges[0]?Math.max(e.ranges[0].start+1,e.ranges[0].end+1):void 0,sourceAgentId:r.sourceAgentId}:o);return}}}catch{}o?.suppressSearchOnMiss||cs(i,a)}}},[cs,ss,Yr,ls,fs]),ms=(0,G.useCallback)(async e=>{if(I(e.kind===`agent`?e.readingAnchor:void 0),e.kind===`agent`)return qr.has(e.agentId)?(yn(null),xn(null),Cn(null),Tn(null),Po(),H(`projects`),xe(`terminal`),A(e.agentId,{focusTerminal:!1}),yo(),!0):!1;let t=_(e,[...Y.filter(e=>!e.isMain).map(e=>({agentId:e.id,workspace:UD(e)})),...He.map(e=>({agentId:Un(e),workspace:e}))],Ye);if(!t)return!1;let n=Yr(t.agentId,t.agentId);if(e.kind===`folder`)try{let e=f((await V(n.filesId,t.filePath)).items);if(e){let t=await le(n.filesId,e);return await ss(n.filesId,t,{sourceAgentId:n.sourceAgentId}),!0}return ls(n.filesId,t.filePath,`directory`),!0}catch{return!1}let r={...C(e),sourceAgentId:n.sourceAgentId};if(fs(n.filesId,t.filePath,r))return!0;try{let e=await le(n.filesId,t.filePath);return await ss(n.filesId,e,r),!0}catch{return!1}},[Y,Po,yo,A,H,ss,He,ls,Yr,fs,qr]),hs=(0,G.useRef)(ms);hs.current=ms;let gs=(0,G.useCallback)(()=>{if(typeof window>`u`)return;let e=d(window.location.search);window.history.replaceState(window.history.state,``,`${window.location.pathname}${e}${window.location.hash}`)},[]);(0,G.useEffect)(()=>{if(!dn)return;let e=!1,t=null,n=dn.kind===`agent`?dn.agentId:dn.absolutePath||(dn.kind===`folder`?dn.folderPath:dn.filePath);return hs.current(dn).then(r=>{if(!e){if(r){pn(null),gs();return}if(Dr.current+=1,Dr.current>=20){Hn({id:Date.now(),kind:`error`,message:J.sharedLocationUnavailable(n)}),pn(null),gs();return}t=window.setTimeout(()=>{hn(e=>e+1)},250)}}).catch(()=>{e||(Hn({id:Date.now(),kind:`error`,message:J.sharedLocationUnavailable(n)}),pn(null),gs())}),()=>{e=!0,t!==null&&window.clearTimeout(t)}},[gs,J.sharedLocationUnavailable,dn,mn]);let _s=(0,G.useCallback)(async e=>{if(e.kind===`agent`){if(!qr.has(e.agentId))return!1}else if(!Jr.has(e.agentId))return!1;if(yn(null),xn(null),Cn(null),Tn(null),Po(),H(`projects`),e.kind===`agent`)return xe(`terminal`),A(e.agentId),yo(),!0;let t={view:e.view,lineNumber:e.lineNumber,column:e.column,endColumn:e.endColumn,sourceAgentId:e.sourceAgentId},n=Yr(e.agentId,e.sourceAgentId);if(fs(n.filesId,e.filePath,t))return!0;try{let r=await le(n.filesId,e.filePath);return await ss(n.filesId,r,t),!0}catch{return!1}},[Po,yo,A,H,ss,Yr,fs,qr,Jr]),vs=(0,G.useCallback)(e=>{let t=Ae(e);return t?((async()=>{let n=t;for(;n;){if(await _s(n))return;n=Ae(e)}})().finally(()=>{je()}),!0):!1},[Ae,je,_s]),ys=(0,G.useCallback)(e=>{Er.current+=1,xe(`terminal`),H(`projects`),A(e,{focusTerminal:!re()}),yo()},[yo,A,H]),bs=(0,G.useCallback)(e=>{let t=U.close(e);t.closedFiles.length!==0&&t.activeFileClosed&&xe(t.activeFile?`editor`:`terminal`)},[U]),xs=(0,G.useCallback)((e,t,n)=>{bs([{agentId:e,filePath:t,workspaceRoot:n}])},[bs]),Ss=(0,G.useCallback)(()=>{let e=U.reopenLastClosed(e=>Jr.has(e.agentId))?.activeFile;if(!e)return!1;yn(null),xn(null),Cn(null),Tn(null),Po(),H(`projects`),xe(`editor`);let t=e.sourceAgentId;return t&&Y.some(e=>e.id===t)&&A(t,{focusTerminal:!1}),yo(),!0},[Y,Po,yo,A,H,Jr,U]),Cs=(0,G.useCallback)((e,t)=>U.update(e,t),[U]),ws=(0,G.useCallback)(e=>{U.updateDraft(e)},[U]),Ts=(0,G.useCallback)((e,t)=>{t.length!==0&&U.move(e,t)},[U]),Es=(0,G.useCallback)((e,t)=>{if(t.length===0)return;let n=U.deleteEntries(e,t);n.activeFileDeleted&&(n.activeFile||xe(`terminal`))},[U]),Ds=(0,G.useCallback)((e,t)=>{e.preventDefault(),e.stopPropagation();let n=Y.find(e=>e.id===t),r=nM(e.clientX,e.clientY,aM(n));xn(null),Cn(null),Tn(null),yn({agentId:t,x:r.x,y:r.y})},[Y]),Os=(0,G.useCallback)((e,t)=>{if(e.key!==`ContextMenu`&&!(e.shiftKey&&e.key===`F10`))return;e.preventDefault(),e.stopPropagation();let n=e.currentTarget.getBoundingClientRect(),r=Y.find(e=>e.id===t),i=nM(n.left+24,n.top+n.height,aM(r));xn(null),Cn(null),Tn(null),yn({agentId:t,x:i.x,y:i.y})},[Y]),ks=(0,G.useCallback)((e,t)=>{e.preventDefault(),e.stopPropagation();let n=e.currentTarget.getBoundingClientRect(),r=li.find(e=>e.id===t),i=r?.hasMain?4:ID(r)?8:7,a=tM(i,r?.hasMain?1:2)+i*8,o=ce()?iM(n,a,void 0,eI):rM(n,a);yn(null),Cn(null),Tn(null),xn({projectId:t,x:o.x,y:o.y})},[li]),As=(0,G.useCallback)((e,t)=>{if(e.key!==`ContextMenu`&&!(e.shiftKey&&e.key===`F10`))return;e.preventDefault(),e.stopPropagation();let n=e.currentTarget.getBoundingClientRect(),r=li.find(e=>e.id===t),i=r?.hasMain?4:ID(r)?8:7,a=tM(i,r?.hasMain?1:2)+i*8,o=ce()?iM(n,a,void 0,eI):rM(n,a);yn(null),Cn(null),Tn(null),xn({projectId:t,x:o.x,y:o.y})},[li]),js=(0,G.useCallback)((e,t,n)=>{e.preventDefault(),e.stopPropagation();let r=nM(e.clientX,e.clientY,tM(3));yn(null),xn(null),Tn(null),Cn({provider:t,sessionId:n,x:r.x,y:r.y})},[]),Ms=(0,G.useCallback)((e,t,n)=>{if(e.key!==`ContextMenu`&&!(e.shiftKey&&e.key===`F10`))return;e.preventDefault(),e.stopPropagation();let r=e.currentTarget.getBoundingClientRect(),i=nM(r.left+24,r.top+r.height,tM(3));yn(null),xn(null),Tn(null),Cn({provider:t,sessionId:n,x:i.x,y:i.y})},[]),Ns=(0,G.useCallback)(()=>{if(!ia)return;let e=u(ia);yn(null),Tn(null),Fn({kind:`agent`,agentId:ia.id,title:e})},[ia]),Ps=(0,G.useCallback)(()=>{aa&&(xn(null),Tn(null),Fn({kind:`project`,projectId:aa.id,workspace:aa.workspace,title:aa.name}))},[aa]),Q=(0,G.useCallback)(()=>{let e=Nn;Fn(null),e&&(e.kind===`agent`&&Qo(e.agentId),e.kind===`project`&&es(e.projectId))},[Qo,es,Nn]),Fs=(0,G.useCallback)(()=>{if(!Nn)return;let e=Nn.title.trim();if(Nn.kind===`agent`){if(!e)return;P(Nn.agentId,e),Fn(null),Qo(Nn.agentId);return}e&&(Qe({...Ze,[Nn.workspace]:e}),fetch(r(`/api/projects/name`),{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify({workspace:Nn.workspace,name:e})}).then(async e=>{let t=await e.json().catch(()=>null);if(!e.ok)throw Error(t?.error||J.copyFailed)}).catch(()=>{Qe(t=>{if(t[Nn.workspace]!==e)return t;let n={...t},r=Ze[Nn.workspace];return r?n[Nn.workspace]=r:delete n[Nn.workspace],n}),Hn({id:Date.now(),kind:`error`,message:J.copyFailed})}),Fn(null),es(Nn.projectId))},[J.copyFailed,Qo,es,P,Ze,Nn]),Is=(0,G.useCallback)(async(e,t)=>{yn(null),xn(null),Cn(null),Tn(null);let n=await CI(e);Hn({id:Date.now(),kind:n?`success`:`error`,message:n?J.copiedWorkingDirectory:J.copyFailed}),t?.kind===`agent`&&Qo(t.id),t?.kind===`agent-session`&&$o(t.provider,ZD(t))},[J.copiedWorkingDirectory,J.copyFailed,Qo,$o]),Ls=(0,G.useCallback)(()=>{ia&&(yn(null),Tn(null),Ln({agentId:ia.id,title:u(ia),acknowledgeUnprovenAcpExit:ia.requiresProcessExitAcknowledgement===!0}))},[ia]),Rs=(0,G.useCallback)(()=>{let e=In?.agentId;Ln(null),e&&Qo(e)},[Qo,In?.agentId]),zs=(0,G.useCallback)(()=>{In&&(ae(In.agentId,{acknowledgeUnprovenAcpExit:In.acknowledgeUnprovenAcpExit}),Ln(null))},[In,ae]),Bs=(0,G.useCallback)(e=>{ia&&(yn(null),Tn(null),R(ia.id,e))},[ia,R]),Vs=(0,G.useCallback)(e=>{if(!ia)return;let t=ia.id;if(yn(null),Tn(null),e.archived===!0){let e=ia.providerSessionKey||Ak(ia.source);e&&Do(e),kr.current=t,window.setTimeout(()=>Ao(),120),window.setTimeout(()=>Ao(),360),window.setTimeout(()=>Ao(),720)}let n=te(t,e);e.archived===!0&&ko(n),e.archived!==!0&&Qo(t)},[ia,Ao,Qo,te,Do,ko]),Hs=(0,G.useCallback)((e,t)=>{let n=e.id;if(yn(null),Tn(null),t.archived===!0){let t=e.providerSessionKey||Ak(e.source);t&&Do(t),kr.current=n,window.setTimeout(()=>Ao(),120),window.setTimeout(()=>Ao(),360),window.setTimeout(()=>Ao(),720)}let r=te(n,t);t.archived===!0&&ko(r),t.archived!==!0&&Qo(n)},[Ao,Qo,te,Do,ko]),Us=(0,G.useCallback)(async(e,t,n)=>{try{let i=await fetch(r(`/api/agents/${encodeURIComponent(e)}/reorder`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({beforeAgentId:t,afterAgentId:n})});if(!i.ok){let e=await i.json().catch(()=>null);throw Error(e?.error||J.reorderAgentFailed)}}catch(e){Hn({id:Date.now(),kind:`error`,message:e instanceof Error?e.message:J.reorderAgentFailed})}},[J.reorderAgentFailed]),Ws=(0,G.useCallback)(e=>{kr.current=null,Ar.current=e,te(e,{archived:!1}),Po(),H(`projects`),[120,360,720,1200,1800].forEach(t=>{window.setTimeout(()=>{Mo()||Zo(e)},t)})},[Po,Zo,te,H,Mo]),Gs=(0,G.useCallback)(e=>{ne(e)},[ne]),Ks=(0,G.useCallback)(async(e,t,n=``,i=``)=>{let a=ZD({provider:e,id:t,providerHomeId:n}),o=()=>{At(r=>r.map(r=>r.provider===e&&r.id===t&&(r.providerHomeId||`default`)===(n||`default`)?{...r,archived:!1}:r))},s=Y.find(r=>(r.providerSessionKey===a||r.source===Ok(e,t,n))&&r.archived!==!0&&r.status!==`dead`&&r.status!==`stopped`);if(s){try{await Vo(UD(s))}catch(e){Hn({id:Date.now(),kind:`error`,message:e instanceof Error?e.message:`Failed to resume agent session`});return}o(),Eo(e,t,n),A(s.id),yo();return}try{let a=await fetch(r(`/api/agent-sessions/${encodeURIComponent(e)}/${encodeURIComponent(t)}/resume`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({unarchiveArchived:!0,providerHomeId:n,...[`codex`,`claude`,`opencode`,`qoder`].includes(e)?{agentRuntimeMode:`chat`,acpHistoryMode:`load`}:{},...i?{customTitle:i}:{}})}),s=await a.json().catch(()=>null);if(!a.ok||!s?.agentId){Hn({id:Date.now(),kind:`error`,message:s?.error||`Failed to resume agent session (${a.status})`});return}o(),Eo(e,t,n),j(s.agentId),yo()}catch(e){Hn({id:Date.now(),kind:`error`,message:e instanceof Error?e.message:`Failed to resume agent session`})}},[Y,Eo,yo,Vo,A,j]);br.current=Ks;let qs=(0,G.useCallback)(e=>{let t=fI(e.source);if(t){Ks(t.provider,t.sessionId,t.providerHomeId,e.customTitle||``),H(`projects`);return}M(wM(e),e.command||void 0,null,e.customTitle||void 0)},[M,H,Ks]),Js=(0,G.useCallback)(e=>{if(e.preventDefault(),e.stopPropagation(),yn(null),xn(null),Cn(null),!ce()){Tn(null),Dn(!0);return}let t=e.currentTarget.getBoundingClientRect();Tn({x:Math.max(8,t.right-164),y:Math.min(window.innerHeight-12,t.bottom+6),returnFocusTarget:e.currentTarget})},[]),Ys=(0,G.useCallback)(async()=>{Tn(null);try{let e=m(ha),t=await fetch(r(`/api/share/qr-ticket`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e?{target:e}:{})}),n=await t.json().catch(()=>null);if(!t.ok||!n?.longUrl&&!n?.shortUrl)throw Error(n?.error||J.shareLinkFailed);jn(n.longUrl||n.shortUrl||``)}catch(e){if(e instanceof DOMException&&e.name===`AbortError`)return;Hn({id:Date.now(),kind:`error`,message:e instanceof Error?e.message:J.shareLinkFailed})}},[J.shareLinkFailed,ha]),Xs=(0,G.useCallback)(e=>{Tn(null),fe({language:e})},[fe]),Zs=(0,G.useCallback)(e=>{Tn(null),fe({appearance:e})},[fe]),Qs=(0,G.useCallback)(()=>{Tn(null),Dn(!0)},[]),$s=(0,G.useCallback)(e=>{e.preventDefault(),e.stopPropagation(),Tn(null),Dn(!0)},[]),ec=(0,G.useMemo)(()=>ce()?Rj([{type:`separator`,id:`options-mobile-share-separator`},{type:`item`,id:`options-mobile-share`,label:J.sharePage,ariaLabel:J.sharePage,onSelect:Ys}]):Rj([{type:`item`,id:`options-appearance-system`,label:BF(J.appearanceSystem),ariaLabel:J.appearanceSystem,checked:k.appearance===`system`,onSelect:()=>Zs(`system`)},{type:`item`,id:`options-appearance-light`,label:BF(J.appearanceLight),ariaLabel:J.appearanceLight,checked:k.appearance===`light`,onSelect:()=>Zs(`light`)},{type:`item`,id:`options-appearance-dark`,label:BF(J.appearanceDark),ariaLabel:J.appearanceDark,checked:k.appearance===`dark`,onSelect:()=>Zs(`dark`)},{type:`separator`,id:`options-appearance-language-separator`},{type:`item`,id:`options-language-en`,label:RF(J.languageEnglish),ariaLabel:J.languageEnglish,checked:k.language===`en`,onSelect:()=>Xs(`en`)},{type:`item`,id:`options-language-zh`,label:RF(J.languageChinese),ariaLabel:J.languageChinese,checked:k.language===`zh`,onSelect:()=>Xs(`zh`)},{type:`separator`,id:`options-settings-separator`},{type:`item`,id:`options-open-settings`,label:J.openSettings,ariaLabel:J.openSettings,onSelect:Qs}]),[J.appearanceDark,J.appearanceLight,J.appearanceSystem,J.languageChinese,J.languageEnglish,J.openSettings,J.sharePage,Qs,Ys,k.appearance,k.language,Zs,Xs]),tc=(0,G.useCallback)((e,t)=>{fetch(r(`/api/settings`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({agentLaunchProfiles:{[e]:t}})}).catch(()=>{})},[]),nc=(0,G.useCallback)(e=>{if(l)return;if(Vi===`claude`){let t=WP(e)?e:`default`;bt(t),tc(`claude`,{permissionMode:t}),X&&(Hn({id:Date.now(),kind:`success`,message:J.permissionProfileRestarting}),te(X.id,{launchPermissionMode:t})),ra(),La();return}let t=UP(e)?e:`approve`;it(t),tc(`codex`,{approvalMode:t}),X&&Vi===`codex`&&(Hn({id:Date.now(),kind:`success`,message:J.permissionProfileRestarting}),te(X.id,{launchPermissionMode:t})),ra(),La()},[X,ra,Vi,J.permissionProfileRestarting,La,te,l,tc]),rc=(0,G.useCallback)((e,t)=>{l||(Hn({id:Date.now(),kind:`success`,message:J.runtimeModeRestarting}),te(e,{agentRuntimeMode:t}))},[J.runtimeModeRestarting,te,l]),ic=(0,G.useCallback)((e,t)=>{let n=Y.find(t=>t.id===e);l||!ND(n)||wD(n)||(yn(null),Tn(null),rc(e,t))},[Y,l,rc]),ac=(0,G.useCallback)((e,t,n)=>{st(e),lt(t),dt(n),at(`${e}:${t}`),tc(`codex`,{model:e,reasoningEffort:t,serviceTier:n})},[tc]),oc=(0,G.useCallback)(e=>{if(Vi===`claude`){let t=JP(e);St(t),ra(),La(),tc(`claude`,{model:t,effort:Ct});return}let t=ft.find(t=>t.value===e),n=t?.reasoningLevels??[],r=t?.serviceTiers??[],i=n.some(e=>e.value===qi)?qi:t?.defaultEffort||n[0]?.value||qi,a=r.some(e=>e.value===Ji)?Ji:`default`;if(ra(),La(),X&&uI(X)){co(X,e,i,a).then(t=>{t&&ac(e,i,a)});return}ac(e,i,a)},[X,co,Ct,ra,ft,qi,Ji,ac,Vi,La,tc]),sc=(0,G.useCallback)((e,t)=>{if(Vi!==`codex`)return;let n=ft.find(t=>t.value===e);if(!n)return;let r=n.reasoningLevels?.some(e=>e.value===t)?t:n.defaultEffort||n.reasoningLevels?.[0]?.value||t,i=n.serviceTiers?.some(e=>e.value===Ji)?Ji:`default`;if(X&&uI(X)){co(X,e,r,i).then(t=>{t&&ac(e,r,i)});return}ac(e,r,i)},[X,co,ft,Ji,ac,Vi]),cc=(0,G.useCallback)(e=>{if(Vi===`claude`){let t=XP(e);wt(t),ra(),La(),tc(`claude`,{model:xt,effort:t});return}if(ra(),La(),X&&uI(X)){co(X,Ki,e,Ji).then(t=>{t&&ac(Ki,e,Ji)});return}ac(Ki,e,Ji)},[X,co,xt,ra,Ki,Ji,ac,Vi,La,tc]),lc=(0,G.useCallback)(e=>{if(Vi!==`claude`){if(ra(),La(),X&&uI(X)){co(X,Ki,qi,e).then(t=>{t&&ac(Ki,qi,e)});return}ac(Ki,qi,e)}},[X,co,ra,Ki,qi,ac,Vi,La]),uc=(0,G.useCallback)(e=>{if(Vi===`codex`){if(X&&uI(X)){co(X,Ki,qi,e).then(t=>{t&&ac(Ki,qi,e)});return}ac(Ki,qi,e)}},[X,co,Ki,qi,ac,Vi]),dc=(0,G.useCallback)(()=>{if(qt){_r.current?.stop(),_r.current=null,Yt(!1);return}let e=Oi;if(!e)return;let t=re(),n=cI(),r=Gt&&!n?window.SpeechRecognition||window.webkitSpeechRecognition:null;if(!r){(cI()||t)&&La(),Yt(!1);return}let i=new r,a=null,o=()=>{a!==null&&(window.clearTimeout(a),a=null)},s=()=>{if(_r.current===i)try{i.stop()}catch{Yt(!1),_r.current=null}};i.continuous=!1,i.interimResults=!1,i.lang=k.language===`zh`?`zh-CN`:navigator.language||`en-US`,i.onresult=t=>{let n=``;for(let e=t.resultIndex;e<t.results.length;e+=1)n+=t.results[e]?.[0]?.transcript??``;n.trim()&&(he(e,e=>{let t=e.draft&&!/\s$/.test(e.draft)?` `:``;return{...e,draft:`${e.draft}${t}${n.trim()}`}}),La())},i.onerror=()=>{o(),Yt(!1)},i.onspeechend=s,i.onaudioend=s,i.onend=()=>{o(),Yt(!1),_r.current=null},_r.current=i,Yt(!0);try{i.start(),a=window.setTimeout(s,6e4)}catch{o(),_r.current=null,Yt(!1),t&&La()}},[Oi,La,qt,Gt,k.language,he]),fc=(0,G.useCallback)(async()=>{if(!aa?.workspace)return;let e=aa.id,t=aa.workspace;xn(null),Tn(null);try{let e=await fetch(r(`/api/projects/pin`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({workspace:t,pinned:!aa.pinned})}),n=await e.json().catch(()=>null);if(!e.ok)throw Error(n?.error||`Project request failed (${e.status})`)}catch(e){Hn({id:Date.now(),kind:`error`,message:e instanceof Error?e.message:J.copyFailed})}window.requestAnimationFrame(()=>es(e))},[aa,J.copyFailed,es]),pc=(0,G.useCallback)(async()=>{if(!aa?.workspace)return;let e=aa.id,t=Un(aa.workspace);xn(null),Tn(null);try{let e=await fetch(r(`/api/projects/reveal`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({rootId:t})}),n=await e.json().catch(()=>null);if(!e.ok)throw Error(n?.error||J.revealInFinderFailed)}catch(e){Hn({id:Date.now(),kind:`error`,message:e instanceof Error?e.message:J.revealInFinderFailed})}es(e)},[aa,J.revealInFinderFailed,es]),mc=(0,G.useCallback)(async()=>{if(!aa?.workspace)return;let e=aa.id,t=Un(aa.workspace);xn(null),Tn(null);try{let e=await fetch(r(`/api/projects/create-worktree`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({rootId:t})}),n=await e.json().catch(()=>null);if(!e.ok)throw Error(n?.error||J.permanentWorktreeFailed);Hn({id:Date.now(),kind:`success`,message:J.permanentWorktreeCreated})}catch(e){Hn({id:Date.now(),kind:`error`,message:e instanceof Error?e.message:J.permanentWorktreeFailed})}es(e)},[aa,J.permanentWorktreeCreated,J.permanentWorktreeFailed,es]),hc=(0,G.useCallback)(()=>{if(!aa)return;let e=aa.id;aa.agents.forEach(e=>{e.unread&&ro(e.id,!0)}),xn(null),Tn(null),es(e)},[aa,es,ro]),gc=(0,G.useCallback)(()=>{if(!aa)return;let e=aa.workspace,t=aa.agents.filter(e=>!e.isMain),n=Qr.filter(t=>$D(t)===e);if(t.length===0&&n.length===0){xn(null),Tn(null),Or.current=`list`;return}t.forEach(e=>{te(e.id,{archived:!0})}),Oo(n.map(ZD)),xn(null),Tn(null),Or.current=`list`},[Qr,aa,te,Oo]),_c=(0,G.useCallback)(async()=>{if(!(!aa||aa.hasMain||aa.agents.length>0||aa.agentSessions.length>0||aa.hasOpenFile)){try{let e=await fetch(r(`/api/projects/remove`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({workspace:aa.workspace})}),t=await e.json().catch(()=>null);if(!e.ok)throw Error(t?.error||`Project request failed (${e.status})`)}catch(e){Hn({id:Date.now(),kind:`error`,message:e instanceof Error?e.message:J.copyFailed})}xn(null),Tn(null),Or.current=`list`}},[aa,J.copyFailed]),vc=(0,G.useCallback)(()=>{aa&&(xn(null),Tn(null),Bn({projectId:aa.id,workspace:aa.workspace,sessionHandles:aa.agentSessions.map(ZD)}))},[aa]),yc=(0,G.useCallback)(()=>{let e=zn?.projectId;Bn(null),e&&es(e)},[zn?.projectId,es]),bc=(0,G.useCallback)(async()=>{if(!zn)return;let e=zn,t=await B(e.workspace,{force:!0});t.deleted&&(Oo([...e.sessionHandles,...t.removedMainPageSessionKeys??[]]),Or.current=`list`,Bn(null))},[zn,B,Oo]),xc=(0,G.useCallback)(()=>{let e=vn?.agentId,t=bn?.projectId,n=Sn?.provider,r=Sn?.sessionId,i=wn?.returnFocusTarget??null;yn(null),xn(null),Cn(null),Tn(null),e?Qo(e):t?es(t):n&&r?$o(n,r):i&&window.requestAnimationFrame(()=>i.focus({preventScroll:!0}))},[vn?.agentId,Sn?.provider,Sn?.sessionId,Qo,$o,es,wn?.returnFocusTarget,bn?.projectId]),Sc=(0,G.useCallback)((e,t)=>{if(!t)return!1;if(e.key===`Escape`)return e.preventDefault(),e.stopPropagation(),xc(),!0;let n=Array.from(t.querySelectorAll(`button:not(:disabled)`));if(n.length===0)return;let r=n.findIndex(e=>e===document.activeElement),i=Math.min(gr.current,n.length-1),a=r===-1?i:r,o=e=>{gr.current=e,n[e]?.focus()};if(e.key===`Tab`){hr.current=!0,e.preventDefault(),e.stopPropagation();let t=a+(e.shiftKey?-1:1);if(t<0||t>=n.length){xc();return}return o(t),!0}if(e.key===`ArrowDown`||e.key===`ArrowUp`){hr.current=!0,e.preventDefault(),e.stopPropagation();let t=e.key===`ArrowDown`?1:-1;return o(a===-1?t>0?0:n.length-1:(a+t+n.length)%n.length),!0}return e.key===`Home`?(hr.current=!0,e.preventDefault(),e.stopPropagation(),o(0),!0):e.key===`End`?(hr.current=!0,e.preventDefault(),e.stopPropagation(),o(n.length-1),!0):!1},[xc]),Cc=(0,G.useCallback)(e=>{e.defaultPrevented||Sc(e.nativeEvent,e.currentTarget)},[Sc]);(0,G.useLayoutEffect)(()=>{if(!vn&&!bn&&!Sn&&!wn)return;let e=e=>{Sc(e,document.querySelector(`.code-context-menu`))&&e.stopImmediatePropagation()};return document.addEventListener(`keydown`,e,!0),()=>document.removeEventListener(`keydown`,e,!0)},[vn,Sn,Sc,wn,bn]);let wc=(0,G.useCallback)(e=>{let t=Array.from(e.currentTarget.querySelectorAll(`button:not(:disabled)`)),n=e.target instanceof Element?e.target.closest(`button`):null,r=t.findIndex(e=>e===n||e===document.activeElement);if(e.key===`Escape`){e.preventDefault(),e.stopPropagation(),ra(),La();return}if(e.key===`Tab`){e.preventDefault(),e.stopPropagation();let t=Fi?`[data-testid="code-composer-model-picker"]`:Ii?mI()?`[data-testid="code-composer-send"]`:`[data-testid="code-composer-mic"]`:`[data-testid="code-composer-approval"]`;ra(),window.requestAnimationFrame(()=>{document.querySelector(t)?.focus({preventScroll:!0})});return}if(e.key===`ArrowDown`||e.key===`ArrowUp`){e.preventDefault(),e.stopPropagation();let n=e.key===`ArrowDown`?1:-1;t[r===-1?n>0?0:t.length-1:(r+n+t.length)%t.length]?.focus();return}if(e.key===`Home`){e.preventDefault(),e.stopPropagation(),t[0]?.focus();return}e.key===`End`&&(e.preventDefault(),e.stopPropagation(),t[t.length-1]?.focus())},[Fi,ra,La,Ii]),Tc=(0,G.useCallback)(e=>{let t=e.relatedTarget;t&&(t instanceof Node&&e.currentTarget.contains(t)||t instanceof Element&&t.closest(`.code-composer`)||ra())},[ra]);(0,G.useEffect)(()=>{function e(e){if(a)return;let t=e.target;if(vn||bn||Sn||wn){if(Sc(e,mr.current))return;if(e.key.length===1||e.key===`Tab`||e.key===`ArrowDown`||e.key===`ArrowUp`||e.key===`Home`||e.key===`End`){e.preventDefault(),e.stopPropagation();return}}if(e.key===`Escape`&&Nn){e.preventDefault(),Q();return}if(e.key===`Escape`&&In){e.preventDefault(),Rs();return}if(e.key===`Escape`&&zn){e.preventDefault(),yc();return}if(Nn||In||zn){en(t)||(e.preventDefault(),e.stopPropagation());return}let n=O?Qn(e):null;if(n){_I(e),vs(n);return}if(HF(e)&&!en(t)){e.preventDefault(),e.stopPropagation(),Ss();return}if((e.ctrlKey||e.metaKey)&&e.key.toLowerCase()===`p`&&!e.altKey&&!e.shiftKey&&!Nn&&!In&&!zn&&!en(t)&&!dI(t)&&!Xt(t)){let n=fa(t)??da;if(!n)return;e.preventDefault(),cs(n);return}if(!(Zt(t)||Xt(t))&&!(en(t)&&e.key!==`Escape`)){if(e.key===`Escape`&&(Pi||Fi||Ii)){e.preventDefault(),ra(),La();return}if(e.key===`Escape`&&i!==`projects`){e.preventDefault(),yn(null),xn(null),Cn(null),Tn(null),Po(),H(`projects`),Or.current=`active-force`;return}if(e.key===`Escape`&&(vn||bn||Sn||wn)){e.preventDefault();let t=vn?.agentId,n=bn?.projectId,r=Sn?.provider,i=Sn?.sessionId,a=wn?.returnFocusTarget??null;yn(null),xn(null),Cn(null),Tn(null),t?Qo(t):n?es(n):r&&i?$o(r,i):a&&window.requestAnimationFrame(()=>a.focus({preventScroll:!0}));return}if(O){if((e.ctrlKey||e.metaKey)&&e.key.toLowerCase()===`b`){e.preventDefault(),Ur();return}e.key===`/`&&!e.ctrlKey&&!e.metaKey&&!e.altKey&&!e.shiftKey&&(e.preventDefault(),vo())}}}return window.addEventListener(`keydown`,e,!0),()=>window.removeEventListener(`keydown`,e,!0)},[i,vn,Fi,ra,yc,Rs,Q,Sn,zn,a,Qo,$o,La,es,cs,Sc,In,O,Ii,vs,wn,Pi,da,fa,bn,Nn,Ss,Po,H,vo,Ur]),(0,G.useEffect)(()=>{if(!Nn)return;let e=Nn.title,t=!1;return jP(()=>{let n=cr.current;if(!n)return;let r=document.activeElement;if(r!==n&&!q.current?.contains(r)&&n.focus(),!t&&document.activeElement===n&&n.value===e){if(t=!0,Nn.kind===`project`){let e=n.value.length;n.setSelectionRange(e,e);return}n.select()}},{delays:[0,80,180,360]})},[Xn]),(0,G.useEffect)(()=>In?jP(()=>{lr.current?.contains(document.activeElement)||ur.current?.focus()},{runNow:!1,delays:[180]}):void 0,[In]),(0,G.useEffect)(()=>zn?jP(()=>{dr.current?.contains(document.activeElement)||fr.current?.focus()},{runNow:!1,delays:[180]}):void 0,[zn]),(0,G.useEffect)(()=>{if(!Vn)return;let e=window.setTimeout(()=>Hn(null),1700);return()=>window.clearTimeout(e)},[Vn]),(0,G.useEffect)(()=>{function e(e){let t=e.target;t instanceof Element&&t.closest(`.code-context-menu`)||(yn(null),xn(null),Cn(null),Tn(null))}if(!(!vn&&!bn&&!Sn&&!wn))return window.addEventListener(`pointerdown`,e),()=>window.removeEventListener(`pointerdown`,e)},[vn,Sn,wn,bn]),(0,G.useEffect)(()=>{function e(e){let t=e.target;t instanceof Element&&t.closest(`.code-composer-menu-anchor`)||ra()}if(!(!Pi&&!Fi&&!Ii))return window.addEventListener(`pointerdown`,e),()=>window.removeEventListener(`pointerdown`,e)},[Fi,ra,Ii,Pi]),(0,G.useLayoutEffect)(()=>!vn&&!bn&&!Sn&&!wn?void 0:(hr.current=!1,gr.current=0,jP(()=>{if(hr.current)return;let e=mr.current;if(!e)return;let t=document.activeElement;if(t instanceof HTMLButtonElement&&e.contains(t))return;let n=e.querySelector(`button:not(:disabled)`);n&&(gr.current=0,n.focus())},{delays:[0,80,180,360]})),[vn,Sn,wn,bn]),(0,G.useEffect)(()=>{if(!Ii)return;let e=window.setTimeout(()=>{let e=Li===`model`?`.code-model-submenu .code-model-option.selected`:Li===`speed`?`.code-speed-submenu .code-model-option.selected`:`.code-model-picker-menu > .code-model-option.selected`,t=or.current?.querySelector(e),n=or.current?.querySelector(`button:not(:disabled)`);(t??n)?.focus()},0);return()=>window.clearTimeout(e)},[Ii,Li,_a,va,ya]),(0,G.useEffect)(()=>{if(!Pi)return;let e=window.setTimeout(()=>{ir.current?.querySelector(`button:not(:disabled)`)?.focus()},0);return()=>window.clearTimeout(e)},[Pi]),(0,G.useEffect)(()=>{if(!Fi)return;let e=window.setTimeout(()=>{let e=ar.current?.querySelector(`.code-approval-option.selected`),t=ar.current?.querySelector(`button:not(:disabled)`);(e??t)?.focus()},0);return()=>window.clearTimeout(e)},[Fi,Ca]),(0,G.useEffect)(()=>{if(!pe)return;let e=window.setInterval(()=>$n(Date.now()),6e4);return()=>window.clearInterval(e)},[pe]),(0,G.useEffect)(()=>{let e=window.matchMedia(`(max-width: 980px)`),t=()=>{Kt(!!(window.SpeechRecognition||window.webkitSpeechRecognition)&&!cI())};return t(),e.addEventListener(`change`,t),()=>{e.removeEventListener(`change`,t),_r.current?.stop(),_r.current=null}},[]),(0,G.useEffect)(()=>za(),[za]),(0,G.useEffect)(()=>{document.title=`${On} · Farming Code`},[On]),(0,G.useEffect)(()=>{let e=()=>{za(),Ka()};return window.addEventListener(`farming-agent-homes-saved`,e),()=>window.removeEventListener(`farming-agent-homes-saved`,e)},[Ka,za]),(0,G.useEffect)(()=>Ha(),[Ha]),(0,G.useEffect)(()=>Ya(Vi||``,X?.cwd),[X?.cwd,Vi,Ya]),(0,G.useEffect)(()=>{if(Ii)return Va()},[Va,Ii]),(0,G.useEffect)(()=>{if(!(!Ii||Vi!==`claude`))return Ha()},[Vi,Ha,Ii]),(0,G.useEffect)(()=>Ka(),[Ka]),(0,G.useEffect)(()=>{Ia()},[Ia,Oi,Ni,ji]),(0,G.useEffect)(()=>{ki.composer.permissionMode||ki.composer.modelPicker||na(e=>{let t=YA(e);return ki.composer.plusMenu||t.mode===`default`?t:{...t,mode:`default`}})},[ki,na]),(0,G.useEffect)(()=>{i!==`search`&&Fe&&Po(),i!==`projects`&&(yn(null),xn(null),Cn(null),Tn(null),ra())},[i,Po,ra,Fe]),(0,G.useEffect)(()=>{a&&(yn(null),xn(null),Cn(null),Tn(null),ra())},[ra,a]),(0,G.useEffect)(()=>{if(i===`projects`)return za()},[i,za]),(0,G.useEffect)(()=>{if(i!==`history`)return;let e=!1,t=jr.current;return fetch(r(`/api/settings`)).then(e=>e.json()).then(n=>{if(e)return;let r=n.settings??{};Ve(fn(r.lastMainWorkspace,r.workspaceHistory??[])),Qe(zF(r.projectNames)),t===jr.current&&nt(new Set(Ek(r.mainPageSessionKeys??[]))),Ra(r),Ka(!0)}).catch(()=>{e||Ve([])}),()=>{e=!0}},[i,Ra,Ka]),(0,G.useEffect)(()=>{function e(e){Lr.current&&(e.preventDefault(),Xo(e.clientX))}function t(){Lr.current&&(Lr.current=!1,document.body.classList.remove(`code-resizing-sidebar`))}return window.addEventListener(`pointermove`,e),window.addEventListener(`pointerup`,t),window.addEventListener(`pointercancel`,t),()=>{window.removeEventListener(`pointermove`,e),window.removeEventListener(`pointerup`,t),window.removeEventListener(`pointercancel`,t),document.body.classList.remove(`code-resizing-sidebar`)}},[Xo]),(0,G.useEffect)(()=>{let e=er.current;if(!e||typeof ResizeObserver>`u`)return;let t=e=>{if(mI()){zr.current||Vr(),zr.current=!0;return}if(zr.current=!1,hI(e)){Vr();return}Rr.current&&Hr()};t(e.getBoundingClientRect().width);let n=new ResizeObserver(n=>{t(n[0]?.contentRect.width??e.getBoundingClientRect().width)});return n.observe(e),()=>n.disconnect()},[Vr,Hr]),(0,G.useEffect)(()=>{let e=Or.current;if(!e||i!==`projects`||Fe)return;Or.current=null;let t,n=0,r=e===`active-force`?4:12,a=()=>{n>=r||(t=window.setTimeout(o,90))},o=()=>{if(n+=1,Mo()){a();return}let t=!1;e===`list`?(pr.current?.focus({preventScroll:!0}),t=document.activeElement===pr.current):t=Ao(),(!t||e===`active-force`)&&a()},s=window.setTimeout(()=>{o()},e===`list`?0:50);return()=>{window.clearTimeout(s),t!==void 0&&window.clearTimeout(t)}},[c,i,Ao,Fe,Mo]),(0,G.useEffect)(()=>{if(!kr.current||i!==`projects`||Fe)return;kr.current=null;let e,t=0,n=()=>{t>=12||(e=window.setTimeout(r,90))},r=()=>{if(t+=1,Mo()){n();return}No({skipIfFocusMoved:!0}),n()},a=window.setTimeout(()=>{r(),e=window.setTimeout(r,180)},50);return()=>{window.clearTimeout(a),e!==void 0&&window.clearTimeout(e)}},[Y.length,c,i,No,Fe,Mo]),(0,G.useEffect)(()=>{let e=Ar.current;if(!e||i!==`projects`||Fe||!Y.some(t=>t.id===e))return;Ar.current=null;let t,n=0,r=()=>{n+=1,Mo()||Zo(e),!(n>=60)&&(t=window.setTimeout(()=>{window.requestAnimationFrame(r)},80))},a=window.setTimeout(()=>{window.requestAnimationFrame(r)},50);return()=>{window.clearTimeout(a),t!==void 0&&window.clearTimeout(t)}},[Y,i,Zo,Fe,Mo]),(0,G.useEffect)(()=>{ua&&_n(ua)},[ua]),(0,G.useEffect)(()=>{Be(0)},[fi,Fe]),(0,G.useEffect)(()=>{Be(e=>vi.length===0?0:Math.min(e,vi.length-1))},[vi.length]);let Ec={"--code-sidebar-width":`${on?JF:rn}px`};return(0,K.jsxs)(`div`,{className:`code-workspace ${on?`sidebar-collapsed`:``}`,"data-testid":`code-workspace`,ref:er,style:Ec,children:[(0,K.jsx)(LM,{sidebarCollapsed:on,emptyHomeActionRequest:ln,activeView:i,searchOpen:Fe,displayedProjects:ui,collapsedProjectIds:Qt,normalizedSearch:``,hasProjectListItems:hi,hasDisplayedProjectListItems:hi,activeTerminalId:c,selectedSearchAgentId:ca,selectedSearchSessionHandle:la,claimedAgentSessionKeyByAgentId:Zr.claimedAgentSessionKeyByAgentId,agentShortcutKeys:yi,keyboardShortcutsEnabled:O,now:Zn,mainAgent:Kr,usageSummary:o,instanceName:On,shareTarget:ha,agentLaunchOptions:$e,agentCreationWorkspace:pa,openWorkspaceFile:W,openWorkspaceFiles:Ne,fileRevealRequest:Kn,fileSearchFocusRequest:Jn,projectListRef:pr,canLoadMoreAgentSessions:Nt,onLoadMoreAgentSessions:Ja,onNewAgent:xo,onStartAgent:So,onToggleSidebar:Ur,onOpenSearch:Lo,onOpenWorkspaceView:Ro,onOpenMainAgent:()=>{Kr&&(xe(`terminal`),H(`projects`),A(Kr.id))},onRestartMainAgent:ie,onProjectListKeyDown:Ko,onToggleProject:zo,onToggleProjectSessions:Ho,onMountProject:Vo,onOpenProjectContextMenu:ks,onOpenProjectKeyboardMenu:As,onOpenAgent:as,onUpdateAgentFlags:Hs,onReorderAgent:Us,onOpenAgentContextMenu:Ds,onOpenAgentKeyboardMenu:Os,onResumeAgentSession:Ks,onOpenAgentSessionContextMenu:js,onOpenAgentSessionKeyboardMenu:Ms,onOpenProjectFile:ss,onSelectOpenWorkspaceFile:fs,onCloseOpenWorkspaceFile:xs,onMoveWorkspaceEntries:Ts,onDeleteWorkspaceEntries:Es,onRefreshProjectOpenFiles:Pe,onOpenOptionsMenu:$s,onRenameInstance:Ba,copy:J}),(0,K.jsx)(wP,{open:En,activeAgentId:i===`projects`?X?.id??null:null,language:k.language,uiPreferences:k,agentLaunchOptions:$e,onClose:()=>Dn(!1),onUpdateUiPreferences:fe}),An&&(0,K.jsx)(Lj,{copy:J,title:ja,url:An,onClose:()=>jn(``)}),(0,K.jsx)(`div`,{className:`code-sidebar-resizer`,"data-testid":`code-sidebar-resizer`,role:`separator`,"aria-label":J.resizeNavigation,"aria-orientation":`vertical`,"aria-valuemin":WF,"aria-valuemax":GF,"aria-valuenow":on?JF:rn,onPointerDown:rs}),!on&&(0,K.jsx)(`button`,{type:`button`,className:`code-mobile-sidebar-backdrop`,"data-testid":`code-mobile-sidebar-backdrop`,"aria-label":J.closeNavigation,onPointerDown:Vr}),(0,K.jsxs)(`div`,{className:`code-mobile-topbar`,"data-testid":`code-mobile-topbar`,children:[Fa?(0,K.jsx)(`button`,{type:`button`,className:`code-mobile-topbar-button back`,"data-testid":`code-mobile-back`,"aria-label":J.backToAgent,onClick:()=>{Pa&&ys(Pa)},children:(0,K.jsx)(`span`,{"aria-hidden":`true`})}):(0,K.jsx)(`button`,{type:`button`,className:`code-mobile-topbar-button menu`,"data-testid":`code-mobile-menu`,"aria-label":J.openNavigation,onClick:bo,children:(0,K.jsx)(`span`,{"aria-hidden":`true`})}),(0,K.jsxs)(`div`,{className:`code-mobile-topbar-title`,children:[(0,K.jsx)(`strong`,{children:ja}),Na&&(0,K.jsxs)(`span`,{children:[(0,K.jsx)(`i`,{"aria-hidden":`true`}),Na]})]}),(0,K.jsx)(`button`,{type:`button`,className:`code-mobile-topbar-button more`,"data-testid":`code-mobile-more`,"aria-label":J.openOptions,onClick:Js,children:(0,K.jsx)(`span`,{"aria-hidden":`true`})})]}),wn&&(0,K.jsx)(`div`,{className:`code-context-menu code-options-menu`,"data-testid":`code-options-menu`,style:{left:wn.x,top:wn.y},role:`menu`,ref:mr,onKeyDownCapture:Cc,onKeyDown:Cc,children:(0,K.jsx)(TI,{entries:ec})}),(0,K.jsx)(zA,{activeView:i,showFileEditor:ma,openWorkspaceFile:W,openWorkspaceFiles:Ne,openAgentsCount:xi.length,openAgents:Ci,activeTerminalId:c,permissionSwitchingAgentId:l,agentSwitchingKind:h,terminalFocusRequest:w,agentCreationWorkspace:pa,displayedProjects:gi,searchQuery:Le,searchHasQuery:pi,searchLoading:Lt,visibleSearchTargetCount:vi.length,selectedSearchAgentId:ca,selectedSearchSessionHandle:la,searchInputRef:sr,archivedRuns:ii,archivedAgents:ri,historyAgentSessions:ai,canLoadMoreHistoryAgentSessions:Nt,now:Zn,acpComposerProps:{active:!!X&&!Ti,agentId:X?.id||``,runtimeState:wi?.state||``,sessionUpdatedAt:wi?.sessionUpdatedAt||``,runtimeError:wi?.error||``,draft:ji,attachments:Mi,composerMode:Ni,contextWindow:Di,pendingFollowUp:Qi??null,submitAction:Z,textareaRef:tr,attachmentInputRef:rr,permissions:wi?.pendingPermissions.length?wi.pendingPermissions:wi?.pendingPermission?[wi.pendingPermission]:[],elicitations:wi?.pendingElicitations.length?wi.pendingElicitations:wi?.pendingElicitation?[wi.pendingElicitation]:[],activeElicitations:wi?.activeElicitations||[],speechSupported:Gt,speechListening:qt,onDraftChange:oo,onNavigateHistory:so,onRemoveAttachment:$a,onSubmit:fo,onInterrupt:po,onDiscardPendingFollowUp:_o,onToggleSpeechInput:dc,onPasteAttachment:to,onAttachmentFiles:eo,onChooseAttachmentFile:Xa,onActivateComposerMode:no,onClearComposerMode:()=>{na(e=>({...e,mode:`default`}))},onRespondToPermission:mo,onRespondToElicitation:ho},composerProps:{active:!!X&&!Ti,agentKind:Vi,capabilities:ki.composer,slashCommands:Zi,draft:ji,attachments:Mi,composerMode:Ni,plusMenuOpen:Pi,approvalMenuOpen:Fi,modelMenuOpen:Ii,modelPickerPane:Li,agentModelPreset:ba,agentModel:_a,agentReasoningEffort:va,agentServiceTier:ya,agentModelOptions:ga,currentPermissionMode:Ca,permissionModeDisabled:!!l,modelProfileDisabled:Ei||!!(X&&uI(X)&&X.terminalStatus?.activity===`busy`),currentPermissionLabel:wa,currentPermissionColor:Ta,permissionModeHint:J.permissionRestartHint,currentModelLabel:Ea,currentReasoningLabel:Da,currentSpeedLabel:Oa,currentReasoningOptions:xa,currentServiceTierOptions:Sa,permissionModeOptions:ka,contextWindow:Di,pendingFollowUp:Qi?{messages:Qi.messages,createdAt:Qi.createdAt}:null,submitAction:ta,speechSupported:Gt,speechListening:qt,textareaRef:tr,attachmentInputRef:rr,plusMenuRef:ir,approvalMenuRef:ar,modelMenuRef:or,onDraftChange:oo,onNavigateHistory:so,onRemoveAttachment:$a,onSubmit:uo,onInterrupt:po,onSendPendingFollowUp:go,onDiscardPendingFollowUp:_o,onPasteAttachment:to,onAttachmentFiles:eo,onChooseAttachmentFile:Xa,onActivateComposerMode:no,onClearComposerMode:()=>{na(e=>({...e,mode:`default`})),La()},onTogglePlusMenu:()=>{na(e=>({...e,ui:{plusMenuOpen:!e.ui.plusMenuOpen,approvalMenuOpen:!1,modelMenuOpen:!1,modelPickerPane:null}}))},onToggleApprovalMenu:()=>{na(e=>({...e,ui:{plusMenuOpen:!1,approvalMenuOpen:!e.ui.approvalMenuOpen,modelMenuOpen:!1,modelPickerPane:null}}))},onToggleModelMenu:()=>{na(e=>({...e,ui:{plusMenuOpen:!1,approvalMenuOpen:!1,modelMenuOpen:!e.ui.modelMenuOpen,modelPickerPane:null}}))},onCloseMenus:ra,onSetModelPickerPane:e=>{na(t=>({...t,ui:{...t.ui,modelPickerPane:e}}))},onComposerMenuKeyDown:wc,onComposerMenuBlur:Tc,onUpdatePermissionMode:nc,onUpdateModel:oc,onUpdateReasoningEffort:cc,onUpdateServiceTier:lc,onUpdateModelProfile:sc,onUpdateServiceTierInline:uc,onToggleSpeechInput:dc},onNewAgent:M,onOpenHistory:()=>Ro(`history`),onOpenSearch:Lo,onOpenShare:()=>Wr(`share`),onOpenAppMode:()=>Wr(`focus`),onCollapseSidebar:Br,onOpenTerminal:A,onOpenTerminalPath:ds,onResolveTerminalPath:us,onTerminalFollowOutputChange:ao,onAgentReadLatest:io,onRuntimeModeChange:rc,onForkAgent:R,onSessionOutput:ue,onOpenSearchAgent:is,onOpenSearchSession:e=>{Ks(e.provider,e.id,e.providerHomeId),Po(),H(`projects`)},onSearchQueryChange:Re,onSearchKeyDown:Yo,onCloseSearch:Fo,onBackToProjects:()=>Io(`projects`),onLoadMoreHistoryAgentSessions:Ja,onSearchHistoryAgentSessions:Wa,onResumeHistorySession:Ks,onContinueArchivedRun:qs,onOpenArchivedAgent:Gs,onRestoreArchivedAgent:Ws,onChangeWorkspaceFileDraft:ws,onUpdateOpenWorkspaceFile:Cs,onSelectOpenWorkspaceFile:fs,onOpenWorkspaceFilePath:ps,canNavigateWorkspaceBack:Te,canNavigateWorkspaceForward:Ee,onNavigateWorkspaceHistory:vs,onCloseOpenWorkspaceFile:xs,onCloseOpenWorkspaceFiles:bs,onRevealWorkspaceFileInExplorer:ls,onFocusWorkspaceFilesSearch:cs,onRecordWorkspaceNavigationCursor:ke,onBackToAgentFromFile:ys,copy:J}),(0,K.jsx)(zj,{contextMenuAgent:ia,contextMenuAgentSession:oa,contextMenuProject:aa,agentMenu:vn,projectMenu:bn,agentSessionMenu:Sn,renameDialog:Nn,killDialog:In,deleteWorktreeDialog:zn,copyNotice:Vn,contextMenuRef:mr,renameDialogRef:q,renameInputRef:cr,killDialogRef:lr,killCancelButtonRef:ur,deleteWorktreeDialogRef:dr,deleteWorktreeCancelButtonRef:fr,onContextMenuKeyDown:Cc,runtimeSwitchDisabled:!!l,onSwitchAgentRuntime:ic,onUpdateAgentFlags:Vs,onRenameAgent:Ns,onRenameProject:Ps,onCopyAgentWorkingDirectory:()=>{ia&&Is(UD(ia),{kind:`agent`,id:ia.id})},onForkAgent:Bs,onKillAgent:Ls,onOpenSession:(e,t)=>{Cn(null),Tn(null),Ks(e,t,oa?.providerHomeId),oa&&$o(e,ZD(oa))},onToggleSessionPinned:ts,onArchiveSession:ns,onCopySessionWorkingDirectory:()=>{oa&&Is(eO(oa),{kind:`agent-session`,provider:oa.provider,id:oa.id,providerHomeId:oa.providerHomeId})},onToggleProjectPinned:fc,onRevealProject:pc,onCreatePermanentWorktree:mc,onMarkProjectRead:hc,onArchiveProject:gc,onRemoveProject:_c,onDeleteWorktree:vc,onCloseRenameDialog:Q,onRenameDialogTitleChange:e=>Fn(t=>t&&{...t,title:e}),onSubmitRenameDialog:Fs,onCloseKillDialog:Rs,onSubmitKillDialog:zs,onCloseDeleteWorktreeDialog:yc,onSubmitDeleteWorktreeDialog:bc,copy:J})]})}function TI({entries:e}){return(0,K.jsx)(K.Fragment,{children:e.map(e=>e.type===`separator`?(0,K.jsx)(`div`,{className:`code-context-menu-separator`,role:`separator`},e.id):(0,K.jsxs)(`button`,{type:`button`,role:typeof e.checked==`boolean`?`menuitemradio`:`menuitem`,"aria-checked":typeof e.checked==`boolean`?e.checked:void 0,"aria-label":e.ariaLabel,className:[e.danger?`danger`:``,typeof e.checked==`boolean`?`selectable`:``,e.checked?`checked`:``].filter(Boolean).join(` `)||void 0,disabled:e.disabled,onClick:e.onSelect,children:[typeof e.checked==`boolean`&&(0,K.jsx)(`span`,{className:`code-options-menu-check`,"aria-hidden":`true`,children:e.checked?(0,K.jsx)(Te,{}):null}),e.icon&&(0,K.jsx)(`span`,{className:`code-context-menu-icon`,"aria-hidden":`true`,children:(0,K.jsx)(Hj,{kind:e.icon})}),(0,K.jsx)(`span`,{children:e.label})]},e.id))})}var EI={appearance:`system`,language:`en`};function DI(e){return e===`system`||e===`light`||e===`dark`?e:EI.appearance}function OI(e){return e===`zh`||e===`en`?e:EI.language}function kI(e){return e===`system`?typeof window<`u`&&window.matchMedia(`(prefers-color-scheme: dark)`).matches?`dark`:`light`:e}function AI(e=`terminal`,t={}){if(typeof document>`u`)return;let n=document.body,r=t.crtEffects!==!1,i=DI(t.appearance),a=kI(i);n.dataset.theme=e,n.dataset.crtEffects=r?`on`:`off`,n.dataset.appearancePreference=i,n.dataset.appearance=a,r?n.classList.remove(`no-crt`):n.classList.add(`no-crt`)}var jI=!1,MI=240,NI=3e4,PI=1e4,FI=6e4,II=45e3,LI=6e4;function RI(e){if(e)return e.gitWorktree?.workspace?e.gitWorktree.workspace:e.projectWorkspace?e.projectWorkspace:e.cwd}function zI(e){return!e.archived&&e.status!==`dead`&&e.status!==`stopped`}function BI(e,t){return e.restartedFromAgentId===t||e.restartedFromAgentIds?.includes(t)===!0}function VI(e,t,n){return e.filter(e=>zI(e)&&BI(e,t)&&(!n?.providerSessionProvider||!n.providerSessionId||e.providerSessionProvider===n.providerSessionProvider&&(n.providerSessionTemporary===!0||e.providerSessionId===n.providerSessionId)&&(e.providerHomeId||``)===(n.providerHomeId||``))).sort((e,t)=>{let n=(t.restartedFromAgentIds?.length??0)-(e.restartedFromAgentIds?.length??0);return n===0?(t.startedAt??0)-(e.startedAt??0):n})[0]??null}function HI(e){return e?.providerSessionProvider===`codex`&&!!e.providerSessionId&&e.providerSessionTemporary!==!0}function UI(e){if(!e||!e.isConnected||e.getAttribute(`aria-disabled`)===`true`||`disabled`in e&&e.disabled)return!1;let t=window.getComputedStyle(e);return t.display!==`none`&&t.visibility!==`hidden`&&e.getClientRects().length>0}function WI(e){return UI(e)?(e.focus({preventScroll:!0}),document.activeElement===e||e.contains(document.activeElement)):!1}function GI(){Rn(`app`);let e=Wt(),t=Jt(),{keyMap:n}=Yt(e.agents,e.mainAgentId),[i]=(0,G.useState)(()=>y()),[a,o]=(0,G.useState)(`none`),[s,c]=(0,G.useState)(void 0),[l,u]=(0,G.useState)(void 0),[d,f]=(0,G.useState)(void 0),[p,m]=(0,G.useState)(()=>i.openTerminalIds??[]),[h,_]=(0,G.useState)(()=>{let e=i.activeTerminalId??i.openTerminalIds?.[0];return e?[e]:[]}),[v,b]=(0,G.useState)(()=>i.activeTerminalId??null),[x,S]=(0,G.useState)(null),[C,w]=(0,G.useState)(null),[T,ee]=(0,G.useState)(()=>i.activeView??`projects`),[E,D]=(0,G.useState)(null),[O,k]=(0,G.useState)(null),[A,j]=(0,G.useState)(null),[M,N]=(0,G.useState)(null),[P,te]=(0,G.useState)({}),[F,ne]=(0,G.useState)(EI),I=(0,G.useRef)(null),L=(0,G.useRef)(null),R=(0,G.useRef)(new Set),z=(0,G.useRef)(null),B=(0,G.useRef)(null),V=(0,G.useRef)([]),ie=(0,G.useRef)(!1),H=(0,G.useRef)(!1),oe=(0,G.useRef)(!1),se=(0,G.useRef)(void 0),le=(0,G.useRef)(null),ue=(0,G.useRef)(0);(0,G.useLayoutEffect)(()=>{V.current=p},[p]),(0,G.useEffect)(()=>{g({activeTerminalId:v,activeView:T,openTerminalIds:p})},[v,T,p]);let de=(0,G.useCallback)(e=>{B.current=e,k(e)},[]),fe=a,pe=(0,G.useMemo)(()=>kP(F.language),[F.language]),me=(0,G.useMemo)(()=>{if(!O)return e.agents;let t=e.agents.filter(e=>e.id===O.agent.id||!BI(e,O.originalAgentId));return t.some(e=>e.id===O.agent.id)?t:[...t,O.agent]},[O,e.agents]),he=(0,G.useMemo)(()=>{let e=new Map,t=new Set([...p,...h]);return v&&t.add(v),t.forEach(t=>{if(me.some(e=>e.id===t&&zI(e)))return;let n=VI(me,t);n&&e.set(t,n.id)}),e},[v,me,p,h]),ge=(0,G.useMemo)(()=>{if(v){let e=he.get(v);if(e)return{originalAgentId:v,replacementAgentId:e}}let e=he.entries().next().value;return e?{originalAgentId:e[0],replacementAgentId:e[1]}:null},[v,he]),_e=(0,G.useMemo)(()=>Array.from(new Set(p.map(e=>he.get(e)??e))),[he,p]),ve=(0,G.useMemo)(()=>PF(h.map(e=>he.get(e)??e)),[he,h]),ye=v?he.get(v)??v:null;(0,G.useLayoutEffect)(()=>{ge&&(m(_e),_(ve),b(ye),j(ge))},[ye,_e,ve,ge]),(0,G.useLayoutEffect)(()=>{ye&&_(e=>IF(e,ye))},[ye]),(0,G.useEffect)(()=>{!A||ge||j(null)},[A,ge]),(0,G.useEffect)(()=>{let t=B.current;if(!t)return;let n=VI(e.agents,t.originalAgentId,t.agent);if(!n||n.id===t.agent.id)return;let r=t.agent.id,i={...t,agent:n,replacementAgentId:n.id,transitionFromAgentId:r};m(e=>Array.from(new Set(e.map(e=>BI(n,e)?n.id:e)))),_(e=>FF(e,e.map(e=>BI(n,e)?n.id:e))),b(e=>e&&BI(n,e)?n.id:e),de(i)},[de,O?.agent.id,O?.originalAgentId,e.agents]),(0,G.useEffect)(()=>{let t=O;!t?.requestSettled||!t.replacementAgentId||e.agents.some(e=>e.id===t.agent.id)&&B.current?.agent.id===t.agent.id&&(z.current=null,de(null))},[de,O?.agent.id,O?.replacementAgentId,O?.requestSettled,e.agents]),(0,G.useEffect)(()=>{let e=O;if(!e?.requestSettled||!e.requestError||e.replacementAgentId)return;let t=e.requestErrorAt??Date.now(),n=()=>{let n=pt();if(e.requestFreshStateAt||!n.connected||n.lastMessageAt<=t)return!1;let r=B.current;return r?.originalAgentId===e.originalAgentId&&!r.replacementAgentId&&!r.requestFreshStateAt&&de({...r,requestFreshStateAt:n.lastMessageAt}),!0};if(n())return;let r=mt(n),i=t+FI,a=e.requestFreshStateAt?e.requestFreshStateAt+PI:1/0,o=Math.max(0,Math.min(i,a)-Date.now()),s=window.setTimeout(()=>{let t=B.current;!t?.requestSettled||!t.requestError||t.replacementAgentId||t.originalAgentId!==e.originalAgentId||(z.current=null,de(null),D({id:Date.now(),kind:`error`,message:t.requestError}))},o);return()=>{r(),window.clearTimeout(s)}},[de,O]),(0,G.useEffect)(()=>{let e=O;if(!e)return;let t=Math.max(0,e.startedAt+LI-Date.now()),n=window.setTimeout(()=>{let t=B.current;!t||t.startedAt!==e.startedAt||(z.current=null,de(null),D({id:Date.now(),kind:`error`,message:pe.agentRestartTimedOut}))},t);return()=>window.clearTimeout(n)},[de,pe.agentRestartTimedOut,O]);let be=(0,G.useCallback)(e=>{let t={appearance:DI(e.appearance??F.appearance),language:OI(e.language??F.language)};ne(t),fetch(r(`/api/settings`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)}).then(e=>e.json()).then(e=>{let n=e.settings??{};ne({appearance:DI(n.appearance??t.appearance),language:OI(n.language??t.language)})}).catch(()=>{D({id:Date.now(),kind:`error`,message:`Failed to save preferences`})})},[F.appearance,F.language]),xe=(0,G.useCallback)(e=>{let t=Array.from(new Set(e.filter(Boolean)));t.length!==0&&fetch(r(`/api/codex/context-windows`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({agentIds:t})}).then(e=>e.json()).then(e=>{let t=Array.isArray(e.contextWindows)?e.contextWindows:[];te(e=>{let n={...e};return t.forEach(e=>{let t=String(e?.agentId||``);t&&(e&&e.available===!0?n[t]=e:delete n[t])}),n})}).catch(()=>{})},[]);(0,G.useEffect)(()=>{if(e.connected){if(e.mainAgentId||e.agents.some(e=>e.isMain)){ie.current=!1;return}ie.current||(ie.current=!0,e.startAgent(`bash`,void 0,!0))}},[e.agents,e.connected,e.mainAgentId,e.startAgent]),(0,G.useEffect)(()=>{let e=()=>{let e=window.visualViewport,t=e?.width??window.innerWidth,n=e?.height??window.innerHeight,r=e?.offsetTop??0,i=e?.offsetLeft??0,a=ce(),o=re(),s=window.innerHeight||n||MI,c=a?Math.min(Math.max(n,MI),Math.max(s,MI)):n,l=Math.max(0,s-n-r),u=o&&ae(),d=a&&o&&l>80,f=navigator.standalone===!0||window.matchMedia(`(display-mode: standalone)`).matches;document.body.classList.toggle(`code-compact-layout`,a),document.body.classList.toggle(`code-mobile-touch`,a&&o),document.body.classList.toggle(`code-mobile-ios`,u),document.body.classList.toggle(`code-mobile-standalone`,a&&f),document.body.classList.toggle(`code-mobile-keyboard-active`,d),document.documentElement.style.setProperty(`--app-visual-width`,`${t}px`),document.documentElement.style.setProperty(`--app-visual-height`,`${c}px`),document.documentElement.style.setProperty(`--app-visual-offset-top`,`${r}px`),document.documentElement.style.setProperty(`--app-visual-offset-left`,`${i}px`),document.documentElement.style.setProperty(`--mobile-keyboard-offset`,`${l}px`)};return e(),window.addEventListener(`resize`,e),window.visualViewport?.addEventListener(`resize`,e),window.visualViewport?.addEventListener(`scroll`,e),()=>{window.removeEventListener(`resize`,e),window.visualViewport?.removeEventListener(`resize`,e),window.visualViewport?.removeEventListener(`scroll`,e),document.documentElement.style.removeProperty(`--app-visual-width`),document.documentElement.style.removeProperty(`--app-visual-height`),document.documentElement.style.removeProperty(`--app-visual-offset-top`),document.documentElement.style.removeProperty(`--app-visual-offset-left`),document.documentElement.style.removeProperty(`--mobile-keyboard-offset`),document.body.classList.remove(`code-compact-layout`),document.body.classList.remove(`code-mobile-touch`),document.body.classList.remove(`code-mobile-ios`),document.body.classList.remove(`code-mobile-standalone`),document.body.classList.remove(`code-mobile-keyboard-active`)}},[]);let Se=(0,G.useCallback)((t,n)=>{v!==t&&e.focusAgent(t),m(e=>e.includes(t)?e:[...e,t]),_(e=>IF(e,t)),b(t),ee(`projects`),n?.focusTerminal!==!1&&S(e=>({agentId:t,nonce:(e?.nonce??0)+1})),o(`none`)},[v,e]),Ce=(0,G.useCallback)((e,t)=>{w({agentId:e,options:t})},[]),we=(0,G.useCallback)((e,t)=>{if(e===v&&p.includes(e)){Se(e,t);return}Ce(e,t)},[Se,v,p,Ce]);(0,G.useEffect)(()=>{C&&me.some(e=>e.id===C.agentId&&zI(e))&&(w(null),Se(C.agentId,C.options))},[Se,me,C]);let U=(0,G.useCallback)(e=>{let t=new Set(e);if(t.size===0)return;let n=V.current,r=n.indexOf(v??``),i=n.filter(e=>!t.has(e)),a=r===-1?i[i.length-1]??null:i[Math.min(r,i.length-1)]??null;V.current=i,m(i),_(e=>{let n=PF(e.filter(e=>!t.has(e)));return a?IF(n,a):n}),b(e=>!e||!t.has(e)?e:a),v&&t.has(v)&&a&&S(e=>({agentId:a,nonce:(e?.nonce??0)+1}))},[v]),Te=(0,G.useCallback)(e=>{U([e])},[U]),Ee=(0,G.useCallback)(e=>{if(p.length===0)return;let t=p[(Math.max(0,p.findIndex(e=>e===v))+e+p.length)%p.length];t&&we(t)},[v,we,p]),De=(0,G.useCallback)((e,t,n,r)=>{let i=ue.current+1;ue.current=i,le.current=n??(document.activeElement instanceof HTMLElement?document.activeElement:null),c(e),u(t),f(r),ee(`projects`),o(`input`);let a=()=>{ue.current===i&&o(e=>e===`input`?e:`input`)};window.requestAnimationFrame(a),window.setTimeout(a,80),window.setTimeout(a,180)},[]),Oe=(0,G.useCallback)(()=>{let e=ue.current,t=le.current,n=t?.getAttribute(`data-testid`)===`code-new-agent`;le.current=null;let r=()=>{ue.current===e&&(WI(t)||n&&WI(document.querySelector(`[data-testid="code-new-agent"]`))||WI((v?Array.from(document.querySelectorAll(`[data-testid="code-agent-row"]`)).find(e=>e.dataset.agentId===v):null)??null)||WI(document.querySelector(`[data-testid="code-new-agent"]`))||WI(document.querySelector(`[data-testid="code-project-list"]`)))};window.requestAnimationFrame(r),window.setTimeout(r,80),window.setTimeout(r,180)},[v]),ke=(0,G.useCallback)(()=>{ue.current+=1,o(`none`),Oe()},[Oe]),Ae=(0,G.useCallback)(e=>{D({id:Date.now(),kind:`error`,message:e})},[]),je=(0,G.useCallback)((t,n={})=>{AC(t).catch(e=>{console.error(`Failed to destroy killed terminal session:`,e)}),e.killAgent(t,n),Te(t)},[e,Te]),Me=(0,G.useCallback)(t=>{e.interruptAgent(t)},[e]),W=(0,G.useCallback)(t=>{L.current||(ie.current=!0,L.current={beforeIds:new Set(e.agents.map(e=>e.id))},e.restartMainAgent(t)||(L.current=null,ie.current=!1))},[e]),Ne=(0,G.useCallback)((t,n,r)=>{I.current||(ue.current+=1,I.current={beforeIds:new Set(e.agents.map(e=>e.id))},e.startAgent(t,n,!1,r)||(I.current=null))},[e]);(0,G.useEffect)(()=>{let t=e.lastStartedAgentId,n=I.current;!t||!n||n.beforeIds.has(t)||(I.current=null,o(`none`),Ce(t))},[Ce,e.lastStartedAgentId]);let Pe=(0,G.useCallback)(async(e,t,n)=>{if(!R.current.has(e)){R.current.add(e);try{let i=await fetch(r(`/api/agents/${e}/fork`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({mode:t,...n})}),a=await i.json().catch(()=>null);if(!i.ok||!a?.agentId){Ae(a?.error||`Failed to fork agent (${i.status})`);return}Ce(a.agentId)}catch(e){Ae(e instanceof Error?e.message:`Failed to fork agent`)}finally{R.current.delete(e)}}},[Ae,Ce]),Fe=(0,G.useCallback)(async(e,t)=>{try{let n=await fetch(r(`/api/projects/delete-worktree`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({workspace:e,force:t?.force===!0})}),i=await n.json().catch(()=>null);if(!n.ok&&i?.requiresForce!==!0&&Ae(i?.error||`Failed to delete worktree (${n.status})`),i?.deleted&&U(i.archivedAgentIds??[]),i)return i;let a=`Failed to delete worktree (${n.status})`;return Ae(a),{error:a}}catch(e){let t=e instanceof Error?e.message:`Failed to delete worktree`;return Ae(t),{error:t}}},[U,Ae]),Ie=(0,G.useCallback)(async(e,t)=>{try{let n=await fetch(r(`/api/agents/${e}`),{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify({customTitle:t})}),i=await n.json().catch(()=>null);n.ok||Ae(i?.error||`Failed to rename agent (${n.status})`)}catch(e){Ae(e instanceof Error?e.message:`Failed to rename agent`)}},[Ae]),Le=(0,G.useCallback)(async(t,n)=>{if(n.unread===!1&&Object.keys(n).every(e=>e===`unread`||e===`readAttentionSeq`||e===`readOutputEpoch`||e===`readOutputSeq`)&&z.current===t)return!0;let i=typeof n.launchPermissionMode==`string`?n.launchPermissionMode:``,a=typeof n.agentRuntimeMode==`string`,o=i||a?e.agents.find(e=>e.id===t)??null:null;if(o){if(z.current)return!1;z.current=t,de({originalAgentId:t,agent:o,kind:a?`runtime`:`permission`,startedAt:Date.now()})}let s=()=>{o&&B.current?.originalAgentId===t&&(z.current=null,de(null))};try{let e=new AbortController,a=window.setTimeout(()=>e.abort(),II),c=await fetch(r(`/api/agents/${t}`),{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify(n),signal:e.signal});window.clearTimeout(a);let l=await c.json().catch(()=>null);if(!c.ok){let e=B.current;return o&&e?.originalAgentId===t&&e.replacementAgentId?(de({...e,requestSettled:!0}),l??!0):(s(),Ae(l?.error||`Failed to update agent (${c.status})`),!1)}if(l?.warning&&Ae(l.warning),n.archived===!0&&Te(t),l?.restartedAgentId){let e=l.restartedAgentId,r=B.current;o&&r?.originalAgentId===t&&(r.agent.id===t?(m(n=>n.map(n=>n===t?e:n)),_(n=>FF(n,n.map(n=>n===t?e:n))),b(n=>n===t?e:n),de({...r,replacementAgentId:e,transitionFromAgentId:t,requestSettled:!0,agent:{...r.agent,id:e,launchPermissionMode:l.launchPermissionMode??i,runtimeBinding:Fn(l.agentRuntimeMode??n.agentRuntimeMode,r.agent.runtimeBinding),restartedFromAgentId:t,restartedFromAgentIds:Array.from(new Set([...r.agent.restartedFromAgentIds??[],t]))}})):de({...r,requestSettled:!0,requestError:void 0}))}else s();return l??!0}catch(e){let n=e instanceof DOMException&&e.name===`AbortError`?pe.agentRestartTimedOut:e instanceof Error?e.message:`Failed to update agent`,r=B.current;return o&&r?.originalAgentId===t?(de({...r,requestSettled:!0,requestError:n,requestErrorAt:Date.now()}),!!r.replacementAgentId):(Ae(n),!1)}},[Te,de,pe.agentRestartTimedOut,Ae,e.agents]),Re=(0,G.useCallback)(async e=>{await Le(e,{archived:!1})&&Ce(e)},[Le,Ce]),ze=(0,G.useMemo)(()=>me.find(e=>e.id===ye)??null,[me,ye]);return(0,G.useEffect)(()=>{if(!t||!HI(ze))return;let e=ze.id,n,r;return n=window.setTimeout(()=>xe([e]),2500),r=window.setInterval(()=>xe([e]),NI),()=>{n!==void 0&&window.clearTimeout(n),r!==void 0&&window.clearInterval(r)}},[ze?.id,ze?.providerSessionId,ze?.providerSessionProvider,ze?.providerSessionTemporary,t,xe]),(0,G.useEffect)(()=>{let e=RI(ze);e&&(se.current=e)},[ze]),nn((0,G.useMemo)(()=>[],[ze,Ee,n,De,we]),jI),(0,G.useEffect)(()=>{e.error&&(I.current=null,w(null),L.current=null,ie.current=!1,Ae(e.error))},[Ae,e.error,e.errorId]),(0,G.useEffect)(()=>{if(!E)return;let e=window.setTimeout(()=>D(null),2800);return()=>window.clearTimeout(e)},[E]),(0,G.useEffect)(()=>{if(!t)return;let e=!1,n,i,a=()=>{fetch(r(`/api/usage`)).then(e=>e.json()).then(t=>{e||N(t.usage??null)}).catch(()=>{e||N(null)})};return i=window.setTimeout(a,1500),n=window.setInterval(a,6e4),()=>{e=!0,i!==void 0&&window.clearTimeout(i),n!==void 0&&window.clearInterval(n)}},[t]),(0,G.useEffect)(()=>{jC(ve).catch(e=>{console.error(`Failed to prune terminal sessions:`,e)})},[ve]),(0,G.useEffect)(()=>{let e=new Set(me.filter(zI).map(e=>e.id));m(t=>Array.from(new Set(t.map(t=>e.has(t)?t:VI(me,t)?.id??t))).filter(t=>e.has(t)||B.current?.agent.id===t)),_(t=>FF(t,t.map(t=>e.has(t)?t:VI(me,t)?.id??t).filter(t=>e.has(t)||B.current?.agent.id===t)))},[me]),(0,G.useEffect)(()=>{let e=new Set(me.filter(zI).map(e=>e.id));b(t=>t&&(e.has(t)||B.current?.agent.id===t)?t:p[0]??null)},[me,p]),(0,G.useEffect)(()=>{me.some(e=>!e.isMain&&zI(e))||(H.current=!1)},[me]),(0,G.useEffect)(()=>{if(p.length>0||H.current)return;let e=me.find(e=>!e.isMain&&zI(e))?.id;e&&(H.current=!0,m([e]),_([e]),b(e))},[me,p.length,e.mainAgentId]),(0,G.useEffect)(()=>{let t=L.current;if(!t)return;let n=e.agents.find(e=>e.isMain&&!e.archived&&!t.beforeIds.has(e.id));n&&(L.current=null,ie.current=!1,we(n.id))},[we,e.agents]),(0,G.useEffect)(()=>{if(oe.current||e.agents.length===0)return;let t=new URLSearchParams(window.location.search).get(`agent`);if(!t){oe.current=!0;return}e.agents.some(e=>e.id===t&&!e.archived)&&(oe.current=!0,we(t))},[we,e.agents]),(0,G.useEffect)(()=>(document.body.classList.add(`code-mode`),()=>{document.body.classList.remove(`code-mode`)}),[]),(0,G.useEffect)(()=>{let e=()=>{AI(`terminal`,{crtEffects:!1,appearance:F.appearance})};if(e(),F.appearance!==`system`)return;let t=window.matchMedia(`(prefers-color-scheme: dark)`);return t.addEventListener(`change`,e),()=>t.removeEventListener(`change`,e)},[F.appearance]),(0,G.useEffect)(()=>{let e=!1;return fetch(r(`/api/settings`)).then(e=>e.json()).then(t=>{if(e)return;let n=t.settings??{};ne({appearance:DI(n.appearance),language:OI(n.language)})}).catch(()=>{}),()=>{e=!0}},[]),(0,K.jsxs)(`div`,{className:`app-container code-app-shell`,"data-testid":`app-shell`,children:[(0,K.jsx)(wI,{agents:me,taskHistory:e.taskHistory,mainPageSessionKeys:e.mainPageSessionKeys,activeView:T,dialogOpen:fe!==`none`,usageSummary:M,contextWindowByAgentId:P,activeTerminalId:ye,permissionSwitchingAgentId:O?.agent.id??null,agentSwitchingKind:O?.kind??null,permissionSwitchReplacement:O?.replacementAgentId?{originalAgentId:O.transitionFromAgentId??O.originalAgentId,replacementAgentId:O.replacementAgentId}:ge??A,retainedAgentViewIds:ve,terminalFocusRequest:x,remoteProjectWorkspaces:e.projectWorkspaces,remotePinnedProjectWorkspaces:e.pinnedProjectWorkspaces,keyMap:n,keyboardShortcutsEnabled:jI,uiPreferences:F,onOpenTerminal:we,onOpenTerminalWhenReady:Ce,onNewAgent:De,onStartAgent:Ne,onRenameAgent:Ie,onUpdateAgentFlags:Le,onOpenArchivedAgent:Re,onForkAgent:Pe,onDeleteForkWorktreeProject:Fe,onRestartMainAgent:W,onWorkspaceViewChange:ee,onKill:je,onInterruptAgent:Me,sendComposerInput:e.sendComposerInput,onSessionOutput:e.onSessionOutput,onUpdateUiPreferences:be}),(0,K.jsx)(An,{open:fe===`input`,mustStartMain:!1,initialWorkspace:s,initialCommand:l,initialCustomTitle:d,showWorkflowTaskFields:!1,copy:pe,onStart:Ne,onClose:ke}),(0,K.jsx)(jn,{copy:pe}),E&&(0,K.jsx)(`div`,{className:`app-toast ${E.kind}`,"data-testid":`app-toast`,role:`status`,children:E.message})]})}export{GI as App};
|