farming-code 2.2.11 → 2.2.12

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.
Files changed (34) hide show
  1. package/README.md +8 -7
  2. package/README.zh_cn.md +8 -7
  3. package/backend/agent-manager.js +104 -5
  4. package/backend/codex-session-archive.js +13 -4
  5. package/backend/config-manager.js +5 -0
  6. package/backend/executable-discovery.js +2 -0
  7. package/backend/server.js +62 -0
  8. package/backend/usage-monitor.js +97 -15
  9. package/backend/workspace-directory.js +80 -0
  10. package/dist/assets/App-DWsa7DXG.js +206 -0
  11. package/dist/assets/{FileEditorMarkdownPreview--Cri80nQ.js → FileEditorMarkdownPreview-UlVd0O4D.js} +1 -1
  12. package/dist/assets/FileEditorPane-Dxx4rKOg.js +2 -0
  13. package/dist/assets/IconGlyphs-AU22gPDY.js +1 -0
  14. package/dist/assets/{ProjectFilesSection-Cz1wG4NT.js → ProjectFilesSection-DE7Nb9Jk.js} +3 -3
  15. package/dist/assets/ReviewPage-CeDKDyZh.js +3 -0
  16. package/dist/assets/code-dark-DPiuyeSp.css +1 -0
  17. package/dist/assets/{index-miO2r9IZ.js → index-CUFPJoa5.js} +2 -2
  18. package/dist/assets/main-Bqtb5kuz.css +1 -0
  19. package/dist/assets/{monaco.contribution-CyLosfZI.js → monaco.contribution-BXz-lfFB.js} +2 -2
  20. package/dist/assets/{tsMode-DGZTlTj8.js → tsMode-B0oUTcXQ.js} +1 -1
  21. package/dist/assets/workspace-editor-monaco-BICJESG0.js +4 -0
  22. package/dist/assets/workspace-editor-monaco-DRJ7IaXk.js +1 -0
  23. package/dist/farming-2/site.webmanifest +2 -0
  24. package/dist/index.html +1 -1
  25. package/frontend/skins/crt/app.js +2 -0
  26. package/package.json +1 -1
  27. package/dist/assets/App-CHYpgECZ.js +0 -208
  28. package/dist/assets/FileEditorPane-DGJlEKdf.js +0 -2
  29. package/dist/assets/IconGlyphs-Cc14sepw.js +0 -1
  30. package/dist/assets/ReviewPage-LonRc6Fz.js +0 -3
  31. package/dist/assets/code-dark-B1pAtO_P.css +0 -1
  32. package/dist/assets/main-DNe0jPw-.css +0 -1
  33. package/dist/assets/workspace-editor-monaco-5gFbeDPF.js +0 -1
  34. package/dist/assets/workspace-editor-monaco-xPv8JzHH.js +0 -4
@@ -1,4 +1,4 @@
1
- import{n as e,r as t,t as n}from"./chunk-DECur_0Z.js";import{i as r,n as i,t as a}from"./jsx-runtime-BthL93pI.js";import{t as o}from"./react-dom-gtU6X-Hj.js";import{$ as s,B as c,D as l,E as u,F as d,G as f,H as p,J as m,K as h,M as g,N as _,O as v,P as y,Q as b,U as x,V as S,W as C,X as w,Y as T,Z as E,f as D,j as O,p as k,q as A,r as j,s as M,t as N,y as ee,z as P}from"./workspace-view-state-DvYG_9PH.js";import{_ as te,a as ne,c as re,d as ie,f as F,h as I,i as ae,k as L,n as R,r as oe,t as se,u as ce,y as le}from"./file-icons-Bw2qd5iT.js";import{_ as ue,g as de,l as z,o as fe,s as B}from"./IconGlyphs-Cc14sepw.js";import{u as pe}from"./workspace-working-copy-D8-s_Sgh.js";import{t as me}from"./useWorkspaceMenuKeyboard-Brws6Ar9.js";var V=t(r()),H=a();function he(e){return{"--change-indent":`${18+e*12}px`,"--change-guide-width":`${e*12}px`}}function ge(e){return e.sort((e,t)=>e.type===`directory`&&t.type!==`directory`?-1:e.type!==`directory`&&t.type===`directory`?1:e.name.localeCompare(t.name)||e.path.localeCompare(t.path)),e.forEach(e=>{e.type===`directory`&&ge(e.children)}),e}function _e(e){return e.reduce((e,t)=>t.type===`file`?e+1:(t.descendantCount=+!!t.change+_e(t.children),e+t.descendantCount),0)}function ve(e){return e.map(e=>{if(e.type===`file`)return e;let t={...e,children:ve(e.children)};for(;!t.change&&t.children.length===1&&t.children[0]?.type===`directory`&&!t.children[0].change;){let e=t.children[0];t={...e,displayName:`${t.displayName??t.name}/${e.displayName??e.name}`}}return t})}function ye(e,t){let n=[],r=new Map([[``,n]]),i=new Map,a=(e,n,a)=>{let o=i.get(e);if(o)return o;let s=[],c={id:`${t}:dir:${e}`,name:a,path:e,type:`directory`,children:s,descendantCount:0};return i.set(e,c),r.set(e,s),r.get(n)?.push(c),c};e.forEach(e=>{let n=e.path.replace(/\/+$/,``),o=n.split(`/`).filter(Boolean);if(o.length===0)return;let s=``,c=e.type===`directory`||e.path.endsWith(`/`),l=c?o.length:o.length-1;for(let e=0;e<l;e+=1){let t=o[e];if(!t)continue;let n=o.slice(0,e+1).join(`/`);a(n,s,t),s=n}if(c){let t=i.get(n);t&&(t.change=e);return}r.get(s)?.push({id:`${t}:file:${g(e)}`,name:o[o.length-1]||e.name,path:e.path,type:`file`,change:e})});let o=ve(ge(n));return _e(o),o}function be({activeFilePath:e,change:t,copy:n,onOpenChange:r}){let i=e===t.path,a=n.gitStatus(t.gitStatus),o=t.gitStatus===`untracked`?``:t.gitStatusLabel,s=t.previousPath?O(t):``;return(0,H.jsx)(`div`,{className:`code-file-change-row ${i?`active`:``}`,"data-testid":`code-file-change-row`,"data-file-path":t.path,"data-file-type":`file`,title:_(t,a),children:(0,H.jsxs)(`button`,{type:`button`,className:`code-file-change-main`,onClick:()=>r(t),children:[(0,H.jsx)(`span`,{className:`code-file-chevron placeholder`,"aria-hidden":`true`}),(0,H.jsx)(`img`,{className:`code-file-type-icon file`,src:R(t.path),alt:``,"aria-hidden":`true`}),(0,H.jsx)(`span`,{className:`code-file-change-name`,children:t.name}),(0,H.jsx)(`span`,{className:`code-file-change-path`,children:s}),(0,H.jsx)(`span`,{className:`code-file-change-status ${t.gitStatus}`,title:a,children:o})]})},g(t))}function xe({activeFilePath:e,copy:t,depth:n,nodes:r,openDirectoryIds:i,onOpenChange:a,onToggleDirectory:o}){return(0,H.jsx)(H.Fragment,{children:r.map(r=>{if(r.type===`file`)return(0,H.jsx)(`div`,{style:he(n),children:(0,H.jsx)(be,{activeFilePath:e,change:r.change,copy:t,onOpenChange:a})},r.id);let s=r.children.length>0,c=s&&i.has(r.id);return(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`div`,{className:`code-file-change-row directory`,"data-testid":`code-file-change-directory-row`,"data-file-path":r.path,"data-file-type":`directory`,title:r.path,style:he(n),children:(0,H.jsxs)(`button`,{type:`button`,className:`code-file-change-main directory`,"aria-expanded":s?c:void 0,onClick:()=>{s&&o(r.id)},children:[(0,H.jsx)(`span`,{className:`code-file-chevron ${s?c?`expanded`:`collapsed`:`placeholder`}`,"aria-hidden":`true`,children:s?c?(0,H.jsx)(B,{}):(0,H.jsx)(z,{}):null}),(0,H.jsx)(`span`,{className:`code-file-change-name`,children:r.displayName??r.name}),(0,H.jsx)(`span`,{className:`code-file-change-status directory`,children:r.descendantCount||``})]})}),c&&(0,H.jsx)(xe,{activeFilePath:e,copy:t,depth:n+1,nodes:r.children,openDirectoryIds:i,onOpenChange:a,onToggleDirectory:o})]},r.id)})})}function Se({activeFilePath:e,agentId:t,changes:n,collapsed:r,copy:a,projectId:o,refreshing:s,onOpenChange:c,onToggleCollapsed:l}){let[u,d]=(0,V.useState)(!0),[f,p]=(0,V.useState)(()=>new Set),m=(0,V.useMemo)(()=>n.items.filter(e=>e.gitStatus!==`untracked`),[n.items]),h=(0,V.useMemo)(()=>n.items.filter(e=>e.gitStatus===`untracked`),[n.items]),g=(0,V.useMemo)(()=>ye(m,`tracked`),[m]),_=(0,V.useMemo)(()=>ye(h,`untracked`),[h]),v=s||n.loading,y=v?`refreshing`:n.error?`stale`:`refreshed`;if(n.items.length===0&&!n.error)return null;let b=()=>{r&&n.refreshChanges(),l()},x=()=>{d(e=>(e&&n.refreshChanges(),!e))},S=e=>{p(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},C=e=>{let n=new URLSearchParams({agentId:t,scope:e});e===`untracked`&&n.set(`modifiedWithinDays`,`3`),window.open(i(`/review?${n.toString()}`),`_blank`,`noopener,noreferrer`)};return(0,H.jsxs)(`div`,{className:`code-file-changes-section`,"data-testid":`code-file-changes-section`,"data-project-id":o,"aria-label":a.changedFiles,"aria-busy":v,children:[m.length>0&&(0,H.jsxs)(`div`,{className:`code-file-change-group tracked ${r?`collapsed`:``}`,"data-testid":`code-file-change-tracked-group`,children:[(0,H.jsxs)(`div`,{className:`code-file-change-group-header`,children:[(0,H.jsxs)(`button`,{type:`button`,className:`code-file-change-group-toggle`,"aria-expanded":!r,onClick:b,children:[(0,H.jsx)(`span`,{className:`code-file-section-chevron ${r?`collapsed`:`expanded`}`,"aria-hidden":`true`,children:r?(0,H.jsx)(z,{}):(0,H.jsx)(B,{})}),(0,H.jsx)(`span`,{children:a.changes}),(0,H.jsx)(`span`,{className:`code-file-changes-count ${y}`,"data-testid":`code-file-changes-tracked-count`,"data-refresh-state":y,"aria-label":v?a.refreshingFiles:void 0,title:n.error??void 0,children:v?(0,H.jsx)(`span`,{className:`code-file-changes-count-loader`,"aria-hidden":`true`,children:`···`}):m.length})]}),(0,H.jsx)(`button`,{type:`button`,className:`code-file-change-review`,onClick:()=>C(`tracked`),children:a.reviewChanges})]}),!r&&(0,H.jsx)(xe,{activeFilePath:e,copy:a,depth:0,nodes:g,openDirectoryIds:f,onOpenChange:c,onToggleDirectory:S})]}),h.length>0&&(0,H.jsxs)(`div`,{className:`code-file-change-group untracked ${u?`collapsed`:``}`,"data-testid":`code-file-change-untracked-group`,children:[(0,H.jsxs)(`div`,{className:`code-file-change-group-header`,children:[(0,H.jsxs)(`button`,{type:`button`,className:`code-file-change-group-toggle`,"aria-expanded":!u,onClick:x,children:[(0,H.jsx)(`span`,{className:`code-file-section-chevron ${u?`collapsed`:`expanded`}`,"aria-hidden":`true`,children:u?(0,H.jsx)(z,{}):(0,H.jsx)(B,{})}),(0,H.jsx)(`span`,{children:a.untrackedChanges}),(0,H.jsx)(`span`,{className:`code-file-changes-count ${y}`,"data-testid":`code-file-changes-untracked-count`,"data-refresh-state":y,"aria-label":v?a.refreshingFiles:void 0,title:n.error??void 0,children:v?(0,H.jsx)(`span`,{className:`code-file-changes-count-loader`,"aria-hidden":`true`,children:`···`}):(0,H.jsxs)(H.Fragment,{children:[h.length,n.truncated?`+`:``]})})]}),(0,H.jsx)(`button`,{type:`button`,className:`code-file-change-review`,onClick:()=>C(`untracked`),children:a.reviewChanges})]}),!u&&(0,H.jsx)(xe,{activeFilePath:e,copy:a,depth:0,nodes:_,openDirectoryIds:f,onOpenChange:c,onToggleDirectory:S})]}),n.error&&(0,H.jsx)(`div`,{className:`code-file-changes-status error`,"data-testid":`code-file-changes-error`,children:n.error})]})}function Ce(e){let t=e.trim().replace(/^\.\/+/,``);if(!t)return null;let n=t.match(/^(.+?)#L(\d+)(?:C(\d+))?$/i);if(n)return{path:n[1]||``,lineNumber:Number(n[2]),column:n[3]?Number(n[3]):void 0};let r=t.match(/^(.+?):(\d+)(?::(\d+))?$/);return r?{path:r[1]||``,lineNumber:Number(r[2]),column:r[3]?Number(r[3]):void 0}:null}function we(e){let t=e.ranges[0];return t?{lineNumber:e.lineNumber,column:t.start+1,endColumn:Math.max(t.start+1,t.end+1)}:{lineNumber:e.lineNumber}}function Te(e){return e.kind===`path`?{path:e.path}:{path:e.path,target:we(e)}}function Ee(e){let t=Ce(e);return t?{path:t.path,target:{lineNumber:t.lineNumber,column:t.column}}:null}function De({active:e,activeMatchIndex:t,jumpTarget:n,listboxId:r}){if(e)return n?`${r}-jump`:t>=0?`${r}-${t}`:void 0}function Oe(e,t){let n=t.trim().replace(/^\.\/+/,``).toLowerCase();if(!e||!n)return null;let r=e.toLowerCase().indexOf(n);return r===-1?null:{start:r,end:r+n.length}}function ke(e,t){if(t===0)return!0;let n=e[t-1]??``,r=e[t]??``;return/[-_\s./\\]/.test(n)?!0:/[a-z0-9]/.test(n)&&/[A-Z]/.test(r)}function Ae(e,t,n){let r=[],i=0;for(let a=0;a<e.length&&i<t.length;a+=1)n&&!ke(e,a)||e[a]?.toLowerCase()===t[i]&&(r.push({start:a,end:a+1}),i+=1);return i===t.length?r:[]}function je(e,t){let n=t.trim().replace(/^\.\/+/,``).toLowerCase();if(!e||!n||n.length>6)return[];let r=Ae(e,n,!0);return r.length>0?r:Ae(e,n,!1)}function Me(e,t){let n=[];return t.map(t=>({start:Math.max(0,Math.min(e.length,t.start)),end:Math.max(0,Math.min(e.length,t.end))})).filter(e=>e.end>e.start).sort((e,t)=>e.start-t.start||e.end-t.end).forEach(e=>{let t=n[n.length-1];if(t&&e.start<=t.end){t.end=Math.max(t.end,e.end);return}n.push(e)}),n}function Ne(e,t){let n=Oe(e,t);return n?[n]:je(e,t)}function Pe(e,t=[]){let n=Me(e,t);if(n.length===0)return e;let r=[],i=0;return n.forEach((t,n)=>{t.start>i&&r.push(e.slice(i,t.start)),r.push((0,H.jsx)(`span`,{className:`code-file-search-highlight`,children:e.slice(t.start,t.end)},`${t.start}:${t.end}:${n}`)),i=t.end}),i<e.length&&r.push(e.slice(i)),r}function Fe(e,t){return Pe(e,Ne(e,t))}function Ie(e){let t=e.replace(/\\/g,`/`),n=t.lastIndexOf(`/`);return n===-1?{directory:``,name:t}:{directory:t.slice(0,n),name:t.slice(n+1)||t}}function Le(e){if(!e||typeof window>`u`)return null;let t=e.getBoundingClientRect();if(L()){let n=window.visualViewport,r=n?.offsetTop??0,i=n?.offsetLeft??0,a=n?.width??window.innerWidth,o=n?.height??window.innerHeight,s=e.closest(`.code-sidebar`)?.getBoundingClientRect(),c=Math.max(i+6,(s?.left??i)+6),l=Math.min(i+a-6,(s?.right??i+a)-6),u=r+o-t.bottom-10,d=t.top-r-10,f=u<120&&d>u,p=Math.max(72,Math.min(320,f?d:u));return{left:c,top:f?Math.max(r+6,t.top-p-4):Math.max(r+6,t.bottom+4),width:Math.max(180,l-c),maxHeight:p}}let n=Math.max(document.documentElement.clientWidth,window.innerWidth||0),r=Math.max(document.documentElement.clientHeight,window.innerHeight||0),i=Math.max(240,n-24),a=Math.min(620,i,Math.max(420,t.width)),o=Math.max(12,Math.min(t.left,n-a-12)),s=Math.min(t.bottom+6,r-12);return{left:o,top:s,width:a,maxHeight:Math.max(168,Math.min(420,r-s-12))}}function Re({path:e,query:t}){let{directory:n,name:r}=Ie(e);return(0,H.jsxs)(`span`,{className:`code-file-search-copy`,children:[(0,H.jsx)(`span`,{className:`code-file-search-name`,children:Fe(r,t)}),n&&(0,H.jsx)(`span`,{className:`code-file-search-directory`,children:Fe(n,t)})]})}function ze({activeMatchIndex:e,anchorRef:t,copy:n,containerRef:r,error:i,jumpTarget:a,listboxId:o,loading:s,matches:c,openFileError:l,query:u,showIgnoredSearch:d,timeoutMs:f,truncated:p,onOpenJumpQuery:m,onOpenMatch:h,onSearchIgnored:g,onSelectMatchIndex:_}){let[v,y]=(0,V.useState)(()=>Le(t.current)),b=(0,V.useCallback)(()=>{y(Le(t.current))},[t]);return(0,V.useLayoutEffect)(()=>{b();let e=t.current?.closest(`.code-project-list`);return window.addEventListener(`resize`,b),window.addEventListener(`scroll`,b,!0),window.visualViewport?.addEventListener(`resize`,b),window.visualViewport?.addEventListener(`scroll`,b),e?.addEventListener(`scroll`,b,{passive:!0}),()=>{window.removeEventListener(`resize`,b),window.removeEventListener(`scroll`,b,!0),window.visualViewport?.removeEventListener(`resize`,b),window.visualViewport?.removeEventListener(`scroll`,b),e?.removeEventListener(`scroll`,b)}},[t,b]),(0,H.jsx)(`div`,{ref:r,id:o,className:`code-file-search-results`,"data-testid":`code-file-search-results`,role:`listbox`,"aria-label":n.searchFilesOrJump,style:v?{left:v.left,top:v.top,width:v.width,maxHeight:v.maxHeight}:void 0,children:a?l?(0,H.jsx)(`div`,{className:`code-file-search-state error`,children:l}):(0,H.jsxs)(`button`,{id:`${o}-jump`,type:`button`,className:`code-file-search-result jump active`,onClick:()=>m(u),role:`option`,"aria-selected":`true`,children:[(0,H.jsx)(`span`,{className:`code-file-search-kind`,children:n.go}),(0,H.jsx)(Re,{path:a.path,query:u}),(0,H.jsx)(`span`,{className:`code-file-search-line`,children:a.lineNumber})]}):s?(0,H.jsx)(`div`,{className:`code-file-search-state`,children:n.searching}):i?(0,H.jsx)(`div`,{className:`code-file-search-state error`,children:i}):c.length===0?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`div`,{className:`code-file-search-state`,children:n.noMatches}),d&&(0,H.jsx)(`button`,{type:`button`,className:`code-file-search-ignored-action`,onClick:g,children:n.searchIgnoredFolders}),p&&(0,H.jsx)(`div`,{className:`code-file-search-state muted`,children:n.searchIncomplete(f)})]}):(0,H.jsxs)(H.Fragment,{children:[c.map((t,r)=>(0,H.jsxs)(`button`,{id:`${o}-${r}`,type:`button`,className:`code-file-search-result ${r===e?`active`:``}`,onPointerMove:e=>{e.pointerType===`mouse`&&_(r)},onClick:()=>h(t),title:t.entryType===`directory`?t.path:`${t.path}:${t.lineNumber}`,role:`option`,"aria-selected":r===e,children:[(0,H.jsx)(`img`,{className:`code-file-type-icon ${t.entryType===`directory`?`folder`:`file`}`,src:t.entryType===`directory`?se(t.path,!1):R(t.path),alt:``,"aria-hidden":`true`}),(0,H.jsx)(Re,{path:t.path,query:u}),t.kind===`path`?(0,H.jsx)(`span`,{className:`code-file-search-kind`,children:t.entryType===`directory`?n.folder:n.file}):(0,H.jsx)(`span`,{className:`code-file-search-line`,children:t.lineNumber}),t.lines&&(0,H.jsx)(`span`,{className:`code-file-search-preview`,children:Pe(t.lines,t.ranges)})]},`${t.path}:${t.lineNumber}:${r}`)),d&&(0,H.jsx)(`button`,{type:`button`,className:`code-file-search-ignored-action`,onClick:g,children:n.searchIgnoredFolders}),p&&(0,H.jsx)(`div`,{className:`code-file-search-state muted`,children:n.moreMatchesOmitted})]})})}var Be=12;function Ve(e,t){return e===`git`?t.containsUncommittedChanges:e===`external`?t.changedOnDisk:e===`dirty`?t.unsavedChanges:t.changedOnDisk}function He(e){return{"--file-indent":`${4+e*Be}px`,"--file-status-indent":`${22+e*Be}px`,"--file-guide-width":`${e*Be}px`,"--file-depth":e}}function Ue(e){return e===`untracked`?void 0:e}function We(e){let t=Ue(e);return t?`code-file-descendant-status ${t}`:``}function Ge(e,t){for(let n of e)if(T(t,n))return!0;return!1}function Ke({activeFilePath:e,editorDirtyFilePaths:t,editorExternalChangedFilePaths:n,openFilePendingPath:r,item:i,isFocused:a,isOpen:o,isSelected:s}){let c=i.type===`directory`,l=e===i.path,u=c&&i.loading===!0,d=!c&&r===i.path,f=!c&&t.has(i.path),p=!c&&n.has(i.path),m=c&&Ge(t,i.path),h=c&&Ge(n,i.path),g=Ue(i.gitStatus),_=Ue(i.descendantGitStatus),v=g?i.gitStatusLabel:void 0,y=!!g,b=c&&!!_,x=c&&(b||m||h),S=_??(h?`external`:m?`dirty`:void 0),C=_?We(_):S?`code-file-descendant-status ${S}`:``,w=b?`git`:h?`external`:m?`dirty`:null,T=p?`external`:f?`dirty`:void 0,E=T?`code-file-changed ${T}`:``,D=p?`external`:f?`dirty`:null,O=g?`code-file-git-status ${g}`:``;return{active:l,chevronState:c?o?`expanded`:`collapsed`:`placeholder`,directoryLoading:u,directoryDotClassName:C,directoryDotKind:S,directoryDotTitleKind:w,editorDirty:f,editorExternalChanged:p,fileChangedClassName:E,fileChangedKind:T,fileChangedTitleKind:D,fileOpening:d,hasDescendantGitStatus:b,hasEditorDirtyDescendant:m,hasEditorExternalChangedDescendant:h,isDirectory:c,rowClasses:[`code-file-row`,c?`directory`:`file`,l?`active`:``,f?`editor-dirty`:``,p?`editor-external-changed`:``,m?`editor-descendant-dirty`:``,h?`editor-descendant-external-changed`:``,a?`focused`:``,s?`selected`:``,u?`loading`:``,d?`opening`:``,i.ignored?`ignored`:``,i.symbolicLink?`symbolic-link`:``,i.external?`external-link`:``,i.linkError?`link-error`:``,y?`git-status`:``,g?`git-${g}`:``,b?`git-descendant`:``,_?`git-descendant-${_}`:``].filter(Boolean).join(` `),showDirectoryDot:x,visibleGitStatus:g,visibleGitStatusClassName:O,visibleGitStatusLabel:v}}function qe({label:e,options:t,testId:n,submenuTestId:r,onOpenDialog:i,onSelect:a}){let[o,c]=(0,V.useState)(!1),[l,u]=(0,V.useState)(`right`),d=(0,V.useRef)(null),f=(0,V.useRef)(null),p=(0,V.useRef)(null),m=(0,V.useRef)(null),h=t.length>0,g=(0,V.useCallback)(()=>{m.current!==null&&(window.clearTimeout(m.current),m.current=null)},[]),_=(0,V.useCallback)((e=f.current)=>{if(!h)return;g();let t=e?.getBoundingClientRect();t&&t.right+156+12>window.innerWidth?u(`left`):u(`right`),c(!0)},[g,h]),v=(0,V.useCallback)(()=>{g(),m.current=window.setTimeout(()=>{c(!1),m.current=null},120)},[g]),y=(0,V.useCallback)(e=>{_(e.currentTarget.querySelector(`button`))},[_]),x=(0,V.useCallback)(()=>{window.setTimeout(()=>{p.current?.querySelector(`button:not(:disabled)`)?.focus()},0)},[]),S=(0,V.useCallback)(e=>{h&&e.key===`ArrowRight`&&(e.preventDefault(),e.stopPropagation(),_(e.currentTarget),x())},[x,h,_]),C=(0,V.useCallback)(e=>{e.key===`ArrowLeft`&&(e.preventDefault(),e.stopPropagation(),c(!1),f.current?.focus())},[]);return(0,H.jsxs)(`div`,{ref:d,className:`code-agent-launch-submenu`,onPointerEnter:y,onPointerLeave:v,onFocus:()=>g(),onBlur:e=>{e.currentTarget.contains(e.relatedTarget)||c(!1)},children:[(0,H.jsxs)(`button`,{ref:f,type:`button`,role:`menuitem`,className:`code-agent-launch-submenu-trigger`,"data-testid":n,"aria-haspopup":h?`menu`:void 0,"aria-expanded":h?o:void 0,onClick:i,onKeyDown:S,children:[(0,H.jsx)(`span`,{children:e}),h&&(0,H.jsx)(z,{className:`code-agent-launch-submenu-arrow`})]}),h&&o&&(0,H.jsx)(`div`,{ref:p,className:`code-agent-launch-submenu-panel ${l}`,"data-testid":r,role:`menu`,onPointerEnter:()=>g(),onPointerLeave:v,onKeyDown:C,children:t.map(e=>(0,H.jsxs)(`button`,{type:`button`,role:`menuitem`,"data-testid":`agent-launch-${e.name}`,onClick:()=>a(e.command||e.name),children:[(0,H.jsx)(b,{name:e.name}),(0,H.jsx)(`span`,{children:s(e.name)})]},e.name))})]})}function Je({copy:e,agentLaunchOptions:t,fileMenu:n,menuRef:r,onClose:i,onCloseWithFocusRestore:a,onCopyRelativePath:o,onCopyShareUrl:s,onOpenNewAgent:c,onRefreshTarget:l,onStartAgent:u,onStartOperation:d,readOnly:f=!1}){let p=me({menuOpen:!!n,menuRef:r,onClose:i,onCloseWithFocusRestore:a});if(!n)return null;let m=n.item?.readOnly===!0,h=!f&&!m,g=!f&&(!m||n.item?.symbolicLink===!0);return(0,H.jsxs)(`div`,{ref:r,className:`code-context-menu code-file-context-menu`,"data-testid":`code-file-context-menu`,style:{left:n.x,top:n.y},role:`menu`,onKeyDown:p,onMouseDown:e=>e.stopPropagation(),children:[h&&(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`button`,{type:`button`,role:`menuitem`,autoFocus:!0,onClick:()=>d(`new-file`),children:e.newFile}),(0,H.jsx)(`button`,{type:`button`,role:`menuitem`,onClick:()=>d(`new-folder`),children:e.newFolder}),(0,H.jsx)(`div`,{className:`code-context-menu-separator`,role:`separator`}),(0,H.jsx)(qe,{label:e.newAgent,options:t,testId:`file-new-agent-submenu-trigger`,submenuTestId:`file-new-agent-submenu`,onOpenDialog:c,onSelect:u}),(0,H.jsx)(`div`,{className:`code-context-menu-separator`,role:`separator`})]}),(0,H.jsx)(`button`,{type:`button`,role:`menuitem`,onClick:l,children:e.refresh}),n.item&&(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`div`,{className:`code-context-menu-separator`,role:`separator`}),g&&(0,H.jsx)(`button`,{type:`button`,role:`menuitem`,onClick:()=>d(`rename`),children:e.rename}),(0,H.jsx)(`button`,{type:`button`,role:`menuitem`,onClick:o,children:e.copyRelativePath}),(n.item.type===`file`||n.item.type===`directory`)&&(0,H.jsx)(`button`,{type:`button`,role:`menuitem`,onClick:s,children:e.copyShareUrl}),g&&(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`div`,{className:`code-context-menu-separator`,role:`separator`}),(0,H.jsx)(`button`,{type:`button`,role:`menuitem`,className:`danger`,onClick:()=>d(`delete`),children:e.delete})]})]})]})}var Ye=220,Xe=8,Ze=26,Qe=11,$e=10;function et(e){return e?e.type===`directory`?e.path:w(e.path):``}function tt(e,t){return e===`rename`||e===`delete`?t?.name??``:``}function nt(e,t){return{kind:e,item:t,parentPath:et(t),name:tt(e,t)}}function rt(e){if(e.kind!==`rename`||e.item?.type!==`file`)return e.name.length;let t=e.name.lastIndexOf(`.`);return t>0?t:e.name.length}function it(e){let t=e.name.trim();if(e.kind!==`rename`||e.item?.type!==`file`)return t;let n=e.item.name.lastIndexOf(`.`);if(n<=0)return t;let r=e.item.name.slice(n);return t.endsWith(`${r}${r}`)?t.slice(0,-r.length):t}function at(e,t){switch(e.kind){case`new-file`:return t.newFile;case`new-folder`:return t.newFolder;case`rename`:return t.rename;case`delete`:return t.delete}}function U(e,t,n,r,i,a=0){let o=n?8:4,s=n?4:2,c=a>0?$e+a*Ze:0,l=$e+o*Ze+s*Qe+c;return{x:Math.max(Xe,Math.min(e,r-Ye-Xe)),y:Math.max(Xe,Math.min(t,i-l-Xe))}}function ot({agentId:e,copy:t,fileOperation:n,inputRef:r,onCancel:i,onInputName:a,onSubmit:o,onUpdateName:s}){return!n||n.kind===`rename`?null:(0,H.jsx)(`div`,{className:n.kind===`delete`?`code-file-operation-shell delete-confirm`:`code-file-operation-shell`,"data-testid":`code-file-operation-backdrop`,onMouseDown:e=>{e.stopPropagation(),n.kind===`delete`&&e.target===e.currentTarget&&i()},children:(0,H.jsxs)(`form`,{className:`code-file-operation-dialog`,"data-testid":`code-file-operation-dialog`,role:`dialog`,"aria-labelledby":`code-file-operation-title`,autoComplete:`off`,onMouseDown:e=>e.stopPropagation(),onKeyDown:e=>{e.key===`Escape`&&(e.preventDefault(),i())},onSubmit:e=>{e.preventDefault(),o()},children:[(0,H.jsx)(`label`,{id:`code-file-operation-title`,htmlFor:`code-file-operation-input`,children:at(n,t)}),n.kind===`delete`?(0,H.jsx)(`p`,{className:`code-file-operation-text`,children:n.item?.type===`directory`?t.deleteFolderContents(n.item?.path):t.deleteFile(n.item?.path)}):(0,H.jsx)(`input`,{id:`code-file-operation-input`,"data-testid":`code-file-operation-input`,name:`farming-file-${e}-${n.kind}`,type:`text`,inputMode:`text`,ref:r,value:n.name,autoComplete:`off`,"aria-autocomplete":`none`,autoCapitalize:`none`,autoCorrect:`off`,spellCheck:!1,enterKeyHint:`done`,"data-lpignore":`true`,"data-1p-ignore":`true`,"data-bwignore":`true`,"data-form-type":`other`,autoFocus:!0,onInput:e=>{a(e.currentTarget.value)},onChange:e=>{s(e.target.value)},onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),e.stopPropagation(),o())}}),(0,H.jsxs)(`div`,{className:`code-rename-actions`,children:[(0,H.jsx)(`button`,{type:`button`,onClick:i,children:t.cancel}),(0,H.jsx)(`button`,{type:`submit`,className:n.kind===`delete`?`danger`:`primary`,disabled:n.kind!==`delete`&&!n.name.trim(),children:n.kind===`delete`?t.delete:t.save})]})]})})}function st({agentId:e,copy:t,agentLaunchOptions:n,fileMenu:r,fileMenuRef:i,fileOperation:a,fileOperationInputRef:o,onCloseFileMenu:s,onCloseFileMenuWithFocusRestore:c,onCloseFileOperation:l,onCopyFileMenuPath:u,onCopyFileMenuShareUrl:d,onOpenNewAgent:f,onRefreshFileMenuTarget:p,onRememberFileOperationName:m,onStartAgent:h,onStartFileMenuOperation:g,onSubmitFileOperation:_,onUpdateFileOperationName:v,readOnly:y=!1}){return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(Je,{copy:t,agentLaunchOptions:n,fileMenu:r,menuRef:i,onClose:s,onCloseWithFocusRestore:c,onCopyRelativePath:u,onCopyShareUrl:d,onOpenNewAgent:f,onRefreshTarget:p,onStartAgent:h,onStartOperation:g,readOnly:y}),(0,H.jsx)(ot,{agentId:e,copy:t,fileOperation:a,inputRef:o,onCancel:l,onInputName:m,onSubmit:()=>{_()},onUpdateName:v})]})}var ct=n((e=>{var t=r();function n(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}var i=typeof Object.is==`function`?Object.is:n,a=t.useState,o=t.useEffect,s=t.useLayoutEffect,c=t.useDebugValue;function l(e,t){var n=t(),r=a({inst:{value:n,getSnapshot:t}}),i=r[0].inst,l=r[1];return s(function(){i.value=n,i.getSnapshot=t,u(i)&&l({inst:i})},[e,n,t]),o(function(){return u(i)&&l({inst:i}),e(function(){u(i)&&l({inst:i})})},[e]),c(n),n}function u(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!i(e,n)}catch{return!0}}function d(e,t){return t()}var f=typeof window>`u`||window.document===void 0||window.document.createElement===void 0?d:l;e.useSyncExternalStore=t.useSyncExternalStore===void 0?f:t.useSyncExternalStore})),lt=n(((e,t)=>{t.exports=ct()})),ut=(0,V.createContext)(null);function W(){let e=(0,V.useContext)(ut);if(e===null)throw Error(`No Tree Api Provided`);return e}var dt=(0,V.createContext)(null);function ft(){let e=(0,V.useContext)(dt);if(e===null)throw Error(`Provide a NodesContext`);return e}var pt=(0,V.createContext)(null);function mt(){let e=(0,V.useContext)(pt);if(e===null)throw Error(`Provide a DnDContext`);return e}var ht=(0,V.createContext)(0);function gt(){(0,V.useContext)(ht)}var _t=e({access:()=>Mt,bound:()=>vt,dfs:()=>Tt,focusNextElement:()=>Dt,focusPrevElement:()=>Ot,getInsertIndex:()=>Rt,getInsertParentId:()=>Vt,getTreeLinePrefix:()=>Bt,identify:()=>Pt,identifyNull:()=>Nt,indexOf:()=>Ct,isClosed:()=>bt,isDescendant:()=>St,isItem:()=>yt,isOpenWithEmptyChildren:()=>xt,mergeRefs:()=>Ft,noop:()=>wt,safeRun:()=>It,waitFor:()=>Lt,walk:()=>Et});function vt(e,t,n){return Math.max(Math.min(e,n),t)}function yt(e){return e&&e.isLeaf}function bt(e){return e&&e.isInternal&&!e.isOpen}function xt(e){return e&&e.isOpen&&!e.children?.length}var St=(e,t)=>{let n=e;for(;n;){if(n.id===t.id)return!0;n=n.parent}return!1},Ct=e=>{if(!e.parent)throw Error(`Node does not have a parent`);return e.parent.children.findIndex(t=>t.id===e.id)};function wt(){}function Tt(e,t){if(!e)return null;if(e.id===t)return e;if(e.children)for(let n of e.children){let e=Tt(n,t);if(e)return e}return null}function Et(e,t){if(t(e),e.children)for(let n of e.children)Et(n,t)}function Dt(e){let t=jt(e),n;for(let r=0;r<t.length;++r)if(t[r]===e){n=kt(t,r);break}n?.focus()}function Ot(e){let t=jt(e),n;for(let r=0;r<t.length;++r)if(t[r]===e){n=At(t,r);break}n?.focus()}function kt(e,t){return t+1<e.length?e[t+1]:e[0]}function At(e,t){return t-1>=0?e[t-1]:e[e.length-1]}function jt(e){return Array.from(document.querySelectorAll(`button:not([disabled]), [href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"]):not([disabled]), details:not([disabled]), summary:not(:disabled)`)).filter(t=>t===e||!e.contains(t))}function Mt(e,t){return typeof t==`boolean`?t:typeof t==`string`?e[t]:t(e)}function Nt(e){return e===null?null:Pt(e)}function Pt(e){return typeof e==`string`?e:e.id}function Ft(...e){return t=>{e.forEach(e=>{typeof e==`function`?e(t):e!=null&&(e.current=t)})}}function It(e,...t){if(e)return e(...t)}function Lt(e){return new Promise((t,n)=>{let r=0;function i(){r+=1,r===100&&n(),e()?t():setTimeout(i,10)}i()})}function Rt(e){let t=e.focusedNode;return t?t.isOpen?0:t.parent?t.childIndex+1:0:e.root.children?.length??0}var zt={last:`└ `,middle:`├ `,pipe:`│ `,blank:`  `};function Bt(e,t={}){let n=Object.assign(Object.assign({},zt),t);if(e.level===0)return``;let r=e.nextSibling===null?n.last:n.middle,i=e.parent;for(;i&&i.level>0;)r=(i.nextSibling===null?n.blank:n.pipe)+r,i=i.parent;return r}function Vt(e){let t=e.focusedNode;return t?t.isOpen?t.id:t.parent&&!t.parent.isRoot?t.parent.id:null:null}var Ht={display:`flex`,alignItems:`center`,zIndex:1},Ut={flex:1,height:`2px`,background:`#4B91E2`,borderRadius:`1px`},Wt={width:`4px`,height:`4px`,boxShadow:`0 0 0 3px #4B91E2`,borderRadius:`50%`},Gt=V.memo(function({top:e,left:t,indent:n}){let r={position:`absolute`,pointerEvents:`none`,top:e-2+`px`,left:t+`px`,right:n+`px`};return(0,H.jsxs)(`div`,{style:Object.assign(Object.assign({},Ht),r),children:[(0,H.jsx)(`div`,{style:Object.assign({},Wt)}),(0,H.jsx)(`div`,{style:Object.assign({},Ut)})]})});function Kt({node:e,attrs:t,innerRef:n,children:r}){return(0,H.jsx)(`div`,Object.assign({},t,{ref:n,onFocus:e=>e.stopPropagation(),onClick:e.handleClick,children:r}))}function qt(e){return(0,H.jsxs)(`div`,{ref:e.dragHandle,style:e.style,children:[(0,H.jsx)(`span`,{onClick:t=>{t.stopPropagation(),e.node.toggle()},children:e.node.isLeaf?`🌳`:e.node.isOpen?`🗁`:`🗀`}),` `,e.node.isEditing?(0,H.jsx)(Yt,Object.assign({},e)):(0,H.jsx)(Jt,Object.assign({},e))]})}function Jt(e){return(0,H.jsx)(H.Fragment,{children:(0,H.jsx)(`span`,{children:e.node.data.name})})}function Yt({node:e}){let t=(0,V.useRef)();return(0,V.useEffect)(()=>{var e,n;(e=t.current)==null||e.focus(),(n=t.current)==null||n.select()},[]),(0,H.jsx)(`input`,{ref:t,defaultValue:e.data.name,onBlur:()=>e.reset(),onKeyDown:n=>{n.key===`Escape`&&e.reset(),n.key===`Enter`&&e.submit(t.current?.value||``)}})}var Xt=`__REACT_ARBORIST_INTERNAL_ROOT__`;function Zt(e){function t(n,r,i){let a=new Qt({tree:e,data:n,level:r,parent:i,id:e.accessId(n),children:null,isDraggable:e.isDraggable(n),rowIndex:null}),o=e.accessChildren(n);return o&&(a.children=o.map(e=>t(e,r+1,a))),a}let n=new Qt({tree:e,id:Xt,data:{id:Xt},level:-1,parent:null,children:null,isDraggable:!0,rowIndex:null});return n.children=(e.props.data??[]).map(e=>t(e,0,n)),n}var Qt=class e{constructor(e){this.handleClick=e=>{(e.metaKey||e.ctrlKey)&&!this.tree.props.disableMultiSelection?this.isSelected?this.deselect():this.selectMulti():e.shiftKey&&!this.tree.props.disableMultiSelection?this.selectContiguous():(this.select(),this.activate())},this.tree=e.tree,this.id=e.id,this.data=e.data,this.level=e.level,this.children=e.children,this.parent=e.parent,this.isDraggable=e.isDraggable,this.rowIndex=e.rowIndex}get isRoot(){return this.id===Xt}get isLeaf(){return!Array.isArray(this.children)}get isInternal(){return!this.isLeaf}get isOpen(){return this.isLeaf?!1:this.tree.isOpen(this.id)}get isClosed(){return this.isLeaf?!1:!this.tree.isOpen(this.id)}get isEditable(){return this.tree.isEditable(this.data)}get isSelectable(){return this.tree.isSelectable(this.data)}get isEditing(){return this.tree.editingId===this.id}get isSelected(){return this.tree.isSelected(this.id)}get isOnlySelection(){return this.isSelected&&this.tree.hasOneSelection}get isSelectedStart(){return this.isSelected&&!this.prev?.isSelected}get isSelectedEnd(){return this.isSelected&&!this.next?.isSelected}get isFocused(){return this.tree.isFocused(this.id)}get isDragging(){return this.tree.isDragging(this.id)}get willReceiveDrop(){return this.tree.willReceiveDrop(this.id)}get state(){return{isClosed:this.isClosed,isDragging:this.isDragging,isEditing:this.isEditing,isFocused:this.isFocused,isInternal:this.isInternal,isLeaf:this.isLeaf,isOpen:this.isOpen,isSelected:this.isSelected,isSelectedEnd:this.isSelectedEnd,isSelectedStart:this.isSelectedStart,willReceiveDrop:this.willReceiveDrop}}get childIndex(){return this.parent&&this.parent.children?this.parent.children.findIndex(e=>e.id===this.id):-1}get next(){return this.rowIndex===null?null:this.tree.at(this.rowIndex+1)}get prev(){return this.rowIndex===null?null:this.tree.at(this.rowIndex-1)}get nextSibling(){let e=this.childIndex;return this.parent?.children[e+1]??null}isAncestorOf(e){if(!e)return!1;let t=e;for(;t;){if(t.id===this.id)return!0;t=t.parent}return!1}select(){this.tree.select(this)}deselect(){this.tree.deselect(this)}selectMulti(){this.tree.selectMulti(this)}selectContiguous(){this.tree.selectContiguous(this)}activate(){this.tree.activate(this)}focus(){this.tree.focus(this)}toggle(){this.tree.toggle(this)}open(){this.tree.open(this)}openParents(){this.tree.openParents(this)}close(){this.tree.close(this)}submit(e){this.tree.submit(this,e)}reset(){this.tree.reset()}clone(){return new e(Object.assign({},this))}edit(){return this.tree.edit(this)}};function $t(e){return{type:`EDIT`,id:e}}function en(e={id:null},t){return t.type===`EDIT`?Object.assign(Object.assign({},e),{id:t.id}):e}function tn(e){return{type:`FOCUS`,id:e}}function nn(){return{type:`TREE_BLUR`}}function rn(e={id:null,treeFocused:!1},t){return t.type===`FOCUS`?Object.assign(Object.assign({},e),{id:t.id,treeFocused:!0}):t.type===`TREE_BLUR`?Object.assign(Object.assign({},e),{treeFocused:!1}):e}var an={open(e,t){return{type:`VISIBILITY_OPEN`,id:e,filtered:t}},close(e,t){return{type:`VISIBILITY_CLOSE`,id:e,filtered:t}},toggle(e,t){return{type:`VISIBILITY_TOGGLE`,id:e,filtered:t}},clear(e){return{type:`VISIBILITY_CLEAR`,filtered:e}}};function on(e={},t){if(t.type===`VISIBILITY_OPEN`)return Object.assign(Object.assign({},e),{[t.id]:!0});if(t.type===`VISIBILITY_CLOSE`)return Object.assign(Object.assign({},e),{[t.id]:!1});if(t.type===`VISIBILITY_TOGGLE`){let n=e[t.id];return Object.assign(Object.assign({},e),{[t.id]:!n})}else if(t.type===`VISIBILITY_CLEAR`)return{};else return e}function sn(e={filtered:{},unfiltered:{}},t){return t.type.startsWith(`VISIBILITY`)?t.filtered?Object.assign(Object.assign({},e),{filtered:on(e.filtered,t)}):Object.assign(Object.assign({},e),{unfiltered:on(e.unfiltered,t)}):e}var cn=e=>({nodes:{open:{filtered:{},unfiltered:e?.initialOpenState??{}},focus:{id:null,treeFocused:!1},edit:{id:null},drag:{id:null,selectedIds:[],destinationParentId:null,destinationIndex:null},selection:{ids:new Set,anchor:null,mostRecent:null}},dnd:{cursor:{type:`none`},dragId:null,dragIds:[],parentId:null,index:-1}}),ln={clear:()=>({type:`SELECTION_CLEAR`}),only:e=>({type:`SELECTION_ONLY`,id:Pt(e)}),add:e=>({type:`SELECTION_ADD`,ids:(Array.isArray(e)?e:[e]).map(Pt)}),remove:e=>({type:`SELECTION_REMOVE`,ids:(Array.isArray(e)?e:[e]).map(Pt)}),set:e=>Object.assign({type:`SELECTION_SET`},e),mostRecent:e=>({type:`SELECTION_MOST_RECENT`,id:e===null?null:Pt(e)}),anchor:e=>({type:`SELECTION_ANCHOR`,id:e===null?null:Pt(e)})};function un(e=cn().nodes.selection,t){let n=e.ids;switch(t.type){case`SELECTION_CLEAR`:return Object.assign(Object.assign({},e),{ids:new Set});case`SELECTION_ONLY`:return Object.assign(Object.assign({},e),{ids:new Set([t.id])});case`SELECTION_ADD`:return t.ids.length===0?e:(t.ids.forEach(e=>n.add(e)),Object.assign(Object.assign({},e),{ids:new Set(n)}));case`SELECTION_REMOVE`:return t.ids.length===0?e:(t.ids.forEach(e=>n.delete(e)),Object.assign(Object.assign({},e),{ids:new Set(n)}));case`SELECTION_SET`:return Object.assign(Object.assign({},e),{ids:t.ids,mostRecent:t.mostRecent,anchor:t.anchor});case`SELECTION_MOST_RECENT`:return Object.assign(Object.assign({},e),{mostRecent:t.id});case`SELECTION_ANCHOR`:return Object.assign(Object.assign({},e),{anchor:t.id});default:return e}}var dn={cursor(e){return{type:`DND_CURSOR`,cursor:e}},dragStart(e,t){return{type:`DND_DRAG_START`,id:e,dragIds:t}},dragEnd(){return{type:`DND_DRAG_END`}},hovering(e,t){return{type:`DND_HOVERING`,parentId:e,index:t}}};function fn(e=cn().dnd,t){switch(t.type){case`DND_CURSOR`:return Object.assign(Object.assign({},e),{cursor:t.cursor});case`DND_DRAG_START`:return Object.assign(Object.assign({},e),{dragId:t.id,dragIds:t.dragIds});case`DND_DRAG_END`:return cn().dnd;case`DND_HOVERING`:return Object.assign(Object.assign({},e),{parentId:t.parentId,index:t.index});default:return e}}var pn={position:`fixed`,pointerEvents:`none`,zIndex:100,left:0,top:0,width:`100%`,height:`100%`},mn=e=>{if(!e)return{display:`none`};let{x:t,y:n}=e;return{transform:`translate(${t}px, ${n}px)`}},hn=e=>{if(!e)return{display:`none`};let{x:t,y:n}=e;return{transform:`translate(${t+10}px, ${n+10}px)`}};function gn({offset:e,mouse:t,id:n,dragIds:r,isDragging:i}){return(0,H.jsxs)(_n,{isDragging:i,children:[(0,H.jsx)(vn,{offset:e,children:(0,H.jsx)(bn,{id:n,dragIds:r})}),(0,H.jsx)(yn,{mouse:t,count:r.length})]})}var _n=(0,V.memo)(function(e){return e.isDragging?(0,H.jsx)(`div`,{style:pn,children:e.children}):null});function vn(e){return(0,H.jsx)(`div`,{className:`row preview`,style:mn(e.offset),children:e.children})}function yn(e){let{count:t,mouse:n}=e;return t>1?(0,H.jsx)(`div`,{className:`selected-count`,style:hn(n),children:t}):null}var bn=(0,V.memo)(function(e){let t=W(),n=t.get(e.id);return n?(0,H.jsx)(t.renderNode,{preview:!0,node:n,style:{paddingLeft:n.level*t.indent,opacity:.2,background:`transparent`},tree:t}):null});function xn(){return xn=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},xn.apply(null,arguments)}function Sn(e){if(e===void 0)throw ReferenceError(`this hasn't been initialised - super() hasn't been called`);return e}function Cn(e,t){return Cn=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},Cn(e,t)}function wn(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,Cn(e,t)}var Tn=Number.isNaN||function(e){return typeof e==`number`&&e!==e};function En(e,t){return!!(e===t||Tn(e)&&Tn(t))}function Dn(e,t){if(e.length!==t.length)return!1;for(var n=0;n<e.length;n++)if(!En(e[n],t[n]))return!1;return!0}function On(e,t){t===void 0&&(t=Dn);var n,r=[],i,a=!1;function o(){var o=[...arguments];return a&&n===this&&t(o,r)?i:(i=e.apply(this,o),a=!0,n=this,r=o,i)}return o}var kn=typeof performance==`object`&&typeof performance.now==`function`?function(){return performance.now()}:function(){return Date.now()};function An(e){cancelAnimationFrame(e.id)}function jn(e,t){var n=kn();function r(){kn()-n>=t?e.call(null):i.id=requestAnimationFrame(r)}var i={id:requestAnimationFrame(r)};return i}var Mn=-1;function Nn(e){if(e===void 0&&(e=!1),Mn===-1||e){var t=document.createElement(`div`),n=t.style;n.width=`50px`,n.height=`50px`,n.overflow=`scroll`,document.body.appendChild(t),Mn=t.offsetWidth-t.clientWidth,document.body.removeChild(t)}return Mn}var Pn=null;function Fn(e){if(e===void 0&&(e=!1),Pn===null||e){var t=document.createElement(`div`),n=t.style;n.width=`50px`,n.height=`50px`,n.overflow=`scroll`,n.direction=`rtl`;var r=document.createElement(`div`),i=r.style;return i.width=`100px`,i.height=`100px`,t.appendChild(r),document.body.appendChild(t),t.scrollLeft>0?Pn=`positive-descending`:(t.scrollLeft=1,Pn=t.scrollLeft===0?`negative`:`positive-ascending`),document.body.removeChild(t),Pn}return Pn}var In=150,Ln=function(e,t){return e};function Rn(e){var t,n=e.getItemOffset,r=e.getEstimatedTotalSize,i=e.getItemSize,a=e.getOffsetForIndexAndAlignment,o=e.getStartIndexForOffset,s=e.getStopIndexForStartIndex,c=e.initInstanceProps,l=e.shouldResetStyleCacheOnItemSizeChange,u=e.validateProps;return t=function(e){wn(t,e);function t(t){var r=e.call(this,t)||this;return r._instanceProps=c(r.props,Sn(r)),r._outerRef=void 0,r._resetIsScrollingTimeoutId=null,r.state={instance:Sn(r),isScrolling:!1,scrollDirection:`forward`,scrollOffset:typeof r.props.initialScrollOffset==`number`?r.props.initialScrollOffset:0,scrollUpdateWasRequested:!1},r._callOnItemsRendered=void 0,r._callOnItemsRendered=On(function(e,t,n,i){return r.props.onItemsRendered({overscanStartIndex:e,overscanStopIndex:t,visibleStartIndex:n,visibleStopIndex:i})}),r._callOnScroll=void 0,r._callOnScroll=On(function(e,t,n){return r.props.onScroll({scrollDirection:e,scrollOffset:t,scrollUpdateWasRequested:n})}),r._getItemStyle=void 0,r._getItemStyle=function(e){var t=r.props,a=t.direction,o=t.itemSize,s=t.layout,c=r._getItemStyleCache(l&&o,l&&s,l&&a),u;if(c.hasOwnProperty(e))u=c[e];else{var d=n(r.props,e,r._instanceProps),f=i(r.props,e,r._instanceProps),p=a===`horizontal`||s===`horizontal`,m=a===`rtl`,h=p?d:0;c[e]=u={position:`absolute`,left:m?void 0:h,right:m?h:void 0,top:p?0:d,height:p?`100%`:f,width:p?f:`100%`}}return u},r._getItemStyleCache=void 0,r._getItemStyleCache=On(function(e,t,n){return{}}),r._onScrollHorizontal=function(e){var t=e.currentTarget,n=t.clientWidth,i=t.scrollLeft,a=t.scrollWidth;r.setState(function(e){if(e.scrollOffset===i)return null;var t=r.props.direction,o=i;if(t===`rtl`)switch(Fn()){case`negative`:o=-i;break;case`positive-descending`:o=a-n-i;break}return o=Math.max(0,Math.min(o,a-n)),{isScrolling:!0,scrollDirection:e.scrollOffset<o?`forward`:`backward`,scrollOffset:o,scrollUpdateWasRequested:!1}},r._resetIsScrollingDebounced)},r._onScrollVertical=function(e){var t=e.currentTarget,n=t.clientHeight,i=t.scrollHeight,a=t.scrollTop;r.setState(function(e){if(e.scrollOffset===a)return null;var t=Math.max(0,Math.min(a,i-n));return{isScrolling:!0,scrollDirection:e.scrollOffset<t?`forward`:`backward`,scrollOffset:t,scrollUpdateWasRequested:!1}},r._resetIsScrollingDebounced)},r._outerRefSetter=function(e){var t=r.props.outerRef;r._outerRef=e,typeof t==`function`?t(e):typeof t==`object`&&t&&t.hasOwnProperty(`current`)&&(t.current=e)},r._resetIsScrollingDebounced=function(){r._resetIsScrollingTimeoutId!==null&&An(r._resetIsScrollingTimeoutId),r._resetIsScrollingTimeoutId=jn(r._resetIsScrolling,In)},r._resetIsScrolling=function(){r._resetIsScrollingTimeoutId=null,r.setState({isScrolling:!1},function(){r._getItemStyleCache(-1,null)})},r}t.getDerivedStateFromProps=function(e,t){return zn(e,t),u(e),null};var d=t.prototype;return d.scrollTo=function(e){e=Math.max(0,e),this.setState(function(t){return t.scrollOffset===e?null:{scrollDirection:t.scrollOffset<e?`forward`:`backward`,scrollOffset:e,scrollUpdateWasRequested:!0}},this._resetIsScrollingDebounced)},d.scrollToItem=function(e,t){t===void 0&&(t=`auto`);var n=this.props,r=n.itemCount,i=n.layout,o=this.state.scrollOffset;e=Math.max(0,Math.min(e,r-1));var s=0;if(this._outerRef){var c=this._outerRef;s=i===`vertical`?c.scrollWidth>c.clientWidth?Nn():0:c.scrollHeight>c.clientHeight?Nn():0}this.scrollTo(a(this.props,e,t,o,this._instanceProps,s))},d.componentDidMount=function(){var e=this.props,t=e.direction,n=e.initialScrollOffset,r=e.layout;if(typeof n==`number`&&this._outerRef!=null){var i=this._outerRef;t===`horizontal`||r===`horizontal`?i.scrollLeft=n:i.scrollTop=n}this._callPropsCallbacks()},d.componentDidUpdate=function(){var e=this.props,t=e.direction,n=e.layout,r=this.state,i=r.scrollOffset;if(r.scrollUpdateWasRequested&&this._outerRef!=null){var a=this._outerRef;if(t===`horizontal`||n===`horizontal`)if(t===`rtl`)switch(Fn()){case`negative`:a.scrollLeft=-i;break;case`positive-ascending`:a.scrollLeft=i;break;default:var o=a.clientWidth;a.scrollLeft=a.scrollWidth-o-i;break}else a.scrollLeft=i;else a.scrollTop=i}this._callPropsCallbacks()},d.componentWillUnmount=function(){this._resetIsScrollingTimeoutId!==null&&An(this._resetIsScrollingTimeoutId)},d.render=function(){var e=this.props,t=e.children,n=e.className,i=e.direction,a=e.height,o=e.innerRef,s=e.innerElementType,c=e.innerTagName,l=e.itemCount,u=e.itemData,d=e.itemKey,f=d===void 0?Ln:d,p=e.layout,m=e.outerElementType,h=e.outerTagName,g=e.style,_=e.useIsScrolling,v=e.width,y=this.state.isScrolling,b=i===`horizontal`||p===`horizontal`,x=b?this._onScrollHorizontal:this._onScrollVertical,S=this._getRangeToRender(),C=S[0],w=S[1],T=[];if(l>0)for(var E=C;E<=w;E++)T.push((0,V.createElement)(t,{data:u,key:f(E,u),index:E,isScrolling:_?y:void 0,style:this._getItemStyle(E)}));var D=r(this.props,this._instanceProps);return(0,V.createElement)(m||h||`div`,{className:n,onScroll:x,ref:this._outerRefSetter,style:xn({position:`relative`,height:a,width:v,overflow:`auto`,WebkitOverflowScrolling:`touch`,willChange:`transform`,direction:i},g)},(0,V.createElement)(s||c||`div`,{children:T,ref:o,style:{height:b?`100%`:D,pointerEvents:y?`none`:void 0,width:b?D:`100%`}}))},d._callPropsCallbacks=function(){if(typeof this.props.onItemsRendered==`function`&&this.props.itemCount>0){var e=this._getRangeToRender(),t=e[0],n=e[1],r=e[2],i=e[3];this._callOnItemsRendered(t,n,r,i)}if(typeof this.props.onScroll==`function`){var a=this.state,o=a.scrollDirection,s=a.scrollOffset,c=a.scrollUpdateWasRequested;this._callOnScroll(o,s,c)}},d._getRangeToRender=function(){var e=this.props,t=e.itemCount,n=e.overscanCount,r=this.state,i=r.isScrolling,a=r.scrollDirection,c=r.scrollOffset;if(t===0)return[0,0,0,0];var l=o(this.props,c,this._instanceProps),u=s(this.props,l,c,this._instanceProps),d=!i||a===`backward`?Math.max(1,n):1,f=!i||a===`forward`?Math.max(1,n):1;return[Math.max(0,l-d),Math.max(0,Math.min(t-1,u+f)),l,u]},t}(V.PureComponent),t.defaultProps={direction:`ltr`,itemData:void 0,layout:`vertical`,overscanCount:2,useIsScrolling:!1},t}var zn=function(e,t){e.children,e.direction,e.height,e.layout,e.innerTagName,e.outerTagName,e.width,t.instance},Bn=50,Vn=function(e,t,n){var r=e.itemSize,i=n.itemMetadataMap,a=n.lastMeasuredIndex;if(t>a){var o=0;if(a>=0){var s=i[a];o=s.offset+s.size}for(var c=a+1;c<=t;c++){var l=r(c);i[c]={offset:o,size:l},o+=l}n.lastMeasuredIndex=t}return i[t]},Hn=function(e,t,n){var r=t.itemMetadataMap,i=t.lastMeasuredIndex;return(i>0?r[i].offset:0)>=n?Un(e,t,i,0,n):Wn(e,t,Math.max(0,i),n)},Un=function(e,t,n,r,i){for(;r<=n;){var a=r+Math.floor((n-r)/2),o=Vn(e,a,t).offset;if(o===i)return a;o<i?r=a+1:o>i&&(n=a-1)}return r>0?r-1:0},Wn=function(e,t,n,r){for(var i=e.itemCount,a=1;n<i&&Vn(e,n,t).offset<r;)n+=a,a*=2;return Un(e,t,Math.min(n,i-1),Math.floor(n/2),r)},Gn=function(e,t){var n=e.itemCount,r=t.itemMetadataMap,i=t.estimatedItemSize,a=t.lastMeasuredIndex,o=0;if(a>=n&&(a=n-1),a>=0){var s=r[a];o=s.offset+s.size}var c=(n-a-1)*i;return o+c},Kn=Rn({getItemOffset:function(e,t,n){return Vn(e,t,n).offset},getItemSize:function(e,t,n){return n.itemMetadataMap[t].size},getEstimatedTotalSize:Gn,getOffsetForIndexAndAlignment:function(e,t,n,r,i,a){var o=e.direction,s=e.height,c=e.layout,l=e.width,u=o===`horizontal`||c===`horizontal`?l:s,d=Vn(e,t,i),f=Gn(e,i),p=Math.max(0,Math.min(f-u,d.offset)),m=Math.max(0,d.offset-u+d.size+a);switch(n===`smart`&&(n=r>=m-u&&r<=p+u?`auto`:`center`),n){case`start`:return p;case`end`:return m;case`center`:return Math.round(m+(p-m)/2);default:return r>=m&&r<=p?r:r<m?m:p}},getStartIndexForOffset:function(e,t,n){return Hn(e,n,t)},getStopIndexForStartIndex:function(e,t,n,r){for(var i=e.direction,a=e.height,o=e.itemCount,s=e.layout,c=e.width,l=i===`horizontal`||s===`horizontal`?c:a,u=Vn(e,t,r),d=n+l,f=u.offset+u.size,p=t;p<o-1&&f<d;)p++,f+=Vn(e,p,r).size;return p},initInstanceProps:function(e,t){var n={itemMetadataMap:{},estimatedItemSize:e.estimatedItemSize||Bn,lastMeasuredIndex:-1};return t.resetAfterIndex=function(e,r){r===void 0&&(r=!0),n.lastMeasuredIndex=Math.min(n.lastMeasuredIndex,e-1),t._getItemStyleCache(-1),r&&t.forceUpdate()},n},shouldResetStyleCacheOnItemSizeChange:!1,validateProps:function(e){e.itemSize}}),qn=Rn({getItemOffset:function(e,t){return t*e.itemSize},getItemSize:function(e,t){return e.itemSize},getEstimatedTotalSize:function(e){var t=e.itemCount;return e.itemSize*t},getOffsetForIndexAndAlignment:function(e,t,n,r,i,a){var o=e.direction,s=e.height,c=e.itemCount,l=e.itemSize,u=e.layout,d=e.width,f=o===`horizontal`||u===`horizontal`?d:s,p=Math.max(0,c*l-f),m=Math.min(p,t*l),h=Math.max(0,t*l-f+l+a);switch(n===`smart`&&(n=r>=h-f&&r<=m+f?`auto`:`center`),n){case`start`:return m;case`end`:return h;case`center`:var g=Math.round(h+(m-h)/2);return g<Math.ceil(f/2)?0:g>p+Math.floor(f/2)?p:g;default:return r>=h&&r<=m?r:r<h?h:m}},getStartIndexForOffset:function(e,t){var n=e.itemCount,r=e.itemSize;return Math.max(0,Math.min(n-1,Math.floor(t/r)))},getStopIndexForStartIndex:function(e,t,n){var r=e.direction,i=e.height,a=e.itemCount,o=e.itemSize,s=e.layout,c=e.width,l=r===`horizontal`||s===`horizontal`,u=t*o,d=Math.ceil(((l?c:i)+n-u)/o);return Math.max(0,Math.min(a-1,t+d-1))},initInstanceProps:function(e){},shouldResetStyleCacheOnItemSizeChange:!0,validateProps:function(e){e.itemSize}});function Jn(){let e=W(),t=mt().cursor;if(!t||t.type!==`line`)return null;let n=e.indent,r=e.rowTopPosition(t.index)+(e.props.padding??e.props.paddingTop??0),i=n*t.level,a=e.renderCursor;return(0,H.jsx)(a,{top:r,left:i,indent:n})}var Yn=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols==`function`)for(var i=0,r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]]);return n},Xn=(0,V.forwardRef)(function(e,t){let{children:n}=e,r=Yn(e,[`children`]),i=W();return(0,H.jsxs)(`div`,Object.assign({ref:t},r,{onClick:e=>{e.currentTarget===e.target&&i.deselectAll()},children:[(0,H.jsx)(Zn,{}),n]}))}),Zn=()=>{let e=W();return(0,H.jsx)(`div`,{style:{height:e.rowTopPosition(e.visibleNodes.length),width:`100%`,position:`absolute`,left:`0`,right:`0`},children:(0,H.jsx)(Jn,{})})},Qn=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols==`function`)for(var i=0,r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]]);return n},$n=(0,V.forwardRef)(function(e,t){var{style:n}=e,r=Qn(e,[`style`]);let i=W(),a=i.props.padding??i.props.paddingTop??0,o=i.props.padding??i.props.paddingBottom??0;return(0,H.jsx)(`div`,Object.assign({ref:t,style:Object.assign(Object.assign({},n),{height:`${parseFloat(n.height)+a+o}px`})},r))}),er=(0,V.createContext)({dragDropManager:void 0}),G;(function(e){e.SOURCE=`SOURCE`,e.TARGET=`TARGET`})(G||={});function K(e,t){var n=[...arguments].slice(2);if(!e){var r;if(t===void 0)r=Error(`Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings.`);else{var i=0;r=Error(t.replace(/%s/g,function(){return n[i++]})),r.name=`Invariant Violation`}throw r.framesToPop=1,r}}var tr=`dnd-core/INIT_COORDS`,nr=`dnd-core/BEGIN_DRAG`,rr=`dnd-core/PUBLISH_DRAG_SOURCE`,ir=`dnd-core/HOVER`,ar=`dnd-core/DROP`,or=`dnd-core/END_DRAG`;function sr(e,t){return{type:tr,payload:{sourceClientOffset:t||null,clientOffset:e||null}}}function cr(e){"@babel/helpers - typeof";return cr=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},cr(e)}function lr(e,t,n){return t.split(`.`).reduce(function(e,t){return e&&e[t]?e[t]:n||null},e)}function ur(e,t){return e.filter(function(e){return e!==t})}function dr(e){return cr(e)===`object`}function fr(e,t){var n=new Map,r=function(e){n.set(e,n.has(e)?n.get(e)+1:1)};e.forEach(r),t.forEach(r);var i=[];return n.forEach(function(e,t){e===1&&i.push(t)}),i}function pr(e,t){return e.filter(function(e){return t.indexOf(e)>-1})}var mr={type:tr,payload:{clientOffset:null,sourceClientOffset:null}};function hr(e){return function(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{publishSource:!0},r=n.publishSource,i=r===void 0?!0:r,a=n.clientOffset,o=n.getSourceClientOffset,s=e.getMonitor(),c=e.getRegistry();e.dispatch(sr(a)),gr(t,s,c);var l=yr(t,s);if(l===null){e.dispatch(mr);return}var u=null;if(a){if(!o)throw Error(`getSourceClientOffset must be defined`);_r(o),u=o(l)}e.dispatch(sr(a,u));var d=c.getSource(l).beginDrag(s,l);if(d!=null)return vr(d),c.pinSource(l),{type:nr,payload:{itemType:c.getSourceType(l),item:d,sourceId:l,clientOffset:a||null,sourceClientOffset:u||null,isSourcePublic:!!i}}}}function gr(e,t,n){K(!t.isDragging(),`Cannot call beginDrag while dragging.`),e.forEach(function(e){K(n.getSource(e),`Expected sourceIds to be registered.`)})}function _r(e){K(typeof e==`function`,`When clientOffset is provided, getSourceClientOffset must be a function.`)}function vr(e){K(dr(e),`Item must be an object.`)}function yr(e,t){for(var n=null,r=e.length-1;r>=0;r--)if(t.canDragSource(e[r])){n=e[r];break}return n}function br(e){return function(){if(e.getMonitor().isDragging())return{type:rr}}}function xr(e,t){return t===null?e===null:Array.isArray(e)?e.some(function(e){return e===t}):e===t}function Sr(e){return function(t){var n=(arguments.length>1&&arguments[1]!==void 0?arguments[1]:{}).clientOffset;Cr(t);var r=t.slice(0),i=e.getMonitor(),a=e.getRegistry();return wr(r,i,a),Tr(r,a,i.getItemType()),Er(r,i,a),{type:ir,payload:{targetIds:r,clientOffset:n||null}}}}function Cr(e){K(Array.isArray(e),`Expected targetIds to be an array.`)}function wr(e,t,n){K(t.isDragging(),`Cannot call hover while not dragging.`),K(!t.didDrop(),`Cannot call hover after drop.`);for(var r=0;r<e.length;r++){var i=e[r];K(e.lastIndexOf(i)===r,`Expected targetIds to be unique in the passed array.`),K(n.getTarget(i),`Expected targetIds to be registered.`)}}function Tr(e,t,n){for(var r=e.length-1;r>=0;r--){var i=e[r];xr(t.getTargetType(i),n)||e.splice(r,1)}}function Er(e,t,n){e.forEach(function(e){n.getTarget(e).hover(t,e)})}function Dr(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Or(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?Dr(Object(n),!0).forEach(function(t){kr(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Dr(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function kr(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Ar(e){return function(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},n=e.getMonitor(),r=e.getRegistry();jr(n),Pr(n).forEach(function(i,a){var o=Mr(i,a,r,n),s={type:ar,payload:{dropResult:Or(Or({},t),o)}};e.dispatch(s)})}}function jr(e){K(e.isDragging(),`Cannot call drop while not dragging.`),K(!e.didDrop(),`Cannot call drop twice during one drag operation.`)}function Mr(e,t,n,r){var i=n.getTarget(e),a=i?i.drop(r,e):void 0;return Nr(a),a===void 0&&(a=t===0?{}:r.getDropResult()),a}function Nr(e){K(e===void 0||dr(e),`Drop result must either be an object or undefined.`)}function Pr(e){var t=e.getTargetIds().filter(e.canDropOnTarget,e);return t.reverse(),t}function Fr(e){return function(){var t=e.getMonitor(),n=e.getRegistry();Ir(t);var r=t.getSourceId();return r!=null&&(n.getSource(r,!0).endDrag(t,r),n.unpinSource()),{type:or}}}function Ir(e){K(e.isDragging(),`Cannot call endDrag while not dragging.`)}function Lr(e){return{beginDrag:hr(e),publishDragSource:br(e),hover:Sr(e),drop:Ar(e),endDrag:Fr(e)}}function Rr(e,t){if(!(e instanceof t))throw TypeError(`Cannot call a class as a function`)}function zr(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,`value`in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function Br(e,t,n){return t&&zr(e.prototype,t),n&&zr(e,n),e}function Vr(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var Hr=function(){function e(t,n){var r=this;Rr(this,e),Vr(this,`store`,void 0),Vr(this,`monitor`,void 0),Vr(this,`backend`,void 0),Vr(this,`isSetUp`,!1),Vr(this,`handleRefCountChange`,function(){var e=r.store.getState().refCount>0;r.backend&&(e&&!r.isSetUp?(r.backend.setup(),r.isSetUp=!0):!e&&r.isSetUp&&(r.backend.teardown(),r.isSetUp=!1))}),this.store=t,this.monitor=n,t.subscribe(this.handleRefCountChange)}return Br(e,[{key:`receiveBackend`,value:function(e){this.backend=e}},{key:`getMonitor`,value:function(){return this.monitor}},{key:`getBackend`,value:function(){return this.backend}},{key:`getRegistry`,value:function(){return this.monitor.registry}},{key:`getActions`,value:function(){var e=this,t=this.store.dispatch;function n(n){return function(){var r=[...arguments],i=n.apply(e,r);i!==void 0&&t(i)}}var r=Lr(this);return Object.keys(r).reduce(function(e,t){var i=r[t];return e[t]=n(i),e},{})}},{key:`dispatch`,value:function(e){this.store.dispatch(e)}}]),e}();function q(e){return`Minified Redux error #`+e+`; visit https://redux.js.org/Errors?code=`+e+` for the full message or use the non-minified dev environment for full errors. `}var Ur=(function(){return typeof Symbol==`function`&&Symbol.observable||`@@observable`})(),Wr=function(){return Math.random().toString(36).substring(7).split(``).join(`.`)},Gr={INIT:`@@redux/INIT`+Wr(),REPLACE:`@@redux/REPLACE`+Wr(),PROBE_UNKNOWN_ACTION:function(){return`@@redux/PROBE_UNKNOWN_ACTION`+Wr()}};function Kr(e){if(typeof e!=`object`||!e)return!1;for(var t=e;Object.getPrototypeOf(t)!==null;)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t}function qr(e,t,n){var r;if(typeof t==`function`&&typeof n==`function`||typeof n==`function`&&typeof arguments[3]==`function`)throw Error(q(0));if(typeof t==`function`&&n===void 0&&(n=t,t=void 0),n!==void 0){if(typeof n!=`function`)throw Error(q(1));return n(qr)(e,t)}if(typeof e!=`function`)throw Error(q(2));var i=e,a=t,o=[],s=o,c=!1;function l(){s===o&&(s=o.slice())}function u(){if(c)throw Error(q(3));return a}function d(e){if(typeof e!=`function`)throw Error(q(4));if(c)throw Error(q(5));var t=!0;return l(),s.push(e),function(){if(t){if(c)throw Error(q(6));t=!1,l();var n=s.indexOf(e);s.splice(n,1),o=null}}}function f(e){if(!Kr(e))throw Error(q(7));if(e.type===void 0)throw Error(q(8));if(c)throw Error(q(9));try{c=!0,a=i(a,e)}finally{c=!1}for(var t=o=s,n=0;n<t.length;n++){var r=t[n];r()}return e}function p(e){if(typeof e!=`function`)throw Error(q(10));i=e,f({type:Gr.REPLACE})}function m(){var e,t=d;return e={subscribe:function(e){if(typeof e!=`object`||!e)throw Error(q(11));function n(){e.next&&e.next(u())}return n(),{unsubscribe:t(n)}}},e[Ur]=function(){return this},e}return f({type:Gr.INIT}),r={dispatch:f,subscribe:d,getState:u,replaceReducer:p},r[Ur]=m,r}var Jr=function(e,t){return e===t};function Yr(e,t){return!e&&!t?!0:!e||!t?!1:e.x===t.x&&e.y===t.y}function Xr(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Jr;if(e.length!==t.length)return!1;for(var r=0;r<e.length;++r)if(!n(e[r],t[r]))return!1;return!0}function Zr(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Qr(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?Zr(Object(n),!0).forEach(function(t){$r(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Zr(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function $r(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var ei={initialSourceClientOffset:null,initialClientOffset:null,clientOffset:null};function ti(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:ei,t=arguments.length>1?arguments[1]:void 0,n=t.payload;switch(t.type){case tr:case nr:return{initialSourceClientOffset:n.sourceClientOffset,initialClientOffset:n.clientOffset,clientOffset:n.clientOffset};case ir:return Yr(e.clientOffset,n.clientOffset)?e:Qr(Qr({},e),{},{clientOffset:n.clientOffset});case or:case ar:return ei;default:return e}}var ni=`dnd-core/ADD_SOURCE`,ri=`dnd-core/ADD_TARGET`,ii=`dnd-core/REMOVE_SOURCE`,ai=`dnd-core/REMOVE_TARGET`;function oi(e){return{type:ni,payload:{sourceId:e}}}function si(e){return{type:ri,payload:{targetId:e}}}function ci(e){return{type:ii,payload:{sourceId:e}}}function li(e){return{type:ai,payload:{targetId:e}}}function ui(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function J(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?ui(Object(n),!0).forEach(function(t){di(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):ui(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function di(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var fi={itemType:null,item:null,sourceId:null,targetIds:[],dropResult:null,didDrop:!1,isSourcePublic:null};function pi(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:fi,t=arguments.length>1?arguments[1]:void 0,n=t.payload;switch(t.type){case nr:return J(J({},e),{},{itemType:n.itemType,item:n.item,sourceId:n.sourceId,isSourcePublic:n.isSourcePublic,dropResult:null,didDrop:!1});case rr:return J(J({},e),{},{isSourcePublic:!0});case ir:return J(J({},e),{},{targetIds:n.targetIds});case ai:return e.targetIds.indexOf(n.targetId)===-1?e:J(J({},e),{},{targetIds:ur(e.targetIds,n.targetId)});case ar:return J(J({},e),{},{dropResult:n.dropResult,didDrop:!0,targetIds:[]});case or:return J(J({},e),{},{itemType:null,item:null,sourceId:null,dropResult:null,didDrop:!1,isSourcePublic:null,targetIds:[]});default:return e}}function mi(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0;switch((arguments.length>1?arguments[1]:void 0).type){case ni:case ri:return e+1;case ii:case ai:return e-1;default:return e}}var hi=[],gi=[];hi.__IS_NONE__=!0,gi.__IS_ALL__=!0;function _i(e,t){return e===hi?!1:e===gi||t===void 0?!0:pr(t,e).length>0}function vi(){arguments.length>0&&arguments[0]!==void 0&&arguments[0];var e=arguments.length>1?arguments[1]:void 0;switch(e.type){case ir:break;case ni:case ri:case ai:case ii:return hi;case nr:case rr:case or:case ar:default:return gi}var t=e.payload,n=t.targetIds,r=n===void 0?[]:n,i=t.prevTargetIds,a=i===void 0?[]:i,o=fr(r,a);if(!(o.length>0||!Xr(r,a)))return hi;var s=a[a.length-1],c=r[r.length-1];return s!==c&&(s&&o.push(s),c&&o.push(c)),o}function yi(){return(arguments.length>0&&arguments[0]!==void 0?arguments[0]:0)+1}function bi(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function xi(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?bi(Object(n),!0).forEach(function(t){Si(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):bi(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Si(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Ci(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},t=arguments.length>1?arguments[1]:void 0;return{dirtyHandlerIds:vi(e.dirtyHandlerIds,{type:t.type,payload:xi(xi({},t.payload),{},{prevTargetIds:lr(e,`dragOperation.targetIds`,[])})}),dragOffset:ti(e.dragOffset,t),refCount:mi(e.refCount,t),dragOperation:pi(e.dragOperation,t),stateId:yi(e.stateId)}}function wi(e,t){return{x:e.x+t.x,y:e.y+t.y}}function Ti(e,t){return{x:e.x-t.x,y:e.y-t.y}}function Ei(e){var t=e.clientOffset,n=e.initialClientOffset,r=e.initialSourceClientOffset;return!t||!n||!r?null:Ti(wi(t,r),n)}function Di(e){var t=e.clientOffset,n=e.initialClientOffset;return!t||!n?null:Ti(t,n)}function Oi(e,t){if(!(e instanceof t))throw TypeError(`Cannot call a class as a function`)}function ki(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,`value`in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function Ai(e,t,n){return t&&ki(e.prototype,t),n&&ki(e,n),e}function ji(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var Mi=function(){function e(t,n){Oi(this,e),ji(this,`store`,void 0),ji(this,`registry`,void 0),this.store=t,this.registry=n}return Ai(e,[{key:`subscribeToStateChange`,value:function(e){var t=this,n=(arguments.length>1&&arguments[1]!==void 0?arguments[1]:{handlerIds:void 0}).handlerIds;K(typeof e==`function`,`listener must be a function.`),K(n===void 0||Array.isArray(n),`handlerIds, when specified, must be an array of strings.`);var r=this.store.getState().stateId;return this.store.subscribe(function(){var i=t.store.getState(),a=i.stateId;try{a===r||a===r+1&&!_i(i.dirtyHandlerIds,n)||e()}finally{r=a}})}},{key:`subscribeToOffsetChange`,value:function(e){var t=this;K(typeof e==`function`,`listener must be a function.`);var n=this.store.getState().dragOffset;return this.store.subscribe(function(){var r=t.store.getState().dragOffset;r!==n&&(n=r,e())})}},{key:`canDragSource`,value:function(e){if(!e)return!1;var t=this.registry.getSource(e);return K(t,`Expected to find a valid source. sourceId=${e}`),this.isDragging()?!1:t.canDrag(this,e)}},{key:`canDropOnTarget`,value:function(e){if(!e)return!1;var t=this.registry.getTarget(e);return K(t,`Expected to find a valid target. targetId=${e}`),!this.isDragging()||this.didDrop()?!1:xr(this.registry.getTargetType(e),this.getItemType())&&t.canDrop(this,e)}},{key:`isDragging`,value:function(){return!!this.getItemType()}},{key:`isDraggingSource`,value:function(e){if(!e)return!1;var t=this.registry.getSource(e,!0);return K(t,`Expected to find a valid source. sourceId=${e}`),!this.isDragging()||!this.isSourcePublic()||this.registry.getSourceType(e)!==this.getItemType()?!1:t.isDragging(this,e)}},{key:`isOverTarget`,value:function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{shallow:!1};if(!e)return!1;var n=t.shallow;if(!this.isDragging())return!1;var r=this.registry.getTargetType(e),i=this.getItemType();if(i&&!xr(r,i))return!1;var a=this.getTargetIds();if(!a.length)return!1;var o=a.indexOf(e);return n?o===a.length-1:o>-1}},{key:`getItemType`,value:function(){return this.store.getState().dragOperation.itemType}},{key:`getItem`,value:function(){return this.store.getState().dragOperation.item}},{key:`getSourceId`,value:function(){return this.store.getState().dragOperation.sourceId}},{key:`getTargetIds`,value:function(){return this.store.getState().dragOperation.targetIds}},{key:`getDropResult`,value:function(){return this.store.getState().dragOperation.dropResult}},{key:`didDrop`,value:function(){return this.store.getState().dragOperation.didDrop}},{key:`isSourcePublic`,value:function(){return!!this.store.getState().dragOperation.isSourcePublic}},{key:`getInitialClientOffset`,value:function(){return this.store.getState().dragOffset.initialClientOffset}},{key:`getInitialSourceClientOffset`,value:function(){return this.store.getState().dragOffset.initialSourceClientOffset}},{key:`getClientOffset`,value:function(){return this.store.getState().dragOffset.clientOffset}},{key:`getSourceClientOffset`,value:function(){return Ei(this.store.getState().dragOffset)}},{key:`getDifferenceFromInitialOffset`,value:function(){return Di(this.store.getState().dragOffset)}}]),e}(),Ni=0;function Pi(){return Ni++}function Fi(e){"@babel/helpers - typeof";return Fi=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},Fi(e)}function Ii(e){K(typeof e.canDrag==`function`,`Expected canDrag to be a function.`),K(typeof e.beginDrag==`function`,`Expected beginDrag to be a function.`),K(typeof e.endDrag==`function`,`Expected endDrag to be a function.`)}function Li(e){K(typeof e.canDrop==`function`,`Expected canDrop to be a function.`),K(typeof e.hover==`function`,`Expected hover to be a function.`),K(typeof e.drop==`function`,`Expected beginDrag to be a function.`)}function Ri(e,t){if(t&&Array.isArray(e)){e.forEach(function(e){return Ri(e,!1)});return}K(typeof e==`string`||Fi(e)===`symbol`,t?`Type can only be a string, a symbol, or an array of either.`:`Type can only be a string or a symbol.`)}var zi=typeof global<`u`?global:self,Bi=zi.MutationObserver||zi.WebKitMutationObserver;function Vi(e){return function(){let t=setTimeout(r,0),n=setInterval(r,50);function r(){clearTimeout(t),clearInterval(n),e()}}}function Hi(e){let t=1,n=new Bi(e),r=document.createTextNode(``);return n.observe(r,{characterData:!0}),function(){t=-t,r.data=t}}var Ui=typeof Bi==`function`?Hi:Vi,Wi=class{enqueueTask(e){let{queue:t,requestFlush:n}=this;t.length||(n(),this.flushing=!0),t[t.length]=e}constructor(){this.queue=[],this.pendingErrors=[],this.flushing=!1,this.index=0,this.capacity=1024,this.flush=()=>{let{queue:e}=this;for(;this.index<e.length;){let t=this.index;if(this.index++,e[t].call(),this.index>this.capacity){for(let t=0,n=e.length-this.index;t<n;t++)e[t]=e[t+this.index];e.length-=this.index,this.index=0}}e.length=0,this.index=0,this.flushing=!1},this.registerPendingError=e=>{this.pendingErrors.push(e),this.requestErrorThrow()},this.requestFlush=Ui(this.flush),this.requestErrorThrow=Vi(()=>{if(this.pendingErrors.length)throw this.pendingErrors.shift()})}},Gi=class{call(){try{this.task&&this.task()}catch(e){this.onError(e)}finally{this.task=null,this.release(this)}}constructor(e,t){this.onError=e,this.release=t,this.task=null}},Ki=class{create(e){let t=this.freeTasks,n=t.length?t.pop():new Gi(this.onError,e=>t[t.length]=e);return n.task=e,n}constructor(e){this.onError=e,this.freeTasks=[]}},qi=new Wi,Ji=new Ki(qi.registerPendingError);function Yi(e){qi.enqueueTask(Ji.create(e))}function Xi(e,t){if(!(e instanceof t))throw TypeError(`Cannot call a class as a function`)}function Zi(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,`value`in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function Qi(e,t,n){return t&&Zi(e.prototype,t),n&&Zi(e,n),e}function $i(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function ea(e,t){return aa(e)||ia(e,t)||na(e,t)||ta()}function ta(){throw TypeError(`Invalid attempt to destructure non-iterable instance.
1
+ import{n as e,r as t,t as n}from"./chunk-DECur_0Z.js";import{i as r,n as i,t as a}from"./jsx-runtime-BthL93pI.js";import{t as o}from"./react-dom-gtU6X-Hj.js";import{$ as s,B as c,D as l,E as u,F as d,G as f,H as p,J as m,K as h,M as g,N as _,O as v,P as y,Q as b,U as x,V as S,W as C,X as w,Y as T,Z as E,f as D,j as O,p as k,q as A,r as j,s as M,t as N,y as ee,z as P}from"./workspace-view-state-DvYG_9PH.js";import{_ as te,a as ne,c as re,d as ie,f as F,h as I,i as ae,k as L,n as R,r as oe,t as se,u as ce,y as le}from"./file-icons-Bw2qd5iT.js";import{_ as ue,c as z,s as de,u as B,v as fe}from"./IconGlyphs-AU22gPDY.js";import{u as pe}from"./workspace-working-copy-D8-s_Sgh.js";import{t as me}from"./useWorkspaceMenuKeyboard-Brws6Ar9.js";var V=t(r()),H=a();function he(e){return{"--change-indent":`${18+e*12}px`,"--change-guide-width":`${e*12}px`}}function ge(e){return e.sort((e,t)=>e.type===`directory`&&t.type!==`directory`?-1:e.type!==`directory`&&t.type===`directory`?1:e.name.localeCompare(t.name)||e.path.localeCompare(t.path)),e.forEach(e=>{e.type===`directory`&&ge(e.children)}),e}function _e(e){return e.reduce((e,t)=>t.type===`file`?e+1:(t.descendantCount=+!!t.change+_e(t.children),e+t.descendantCount),0)}function ve(e){return e.map(e=>{if(e.type===`file`)return e;let t={...e,children:ve(e.children)};for(;!t.change&&t.children.length===1&&t.children[0]?.type===`directory`&&!t.children[0].change;){let e=t.children[0];t={...e,displayName:`${t.displayName??t.name}/${e.displayName??e.name}`}}return t})}function ye(e,t){let n=[],r=new Map([[``,n]]),i=new Map,a=(e,n,a)=>{let o=i.get(e);if(o)return o;let s=[],c={id:`${t}:dir:${e}`,name:a,path:e,type:`directory`,children:s,descendantCount:0};return i.set(e,c),r.set(e,s),r.get(n)?.push(c),c};e.forEach(e=>{let n=e.path.replace(/\/+$/,``),o=n.split(`/`).filter(Boolean);if(o.length===0)return;let s=``,c=e.type===`directory`||e.path.endsWith(`/`),l=c?o.length:o.length-1;for(let e=0;e<l;e+=1){let t=o[e];if(!t)continue;let n=o.slice(0,e+1).join(`/`);a(n,s,t),s=n}if(c){let t=i.get(n);t&&(t.change=e);return}r.get(s)?.push({id:`${t}:file:${g(e)}`,name:o[o.length-1]||e.name,path:e.path,type:`file`,change:e})});let o=ve(ge(n));return _e(o),o}function be({activeFilePath:e,change:t,copy:n,onOpenChange:r}){let i=e===t.path,a=n.gitStatus(t.gitStatus),o=t.gitStatus===`untracked`?``:t.gitStatusLabel,s=t.previousPath?O(t):``;return(0,H.jsx)(`div`,{className:`code-file-change-row ${i?`active`:``}`,"data-testid":`code-file-change-row`,"data-file-path":t.path,"data-file-type":`file`,title:_(t,a),children:(0,H.jsxs)(`button`,{type:`button`,className:`code-file-change-main`,onClick:()=>r(t),children:[(0,H.jsx)(`span`,{className:`code-file-chevron placeholder`,"aria-hidden":`true`}),(0,H.jsx)(`img`,{className:`code-file-type-icon file`,src:R(t.path),alt:``,"aria-hidden":`true`}),(0,H.jsx)(`span`,{className:`code-file-change-name`,children:t.name}),(0,H.jsx)(`span`,{className:`code-file-change-path`,children:s}),(0,H.jsx)(`span`,{className:`code-file-change-status ${t.gitStatus}`,title:a,children:o})]})},g(t))}function xe({activeFilePath:e,copy:t,depth:n,nodes:r,openDirectoryIds:i,onOpenChange:a,onToggleDirectory:o}){return(0,H.jsx)(H.Fragment,{children:r.map(r=>{if(r.type===`file`)return(0,H.jsx)(`div`,{style:he(n),children:(0,H.jsx)(be,{activeFilePath:e,change:r.change,copy:t,onOpenChange:a})},r.id);let s=r.children.length>0,c=s&&i.has(r.id);return(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`div`,{className:`code-file-change-row directory`,"data-testid":`code-file-change-directory-row`,"data-file-path":r.path,"data-file-type":`directory`,title:r.path,style:he(n),children:(0,H.jsxs)(`button`,{type:`button`,className:`code-file-change-main directory`,"aria-expanded":s?c:void 0,onClick:()=>{s&&o(r.id)},children:[(0,H.jsx)(`span`,{className:`code-file-chevron ${s?c?`expanded`:`collapsed`:`placeholder`}`,"aria-hidden":`true`,children:s?c?(0,H.jsx)(z,{}):(0,H.jsx)(B,{}):null}),(0,H.jsx)(`span`,{className:`code-file-change-name`,children:r.displayName??r.name}),(0,H.jsx)(`span`,{className:`code-file-change-status directory`,children:r.descendantCount||``})]})}),c&&(0,H.jsx)(xe,{activeFilePath:e,copy:t,depth:n+1,nodes:r.children,openDirectoryIds:i,onOpenChange:a,onToggleDirectory:o})]},r.id)})})}function Se({activeFilePath:e,projectWorkspace:t,changes:n,collapsed:r,copy:a,projectId:o,refreshing:s,onOpenChange:c,onToggleCollapsed:l}){let[u,d]=(0,V.useState)(!0),[f,p]=(0,V.useState)(()=>new Set),m=(0,V.useMemo)(()=>n.items.filter(e=>e.gitStatus!==`untracked`),[n.items]),h=(0,V.useMemo)(()=>n.items.filter(e=>e.gitStatus===`untracked`),[n.items]),g=(0,V.useMemo)(()=>ye(m,`tracked`),[m]),_=(0,V.useMemo)(()=>ye(h,`untracked`),[h]),v=s||n.loading,y=v?`refreshing`:n.error?`stale`:`refreshed`;if(n.items.length===0&&!n.error)return null;let b=()=>{r&&n.refreshChanges(),l()},x=()=>{d(e=>(e&&n.refreshChanges(),!e))},S=e=>{p(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},C=e=>{let n=new URLSearchParams({root:t,scope:e});e===`untracked`&&n.set(`modifiedWithinDays`,`3`),window.open(i(`/review?${n.toString()}`),`_blank`,`noopener,noreferrer`)};return(0,H.jsxs)(`div`,{className:`code-file-changes-section`,"data-testid":`code-file-changes-section`,"data-project-id":o,"aria-label":a.changedFiles,"aria-busy":v,children:[m.length>0&&(0,H.jsxs)(`div`,{className:`code-file-change-group tracked ${r?`collapsed`:``}`,"data-testid":`code-file-change-tracked-group`,children:[(0,H.jsxs)(`div`,{className:`code-file-change-group-header`,children:[(0,H.jsxs)(`button`,{type:`button`,className:`code-file-change-group-toggle`,"aria-expanded":!r,onClick:b,children:[(0,H.jsx)(`span`,{className:`code-file-section-chevron ${r?`collapsed`:`expanded`}`,"aria-hidden":`true`,children:r?(0,H.jsx)(B,{}):(0,H.jsx)(z,{})}),(0,H.jsx)(`span`,{children:a.changes}),(0,H.jsx)(`span`,{className:`code-file-changes-count ${y}`,"data-testid":`code-file-changes-tracked-count`,"data-refresh-state":y,"aria-label":v?a.refreshingFiles:void 0,title:n.error??void 0,children:v?(0,H.jsx)(`span`,{className:`code-file-changes-count-loader`,"aria-hidden":`true`,children:`···`}):m.length})]}),(0,H.jsx)(`button`,{type:`button`,className:`code-file-change-review`,onClick:()=>C(`tracked`),children:a.reviewChanges})]}),!r&&(0,H.jsx)(xe,{activeFilePath:e,copy:a,depth:0,nodes:g,openDirectoryIds:f,onOpenChange:c,onToggleDirectory:S})]}),h.length>0&&(0,H.jsxs)(`div`,{className:`code-file-change-group untracked ${u?`collapsed`:``}`,"data-testid":`code-file-change-untracked-group`,children:[(0,H.jsxs)(`div`,{className:`code-file-change-group-header`,children:[(0,H.jsxs)(`button`,{type:`button`,className:`code-file-change-group-toggle`,"aria-expanded":!u,onClick:x,children:[(0,H.jsx)(`span`,{className:`code-file-section-chevron ${u?`collapsed`:`expanded`}`,"aria-hidden":`true`,children:u?(0,H.jsx)(B,{}):(0,H.jsx)(z,{})}),(0,H.jsx)(`span`,{children:a.untrackedChanges}),(0,H.jsx)(`span`,{className:`code-file-changes-count ${y}`,"data-testid":`code-file-changes-untracked-count`,"data-refresh-state":y,"aria-label":v?a.refreshingFiles:void 0,title:n.error??void 0,children:v?(0,H.jsx)(`span`,{className:`code-file-changes-count-loader`,"aria-hidden":`true`,children:`···`}):(0,H.jsxs)(H.Fragment,{children:[h.length,n.truncated?`+`:``]})})]}),(0,H.jsx)(`button`,{type:`button`,className:`code-file-change-review`,onClick:()=>C(`untracked`),children:a.reviewChanges})]}),!u&&(0,H.jsx)(xe,{activeFilePath:e,copy:a,depth:0,nodes:_,openDirectoryIds:f,onOpenChange:c,onToggleDirectory:S})]}),n.error&&(0,H.jsx)(`div`,{className:`code-file-changes-status error`,"data-testid":`code-file-changes-error`,children:n.error})]})}function Ce(e){let t=e.trim().replace(/^\.\/+/,``);if(!t)return null;let n=t.match(/^(.+?)#L(\d+)(?:C(\d+))?$/i);if(n)return{path:n[1]||``,lineNumber:Number(n[2]),column:n[3]?Number(n[3]):void 0};let r=t.match(/^(.+?):(\d+)(?::(\d+))?$/);return r?{path:r[1]||``,lineNumber:Number(r[2]),column:r[3]?Number(r[3]):void 0}:null}function we(e){let t=e.ranges[0];return t?{lineNumber:e.lineNumber,column:t.start+1,endColumn:Math.max(t.start+1,t.end+1)}:{lineNumber:e.lineNumber}}function Te(e){return e.kind===`path`?{path:e.path}:{path:e.path,target:we(e)}}function Ee(e){let t=Ce(e);return t?{path:t.path,target:{lineNumber:t.lineNumber,column:t.column}}:null}function De({active:e,activeMatchIndex:t,jumpTarget:n,listboxId:r}){if(e)return n?`${r}-jump`:t>=0?`${r}-${t}`:void 0}function Oe(e,t){let n=t.trim().replace(/^\.\/+/,``).toLowerCase();if(!e||!n)return null;let r=e.toLowerCase().indexOf(n);return r===-1?null:{start:r,end:r+n.length}}function ke(e,t){if(t===0)return!0;let n=e[t-1]??``,r=e[t]??``;return/[-_\s./\\]/.test(n)?!0:/[a-z0-9]/.test(n)&&/[A-Z]/.test(r)}function Ae(e,t,n){let r=[],i=0;for(let a=0;a<e.length&&i<t.length;a+=1)n&&!ke(e,a)||e[a]?.toLowerCase()===t[i]&&(r.push({start:a,end:a+1}),i+=1);return i===t.length?r:[]}function je(e,t){let n=t.trim().replace(/^\.\/+/,``).toLowerCase();if(!e||!n||n.length>6)return[];let r=Ae(e,n,!0);return r.length>0?r:Ae(e,n,!1)}function Me(e,t){let n=[];return t.map(t=>({start:Math.max(0,Math.min(e.length,t.start)),end:Math.max(0,Math.min(e.length,t.end))})).filter(e=>e.end>e.start).sort((e,t)=>e.start-t.start||e.end-t.end).forEach(e=>{let t=n[n.length-1];if(t&&e.start<=t.end){t.end=Math.max(t.end,e.end);return}n.push(e)}),n}function Ne(e,t){let n=Oe(e,t);return n?[n]:je(e,t)}function Pe(e,t=[]){let n=Me(e,t);if(n.length===0)return e;let r=[],i=0;return n.forEach((t,n)=>{t.start>i&&r.push(e.slice(i,t.start)),r.push((0,H.jsx)(`span`,{className:`code-file-search-highlight`,children:e.slice(t.start,t.end)},`${t.start}:${t.end}:${n}`)),i=t.end}),i<e.length&&r.push(e.slice(i)),r}function Fe(e,t){return Pe(e,Ne(e,t))}function Ie(e){let t=e.replace(/\\/g,`/`),n=t.lastIndexOf(`/`);return n===-1?{directory:``,name:t}:{directory:t.slice(0,n),name:t.slice(n+1)||t}}function Le(e){if(!e||typeof window>`u`)return null;let t=e.getBoundingClientRect();if(L()){let n=window.visualViewport,r=n?.offsetTop??0,i=n?.offsetLeft??0,a=n?.width??window.innerWidth,o=n?.height??window.innerHeight,s=e.closest(`.code-sidebar`)?.getBoundingClientRect(),c=Math.max(i+6,(s?.left??i)+6),l=Math.min(i+a-6,(s?.right??i+a)-6),u=r+o-t.bottom-10,d=t.top-r-10,f=u<120&&d>u,p=Math.max(72,Math.min(320,f?d:u));return{left:c,top:f?Math.max(r+6,t.top-p-4):Math.max(r+6,t.bottom+4),width:Math.max(180,l-c),maxHeight:p}}let n=Math.max(document.documentElement.clientWidth,window.innerWidth||0),r=Math.max(document.documentElement.clientHeight,window.innerHeight||0),i=Math.max(240,n-24),a=Math.min(620,i,Math.max(420,t.width)),o=Math.max(12,Math.min(t.left,n-a-12)),s=Math.min(t.bottom+6,r-12);return{left:o,top:s,width:a,maxHeight:Math.max(168,Math.min(420,r-s-12))}}function Re({path:e,query:t}){let{directory:n,name:r}=Ie(e);return(0,H.jsxs)(`span`,{className:`code-file-search-copy`,children:[(0,H.jsx)(`span`,{className:`code-file-search-name`,children:Fe(r,t)}),n&&(0,H.jsx)(`span`,{className:`code-file-search-directory`,children:Fe(n,t)})]})}function ze({activeMatchIndex:e,anchorRef:t,copy:n,containerRef:r,error:i,jumpTarget:a,listboxId:o,loading:s,matches:c,openFileError:l,query:u,showIgnoredSearch:d,timeoutMs:f,truncated:p,onOpenJumpQuery:m,onOpenMatch:h,onSearchIgnored:g,onSelectMatchIndex:_}){let[v,y]=(0,V.useState)(()=>Le(t.current)),b=(0,V.useCallback)(()=>{y(Le(t.current))},[t]);return(0,V.useLayoutEffect)(()=>{b();let e=t.current?.closest(`.code-project-list`);return window.addEventListener(`resize`,b),window.addEventListener(`scroll`,b,!0),window.visualViewport?.addEventListener(`resize`,b),window.visualViewport?.addEventListener(`scroll`,b),e?.addEventListener(`scroll`,b,{passive:!0}),()=>{window.removeEventListener(`resize`,b),window.removeEventListener(`scroll`,b,!0),window.visualViewport?.removeEventListener(`resize`,b),window.visualViewport?.removeEventListener(`scroll`,b),e?.removeEventListener(`scroll`,b)}},[t,b]),(0,H.jsx)(`div`,{ref:r,id:o,className:`code-file-search-results`,"data-testid":`code-file-search-results`,role:`listbox`,"aria-label":n.searchFilesOrJump,style:v?{left:v.left,top:v.top,width:v.width,maxHeight:v.maxHeight}:void 0,children:a?l?(0,H.jsx)(`div`,{className:`code-file-search-state error`,children:l}):(0,H.jsxs)(`button`,{id:`${o}-jump`,type:`button`,className:`code-file-search-result jump active`,onClick:()=>m(u),role:`option`,"aria-selected":`true`,children:[(0,H.jsx)(`span`,{className:`code-file-search-kind`,children:n.go}),(0,H.jsx)(Re,{path:a.path,query:u}),(0,H.jsx)(`span`,{className:`code-file-search-line`,children:a.lineNumber})]}):s?(0,H.jsx)(`div`,{className:`code-file-search-state`,children:n.searching}):i?(0,H.jsx)(`div`,{className:`code-file-search-state error`,children:i}):c.length===0?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`div`,{className:`code-file-search-state`,children:n.noMatches}),d&&(0,H.jsx)(`button`,{type:`button`,className:`code-file-search-ignored-action`,onClick:g,children:n.searchIgnoredFolders}),p&&(0,H.jsx)(`div`,{className:`code-file-search-state muted`,children:n.searchIncomplete(f)})]}):(0,H.jsxs)(H.Fragment,{children:[c.map((t,r)=>(0,H.jsxs)(`button`,{id:`${o}-${r}`,type:`button`,className:`code-file-search-result ${r===e?`active`:``}`,onPointerMove:e=>{e.pointerType===`mouse`&&_(r)},onClick:()=>h(t),title:t.entryType===`directory`?t.path:`${t.path}:${t.lineNumber}`,role:`option`,"aria-selected":r===e,children:[(0,H.jsx)(`img`,{className:`code-file-type-icon ${t.entryType===`directory`?`folder`:`file`}`,src:t.entryType===`directory`?se(t.path,!1):R(t.path),alt:``,"aria-hidden":`true`}),(0,H.jsx)(Re,{path:t.path,query:u}),t.kind===`path`?(0,H.jsx)(`span`,{className:`code-file-search-kind`,children:t.entryType===`directory`?n.folder:n.file}):(0,H.jsx)(`span`,{className:`code-file-search-line`,children:t.lineNumber}),t.lines&&(0,H.jsx)(`span`,{className:`code-file-search-preview`,children:Pe(t.lines,t.ranges)})]},`${t.path}:${t.lineNumber}:${r}`)),d&&(0,H.jsx)(`button`,{type:`button`,className:`code-file-search-ignored-action`,onClick:g,children:n.searchIgnoredFolders}),p&&(0,H.jsx)(`div`,{className:`code-file-search-state muted`,children:n.moreMatchesOmitted})]})})}var Be=12;function Ve(e,t){return e===`git`?t.containsUncommittedChanges:e===`external`?t.changedOnDisk:e===`dirty`?t.unsavedChanges:t.changedOnDisk}function He(e){return{"--file-indent":`${6+e*Be}px`,"--file-status-indent":`${24+e*Be}px`,"--file-guide-width":`${e*Be}px`,"--file-depth":e}}function Ue(e){return e===`untracked`?void 0:e}function We(e){let t=Ue(e);return t?`code-file-descendant-status ${t}`:``}function Ge(e,t){for(let n of e)if(T(t,n))return!0;return!1}function Ke({activeFilePath:e,editorDirtyFilePaths:t,editorExternalChangedFilePaths:n,openFilePendingPath:r,item:i,isFocused:a,isOpen:o,isSelected:s}){let c=i.type===`directory`,l=e===i.path,u=c&&i.loading===!0,d=!c&&r===i.path,f=!c&&t.has(i.path),p=!c&&n.has(i.path),m=c&&Ge(t,i.path),h=c&&Ge(n,i.path),g=Ue(i.gitStatus),_=Ue(i.descendantGitStatus),v=g?i.gitStatusLabel:void 0,y=!!g,b=c&&!!_,x=c&&(b||m||h),S=_??(h?`external`:m?`dirty`:void 0),C=_?We(_):S?`code-file-descendant-status ${S}`:``,w=b?`git`:h?`external`:m?`dirty`:null,T=p?`external`:f?`dirty`:void 0,E=T?`code-file-changed ${T}`:``,D=p?`external`:f?`dirty`:null,O=g?`code-file-git-status ${g}`:``;return{active:l,chevronState:c?o?`expanded`:`collapsed`:`placeholder`,directoryLoading:u,directoryDotClassName:C,directoryDotKind:S,directoryDotTitleKind:w,editorDirty:f,editorExternalChanged:p,fileChangedClassName:E,fileChangedKind:T,fileChangedTitleKind:D,fileOpening:d,hasDescendantGitStatus:b,hasEditorDirtyDescendant:m,hasEditorExternalChangedDescendant:h,isDirectory:c,rowClasses:[`code-file-row`,c?`directory`:`file`,l?`active`:``,f?`editor-dirty`:``,p?`editor-external-changed`:``,m?`editor-descendant-dirty`:``,h?`editor-descendant-external-changed`:``,a?`focused`:``,s?`selected`:``,u?`loading`:``,d?`opening`:``,i.ignored?`ignored`:``,i.symbolicLink?`symbolic-link`:``,i.external?`external-link`:``,i.linkError?`link-error`:``,y?`git-status`:``,g?`git-${g}`:``,b?`git-descendant`:``,_?`git-descendant-${_}`:``].filter(Boolean).join(` `),showDirectoryDot:x,visibleGitStatus:g,visibleGitStatusClassName:O,visibleGitStatusLabel:v}}function qe({label:e,options:t,testId:n,submenuTestId:r,onOpenDialog:i,onSelect:a}){let[o,c]=(0,V.useState)(!1),[l,u]=(0,V.useState)(`right`),d=(0,V.useRef)(null),f=(0,V.useRef)(null),p=(0,V.useRef)(null),m=(0,V.useRef)(null),h=t.length>0,g=(0,V.useCallback)(()=>{m.current!==null&&(window.clearTimeout(m.current),m.current=null)},[]),_=(0,V.useCallback)((e=f.current)=>{if(!h)return;g();let t=e?.getBoundingClientRect();t&&t.right+156+12>window.innerWidth?u(`left`):u(`right`),c(!0)},[g,h]),v=(0,V.useCallback)(()=>{g(),m.current=window.setTimeout(()=>{c(!1),m.current=null},120)},[g]),y=(0,V.useCallback)(e=>{_(e.currentTarget.querySelector(`button`))},[_]),x=(0,V.useCallback)(()=>{window.setTimeout(()=>{p.current?.querySelector(`button:not(:disabled)`)?.focus()},0)},[]),S=(0,V.useCallback)(e=>{h&&e.key===`ArrowRight`&&(e.preventDefault(),e.stopPropagation(),_(e.currentTarget),x())},[x,h,_]),C=(0,V.useCallback)(e=>{e.key===`ArrowLeft`&&(e.preventDefault(),e.stopPropagation(),c(!1),f.current?.focus())},[]);return(0,H.jsxs)(`div`,{ref:d,className:`code-agent-launch-submenu`,onPointerEnter:y,onPointerLeave:v,onFocus:()=>g(),onBlur:e=>{e.currentTarget.contains(e.relatedTarget)||c(!1)},children:[(0,H.jsxs)(`button`,{ref:f,type:`button`,role:`menuitem`,className:`code-agent-launch-submenu-trigger`,"data-testid":n,"aria-haspopup":h?`menu`:void 0,"aria-expanded":h?o:void 0,onClick:i,onKeyDown:S,children:[(0,H.jsx)(`span`,{children:e}),h&&(0,H.jsx)(B,{className:`code-agent-launch-submenu-arrow`})]}),h&&o&&(0,H.jsx)(`div`,{ref:p,className:`code-agent-launch-submenu-panel ${l}`,"data-testid":r,role:`menu`,onPointerEnter:()=>g(),onPointerLeave:v,onKeyDown:C,children:t.map(e=>(0,H.jsxs)(`button`,{type:`button`,role:`menuitem`,"data-testid":`agent-launch-${e.name}`,onClick:()=>a(e.command||e.name),children:[(0,H.jsx)(b,{name:e.name}),(0,H.jsx)(`span`,{children:s(e.name)})]},e.name))})]})}function Je({copy:e,agentLaunchOptions:t,fileMenu:n,menuRef:r,onClose:i,onCloseWithFocusRestore:a,onCopyRelativePath:o,onCopyShareUrl:s,onOpenNewAgent:c,onRefreshTarget:l,onStartAgent:u,onStartOperation:d,readOnly:f=!1}){let p=me({menuOpen:!!n,menuRef:r,onClose:i,onCloseWithFocusRestore:a});if(!n)return null;let m=n.item?.readOnly===!0,h=!f&&!m,g=!f&&(!m||n.item?.symbolicLink===!0);return(0,H.jsxs)(`div`,{ref:r,className:`code-context-menu code-file-context-menu`,"data-testid":`code-file-context-menu`,style:{left:n.x,top:n.y},role:`menu`,onKeyDown:p,onMouseDown:e=>{e.preventDefault(),e.stopPropagation()},children:[h&&(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`button`,{type:`button`,role:`menuitem`,autoFocus:!0,onClick:()=>d(`new-file`),children:e.newFile}),(0,H.jsx)(`button`,{type:`button`,role:`menuitem`,onClick:()=>d(`new-folder`),children:e.newFolder}),(0,H.jsx)(`div`,{className:`code-context-menu-separator`,role:`separator`}),(0,H.jsx)(qe,{label:e.newAgent,options:t,testId:`file-new-agent-submenu-trigger`,submenuTestId:`file-new-agent-submenu`,onOpenDialog:c,onSelect:u}),(0,H.jsx)(`div`,{className:`code-context-menu-separator`,role:`separator`})]}),(0,H.jsx)(`button`,{type:`button`,role:`menuitem`,onClick:l,children:e.refresh}),n.item&&(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`div`,{className:`code-context-menu-separator`,role:`separator`}),g&&(0,H.jsx)(`button`,{type:`button`,role:`menuitem`,onClick:()=>d(`rename`),children:e.rename}),(0,H.jsx)(`button`,{type:`button`,role:`menuitem`,onClick:o,children:e.copyRelativePath}),(n.item.type===`file`||n.item.type===`directory`)&&(0,H.jsx)(`button`,{type:`button`,role:`menuitem`,onClick:s,children:e.copyShareUrl}),g&&(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`div`,{className:`code-context-menu-separator`,role:`separator`}),(0,H.jsx)(`button`,{type:`button`,role:`menuitem`,className:`danger`,onClick:()=>d(`delete`),children:e.delete})]})]})]})}var Ye=220,Xe=8,Ze=26,Qe=11,$e=10;function et(e){return e?e.type===`directory`?e.path:w(e.path):``}function tt(e,t){return e===`rename`||e===`delete`?t?.name??``:``}function nt(e,t){return{kind:e,item:t,parentPath:et(t),name:tt(e,t)}}function rt(e){if(e.kind!==`rename`||e.item?.type!==`file`)return e.name.length;let t=e.name.lastIndexOf(`.`);return t>0?t:e.name.length}function it(e){let t=e.name.trim();if(e.kind!==`rename`||e.item?.type!==`file`)return t;let n=e.item.name.lastIndexOf(`.`);if(n<=0)return t;let r=e.item.name.slice(n);return t.endsWith(`${r}${r}`)?t.slice(0,-r.length):t}function at(e,t){switch(e.kind){case`new-file`:return t.newFile;case`new-folder`:return t.newFolder;case`rename`:return t.rename;case`delete`:return t.delete}}function U(e,t,n,r,i,a=0){let o=n?8:4,s=n?4:2,c=a>0?$e+a*Ze:0,l=$e+o*Ze+s*Qe+c;return{x:Math.max(Xe,Math.min(e,r-Ye-Xe)),y:Math.max(Xe,Math.min(t,i-l-Xe))}}function ot({agentId:e,copy:t,fileOperation:n,inputRef:r,onCancel:i,onInputName:a,onSubmit:o,onUpdateName:s}){return!n||n.kind===`rename`?null:(0,H.jsx)(`div`,{className:n.kind===`delete`?`code-file-operation-shell delete-confirm`:`code-file-operation-shell`,"data-testid":`code-file-operation-backdrop`,onMouseDown:e=>{e.stopPropagation(),n.kind===`delete`&&e.target===e.currentTarget&&i()},children:(0,H.jsxs)(`form`,{className:`code-file-operation-dialog`,"data-testid":`code-file-operation-dialog`,role:`dialog`,"aria-labelledby":`code-file-operation-title`,autoComplete:`off`,onMouseDown:e=>e.stopPropagation(),onKeyDown:e=>{e.key===`Escape`&&(e.preventDefault(),i())},onSubmit:e=>{e.preventDefault(),o()},children:[(0,H.jsx)(`label`,{id:`code-file-operation-title`,htmlFor:`code-file-operation-input`,children:at(n,t)}),n.kind===`delete`?(0,H.jsx)(`p`,{className:`code-file-operation-text`,children:n.item?.type===`directory`?t.deleteFolderContents(n.item?.path):t.deleteFile(n.item?.path)}):(0,H.jsx)(`input`,{id:`code-file-operation-input`,"data-testid":`code-file-operation-input`,name:`farming-file-${e}-${n.kind}`,type:`text`,inputMode:`text`,ref:r,value:n.name,autoComplete:`off`,"aria-autocomplete":`none`,autoCapitalize:`none`,autoCorrect:`off`,spellCheck:!1,enterKeyHint:`done`,"data-lpignore":`true`,"data-1p-ignore":`true`,"data-bwignore":`true`,"data-form-type":`other`,autoFocus:!0,onInput:e=>{a(e.currentTarget.value)},onChange:e=>{s(e.target.value)},onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),e.stopPropagation(),o())}}),(0,H.jsxs)(`div`,{className:`code-rename-actions`,children:[(0,H.jsx)(`button`,{type:`button`,onClick:i,children:t.cancel}),(0,H.jsx)(`button`,{type:`submit`,className:n.kind===`delete`?`danger`:`primary`,disabled:n.kind!==`delete`&&!n.name.trim(),children:n.kind===`delete`?t.delete:t.save})]})]})})}function st({agentId:e,copy:t,agentLaunchOptions:n,fileMenu:r,fileMenuRef:i,fileOperation:a,fileOperationInputRef:o,onCloseFileMenu:s,onCloseFileMenuWithFocusRestore:c,onCloseFileOperation:l,onCopyFileMenuPath:u,onCopyFileMenuShareUrl:d,onOpenNewAgent:f,onRefreshFileMenuTarget:p,onRememberFileOperationName:m,onStartAgent:h,onStartFileMenuOperation:g,onSubmitFileOperation:_,onUpdateFileOperationName:v,readOnly:y=!1}){return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(Je,{copy:t,agentLaunchOptions:n,fileMenu:r,menuRef:i,onClose:s,onCloseWithFocusRestore:c,onCopyRelativePath:u,onCopyShareUrl:d,onOpenNewAgent:f,onRefreshTarget:p,onStartAgent:h,onStartOperation:g,readOnly:y}),(0,H.jsx)(ot,{agentId:e,copy:t,fileOperation:a,inputRef:o,onCancel:l,onInputName:m,onSubmit:()=>{_()},onUpdateName:v})]})}var ct=n((e=>{var t=r();function n(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}var i=typeof Object.is==`function`?Object.is:n,a=t.useState,o=t.useEffect,s=t.useLayoutEffect,c=t.useDebugValue;function l(e,t){var n=t(),r=a({inst:{value:n,getSnapshot:t}}),i=r[0].inst,l=r[1];return s(function(){i.value=n,i.getSnapshot=t,u(i)&&l({inst:i})},[e,n,t]),o(function(){return u(i)&&l({inst:i}),e(function(){u(i)&&l({inst:i})})},[e]),c(n),n}function u(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!i(e,n)}catch{return!0}}function d(e,t){return t()}var f=typeof window>`u`||window.document===void 0||window.document.createElement===void 0?d:l;e.useSyncExternalStore=t.useSyncExternalStore===void 0?f:t.useSyncExternalStore})),lt=n(((e,t)=>{t.exports=ct()})),ut=(0,V.createContext)(null);function W(){let e=(0,V.useContext)(ut);if(e===null)throw Error(`No Tree Api Provided`);return e}var dt=(0,V.createContext)(null);function ft(){let e=(0,V.useContext)(dt);if(e===null)throw Error(`Provide a NodesContext`);return e}var pt=(0,V.createContext)(null);function mt(){let e=(0,V.useContext)(pt);if(e===null)throw Error(`Provide a DnDContext`);return e}var ht=(0,V.createContext)(0);function gt(){(0,V.useContext)(ht)}var _t=e({access:()=>Mt,bound:()=>vt,dfs:()=>Tt,focusNextElement:()=>Dt,focusPrevElement:()=>Ot,getInsertIndex:()=>Rt,getInsertParentId:()=>Vt,getTreeLinePrefix:()=>Bt,identify:()=>Pt,identifyNull:()=>Nt,indexOf:()=>Ct,isClosed:()=>bt,isDescendant:()=>St,isItem:()=>yt,isOpenWithEmptyChildren:()=>xt,mergeRefs:()=>Ft,noop:()=>wt,safeRun:()=>It,waitFor:()=>Lt,walk:()=>Et});function vt(e,t,n){return Math.max(Math.min(e,n),t)}function yt(e){return e&&e.isLeaf}function bt(e){return e&&e.isInternal&&!e.isOpen}function xt(e){return e&&e.isOpen&&!e.children?.length}var St=(e,t)=>{let n=e;for(;n;){if(n.id===t.id)return!0;n=n.parent}return!1},Ct=e=>{if(!e.parent)throw Error(`Node does not have a parent`);return e.parent.children.findIndex(t=>t.id===e.id)};function wt(){}function Tt(e,t){if(!e)return null;if(e.id===t)return e;if(e.children)for(let n of e.children){let e=Tt(n,t);if(e)return e}return null}function Et(e,t){if(t(e),e.children)for(let n of e.children)Et(n,t)}function Dt(e){let t=jt(e),n;for(let r=0;r<t.length;++r)if(t[r]===e){n=kt(t,r);break}n?.focus()}function Ot(e){let t=jt(e),n;for(let r=0;r<t.length;++r)if(t[r]===e){n=At(t,r);break}n?.focus()}function kt(e,t){return t+1<e.length?e[t+1]:e[0]}function At(e,t){return t-1>=0?e[t-1]:e[e.length-1]}function jt(e){return Array.from(document.querySelectorAll(`button:not([disabled]), [href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"]):not([disabled]), details:not([disabled]), summary:not(:disabled)`)).filter(t=>t===e||!e.contains(t))}function Mt(e,t){return typeof t==`boolean`?t:typeof t==`string`?e[t]:t(e)}function Nt(e){return e===null?null:Pt(e)}function Pt(e){return typeof e==`string`?e:e.id}function Ft(...e){return t=>{e.forEach(e=>{typeof e==`function`?e(t):e!=null&&(e.current=t)})}}function It(e,...t){if(e)return e(...t)}function Lt(e){return new Promise((t,n)=>{let r=0;function i(){r+=1,r===100&&n(),e()?t():setTimeout(i,10)}i()})}function Rt(e){let t=e.focusedNode;return t?t.isOpen?0:t.parent?t.childIndex+1:0:e.root.children?.length??0}var zt={last:`└ `,middle:`├ `,pipe:`│ `,blank:`  `};function Bt(e,t={}){let n=Object.assign(Object.assign({},zt),t);if(e.level===0)return``;let r=e.nextSibling===null?n.last:n.middle,i=e.parent;for(;i&&i.level>0;)r=(i.nextSibling===null?n.blank:n.pipe)+r,i=i.parent;return r}function Vt(e){let t=e.focusedNode;return t?t.isOpen?t.id:t.parent&&!t.parent.isRoot?t.parent.id:null:null}var Ht={display:`flex`,alignItems:`center`,zIndex:1},Ut={flex:1,height:`2px`,background:`#4B91E2`,borderRadius:`1px`},Wt={width:`4px`,height:`4px`,boxShadow:`0 0 0 3px #4B91E2`,borderRadius:`50%`},Gt=V.memo(function({top:e,left:t,indent:n}){let r={position:`absolute`,pointerEvents:`none`,top:e-2+`px`,left:t+`px`,right:n+`px`};return(0,H.jsxs)(`div`,{style:Object.assign(Object.assign({},Ht),r),children:[(0,H.jsx)(`div`,{style:Object.assign({},Wt)}),(0,H.jsx)(`div`,{style:Object.assign({},Ut)})]})});function Kt({node:e,attrs:t,innerRef:n,children:r}){return(0,H.jsx)(`div`,Object.assign({},t,{ref:n,onFocus:e=>e.stopPropagation(),onClick:e.handleClick,children:r}))}function qt(e){return(0,H.jsxs)(`div`,{ref:e.dragHandle,style:e.style,children:[(0,H.jsx)(`span`,{onClick:t=>{t.stopPropagation(),e.node.toggle()},children:e.node.isLeaf?`🌳`:e.node.isOpen?`🗁`:`🗀`}),` `,e.node.isEditing?(0,H.jsx)(Yt,Object.assign({},e)):(0,H.jsx)(Jt,Object.assign({},e))]})}function Jt(e){return(0,H.jsx)(H.Fragment,{children:(0,H.jsx)(`span`,{children:e.node.data.name})})}function Yt({node:e}){let t=(0,V.useRef)();return(0,V.useEffect)(()=>{var e,n;(e=t.current)==null||e.focus(),(n=t.current)==null||n.select()},[]),(0,H.jsx)(`input`,{ref:t,defaultValue:e.data.name,onBlur:()=>e.reset(),onKeyDown:n=>{n.key===`Escape`&&e.reset(),n.key===`Enter`&&e.submit(t.current?.value||``)}})}var Xt=`__REACT_ARBORIST_INTERNAL_ROOT__`;function Zt(e){function t(n,r,i){let a=new Qt({tree:e,data:n,level:r,parent:i,id:e.accessId(n),children:null,isDraggable:e.isDraggable(n),rowIndex:null}),o=e.accessChildren(n);return o&&(a.children=o.map(e=>t(e,r+1,a))),a}let n=new Qt({tree:e,id:Xt,data:{id:Xt},level:-1,parent:null,children:null,isDraggable:!0,rowIndex:null});return n.children=(e.props.data??[]).map(e=>t(e,0,n)),n}var Qt=class e{constructor(e){this.handleClick=e=>{(e.metaKey||e.ctrlKey)&&!this.tree.props.disableMultiSelection?this.isSelected?this.deselect():this.selectMulti():e.shiftKey&&!this.tree.props.disableMultiSelection?this.selectContiguous():(this.select(),this.activate())},this.tree=e.tree,this.id=e.id,this.data=e.data,this.level=e.level,this.children=e.children,this.parent=e.parent,this.isDraggable=e.isDraggable,this.rowIndex=e.rowIndex}get isRoot(){return this.id===Xt}get isLeaf(){return!Array.isArray(this.children)}get isInternal(){return!this.isLeaf}get isOpen(){return this.isLeaf?!1:this.tree.isOpen(this.id)}get isClosed(){return this.isLeaf?!1:!this.tree.isOpen(this.id)}get isEditable(){return this.tree.isEditable(this.data)}get isSelectable(){return this.tree.isSelectable(this.data)}get isEditing(){return this.tree.editingId===this.id}get isSelected(){return this.tree.isSelected(this.id)}get isOnlySelection(){return this.isSelected&&this.tree.hasOneSelection}get isSelectedStart(){return this.isSelected&&!this.prev?.isSelected}get isSelectedEnd(){return this.isSelected&&!this.next?.isSelected}get isFocused(){return this.tree.isFocused(this.id)}get isDragging(){return this.tree.isDragging(this.id)}get willReceiveDrop(){return this.tree.willReceiveDrop(this.id)}get state(){return{isClosed:this.isClosed,isDragging:this.isDragging,isEditing:this.isEditing,isFocused:this.isFocused,isInternal:this.isInternal,isLeaf:this.isLeaf,isOpen:this.isOpen,isSelected:this.isSelected,isSelectedEnd:this.isSelectedEnd,isSelectedStart:this.isSelectedStart,willReceiveDrop:this.willReceiveDrop}}get childIndex(){return this.parent&&this.parent.children?this.parent.children.findIndex(e=>e.id===this.id):-1}get next(){return this.rowIndex===null?null:this.tree.at(this.rowIndex+1)}get prev(){return this.rowIndex===null?null:this.tree.at(this.rowIndex-1)}get nextSibling(){let e=this.childIndex;return this.parent?.children[e+1]??null}isAncestorOf(e){if(!e)return!1;let t=e;for(;t;){if(t.id===this.id)return!0;t=t.parent}return!1}select(){this.tree.select(this)}deselect(){this.tree.deselect(this)}selectMulti(){this.tree.selectMulti(this)}selectContiguous(){this.tree.selectContiguous(this)}activate(){this.tree.activate(this)}focus(){this.tree.focus(this)}toggle(){this.tree.toggle(this)}open(){this.tree.open(this)}openParents(){this.tree.openParents(this)}close(){this.tree.close(this)}submit(e){this.tree.submit(this,e)}reset(){this.tree.reset()}clone(){return new e(Object.assign({},this))}edit(){return this.tree.edit(this)}};function $t(e){return{type:`EDIT`,id:e}}function en(e={id:null},t){return t.type===`EDIT`?Object.assign(Object.assign({},e),{id:t.id}):e}function tn(e){return{type:`FOCUS`,id:e}}function nn(){return{type:`TREE_BLUR`}}function rn(e={id:null,treeFocused:!1},t){return t.type===`FOCUS`?Object.assign(Object.assign({},e),{id:t.id,treeFocused:!0}):t.type===`TREE_BLUR`?Object.assign(Object.assign({},e),{treeFocused:!1}):e}var an={open(e,t){return{type:`VISIBILITY_OPEN`,id:e,filtered:t}},close(e,t){return{type:`VISIBILITY_CLOSE`,id:e,filtered:t}},toggle(e,t){return{type:`VISIBILITY_TOGGLE`,id:e,filtered:t}},clear(e){return{type:`VISIBILITY_CLEAR`,filtered:e}}};function on(e={},t){if(t.type===`VISIBILITY_OPEN`)return Object.assign(Object.assign({},e),{[t.id]:!0});if(t.type===`VISIBILITY_CLOSE`)return Object.assign(Object.assign({},e),{[t.id]:!1});if(t.type===`VISIBILITY_TOGGLE`){let n=e[t.id];return Object.assign(Object.assign({},e),{[t.id]:!n})}else if(t.type===`VISIBILITY_CLEAR`)return{};else return e}function sn(e={filtered:{},unfiltered:{}},t){return t.type.startsWith(`VISIBILITY`)?t.filtered?Object.assign(Object.assign({},e),{filtered:on(e.filtered,t)}):Object.assign(Object.assign({},e),{unfiltered:on(e.unfiltered,t)}):e}var cn=e=>({nodes:{open:{filtered:{},unfiltered:e?.initialOpenState??{}},focus:{id:null,treeFocused:!1},edit:{id:null},drag:{id:null,selectedIds:[],destinationParentId:null,destinationIndex:null},selection:{ids:new Set,anchor:null,mostRecent:null}},dnd:{cursor:{type:`none`},dragId:null,dragIds:[],parentId:null,index:-1}}),ln={clear:()=>({type:`SELECTION_CLEAR`}),only:e=>({type:`SELECTION_ONLY`,id:Pt(e)}),add:e=>({type:`SELECTION_ADD`,ids:(Array.isArray(e)?e:[e]).map(Pt)}),remove:e=>({type:`SELECTION_REMOVE`,ids:(Array.isArray(e)?e:[e]).map(Pt)}),set:e=>Object.assign({type:`SELECTION_SET`},e),mostRecent:e=>({type:`SELECTION_MOST_RECENT`,id:e===null?null:Pt(e)}),anchor:e=>({type:`SELECTION_ANCHOR`,id:e===null?null:Pt(e)})};function un(e=cn().nodes.selection,t){let n=e.ids;switch(t.type){case`SELECTION_CLEAR`:return Object.assign(Object.assign({},e),{ids:new Set});case`SELECTION_ONLY`:return Object.assign(Object.assign({},e),{ids:new Set([t.id])});case`SELECTION_ADD`:return t.ids.length===0?e:(t.ids.forEach(e=>n.add(e)),Object.assign(Object.assign({},e),{ids:new Set(n)}));case`SELECTION_REMOVE`:return t.ids.length===0?e:(t.ids.forEach(e=>n.delete(e)),Object.assign(Object.assign({},e),{ids:new Set(n)}));case`SELECTION_SET`:return Object.assign(Object.assign({},e),{ids:t.ids,mostRecent:t.mostRecent,anchor:t.anchor});case`SELECTION_MOST_RECENT`:return Object.assign(Object.assign({},e),{mostRecent:t.id});case`SELECTION_ANCHOR`:return Object.assign(Object.assign({},e),{anchor:t.id});default:return e}}var dn={cursor(e){return{type:`DND_CURSOR`,cursor:e}},dragStart(e,t){return{type:`DND_DRAG_START`,id:e,dragIds:t}},dragEnd(){return{type:`DND_DRAG_END`}},hovering(e,t){return{type:`DND_HOVERING`,parentId:e,index:t}}};function fn(e=cn().dnd,t){switch(t.type){case`DND_CURSOR`:return Object.assign(Object.assign({},e),{cursor:t.cursor});case`DND_DRAG_START`:return Object.assign(Object.assign({},e),{dragId:t.id,dragIds:t.dragIds});case`DND_DRAG_END`:return cn().dnd;case`DND_HOVERING`:return Object.assign(Object.assign({},e),{parentId:t.parentId,index:t.index});default:return e}}var pn={position:`fixed`,pointerEvents:`none`,zIndex:100,left:0,top:0,width:`100%`,height:`100%`},mn=e=>{if(!e)return{display:`none`};let{x:t,y:n}=e;return{transform:`translate(${t}px, ${n}px)`}},hn=e=>{if(!e)return{display:`none`};let{x:t,y:n}=e;return{transform:`translate(${t+10}px, ${n+10}px)`}};function gn({offset:e,mouse:t,id:n,dragIds:r,isDragging:i}){return(0,H.jsxs)(_n,{isDragging:i,children:[(0,H.jsx)(vn,{offset:e,children:(0,H.jsx)(bn,{id:n,dragIds:r})}),(0,H.jsx)(yn,{mouse:t,count:r.length})]})}var _n=(0,V.memo)(function(e){return e.isDragging?(0,H.jsx)(`div`,{style:pn,children:e.children}):null});function vn(e){return(0,H.jsx)(`div`,{className:`row preview`,style:mn(e.offset),children:e.children})}function yn(e){let{count:t,mouse:n}=e;return t>1?(0,H.jsx)(`div`,{className:`selected-count`,style:hn(n),children:t}):null}var bn=(0,V.memo)(function(e){let t=W(),n=t.get(e.id);return n?(0,H.jsx)(t.renderNode,{preview:!0,node:n,style:{paddingLeft:n.level*t.indent,opacity:.2,background:`transparent`},tree:t}):null});function xn(){return xn=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},xn.apply(null,arguments)}function Sn(e){if(e===void 0)throw ReferenceError(`this hasn't been initialised - super() hasn't been called`);return e}function Cn(e,t){return Cn=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},Cn(e,t)}function wn(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,Cn(e,t)}var Tn=Number.isNaN||function(e){return typeof e==`number`&&e!==e};function En(e,t){return!!(e===t||Tn(e)&&Tn(t))}function Dn(e,t){if(e.length!==t.length)return!1;for(var n=0;n<e.length;n++)if(!En(e[n],t[n]))return!1;return!0}function On(e,t){t===void 0&&(t=Dn);var n,r=[],i,a=!1;function o(){var o=[...arguments];return a&&n===this&&t(o,r)?i:(i=e.apply(this,o),a=!0,n=this,r=o,i)}return o}var kn=typeof performance==`object`&&typeof performance.now==`function`?function(){return performance.now()}:function(){return Date.now()};function An(e){cancelAnimationFrame(e.id)}function jn(e,t){var n=kn();function r(){kn()-n>=t?e.call(null):i.id=requestAnimationFrame(r)}var i={id:requestAnimationFrame(r)};return i}var Mn=-1;function Nn(e){if(e===void 0&&(e=!1),Mn===-1||e){var t=document.createElement(`div`),n=t.style;n.width=`50px`,n.height=`50px`,n.overflow=`scroll`,document.body.appendChild(t),Mn=t.offsetWidth-t.clientWidth,document.body.removeChild(t)}return Mn}var Pn=null;function Fn(e){if(e===void 0&&(e=!1),Pn===null||e){var t=document.createElement(`div`),n=t.style;n.width=`50px`,n.height=`50px`,n.overflow=`scroll`,n.direction=`rtl`;var r=document.createElement(`div`),i=r.style;return i.width=`100px`,i.height=`100px`,t.appendChild(r),document.body.appendChild(t),t.scrollLeft>0?Pn=`positive-descending`:(t.scrollLeft=1,Pn=t.scrollLeft===0?`negative`:`positive-ascending`),document.body.removeChild(t),Pn}return Pn}var In=150,Ln=function(e,t){return e};function Rn(e){var t,n=e.getItemOffset,r=e.getEstimatedTotalSize,i=e.getItemSize,a=e.getOffsetForIndexAndAlignment,o=e.getStartIndexForOffset,s=e.getStopIndexForStartIndex,c=e.initInstanceProps,l=e.shouldResetStyleCacheOnItemSizeChange,u=e.validateProps;return t=function(e){wn(t,e);function t(t){var r=e.call(this,t)||this;return r._instanceProps=c(r.props,Sn(r)),r._outerRef=void 0,r._resetIsScrollingTimeoutId=null,r.state={instance:Sn(r),isScrolling:!1,scrollDirection:`forward`,scrollOffset:typeof r.props.initialScrollOffset==`number`?r.props.initialScrollOffset:0,scrollUpdateWasRequested:!1},r._callOnItemsRendered=void 0,r._callOnItemsRendered=On(function(e,t,n,i){return r.props.onItemsRendered({overscanStartIndex:e,overscanStopIndex:t,visibleStartIndex:n,visibleStopIndex:i})}),r._callOnScroll=void 0,r._callOnScroll=On(function(e,t,n){return r.props.onScroll({scrollDirection:e,scrollOffset:t,scrollUpdateWasRequested:n})}),r._getItemStyle=void 0,r._getItemStyle=function(e){var t=r.props,a=t.direction,o=t.itemSize,s=t.layout,c=r._getItemStyleCache(l&&o,l&&s,l&&a),u;if(c.hasOwnProperty(e))u=c[e];else{var d=n(r.props,e,r._instanceProps),f=i(r.props,e,r._instanceProps),p=a===`horizontal`||s===`horizontal`,m=a===`rtl`,h=p?d:0;c[e]=u={position:`absolute`,left:m?void 0:h,right:m?h:void 0,top:p?0:d,height:p?`100%`:f,width:p?f:`100%`}}return u},r._getItemStyleCache=void 0,r._getItemStyleCache=On(function(e,t,n){return{}}),r._onScrollHorizontal=function(e){var t=e.currentTarget,n=t.clientWidth,i=t.scrollLeft,a=t.scrollWidth;r.setState(function(e){if(e.scrollOffset===i)return null;var t=r.props.direction,o=i;if(t===`rtl`)switch(Fn()){case`negative`:o=-i;break;case`positive-descending`:o=a-n-i;break}return o=Math.max(0,Math.min(o,a-n)),{isScrolling:!0,scrollDirection:e.scrollOffset<o?`forward`:`backward`,scrollOffset:o,scrollUpdateWasRequested:!1}},r._resetIsScrollingDebounced)},r._onScrollVertical=function(e){var t=e.currentTarget,n=t.clientHeight,i=t.scrollHeight,a=t.scrollTop;r.setState(function(e){if(e.scrollOffset===a)return null;var t=Math.max(0,Math.min(a,i-n));return{isScrolling:!0,scrollDirection:e.scrollOffset<t?`forward`:`backward`,scrollOffset:t,scrollUpdateWasRequested:!1}},r._resetIsScrollingDebounced)},r._outerRefSetter=function(e){var t=r.props.outerRef;r._outerRef=e,typeof t==`function`?t(e):typeof t==`object`&&t&&t.hasOwnProperty(`current`)&&(t.current=e)},r._resetIsScrollingDebounced=function(){r._resetIsScrollingTimeoutId!==null&&An(r._resetIsScrollingTimeoutId),r._resetIsScrollingTimeoutId=jn(r._resetIsScrolling,In)},r._resetIsScrolling=function(){r._resetIsScrollingTimeoutId=null,r.setState({isScrolling:!1},function(){r._getItemStyleCache(-1,null)})},r}t.getDerivedStateFromProps=function(e,t){return zn(e,t),u(e),null};var d=t.prototype;return d.scrollTo=function(e){e=Math.max(0,e),this.setState(function(t){return t.scrollOffset===e?null:{scrollDirection:t.scrollOffset<e?`forward`:`backward`,scrollOffset:e,scrollUpdateWasRequested:!0}},this._resetIsScrollingDebounced)},d.scrollToItem=function(e,t){t===void 0&&(t=`auto`);var n=this.props,r=n.itemCount,i=n.layout,o=this.state.scrollOffset;e=Math.max(0,Math.min(e,r-1));var s=0;if(this._outerRef){var c=this._outerRef;s=i===`vertical`?c.scrollWidth>c.clientWidth?Nn():0:c.scrollHeight>c.clientHeight?Nn():0}this.scrollTo(a(this.props,e,t,o,this._instanceProps,s))},d.componentDidMount=function(){var e=this.props,t=e.direction,n=e.initialScrollOffset,r=e.layout;if(typeof n==`number`&&this._outerRef!=null){var i=this._outerRef;t===`horizontal`||r===`horizontal`?i.scrollLeft=n:i.scrollTop=n}this._callPropsCallbacks()},d.componentDidUpdate=function(){var e=this.props,t=e.direction,n=e.layout,r=this.state,i=r.scrollOffset;if(r.scrollUpdateWasRequested&&this._outerRef!=null){var a=this._outerRef;if(t===`horizontal`||n===`horizontal`)if(t===`rtl`)switch(Fn()){case`negative`:a.scrollLeft=-i;break;case`positive-ascending`:a.scrollLeft=i;break;default:var o=a.clientWidth;a.scrollLeft=a.scrollWidth-o-i;break}else a.scrollLeft=i;else a.scrollTop=i}this._callPropsCallbacks()},d.componentWillUnmount=function(){this._resetIsScrollingTimeoutId!==null&&An(this._resetIsScrollingTimeoutId)},d.render=function(){var e=this.props,t=e.children,n=e.className,i=e.direction,a=e.height,o=e.innerRef,s=e.innerElementType,c=e.innerTagName,l=e.itemCount,u=e.itemData,d=e.itemKey,f=d===void 0?Ln:d,p=e.layout,m=e.outerElementType,h=e.outerTagName,g=e.style,_=e.useIsScrolling,v=e.width,y=this.state.isScrolling,b=i===`horizontal`||p===`horizontal`,x=b?this._onScrollHorizontal:this._onScrollVertical,S=this._getRangeToRender(),C=S[0],w=S[1],T=[];if(l>0)for(var E=C;E<=w;E++)T.push((0,V.createElement)(t,{data:u,key:f(E,u),index:E,isScrolling:_?y:void 0,style:this._getItemStyle(E)}));var D=r(this.props,this._instanceProps);return(0,V.createElement)(m||h||`div`,{className:n,onScroll:x,ref:this._outerRefSetter,style:xn({position:`relative`,height:a,width:v,overflow:`auto`,WebkitOverflowScrolling:`touch`,willChange:`transform`,direction:i},g)},(0,V.createElement)(s||c||`div`,{children:T,ref:o,style:{height:b?`100%`:D,pointerEvents:y?`none`:void 0,width:b?D:`100%`}}))},d._callPropsCallbacks=function(){if(typeof this.props.onItemsRendered==`function`&&this.props.itemCount>0){var e=this._getRangeToRender(),t=e[0],n=e[1],r=e[2],i=e[3];this._callOnItemsRendered(t,n,r,i)}if(typeof this.props.onScroll==`function`){var a=this.state,o=a.scrollDirection,s=a.scrollOffset,c=a.scrollUpdateWasRequested;this._callOnScroll(o,s,c)}},d._getRangeToRender=function(){var e=this.props,t=e.itemCount,n=e.overscanCount,r=this.state,i=r.isScrolling,a=r.scrollDirection,c=r.scrollOffset;if(t===0)return[0,0,0,0];var l=o(this.props,c,this._instanceProps),u=s(this.props,l,c,this._instanceProps),d=!i||a===`backward`?Math.max(1,n):1,f=!i||a===`forward`?Math.max(1,n):1;return[Math.max(0,l-d),Math.max(0,Math.min(t-1,u+f)),l,u]},t}(V.PureComponent),t.defaultProps={direction:`ltr`,itemData:void 0,layout:`vertical`,overscanCount:2,useIsScrolling:!1},t}var zn=function(e,t){e.children,e.direction,e.height,e.layout,e.innerTagName,e.outerTagName,e.width,t.instance},Bn=50,Vn=function(e,t,n){var r=e.itemSize,i=n.itemMetadataMap,a=n.lastMeasuredIndex;if(t>a){var o=0;if(a>=0){var s=i[a];o=s.offset+s.size}for(var c=a+1;c<=t;c++){var l=r(c);i[c]={offset:o,size:l},o+=l}n.lastMeasuredIndex=t}return i[t]},Hn=function(e,t,n){var r=t.itemMetadataMap,i=t.lastMeasuredIndex;return(i>0?r[i].offset:0)>=n?Un(e,t,i,0,n):Wn(e,t,Math.max(0,i),n)},Un=function(e,t,n,r,i){for(;r<=n;){var a=r+Math.floor((n-r)/2),o=Vn(e,a,t).offset;if(o===i)return a;o<i?r=a+1:o>i&&(n=a-1)}return r>0?r-1:0},Wn=function(e,t,n,r){for(var i=e.itemCount,a=1;n<i&&Vn(e,n,t).offset<r;)n+=a,a*=2;return Un(e,t,Math.min(n,i-1),Math.floor(n/2),r)},Gn=function(e,t){var n=e.itemCount,r=t.itemMetadataMap,i=t.estimatedItemSize,a=t.lastMeasuredIndex,o=0;if(a>=n&&(a=n-1),a>=0){var s=r[a];o=s.offset+s.size}var c=(n-a-1)*i;return o+c},Kn=Rn({getItemOffset:function(e,t,n){return Vn(e,t,n).offset},getItemSize:function(e,t,n){return n.itemMetadataMap[t].size},getEstimatedTotalSize:Gn,getOffsetForIndexAndAlignment:function(e,t,n,r,i,a){var o=e.direction,s=e.height,c=e.layout,l=e.width,u=o===`horizontal`||c===`horizontal`?l:s,d=Vn(e,t,i),f=Gn(e,i),p=Math.max(0,Math.min(f-u,d.offset)),m=Math.max(0,d.offset-u+d.size+a);switch(n===`smart`&&(n=r>=m-u&&r<=p+u?`auto`:`center`),n){case`start`:return p;case`end`:return m;case`center`:return Math.round(m+(p-m)/2);default:return r>=m&&r<=p?r:r<m?m:p}},getStartIndexForOffset:function(e,t,n){return Hn(e,n,t)},getStopIndexForStartIndex:function(e,t,n,r){for(var i=e.direction,a=e.height,o=e.itemCount,s=e.layout,c=e.width,l=i===`horizontal`||s===`horizontal`?c:a,u=Vn(e,t,r),d=n+l,f=u.offset+u.size,p=t;p<o-1&&f<d;)p++,f+=Vn(e,p,r).size;return p},initInstanceProps:function(e,t){var n={itemMetadataMap:{},estimatedItemSize:e.estimatedItemSize||Bn,lastMeasuredIndex:-1};return t.resetAfterIndex=function(e,r){r===void 0&&(r=!0),n.lastMeasuredIndex=Math.min(n.lastMeasuredIndex,e-1),t._getItemStyleCache(-1),r&&t.forceUpdate()},n},shouldResetStyleCacheOnItemSizeChange:!1,validateProps:function(e){e.itemSize}}),qn=Rn({getItemOffset:function(e,t){return t*e.itemSize},getItemSize:function(e,t){return e.itemSize},getEstimatedTotalSize:function(e){var t=e.itemCount;return e.itemSize*t},getOffsetForIndexAndAlignment:function(e,t,n,r,i,a){var o=e.direction,s=e.height,c=e.itemCount,l=e.itemSize,u=e.layout,d=e.width,f=o===`horizontal`||u===`horizontal`?d:s,p=Math.max(0,c*l-f),m=Math.min(p,t*l),h=Math.max(0,t*l-f+l+a);switch(n===`smart`&&(n=r>=h-f&&r<=m+f?`auto`:`center`),n){case`start`:return m;case`end`:return h;case`center`:var g=Math.round(h+(m-h)/2);return g<Math.ceil(f/2)?0:g>p+Math.floor(f/2)?p:g;default:return r>=h&&r<=m?r:r<h?h:m}},getStartIndexForOffset:function(e,t){var n=e.itemCount,r=e.itemSize;return Math.max(0,Math.min(n-1,Math.floor(t/r)))},getStopIndexForStartIndex:function(e,t,n){var r=e.direction,i=e.height,a=e.itemCount,o=e.itemSize,s=e.layout,c=e.width,l=r===`horizontal`||s===`horizontal`,u=t*o,d=Math.ceil(((l?c:i)+n-u)/o);return Math.max(0,Math.min(a-1,t+d-1))},initInstanceProps:function(e){},shouldResetStyleCacheOnItemSizeChange:!0,validateProps:function(e){e.itemSize}});function Jn(){let e=W(),t=mt().cursor;if(!t||t.type!==`line`)return null;let n=e.indent,r=e.rowTopPosition(t.index)+(e.props.padding??e.props.paddingTop??0),i=n*t.level,a=e.renderCursor;return(0,H.jsx)(a,{top:r,left:i,indent:n})}var Yn=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols==`function`)for(var i=0,r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]]);return n},Xn=(0,V.forwardRef)(function(e,t){let{children:n}=e,r=Yn(e,[`children`]),i=W();return(0,H.jsxs)(`div`,Object.assign({ref:t},r,{onClick:e=>{e.currentTarget===e.target&&i.deselectAll()},children:[(0,H.jsx)(Zn,{}),n]}))}),Zn=()=>{let e=W();return(0,H.jsx)(`div`,{style:{height:e.rowTopPosition(e.visibleNodes.length),width:`100%`,position:`absolute`,left:`0`,right:`0`},children:(0,H.jsx)(Jn,{})})},Qn=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols==`function`)for(var i=0,r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]]);return n},$n=(0,V.forwardRef)(function(e,t){var{style:n}=e,r=Qn(e,[`style`]);let i=W(),a=i.props.padding??i.props.paddingTop??0,o=i.props.padding??i.props.paddingBottom??0;return(0,H.jsx)(`div`,Object.assign({ref:t,style:Object.assign(Object.assign({},n),{height:`${parseFloat(n.height)+a+o}px`})},r))}),er=(0,V.createContext)({dragDropManager:void 0}),G;(function(e){e.SOURCE=`SOURCE`,e.TARGET=`TARGET`})(G||={});function K(e,t){var n=[...arguments].slice(2);if(!e){var r;if(t===void 0)r=Error(`Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings.`);else{var i=0;r=Error(t.replace(/%s/g,function(){return n[i++]})),r.name=`Invariant Violation`}throw r.framesToPop=1,r}}var tr=`dnd-core/INIT_COORDS`,nr=`dnd-core/BEGIN_DRAG`,rr=`dnd-core/PUBLISH_DRAG_SOURCE`,ir=`dnd-core/HOVER`,ar=`dnd-core/DROP`,or=`dnd-core/END_DRAG`;function sr(e,t){return{type:tr,payload:{sourceClientOffset:t||null,clientOffset:e||null}}}function cr(e){"@babel/helpers - typeof";return cr=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},cr(e)}function lr(e,t,n){return t.split(`.`).reduce(function(e,t){return e&&e[t]?e[t]:n||null},e)}function ur(e,t){return e.filter(function(e){return e!==t})}function dr(e){return cr(e)===`object`}function fr(e,t){var n=new Map,r=function(e){n.set(e,n.has(e)?n.get(e)+1:1)};e.forEach(r),t.forEach(r);var i=[];return n.forEach(function(e,t){e===1&&i.push(t)}),i}function pr(e,t){return e.filter(function(e){return t.indexOf(e)>-1})}var mr={type:tr,payload:{clientOffset:null,sourceClientOffset:null}};function hr(e){return function(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{publishSource:!0},r=n.publishSource,i=r===void 0?!0:r,a=n.clientOffset,o=n.getSourceClientOffset,s=e.getMonitor(),c=e.getRegistry();e.dispatch(sr(a)),gr(t,s,c);var l=yr(t,s);if(l===null){e.dispatch(mr);return}var u=null;if(a){if(!o)throw Error(`getSourceClientOffset must be defined`);_r(o),u=o(l)}e.dispatch(sr(a,u));var d=c.getSource(l).beginDrag(s,l);if(d!=null)return vr(d),c.pinSource(l),{type:nr,payload:{itemType:c.getSourceType(l),item:d,sourceId:l,clientOffset:a||null,sourceClientOffset:u||null,isSourcePublic:!!i}}}}function gr(e,t,n){K(!t.isDragging(),`Cannot call beginDrag while dragging.`),e.forEach(function(e){K(n.getSource(e),`Expected sourceIds to be registered.`)})}function _r(e){K(typeof e==`function`,`When clientOffset is provided, getSourceClientOffset must be a function.`)}function vr(e){K(dr(e),`Item must be an object.`)}function yr(e,t){for(var n=null,r=e.length-1;r>=0;r--)if(t.canDragSource(e[r])){n=e[r];break}return n}function br(e){return function(){if(e.getMonitor().isDragging())return{type:rr}}}function xr(e,t){return t===null?e===null:Array.isArray(e)?e.some(function(e){return e===t}):e===t}function Sr(e){return function(t){var n=(arguments.length>1&&arguments[1]!==void 0?arguments[1]:{}).clientOffset;Cr(t);var r=t.slice(0),i=e.getMonitor(),a=e.getRegistry();return wr(r,i,a),Tr(r,a,i.getItemType()),Er(r,i,a),{type:ir,payload:{targetIds:r,clientOffset:n||null}}}}function Cr(e){K(Array.isArray(e),`Expected targetIds to be an array.`)}function wr(e,t,n){K(t.isDragging(),`Cannot call hover while not dragging.`),K(!t.didDrop(),`Cannot call hover after drop.`);for(var r=0;r<e.length;r++){var i=e[r];K(e.lastIndexOf(i)===r,`Expected targetIds to be unique in the passed array.`),K(n.getTarget(i),`Expected targetIds to be registered.`)}}function Tr(e,t,n){for(var r=e.length-1;r>=0;r--){var i=e[r];xr(t.getTargetType(i),n)||e.splice(r,1)}}function Er(e,t,n){e.forEach(function(e){n.getTarget(e).hover(t,e)})}function Dr(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Or(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?Dr(Object(n),!0).forEach(function(t){kr(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Dr(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function kr(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Ar(e){return function(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},n=e.getMonitor(),r=e.getRegistry();jr(n),Pr(n).forEach(function(i,a){var o=Mr(i,a,r,n),s={type:ar,payload:{dropResult:Or(Or({},t),o)}};e.dispatch(s)})}}function jr(e){K(e.isDragging(),`Cannot call drop while not dragging.`),K(!e.didDrop(),`Cannot call drop twice during one drag operation.`)}function Mr(e,t,n,r){var i=n.getTarget(e),a=i?i.drop(r,e):void 0;return Nr(a),a===void 0&&(a=t===0?{}:r.getDropResult()),a}function Nr(e){K(e===void 0||dr(e),`Drop result must either be an object or undefined.`)}function Pr(e){var t=e.getTargetIds().filter(e.canDropOnTarget,e);return t.reverse(),t}function Fr(e){return function(){var t=e.getMonitor(),n=e.getRegistry();Ir(t);var r=t.getSourceId();return r!=null&&(n.getSource(r,!0).endDrag(t,r),n.unpinSource()),{type:or}}}function Ir(e){K(e.isDragging(),`Cannot call endDrag while not dragging.`)}function Lr(e){return{beginDrag:hr(e),publishDragSource:br(e),hover:Sr(e),drop:Ar(e),endDrag:Fr(e)}}function Rr(e,t){if(!(e instanceof t))throw TypeError(`Cannot call a class as a function`)}function zr(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,`value`in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function Br(e,t,n){return t&&zr(e.prototype,t),n&&zr(e,n),e}function Vr(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var Hr=function(){function e(t,n){var r=this;Rr(this,e),Vr(this,`store`,void 0),Vr(this,`monitor`,void 0),Vr(this,`backend`,void 0),Vr(this,`isSetUp`,!1),Vr(this,`handleRefCountChange`,function(){var e=r.store.getState().refCount>0;r.backend&&(e&&!r.isSetUp?(r.backend.setup(),r.isSetUp=!0):!e&&r.isSetUp&&(r.backend.teardown(),r.isSetUp=!1))}),this.store=t,this.monitor=n,t.subscribe(this.handleRefCountChange)}return Br(e,[{key:`receiveBackend`,value:function(e){this.backend=e}},{key:`getMonitor`,value:function(){return this.monitor}},{key:`getBackend`,value:function(){return this.backend}},{key:`getRegistry`,value:function(){return this.monitor.registry}},{key:`getActions`,value:function(){var e=this,t=this.store.dispatch;function n(n){return function(){var r=[...arguments],i=n.apply(e,r);i!==void 0&&t(i)}}var r=Lr(this);return Object.keys(r).reduce(function(e,t){var i=r[t];return e[t]=n(i),e},{})}},{key:`dispatch`,value:function(e){this.store.dispatch(e)}}]),e}();function q(e){return`Minified Redux error #`+e+`; visit https://redux.js.org/Errors?code=`+e+` for the full message or use the non-minified dev environment for full errors. `}var Ur=(function(){return typeof Symbol==`function`&&Symbol.observable||`@@observable`})(),Wr=function(){return Math.random().toString(36).substring(7).split(``).join(`.`)},Gr={INIT:`@@redux/INIT`+Wr(),REPLACE:`@@redux/REPLACE`+Wr(),PROBE_UNKNOWN_ACTION:function(){return`@@redux/PROBE_UNKNOWN_ACTION`+Wr()}};function Kr(e){if(typeof e!=`object`||!e)return!1;for(var t=e;Object.getPrototypeOf(t)!==null;)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t}function qr(e,t,n){var r;if(typeof t==`function`&&typeof n==`function`||typeof n==`function`&&typeof arguments[3]==`function`)throw Error(q(0));if(typeof t==`function`&&n===void 0&&(n=t,t=void 0),n!==void 0){if(typeof n!=`function`)throw Error(q(1));return n(qr)(e,t)}if(typeof e!=`function`)throw Error(q(2));var i=e,a=t,o=[],s=o,c=!1;function l(){s===o&&(s=o.slice())}function u(){if(c)throw Error(q(3));return a}function d(e){if(typeof e!=`function`)throw Error(q(4));if(c)throw Error(q(5));var t=!0;return l(),s.push(e),function(){if(t){if(c)throw Error(q(6));t=!1,l();var n=s.indexOf(e);s.splice(n,1),o=null}}}function f(e){if(!Kr(e))throw Error(q(7));if(e.type===void 0)throw Error(q(8));if(c)throw Error(q(9));try{c=!0,a=i(a,e)}finally{c=!1}for(var t=o=s,n=0;n<t.length;n++){var r=t[n];r()}return e}function p(e){if(typeof e!=`function`)throw Error(q(10));i=e,f({type:Gr.REPLACE})}function m(){var e,t=d;return e={subscribe:function(e){if(typeof e!=`object`||!e)throw Error(q(11));function n(){e.next&&e.next(u())}return n(),{unsubscribe:t(n)}}},e[Ur]=function(){return this},e}return f({type:Gr.INIT}),r={dispatch:f,subscribe:d,getState:u,replaceReducer:p},r[Ur]=m,r}var Jr=function(e,t){return e===t};function Yr(e,t){return!e&&!t?!0:!e||!t?!1:e.x===t.x&&e.y===t.y}function Xr(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Jr;if(e.length!==t.length)return!1;for(var r=0;r<e.length;++r)if(!n(e[r],t[r]))return!1;return!0}function Zr(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Qr(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?Zr(Object(n),!0).forEach(function(t){$r(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Zr(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function $r(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var ei={initialSourceClientOffset:null,initialClientOffset:null,clientOffset:null};function ti(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:ei,t=arguments.length>1?arguments[1]:void 0,n=t.payload;switch(t.type){case tr:case nr:return{initialSourceClientOffset:n.sourceClientOffset,initialClientOffset:n.clientOffset,clientOffset:n.clientOffset};case ir:return Yr(e.clientOffset,n.clientOffset)?e:Qr(Qr({},e),{},{clientOffset:n.clientOffset});case or:case ar:return ei;default:return e}}var ni=`dnd-core/ADD_SOURCE`,ri=`dnd-core/ADD_TARGET`,ii=`dnd-core/REMOVE_SOURCE`,ai=`dnd-core/REMOVE_TARGET`;function oi(e){return{type:ni,payload:{sourceId:e}}}function si(e){return{type:ri,payload:{targetId:e}}}function ci(e){return{type:ii,payload:{sourceId:e}}}function li(e){return{type:ai,payload:{targetId:e}}}function ui(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function J(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?ui(Object(n),!0).forEach(function(t){di(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):ui(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function di(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var fi={itemType:null,item:null,sourceId:null,targetIds:[],dropResult:null,didDrop:!1,isSourcePublic:null};function pi(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:fi,t=arguments.length>1?arguments[1]:void 0,n=t.payload;switch(t.type){case nr:return J(J({},e),{},{itemType:n.itemType,item:n.item,sourceId:n.sourceId,isSourcePublic:n.isSourcePublic,dropResult:null,didDrop:!1});case rr:return J(J({},e),{},{isSourcePublic:!0});case ir:return J(J({},e),{},{targetIds:n.targetIds});case ai:return e.targetIds.indexOf(n.targetId)===-1?e:J(J({},e),{},{targetIds:ur(e.targetIds,n.targetId)});case ar:return J(J({},e),{},{dropResult:n.dropResult,didDrop:!0,targetIds:[]});case or:return J(J({},e),{},{itemType:null,item:null,sourceId:null,dropResult:null,didDrop:!1,isSourcePublic:null,targetIds:[]});default:return e}}function mi(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0;switch((arguments.length>1?arguments[1]:void 0).type){case ni:case ri:return e+1;case ii:case ai:return e-1;default:return e}}var hi=[],gi=[];hi.__IS_NONE__=!0,gi.__IS_ALL__=!0;function _i(e,t){return e===hi?!1:e===gi||t===void 0?!0:pr(t,e).length>0}function vi(){arguments.length>0&&arguments[0]!==void 0&&arguments[0];var e=arguments.length>1?arguments[1]:void 0;switch(e.type){case ir:break;case ni:case ri:case ai:case ii:return hi;case nr:case rr:case or:case ar:default:return gi}var t=e.payload,n=t.targetIds,r=n===void 0?[]:n,i=t.prevTargetIds,a=i===void 0?[]:i,o=fr(r,a);if(!(o.length>0||!Xr(r,a)))return hi;var s=a[a.length-1],c=r[r.length-1];return s!==c&&(s&&o.push(s),c&&o.push(c)),o}function yi(){return(arguments.length>0&&arguments[0]!==void 0?arguments[0]:0)+1}function bi(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function xi(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?bi(Object(n),!0).forEach(function(t){Si(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):bi(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Si(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Ci(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},t=arguments.length>1?arguments[1]:void 0;return{dirtyHandlerIds:vi(e.dirtyHandlerIds,{type:t.type,payload:xi(xi({},t.payload),{},{prevTargetIds:lr(e,`dragOperation.targetIds`,[])})}),dragOffset:ti(e.dragOffset,t),refCount:mi(e.refCount,t),dragOperation:pi(e.dragOperation,t),stateId:yi(e.stateId)}}function wi(e,t){return{x:e.x+t.x,y:e.y+t.y}}function Ti(e,t){return{x:e.x-t.x,y:e.y-t.y}}function Ei(e){var t=e.clientOffset,n=e.initialClientOffset,r=e.initialSourceClientOffset;return!t||!n||!r?null:Ti(wi(t,r),n)}function Di(e){var t=e.clientOffset,n=e.initialClientOffset;return!t||!n?null:Ti(t,n)}function Oi(e,t){if(!(e instanceof t))throw TypeError(`Cannot call a class as a function`)}function ki(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,`value`in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function Ai(e,t,n){return t&&ki(e.prototype,t),n&&ki(e,n),e}function ji(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var Mi=function(){function e(t,n){Oi(this,e),ji(this,`store`,void 0),ji(this,`registry`,void 0),this.store=t,this.registry=n}return Ai(e,[{key:`subscribeToStateChange`,value:function(e){var t=this,n=(arguments.length>1&&arguments[1]!==void 0?arguments[1]:{handlerIds:void 0}).handlerIds;K(typeof e==`function`,`listener must be a function.`),K(n===void 0||Array.isArray(n),`handlerIds, when specified, must be an array of strings.`);var r=this.store.getState().stateId;return this.store.subscribe(function(){var i=t.store.getState(),a=i.stateId;try{a===r||a===r+1&&!_i(i.dirtyHandlerIds,n)||e()}finally{r=a}})}},{key:`subscribeToOffsetChange`,value:function(e){var t=this;K(typeof e==`function`,`listener must be a function.`);var n=this.store.getState().dragOffset;return this.store.subscribe(function(){var r=t.store.getState().dragOffset;r!==n&&(n=r,e())})}},{key:`canDragSource`,value:function(e){if(!e)return!1;var t=this.registry.getSource(e);return K(t,`Expected to find a valid source. sourceId=${e}`),this.isDragging()?!1:t.canDrag(this,e)}},{key:`canDropOnTarget`,value:function(e){if(!e)return!1;var t=this.registry.getTarget(e);return K(t,`Expected to find a valid target. targetId=${e}`),!this.isDragging()||this.didDrop()?!1:xr(this.registry.getTargetType(e),this.getItemType())&&t.canDrop(this,e)}},{key:`isDragging`,value:function(){return!!this.getItemType()}},{key:`isDraggingSource`,value:function(e){if(!e)return!1;var t=this.registry.getSource(e,!0);return K(t,`Expected to find a valid source. sourceId=${e}`),!this.isDragging()||!this.isSourcePublic()||this.registry.getSourceType(e)!==this.getItemType()?!1:t.isDragging(this,e)}},{key:`isOverTarget`,value:function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{shallow:!1};if(!e)return!1;var n=t.shallow;if(!this.isDragging())return!1;var r=this.registry.getTargetType(e),i=this.getItemType();if(i&&!xr(r,i))return!1;var a=this.getTargetIds();if(!a.length)return!1;var o=a.indexOf(e);return n?o===a.length-1:o>-1}},{key:`getItemType`,value:function(){return this.store.getState().dragOperation.itemType}},{key:`getItem`,value:function(){return this.store.getState().dragOperation.item}},{key:`getSourceId`,value:function(){return this.store.getState().dragOperation.sourceId}},{key:`getTargetIds`,value:function(){return this.store.getState().dragOperation.targetIds}},{key:`getDropResult`,value:function(){return this.store.getState().dragOperation.dropResult}},{key:`didDrop`,value:function(){return this.store.getState().dragOperation.didDrop}},{key:`isSourcePublic`,value:function(){return!!this.store.getState().dragOperation.isSourcePublic}},{key:`getInitialClientOffset`,value:function(){return this.store.getState().dragOffset.initialClientOffset}},{key:`getInitialSourceClientOffset`,value:function(){return this.store.getState().dragOffset.initialSourceClientOffset}},{key:`getClientOffset`,value:function(){return this.store.getState().dragOffset.clientOffset}},{key:`getSourceClientOffset`,value:function(){return Ei(this.store.getState().dragOffset)}},{key:`getDifferenceFromInitialOffset`,value:function(){return Di(this.store.getState().dragOffset)}}]),e}(),Ni=0;function Pi(){return Ni++}function Fi(e){"@babel/helpers - typeof";return Fi=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},Fi(e)}function Ii(e){K(typeof e.canDrag==`function`,`Expected canDrag to be a function.`),K(typeof e.beginDrag==`function`,`Expected beginDrag to be a function.`),K(typeof e.endDrag==`function`,`Expected endDrag to be a function.`)}function Li(e){K(typeof e.canDrop==`function`,`Expected canDrop to be a function.`),K(typeof e.hover==`function`,`Expected hover to be a function.`),K(typeof e.drop==`function`,`Expected beginDrag to be a function.`)}function Ri(e,t){if(t&&Array.isArray(e)){e.forEach(function(e){return Ri(e,!1)});return}K(typeof e==`string`||Fi(e)===`symbol`,t?`Type can only be a string, a symbol, or an array of either.`:`Type can only be a string or a symbol.`)}var zi=typeof global<`u`?global:self,Bi=zi.MutationObserver||zi.WebKitMutationObserver;function Vi(e){return function(){let t=setTimeout(r,0),n=setInterval(r,50);function r(){clearTimeout(t),clearInterval(n),e()}}}function Hi(e){let t=1,n=new Bi(e),r=document.createTextNode(``);return n.observe(r,{characterData:!0}),function(){t=-t,r.data=t}}var Ui=typeof Bi==`function`?Hi:Vi,Wi=class{enqueueTask(e){let{queue:t,requestFlush:n}=this;t.length||(n(),this.flushing=!0),t[t.length]=e}constructor(){this.queue=[],this.pendingErrors=[],this.flushing=!1,this.index=0,this.capacity=1024,this.flush=()=>{let{queue:e}=this;for(;this.index<e.length;){let t=this.index;if(this.index++,e[t].call(),this.index>this.capacity){for(let t=0,n=e.length-this.index;t<n;t++)e[t]=e[t+this.index];e.length-=this.index,this.index=0}}e.length=0,this.index=0,this.flushing=!1},this.registerPendingError=e=>{this.pendingErrors.push(e),this.requestErrorThrow()},this.requestFlush=Ui(this.flush),this.requestErrorThrow=Vi(()=>{if(this.pendingErrors.length)throw this.pendingErrors.shift()})}},Gi=class{call(){try{this.task&&this.task()}catch(e){this.onError(e)}finally{this.task=null,this.release(this)}}constructor(e,t){this.onError=e,this.release=t,this.task=null}},Ki=class{create(e){let t=this.freeTasks,n=t.length?t.pop():new Gi(this.onError,e=>t[t.length]=e);return n.task=e,n}constructor(e){this.onError=e,this.freeTasks=[]}},qi=new Wi,Ji=new Ki(qi.registerPendingError);function Yi(e){qi.enqueueTask(Ji.create(e))}function Xi(e,t){if(!(e instanceof t))throw TypeError(`Cannot call a class as a function`)}function Zi(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,`value`in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function Qi(e,t,n){return t&&Zi(e.prototype,t),n&&Zi(e,n),e}function $i(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function ea(e,t){return aa(e)||ia(e,t)||na(e,t)||ta()}function ta(){throw TypeError(`Invalid attempt to destructure non-iterable instance.
2
2
  In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function na(e,t){if(e){if(typeof e==`string`)return ra(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if(n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`)return Array.from(e);if(n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return ra(e,t)}}function ra(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function ia(e,t){var n=e==null?null:typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(n!=null){var r=[],i=!0,a=!1,o,s;try{for(n=n.call(e);!(i=(o=n.next()).done)&&(r.push(o.value),!(t&&r.length===t));i=!0);}catch(e){a=!0,s=e}finally{try{!i&&n.return!=null&&n.return()}finally{if(a)throw s}}return r}}function aa(e){if(Array.isArray(e))return e}function oa(e){var t=Pi().toString();switch(e){case G.SOURCE:return`S${t}`;case G.TARGET:return`T${t}`;default:throw Error(`Unknown Handler Role: ${e}`)}}function sa(e){switch(e[0]){case`S`:return G.SOURCE;case`T`:return G.TARGET;default:K(!1,`Cannot parse handler ID: ${e}`)}}function ca(e,t){var n=e.entries(),r=!1;do{var i=n.next(),a=i.done;if(ea(i.value,2)[1]===t)return!0;r=!!a}while(!r);return!1}var la=function(){function e(t){Xi(this,e),$i(this,`types`,new Map),$i(this,`dragSources`,new Map),$i(this,`dropTargets`,new Map),$i(this,`pinnedSourceId`,null),$i(this,`pinnedSource`,null),$i(this,`store`,void 0),this.store=t}return Qi(e,[{key:`addSource`,value:function(e,t){Ri(e),Ii(t);var n=this.addHandler(G.SOURCE,e,t);return this.store.dispatch(oi(n)),n}},{key:`addTarget`,value:function(e,t){Ri(e,!0),Li(t);var n=this.addHandler(G.TARGET,e,t);return this.store.dispatch(si(n)),n}},{key:`containsHandler`,value:function(e){return ca(this.dragSources,e)||ca(this.dropTargets,e)}},{key:`getSource`,value:function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;return K(this.isSourceId(e),`Expected a valid source ID.`),t&&e===this.pinnedSourceId?this.pinnedSource:this.dragSources.get(e)}},{key:`getTarget`,value:function(e){return K(this.isTargetId(e),`Expected a valid target ID.`),this.dropTargets.get(e)}},{key:`getSourceType`,value:function(e){return K(this.isSourceId(e),`Expected a valid source ID.`),this.types.get(e)}},{key:`getTargetType`,value:function(e){return K(this.isTargetId(e),`Expected a valid target ID.`),this.types.get(e)}},{key:`isSourceId`,value:function(e){return sa(e)===G.SOURCE}},{key:`isTargetId`,value:function(e){return sa(e)===G.TARGET}},{key:`removeSource`,value:function(e){var t=this;K(this.getSource(e),`Expected an existing source.`),this.store.dispatch(ci(e)),Yi(function(){t.dragSources.delete(e),t.types.delete(e)})}},{key:`removeTarget`,value:function(e){K(this.getTarget(e),`Expected an existing target.`),this.store.dispatch(li(e)),this.dropTargets.delete(e),this.types.delete(e)}},{key:`pinSource`,value:function(e){var t=this.getSource(e);K(t,`Expected an existing source.`),this.pinnedSourceId=e,this.pinnedSource=t}},{key:`unpinSource`,value:function(){K(this.pinnedSource,`No source is pinned at the time.`),this.pinnedSourceId=null,this.pinnedSource=null}},{key:`addHandler`,value:function(e,t,n){var r=oa(e);return this.types.set(r,t),e===G.SOURCE?this.dragSources.set(r,n):e===G.TARGET&&this.dropTargets.set(r,n),r}}]),e}();function ua(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:void 0,n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},r=da(arguments.length>3&&arguments[3]!==void 0?arguments[3]:!1),i=new Hr(r,new Mi(r,new la(r))),a=e(i,t,n);return i.receiveBackend(a),i}function da(e){var t=typeof window<`u`&&window.__REDUX_DEVTOOLS_EXTENSION__;return qr(Ci,e&&t&&t({name:`dnd-core`,instanceId:`dnd-core`}))}var fa=[`children`];function pa(e,t){return va(e)||_a(e,t)||ha(e,t)||ma()}function ma(){throw TypeError(`Invalid attempt to destructure non-iterable instance.
3
3
  In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function ha(e,t){if(e){if(typeof e==`string`)return ga(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if(n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`)return Array.from(e);if(n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return ga(e,t)}}function ga(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function _a(e,t){var n=e==null?null:typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(n!=null){var r=[],i=!0,a=!1,o,s;try{for(n=n.call(e);!(i=(o=n.next()).done)&&(r.push(o.value),!(t&&r.length===t));i=!0);}catch(e){a=!0,s=e}finally{try{!i&&n.return!=null&&n.return()}finally{if(a)throw s}}return r}}function va(e){if(Array.isArray(e))return e}function ya(e,t){if(e==null)return{};var n=ba(e,t),r,i;if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(i=0;i<a.length;i++)r=a[i],!(t.indexOf(r)>=0)&&Object.prototype.propertyIsEnumerable.call(e,r)&&(n[r]=e[r])}return n}function ba(e,t){if(e==null)return{};var n={},r=Object.keys(e),i,a;for(a=0;a<r.length;a++)i=r[a],!(t.indexOf(i)>=0)&&(n[i]=e[i]);return n}var xa=0,Sa=Symbol.for(`__REACT_DND_CONTEXT_INSTANCE__`),Ca=(0,V.memo)(function(e){var t=e.children,n=pa(wa(ya(e,fa)),2),r=n[0],i=n[1];return(0,V.useEffect)(function(){if(i){var e=Ea();return++xa,function(){--xa===0&&(e[Sa]=null)}}},[]),(0,H.jsx)(er.Provider,Object.assign({value:r},{children:t}),void 0)});function wa(e){return`manager`in e?[{dragDropManager:e.manager},!1]:[Ta(e.backend,e.context,e.options,e.debugMode),!e.context]}function Ta(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Ea(),n=arguments.length>2?arguments[2]:void 0,r=arguments.length>3?arguments[3]:void 0,i=t;return i[Sa]||(i[Sa]={dragDropManager:ua(e,t,n,r)}),i[Sa]}function Ea(){return typeof global<`u`?global:window}function Da(e,t){if(!(e instanceof t))throw TypeError(`Cannot call a class as a function`)}function Oa(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,`value`in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function ka(e,t,n){return t&&Oa(e.prototype,t),n&&Oa(e,n),e}function Aa(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var ja=!1,Ma=!1,Na=function(){function e(t){Da(this,e),Aa(this,`internalMonitor`,void 0),Aa(this,`sourceId`,null),this.internalMonitor=t.getMonitor()}return ka(e,[{key:`receiveHandlerId`,value:function(e){this.sourceId=e}},{key:`getHandlerId`,value:function(){return this.sourceId}},{key:`canDrag`,value:function(){K(!ja,`You may not call monitor.canDrag() inside your canDrag() implementation. Read more: http://react-dnd.github.io/react-dnd/docs/api/drag-source-monitor`);try{return ja=!0,this.internalMonitor.canDragSource(this.sourceId)}finally{ja=!1}}},{key:`isDragging`,value:function(){if(!this.sourceId)return!1;K(!Ma,`You may not call monitor.isDragging() inside your isDragging() implementation. Read more: http://react-dnd.github.io/react-dnd/docs/api/drag-source-monitor`);try{return Ma=!0,this.internalMonitor.isDraggingSource(this.sourceId)}finally{Ma=!1}}},{key:`subscribeToStateChange`,value:function(e,t){return this.internalMonitor.subscribeToStateChange(e,t)}},{key:`isDraggingSource`,value:function(e){return this.internalMonitor.isDraggingSource(e)}},{key:`isOverTarget`,value:function(e,t){return this.internalMonitor.isOverTarget(e,t)}},{key:`getTargetIds`,value:function(){return this.internalMonitor.getTargetIds()}},{key:`isSourcePublic`,value:function(){return this.internalMonitor.isSourcePublic()}},{key:`getSourceId`,value:function(){return this.internalMonitor.getSourceId()}},{key:`subscribeToOffsetChange`,value:function(e){return this.internalMonitor.subscribeToOffsetChange(e)}},{key:`canDragSource`,value:function(e){return this.internalMonitor.canDragSource(e)}},{key:`canDropOnTarget`,value:function(e){return this.internalMonitor.canDropOnTarget(e)}},{key:`getItemType`,value:function(){return this.internalMonitor.getItemType()}},{key:`getItem`,value:function(){return this.internalMonitor.getItem()}},{key:`getDropResult`,value:function(){return this.internalMonitor.getDropResult()}},{key:`didDrop`,value:function(){return this.internalMonitor.didDrop()}},{key:`getInitialClientOffset`,value:function(){return this.internalMonitor.getInitialClientOffset()}},{key:`getInitialSourceClientOffset`,value:function(){return this.internalMonitor.getInitialSourceClientOffset()}},{key:`getSourceClientOffset`,value:function(){return this.internalMonitor.getSourceClientOffset()}},{key:`getClientOffset`,value:function(){return this.internalMonitor.getClientOffset()}},{key:`getDifferenceFromInitialOffset`,value:function(){return this.internalMonitor.getDifferenceFromInitialOffset()}}]),e}();function Pa(e,t){if(!(e instanceof t))throw TypeError(`Cannot call a class as a function`)}function Fa(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,`value`in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function Ia(e,t,n){return t&&Fa(e.prototype,t),n&&Fa(e,n),e}function La(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var Ra=!1,za=function(){function e(t){Pa(this,e),La(this,`internalMonitor`,void 0),La(this,`targetId`,null),this.internalMonitor=t.getMonitor()}return Ia(e,[{key:`receiveHandlerId`,value:function(e){this.targetId=e}},{key:`getHandlerId`,value:function(){return this.targetId}},{key:`subscribeToStateChange`,value:function(e,t){return this.internalMonitor.subscribeToStateChange(e,t)}},{key:`canDrop`,value:function(){if(!this.targetId)return!1;K(!Ra,`You may not call monitor.canDrop() inside your canDrop() implementation. Read more: http://react-dnd.github.io/react-dnd/docs/api/drop-target-monitor`);try{return Ra=!0,this.internalMonitor.canDropOnTarget(this.targetId)}finally{Ra=!1}}},{key:`isOver`,value:function(e){return this.targetId?this.internalMonitor.isOverTarget(this.targetId,e):!1}},{key:`getItemType`,value:function(){return this.internalMonitor.getItemType()}},{key:`getItem`,value:function(){return this.internalMonitor.getItem()}},{key:`getDropResult`,value:function(){return this.internalMonitor.getDropResult()}},{key:`didDrop`,value:function(){return this.internalMonitor.didDrop()}},{key:`getInitialClientOffset`,value:function(){return this.internalMonitor.getInitialClientOffset()}},{key:`getInitialSourceClientOffset`,value:function(){return this.internalMonitor.getInitialSourceClientOffset()}},{key:`getSourceClientOffset`,value:function(){return this.internalMonitor.getSourceClientOffset()}},{key:`getClientOffset`,value:function(){return this.internalMonitor.getClientOffset()}},{key:`getDifferenceFromInitialOffset`,value:function(){return this.internalMonitor.getDifferenceFromInitialOffset()}}]),e}();function Ba(e){if(typeof e.type!=`string`){var t=e.type.displayName||e.type.name||`the component`;throw Error(`Only native element nodes can now be passed to React DnD connectors.You can either wrap ${t} into a <div>, or turn it into a drag source or a drop target itself.`)}}function Va(e){return function(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:null,n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:null;if(!(0,V.isValidElement)(t)){var r=t;return e(r,n),r}var i=t;return Ba(i),Wa(i,n?function(t){return e(t,n)}:e)}}function Ha(e){var t={};return Object.keys(e).forEach(function(n){var r=e[n];if(n.endsWith(`Ref`))t[n]=e[n];else{var i=Va(r);t[n]=function(){return i}}}),t}function Ua(e,t){typeof e==`function`?e(t):e.current=t}function Wa(e,t){var n=e.ref;return K(typeof n!=`string`,`Cannot connect React DnD to an element with an existing string ref. Please convert it to use a callback ref instead, or wrap it into a <span> or <div>. Read more: https://reactjs.org/docs/refs-and-the-dom.html#callback-refs`),n?(0,V.cloneElement)(e,{ref:function(e){Ua(n,e),Ua(t,e)}}):(0,V.cloneElement)(e,{ref:t})}function Ga(e){"@babel/helpers - typeof";return Ga=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},Ga(e)}function Ka(e){return e!==null&&Ga(e)===`object`&&Object.prototype.hasOwnProperty.call(e,`current`)}function qa(e,t,n,r){var i=n?n.call(r,e,t):void 0;if(i!==void 0)return!!i;if(e===t)return!0;if(typeof e!=`object`||!e||typeof t!=`object`||!t)return!1;var a=Object.keys(e),o=Object.keys(t);if(a.length!==o.length)return!1;for(var s=Object.prototype.hasOwnProperty.bind(t),c=0;c<a.length;c++){var l=a[c];if(!s(l))return!1;var u=e[l],d=t[l];if(i=n?n.call(r,u,d,l):void 0,i===!1||i===void 0&&u!==d)return!1}return!0}function Ja(e,t){if(!(e instanceof t))throw TypeError(`Cannot call a class as a function`)}function Ya(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,`value`in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function Xa(e,t,n){return t&&Ya(e.prototype,t),n&&Ya(e,n),e}function Y(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var Za=function(){function e(t){var n=this;Ja(this,e),Y(this,`hooks`,Ha({dragSource:function(e,t){n.clearDragSource(),n.dragSourceOptions=t||null,Ka(e)?n.dragSourceRef=e:n.dragSourceNode=e,n.reconnectDragSource()},dragPreview:function(e,t){n.clearDragPreview(),n.dragPreviewOptions=t||null,Ka(e)?n.dragPreviewRef=e:n.dragPreviewNode=e,n.reconnectDragPreview()}})),Y(this,`handlerId`,null),Y(this,`dragSourceRef`,null),Y(this,`dragSourceNode`,void 0),Y(this,`dragSourceOptionsInternal`,null),Y(this,`dragSourceUnsubscribe`,void 0),Y(this,`dragPreviewRef`,null),Y(this,`dragPreviewNode`,void 0),Y(this,`dragPreviewOptionsInternal`,null),Y(this,`dragPreviewUnsubscribe`,void 0),Y(this,`lastConnectedHandlerId`,null),Y(this,`lastConnectedDragSource`,null),Y(this,`lastConnectedDragSourceOptions`,null),Y(this,`lastConnectedDragPreview`,null),Y(this,`lastConnectedDragPreviewOptions`,null),Y(this,`backend`,void 0),this.backend=t}return Xa(e,[{key:`receiveHandlerId`,value:function(e){this.handlerId!==e&&(this.handlerId=e,this.reconnect())}},{key:`connectTarget`,get:function(){return this.dragSource}},{key:`dragSourceOptions`,get:function(){return this.dragSourceOptionsInternal},set:function(e){this.dragSourceOptionsInternal=e}},{key:`dragPreviewOptions`,get:function(){return this.dragPreviewOptionsInternal},set:function(e){this.dragPreviewOptionsInternal=e}},{key:`reconnect`,value:function(){this.reconnectDragSource(),this.reconnectDragPreview()}},{key:`reconnectDragSource`,value:function(){var e=this.dragSource,t=this.didHandlerIdChange()||this.didConnectedDragSourceChange()||this.didDragSourceOptionsChange();if(t&&this.disconnectDragSource(),this.handlerId){if(!e){this.lastConnectedDragSource=e;return}t&&(this.lastConnectedHandlerId=this.handlerId,this.lastConnectedDragSource=e,this.lastConnectedDragSourceOptions=this.dragSourceOptions,this.dragSourceUnsubscribe=this.backend.connectDragSource(this.handlerId,e,this.dragSourceOptions))}}},{key:`reconnectDragPreview`,value:function(){var e=this.dragPreview,t=this.didHandlerIdChange()||this.didConnectedDragPreviewChange()||this.didDragPreviewOptionsChange();if(t&&this.disconnectDragPreview(),this.handlerId){if(!e){this.lastConnectedDragPreview=e;return}t&&(this.lastConnectedHandlerId=this.handlerId,this.lastConnectedDragPreview=e,this.lastConnectedDragPreviewOptions=this.dragPreviewOptions,this.dragPreviewUnsubscribe=this.backend.connectDragPreview(this.handlerId,e,this.dragPreviewOptions))}}},{key:`didHandlerIdChange`,value:function(){return this.lastConnectedHandlerId!==this.handlerId}},{key:`didConnectedDragSourceChange`,value:function(){return this.lastConnectedDragSource!==this.dragSource}},{key:`didConnectedDragPreviewChange`,value:function(){return this.lastConnectedDragPreview!==this.dragPreview}},{key:`didDragSourceOptionsChange`,value:function(){return!qa(this.lastConnectedDragSourceOptions,this.dragSourceOptions)}},{key:`didDragPreviewOptionsChange`,value:function(){return!qa(this.lastConnectedDragPreviewOptions,this.dragPreviewOptions)}},{key:`disconnectDragSource`,value:function(){this.dragSourceUnsubscribe&&=(this.dragSourceUnsubscribe(),void 0)}},{key:`disconnectDragPreview`,value:function(){this.dragPreviewUnsubscribe&&(this.dragPreviewUnsubscribe(),this.dragPreviewUnsubscribe=void 0,this.dragPreviewNode=null,this.dragPreviewRef=null)}},{key:`dragSource`,get:function(){return this.dragSourceNode||this.dragSourceRef&&this.dragSourceRef.current}},{key:`dragPreview`,get:function(){return this.dragPreviewNode||this.dragPreviewRef&&this.dragPreviewRef.current}},{key:`clearDragSource`,value:function(){this.dragSourceNode=null,this.dragSourceRef=null}},{key:`clearDragPreview`,value:function(){this.dragPreviewNode=null,this.dragPreviewRef=null}}]),e}();function Qa(e,t){if(!(e instanceof t))throw TypeError(`Cannot call a class as a function`)}function $a(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,`value`in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function eo(e,t,n){return t&&$a(e.prototype,t),n&&$a(e,n),e}function X(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var to=function(){function e(t){var n=this;Qa(this,e),X(this,`hooks`,Ha({dropTarget:function(e,t){n.clearDropTarget(),n.dropTargetOptions=t,Ka(e)?n.dropTargetRef=e:n.dropTargetNode=e,n.reconnect()}})),X(this,`handlerId`,null),X(this,`dropTargetRef`,null),X(this,`dropTargetNode`,void 0),X(this,`dropTargetOptionsInternal`,null),X(this,`unsubscribeDropTarget`,void 0),X(this,`lastConnectedHandlerId`,null),X(this,`lastConnectedDropTarget`,null),X(this,`lastConnectedDropTargetOptions`,null),X(this,`backend`,void 0),this.backend=t}return eo(e,[{key:`connectTarget`,get:function(){return this.dropTarget}},{key:`reconnect`,value:function(){var e=this.didHandlerIdChange()||this.didDropTargetChange()||this.didOptionsChange();e&&this.disconnectDropTarget();var t=this.dropTarget;if(this.handlerId){if(!t){this.lastConnectedDropTarget=t;return}e&&(this.lastConnectedHandlerId=this.handlerId,this.lastConnectedDropTarget=t,this.lastConnectedDropTargetOptions=this.dropTargetOptions,this.unsubscribeDropTarget=this.backend.connectDropTarget(this.handlerId,t,this.dropTargetOptions))}}},{key:`receiveHandlerId`,value:function(e){e!==this.handlerId&&(this.handlerId=e,this.reconnect())}},{key:`dropTargetOptions`,get:function(){return this.dropTargetOptionsInternal},set:function(e){this.dropTargetOptionsInternal=e}},{key:`didHandlerIdChange`,value:function(){return this.lastConnectedHandlerId!==this.handlerId}},{key:`didDropTargetChange`,value:function(){return this.lastConnectedDropTarget!==this.dropTarget}},{key:`didOptionsChange`,value:function(){return!qa(this.lastConnectedDropTargetOptions,this.dropTargetOptions)}},{key:`disconnectDropTarget`,value:function(){this.unsubscribeDropTarget&&=(this.unsubscribeDropTarget(),void 0)}},{key:`dropTarget`,get:function(){return this.dropTargetNode||this.dropTargetRef&&this.dropTargetRef.current}},{key:`clearDropTarget`,value:function(){this.dropTargetRef=null,this.dropTargetNode=null}}]),e}();function no(e,t,n){var r=n.getRegistry(),i=r.addTarget(e,t);return[i,function(){return r.removeTarget(i)}]}function ro(e,t,n){var r=n.getRegistry(),i=r.addSource(e,t);return[i,function(){return r.removeSource(i)}]}var io=typeof window<`u`?V.useLayoutEffect:V.useEffect;function ao(e){"@babel/helpers - typeof";return ao=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},ao(e)}function oo(e,t){if(!(e instanceof t))throw TypeError(`Cannot call a class as a function`)}function so(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,`value`in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function co(e,t,n){return t&&so(e.prototype,t),n&&so(e,n),e}function lo(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var uo=function(){function e(t,n,r){oo(this,e),lo(this,`spec`,void 0),lo(this,`monitor`,void 0),lo(this,`connector`,void 0),this.spec=t,this.monitor=n,this.connector=r}return co(e,[{key:`beginDrag`,value:function(){var e=this.spec,t=this.monitor,n=null;return n=ao(e.item)===`object`?e.item:typeof e.item==`function`?e.item(t):{},n??null}},{key:`canDrag`,value:function(){var e=this.spec,t=this.monitor;return typeof e.canDrag==`boolean`?e.canDrag:typeof e.canDrag==`function`?e.canDrag(t):!0}},{key:`isDragging`,value:function(e,t){var n=this.spec,r=this.monitor,i=n.isDragging;return i?i(r):t===e.getSourceId()}},{key:`endDrag`,value:function(){var e=this.spec,t=this.monitor,n=this.connector,r=e.end;r&&r(t.getItem(),t),n.reconnect()}}]),e}();function fo(e,t,n){var r=(0,V.useMemo)(function(){return new uo(e,t,n)},[t,n]);return(0,V.useEffect)(function(){r.spec=e},[e]),r}function po(){var e=(0,V.useContext)(er).dragDropManager;return K(e!=null,`Expected drag drop context`),e}function mo(e){return(0,V.useMemo)(function(){var t=e.type;return K(t!=null,`spec.type must be defined`),t},[e])}function ho(e,t){return bo(e)||yo(e,t)||_o(e,t)||go()}function go(){throw TypeError(`Invalid attempt to destructure non-iterable instance.
4
4
  In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function _o(e,t){if(e){if(typeof e==`string`)return vo(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if(n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`)return Array.from(e);if(n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return vo(e,t)}}function vo(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function yo(e,t){var n=e==null?null:typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(n!=null){var r=[],i=!0,a=!1,o,s;try{for(n=n.call(e);!(i=(o=n.next()).done)&&(r.push(o.value),!(t&&r.length===t));i=!0);}catch(e){a=!0,s=e}finally{try{!i&&n.return!=null&&n.return()}finally{if(a)throw s}}return r}}function bo(e){if(Array.isArray(e))return e}function xo(e,t,n){var r=po(),i=fo(e,t,n),a=mo(e);io(function(){if(a!=null){var e=ho(ro(a,i,r),2),o=e[0],s=e[1];return t.receiveHandlerId(o),n.receiveHandlerId(o),s}},[r,t,n,i,a])}function So(e){return Eo(e)||To(e)||wo(e)||Co()}function Co(){throw TypeError(`Invalid attempt to spread non-iterable instance.
@@ -8,5 +8,5 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
8
8
  In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function as(e,t){if(e){if(typeof e==`string`)return os(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if(n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`)return Array.from(e);if(n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return os(e,t)}}function os(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function ss(e,t){var n=e==null?null:typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(n!=null){var r=[],i=!0,a=!1,o,s;try{for(n=n.call(e);!(i=(o=n.next()).done)&&(r.push(o.value),!(t&&r.length===t));i=!0);}catch(e){a=!0,s=e}finally{try{!i&&n.return!=null&&n.return()}finally{if(a)throw s}}return r}}function cs(e){if(Array.isArray(e))return e}function ls(e,t,n){var r=po(),i=ns(e,t),a=Xo(e);io(function(){var e=rs(no(a,i,r),2),o=e[0],s=e[1];return t.receiveHandlerId(o),n.receiveHandlerId(o),s},[r,t,i,n,a.map(function(e){return e.toString()}).join(`|`)])}function us(){var e=po();return(0,V.useMemo)(function(){return new za(e)},[e])}function ds(e){var t=po(),n=(0,V.useMemo)(function(){return new to(t.getBackend())},[t]);return io(function(){return n.dropTargetOptions=e||null,n.reconnect(),function(){return n.disconnectDropTarget()}},[e]),n}function fs(e){return(0,V.useMemo)(function(){return e.hooks.dropTarget()},[e])}function ps(e,t){var n=Oo(e,t),r=us(),i=ds(n.options);return ls(n,r,i),[Ko(n.collect,r,i),fs(i)]}function ms(e,t){return ys(e)||vs(e,t)||gs(e,t)||hs()}function hs(){throw TypeError(`Invalid attempt to destructure non-iterable instance.
9
9
  In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function gs(e,t){if(e){if(typeof e==`string`)return _s(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if(n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`)return Array.from(e);if(n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return _s(e,t)}}function _s(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function vs(e,t){var n=e==null?null:typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(n!=null){var r=[],i=!0,a=!1,o,s;try{for(n=n.call(e);!(i=(o=n.next()).done)&&(r.push(o.value),!(t&&r.length===t));i=!0);}catch(e){a=!0,s=e}finally{try{!i&&n.return!=null&&n.return()}finally{if(a)throw s}}return r}}function ys(e){if(Array.isArray(e))return e}function bs(e){var t=po().getMonitor(),n=ms(Ro(t,e),2),r=n[0],i=n[1];return(0,V.useEffect)(function(){return t.subscribeToOffsetChange(i)}),(0,V.useEffect)(function(){return t.subscribeToStateChange(i)}),r}function xs(e){var t=null;return function(){return t??=e(),t}}function Ss(e,t){return e.filter(function(e){return e!==t})}function Cs(e,t){var n=new Set,r=function(e){return n.add(e)};e.forEach(r),t.forEach(r);var i=[];return n.forEach(function(e){return i.push(e)}),i}function ws(e,t){if(!(e instanceof t))throw TypeError(`Cannot call a class as a function`)}function Ts(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,`value`in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function Es(e,t,n){return t&&Ts(e.prototype,t),n&&Ts(e,n),e}function Ds(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var Os=function(){function e(t){ws(this,e),Ds(this,`entered`,[]),Ds(this,`isNodeInDocument`,void 0),this.isNodeInDocument=t}return Es(e,[{key:`enter`,value:function(e){var t=this,n=this.entered.length;return this.entered=Cs(this.entered.filter(function(n){return t.isNodeInDocument(n)&&(!n.contains||n.contains(e))}),[e]),n===0&&this.entered.length>0}},{key:`leave`,value:function(e){var t=this.entered.length;return this.entered=Ss(this.entered.filter(this.isNodeInDocument),e),t>0&&this.entered.length===0}},{key:`reset`,value:function(){this.entered=[]}}]),e}(),ks=xs(function(){return/firefox/i.test(navigator.userAgent)}),As=xs(function(){return!!window.safari});function js(e,t){if(!(e instanceof t))throw TypeError(`Cannot call a class as a function`)}function Ms(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,`value`in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function Ns(e,t,n){return t&&Ms(e.prototype,t),n&&Ms(e,n),e}function Ps(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var Fs=function(){function e(t,n){js(this,e),Ps(this,`xs`,void 0),Ps(this,`ys`,void 0),Ps(this,`c1s`,void 0),Ps(this,`c2s`,void 0),Ps(this,`c3s`,void 0);for(var r=t.length,i=[],a=0;a<r;a++)i.push(a);i.sort(function(e,n){return t[e]<t[n]?-1:1});for(var o=[],s=[],c=[],l,u,d=0;d<r-1;d++)l=t[d+1]-t[d],u=n[d+1]-n[d],s.push(l),o.push(u),c.push(u/l);for(var f=[c[0]],p=0;p<s.length-1;p++){var m=c[p],h=c[p+1];if(m*h<=0)f.push(0);else{l=s[p];var g=s[p+1],_=l+g;f.push(3*_/((_+g)/m+(_+l)/h))}}f.push(c[c.length-1]);for(var v=[],y=[],b,x=0;x<f.length-1;x++){b=c[x];var S=f[x],C=1/s[x],w=S+f[x+1]-b-b;v.push((b-S-w)*C),y.push(w*C*C)}this.xs=t,this.ys=n,this.c1s=f,this.c2s=v,this.c3s=y}return Ns(e,[{key:`interpolate`,value:function(e){var t=this.xs,n=this.ys,r=this.c1s,i=this.c2s,a=this.c3s,o=t.length-1;if(e===t[o])return n[o];for(var s=0,c=a.length-1,l;s<=c;){l=Math.floor(.5*(s+c));var u=t[l];if(u<e)s=l+1;else if(u>e)c=l-1;else return n[l]}o=Math.max(0,c);var d=e-t[o],f=d*d;return n[o]+r[o]*d+i[o]*f+a[o]*d*f}}]),e}(),Is=1;function Ls(e){var t=e.nodeType===Is?e:e.parentElement;if(!t)return null;var n=t.getBoundingClientRect(),r=n.top;return{x:n.left,y:r}}function Rs(e){return{x:e.clientX,y:e.clientY}}function zs(e){var t;return e.nodeName===`IMG`&&(ks()||!((t=document.documentElement)!=null&&t.contains(e)))}function Bs(e,t,n,r){var i=e?t.width:n,a=e?t.height:r;return As()&&e&&(a/=window.devicePixelRatio,i/=window.devicePixelRatio),{dragPreviewWidth:i,dragPreviewHeight:a}}function Vs(e,t,n,r,i){var a=zs(t),o=Ls(a?e:t),s={x:n.x-o.x,y:n.y-o.y},c=e.offsetWidth,l=e.offsetHeight,u=r.anchorX,d=r.anchorY,f=Bs(a,t,c,l),p=f.dragPreviewWidth,m=f.dragPreviewHeight,h=function(){var e=new Fs([0,.5,1],[s.y,s.y/l*m,s.y+m-l]).interpolate(d);return As()&&a&&(e+=(window.devicePixelRatio-1)*m),e},g=function(){return new Fs([0,.5,1],[s.x,s.x/c*p,s.x+p-c]).interpolate(u)},_=i.offsetX,v=i.offsetY,y=_===0||_,b=v===0||v;return{x:y?_:g(),y:b?v:h()}}var Hs=e({FILE:()=>Us,HTML:()=>Ks,TEXT:()=>Gs,URL:()=>Ws}),Us=`__NATIVE_FILE__`,Ws=`__NATIVE_URL__`,Gs=`__NATIVE_TEXT__`,Ks=`__NATIVE_HTML__`;function qs(e,t,n){return t.reduce(function(t,n){return t||e.getData(n)},``)??n}var Js;function Ys(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var Xs=(Js={},Ys(Js,Us,{exposeProperties:{files:function(e){return Array.prototype.slice.call(e.files)},items:function(e){return e.items},dataTransfer:function(e){return e}},matchesTypes:[`Files`]}),Ys(Js,Ks,{exposeProperties:{html:function(e,t){return qs(e,t,``)},dataTransfer:function(e){return e}},matchesTypes:[`Html`,`text/html`]}),Ys(Js,Ws,{exposeProperties:{urls:function(e,t){return qs(e,t,``).split(`
10
10
  `)},dataTransfer:function(e){return e}},matchesTypes:[`Url`,`text/uri-list`]}),Ys(Js,Gs,{exposeProperties:{text:function(e,t){return qs(e,t,``)},dataTransfer:function(e){return e}},matchesTypes:[`Text`,`text/plain`]}),Js);function Zs(e,t){if(!(e instanceof t))throw TypeError(`Cannot call a class as a function`)}function Qs(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,`value`in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function $s(e,t,n){return t&&Qs(e.prototype,t),n&&Qs(e,n),e}function ec(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var tc=function(){function e(t){Zs(this,e),ec(this,`item`,void 0),ec(this,`config`,void 0),this.config=t,this.item={},this.initializeExposedProperties()}return $s(e,[{key:`initializeExposedProperties`,value:function(){var e=this;Object.keys(this.config.exposeProperties).forEach(function(t){Object.defineProperty(e.item,t,{configurable:!0,enumerable:!0,get:function(){return console.warn(`Browser doesn't allow reading "${t}" until the drop event.`),null}})})}},{key:`loadDataTransfer`,value:function(e){var t=this;if(e){var n={};Object.keys(this.config.exposeProperties).forEach(function(r){n[r]={value:t.config.exposeProperties[r](e,t.config.matchesTypes),configurable:!0,enumerable:!0}}),Object.defineProperties(this.item,n)}}},{key:`canDrag`,value:function(){return!0}},{key:`beginDrag`,value:function(){return this.item}},{key:`isDragging`,value:function(e,t){return t===e.getSourceId()}},{key:`endDrag`,value:function(){}}]),e}();function nc(e,t){var n=new tc(Xs[e]);return n.loadDataTransfer(t),n}function rc(e){if(!e)return null;var t=Array.prototype.slice.call(e.types||[]);return Object.keys(Xs).filter(function(e){return Xs[e].matchesTypes.some(function(e){return t.indexOf(e)>-1})})[0]||null}function ic(e,t){if(!(e instanceof t))throw TypeError(`Cannot call a class as a function`)}function ac(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,`value`in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function oc(e,t,n){return t&&ac(e.prototype,t),n&&ac(e,n),e}function sc(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var cc=function(){function e(t,n){ic(this,e),sc(this,`ownerDocument`,null),sc(this,`globalContext`,void 0),sc(this,`optionsArgs`,void 0),this.globalContext=t,this.optionsArgs=n}return oc(e,[{key:`window`,get:function(){if(this.globalContext)return this.globalContext;if(typeof window<`u`)return window}},{key:`document`,get:function(){var e;if((e=this.globalContext)!=null&&e.document)return this.globalContext.document;if(this.window)return this.window.document}},{key:`rootElement`,get:function(){return this.optionsArgs?.rootElement||this.window}}]),e}();function lc(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function uc(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?lc(Object(n),!0).forEach(function(t){Z(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):lc(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function dc(e,t){if(!(e instanceof t))throw TypeError(`Cannot call a class as a function`)}function fc(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,`value`in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function pc(e,t,n){return t&&fc(e.prototype,t),n&&fc(e,n),e}function Z(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var mc=function(){function e(t,n,r){var i=this;dc(this,e),Z(this,`options`,void 0),Z(this,`actions`,void 0),Z(this,`monitor`,void 0),Z(this,`registry`,void 0),Z(this,`enterLeaveCounter`,void 0),Z(this,`sourcePreviewNodes`,new Map),Z(this,`sourcePreviewNodeOptions`,new Map),Z(this,`sourceNodes`,new Map),Z(this,`sourceNodeOptions`,new Map),Z(this,`dragStartSourceIds`,null),Z(this,`dropTargetIds`,[]),Z(this,`dragEnterTargetIds`,[]),Z(this,`currentNativeSource`,null),Z(this,`currentNativeHandle`,null),Z(this,`currentDragSourceNode`,null),Z(this,`altKeyPressed`,!1),Z(this,`mouseMoveTimeoutTimer`,null),Z(this,`asyncEndDragFrameId`,null),Z(this,`dragOverTargetIds`,null),Z(this,`lastClientOffset`,null),Z(this,`hoverRafId`,null),Z(this,`getSourceClientOffset`,function(e){var t=i.sourceNodes.get(e);return t&&Ls(t)||null}),Z(this,`endDragNativeItem`,function(){i.isDraggingNativeItem()&&(i.actions.endDrag(),i.currentNativeHandle&&i.registry.removeSource(i.currentNativeHandle),i.currentNativeHandle=null,i.currentNativeSource=null)}),Z(this,`isNodeInDocument`,function(e){return!!(e&&i.document&&i.document.body&&i.document.body.contains(e))}),Z(this,`endDragIfSourceWasRemovedFromDOM`,function(){var e=i.currentDragSourceNode;e==null||i.isNodeInDocument(e)||i.clearCurrentDragSourceNode()&&i.monitor.isDragging()&&i.actions.endDrag()}),Z(this,`handleTopDragStartCapture`,function(){i.clearCurrentDragSourceNode(),i.dragStartSourceIds=[]}),Z(this,`handleTopDragStart`,function(e){if(!e.defaultPrevented){var t=i.dragStartSourceIds;i.dragStartSourceIds=null;var n=Rs(e);i.monitor.isDragging()&&i.actions.endDrag(),i.actions.beginDrag(t||[],{publishSource:!1,getSourceClientOffset:i.getSourceClientOffset,clientOffset:n});var r=e.dataTransfer,a=rc(r);if(i.monitor.isDragging()){if(r&&typeof r.setDragImage==`function`){var o=i.monitor.getSourceId(),s=i.sourceNodes.get(o),c=i.sourcePreviewNodes.get(o)||s;if(c){var l=i.getCurrentSourcePreviewNodeOptions(),u=l.anchorX,d=l.anchorY,f=l.offsetX,p=l.offsetY,m=Vs(s,c,n,{anchorX:u,anchorY:d},{offsetX:f,offsetY:p});r.setDragImage(c,m.x,m.y)}}try{r?.setData(`application/json`,{})}catch{}i.setCurrentDragSourceNode(e.target),i.getCurrentSourcePreviewNodeOptions().captureDraggingState?i.actions.publishDragSource():setTimeout(function(){return i.actions.publishDragSource()},0)}else if(a)i.beginDragNativeItem(a);else if(r&&!r.types&&(e.target&&!e.target.hasAttribute||!e.target.hasAttribute(`draggable`)))return;else e.preventDefault()}}),Z(this,`handleTopDragEndCapture`,function(){i.clearCurrentDragSourceNode()&&i.monitor.isDragging()&&i.actions.endDrag()}),Z(this,`handleTopDragEnterCapture`,function(e){if(i.dragEnterTargetIds=[],!(!i.enterLeaveCounter.enter(e.target)||i.monitor.isDragging())){var t=e.dataTransfer,n=rc(t);n&&i.beginDragNativeItem(n,t)}}),Z(this,`handleTopDragEnter`,function(e){var t=i.dragEnterTargetIds;i.dragEnterTargetIds=[],i.monitor.isDragging()&&(i.altKeyPressed=e.altKey,t.length>0&&i.actions.hover(t,{clientOffset:Rs(e)}),t.some(function(e){return i.monitor.canDropOnTarget(e)})&&(e.preventDefault(),e.dataTransfer&&(e.dataTransfer.dropEffect=i.getCurrentDropEffect())))}),Z(this,`handleTopDragOverCapture`,function(){i.dragOverTargetIds=[]}),Z(this,`handleTopDragOver`,function(e){var t=i.dragOverTargetIds;if(i.dragOverTargetIds=[],!i.monitor.isDragging()){e.preventDefault(),e.dataTransfer&&(e.dataTransfer.dropEffect=`none`);return}i.altKeyPressed=e.altKey,i.lastClientOffset=Rs(e),i.hoverRafId===null&&typeof requestAnimationFrame<`u`&&(i.hoverRafId=requestAnimationFrame(function(){i.monitor.isDragging()&&i.actions.hover(t||[],{clientOffset:i.lastClientOffset}),i.hoverRafId=null})),(t||[]).some(function(e){return i.monitor.canDropOnTarget(e)})?(e.preventDefault(),e.dataTransfer&&(e.dataTransfer.dropEffect=i.getCurrentDropEffect())):i.isDraggingNativeItem()?e.preventDefault():(e.preventDefault(),e.dataTransfer&&(e.dataTransfer.dropEffect=`none`))}),Z(this,`handleTopDragLeaveCapture`,function(e){i.isDraggingNativeItem()&&e.preventDefault(),i.enterLeaveCounter.leave(e.target)&&i.isDraggingNativeItem()&&setTimeout(function(){return i.endDragNativeItem()},0)}),Z(this,`handleTopDropCapture`,function(e){if(i.dropTargetIds=[],i.isDraggingNativeItem()){var t;e.preventDefault(),(t=i.currentNativeSource)==null||t.loadDataTransfer(e.dataTransfer)}else rc(e.dataTransfer)&&e.preventDefault();i.enterLeaveCounter.reset()}),Z(this,`handleTopDrop`,function(e){var t=i.dropTargetIds;i.dropTargetIds=[],i.actions.hover(t,{clientOffset:Rs(e)}),i.actions.drop({dropEffect:i.getCurrentDropEffect()}),i.isDraggingNativeItem()?i.endDragNativeItem():i.monitor.isDragging()&&i.actions.endDrag()}),Z(this,`handleSelectStart`,function(e){var t=e.target;typeof t.dragDrop==`function`&&(t.tagName===`INPUT`||t.tagName===`SELECT`||t.tagName===`TEXTAREA`||t.isContentEditable||(e.preventDefault(),t.dragDrop()))}),this.options=new cc(n,r),this.actions=t.getActions(),this.monitor=t.getMonitor(),this.registry=t.getRegistry(),this.enterLeaveCounter=new Os(this.isNodeInDocument)}return pc(e,[{key:`profile`,value:function(){return{sourcePreviewNodes:this.sourcePreviewNodes.size,sourcePreviewNodeOptions:this.sourcePreviewNodeOptions.size,sourceNodeOptions:this.sourceNodeOptions.size,sourceNodes:this.sourceNodes.size,dragStartSourceIds:this.dragStartSourceIds?.length||0,dropTargetIds:this.dropTargetIds.length,dragEnterTargetIds:this.dragEnterTargetIds.length,dragOverTargetIds:this.dragOverTargetIds?.length||0}}},{key:`window`,get:function(){return this.options.window}},{key:`document`,get:function(){return this.options.document}},{key:`rootElement`,get:function(){return this.options.rootElement}},{key:`setup`,value:function(){var e=this.rootElement;if(e!==void 0){if(e.__isReactDndBackendSetUp)throw Error(`Cannot have two HTML5 backends at the same time.`);e.__isReactDndBackendSetUp=!0,this.addEventListeners(e)}}},{key:`teardown`,value:function(){var e=this.rootElement;if(e!==void 0&&(e.__isReactDndBackendSetUp=!1,this.removeEventListeners(this.rootElement),this.clearCurrentDragSourceNode(),this.asyncEndDragFrameId)){var t;(t=this.window)==null||t.cancelAnimationFrame(this.asyncEndDragFrameId)}}},{key:`connectDragPreview`,value:function(e,t,n){var r=this;return this.sourcePreviewNodeOptions.set(e,n),this.sourcePreviewNodes.set(e,t),function(){r.sourcePreviewNodes.delete(e),r.sourcePreviewNodeOptions.delete(e)}}},{key:`connectDragSource`,value:function(e,t,n){var r=this;this.sourceNodes.set(e,t),this.sourceNodeOptions.set(e,n);var i=function(t){return r.handleDragStart(t,e)},a=function(e){return r.handleSelectStart(e)};return t.setAttribute(`draggable`,`true`),t.addEventListener(`dragstart`,i),t.addEventListener(`selectstart`,a),function(){r.sourceNodes.delete(e),r.sourceNodeOptions.delete(e),t.removeEventListener(`dragstart`,i),t.removeEventListener(`selectstart`,a),t.setAttribute(`draggable`,`false`)}}},{key:`connectDropTarget`,value:function(e,t){var n=this,r=function(t){return n.handleDragEnter(t,e)},i=function(t){return n.handleDragOver(t,e)},a=function(t){return n.handleDrop(t,e)};return t.addEventListener(`dragenter`,r),t.addEventListener(`dragover`,i),t.addEventListener(`drop`,a),function(){t.removeEventListener(`dragenter`,r),t.removeEventListener(`dragover`,i),t.removeEventListener(`drop`,a)}}},{key:`addEventListeners`,value:function(e){e.addEventListener&&(e.addEventListener(`dragstart`,this.handleTopDragStart),e.addEventListener(`dragstart`,this.handleTopDragStartCapture,!0),e.addEventListener(`dragend`,this.handleTopDragEndCapture,!0),e.addEventListener(`dragenter`,this.handleTopDragEnter),e.addEventListener(`dragenter`,this.handleTopDragEnterCapture,!0),e.addEventListener(`dragleave`,this.handleTopDragLeaveCapture,!0),e.addEventListener(`dragover`,this.handleTopDragOver),e.addEventListener(`dragover`,this.handleTopDragOverCapture,!0),e.addEventListener(`drop`,this.handleTopDrop),e.addEventListener(`drop`,this.handleTopDropCapture,!0))}},{key:`removeEventListeners`,value:function(e){e.removeEventListener&&(e.removeEventListener(`dragstart`,this.handleTopDragStart),e.removeEventListener(`dragstart`,this.handleTopDragStartCapture,!0),e.removeEventListener(`dragend`,this.handleTopDragEndCapture,!0),e.removeEventListener(`dragenter`,this.handleTopDragEnter),e.removeEventListener(`dragenter`,this.handleTopDragEnterCapture,!0),e.removeEventListener(`dragleave`,this.handleTopDragLeaveCapture,!0),e.removeEventListener(`dragover`,this.handleTopDragOver),e.removeEventListener(`dragover`,this.handleTopDragOverCapture,!0),e.removeEventListener(`drop`,this.handleTopDrop),e.removeEventListener(`drop`,this.handleTopDropCapture,!0))}},{key:`getCurrentSourceNodeOptions`,value:function(){var e=this.monitor.getSourceId(),t=this.sourceNodeOptions.get(e);return uc({dropEffect:this.altKeyPressed?`copy`:`move`},t||{})}},{key:`getCurrentDropEffect`,value:function(){return this.isDraggingNativeItem()?`copy`:this.getCurrentSourceNodeOptions().dropEffect}},{key:`getCurrentSourcePreviewNodeOptions`,value:function(){var e=this.monitor.getSourceId();return uc({anchorX:.5,anchorY:.5,captureDraggingState:!1},this.sourcePreviewNodeOptions.get(e)||{})}},{key:`isDraggingNativeItem`,value:function(){var e=this.monitor.getItemType();return Object.keys(Hs).some(function(t){return Hs[t]===e})}},{key:`beginDragNativeItem`,value:function(e,t){this.clearCurrentDragSourceNode(),this.currentNativeSource=nc(e,t),this.currentNativeHandle=this.registry.addSource(e,this.currentNativeSource),this.actions.beginDrag([this.currentNativeHandle])}},{key:`setCurrentDragSourceNode`,value:function(e){var t=this;this.clearCurrentDragSourceNode(),this.currentDragSourceNode=e,this.mouseMoveTimeoutTimer=setTimeout(function(){return t.rootElement?.addEventListener(`mousemove`,t.endDragIfSourceWasRemovedFromDOM,!0)},1e3)}},{key:`clearCurrentDragSourceNode`,value:function(){if(this.currentDragSourceNode){if(this.currentDragSourceNode=null,this.rootElement){var e;(e=this.window)==null||e.clearTimeout(this.mouseMoveTimeoutTimer||void 0),this.rootElement.removeEventListener(`mousemove`,this.endDragIfSourceWasRemovedFromDOM,!0)}return this.mouseMoveTimeoutTimer=null,!0}return!1}},{key:`handleDragStart`,value:function(e,t){e.defaultPrevented||(this.dragStartSourceIds||=[],this.dragStartSourceIds.unshift(t))}},{key:`handleDragEnter`,value:function(e,t){this.dragEnterTargetIds.unshift(t)}},{key:`handleDragOver`,value:function(e,t){this.dragOverTargetIds===null&&(this.dragOverTargetIds=[]),this.dragOverTargetIds.unshift(t)}},{key:`handleDrop`,value:function(e,t){this.dropTargetIds.unshift(t)}}]),e}(),hc;function gc(){return hc||(hc=new Image,hc.src=`data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==`),hc}var _c=function(e,t,n){return new mc(e,t,n)};function vc(e,t){return typeof e==`function`?e(t):e??`NODE`}function yc(e){return e.isDraggable&&!e.isEditing}function bc(e){let t=W(),n=t.selectedIds,[r,i,a]=Yo(()=>({canDrag:()=>yc(e),type:vc(t.props.dragType,e),item:()=>{let r=t.isSelected(e.id)?Array.from(n):[e.id];return t.dispatch(dn.dragStart(e.id,r)),{id:e.id,dragIds:r,data:e.data}},end:()=>{t.hideCursor(),t.redrawList(),t.dispatch(dn.dragEnd())}}),[n,e,t.props.dragType]);return(0,V.useEffect)(()=>{a(gc())},[a]),i}function xc(e,t){let n=e.getBoundingClientRect(),r=t.x-Math.round(n.x),i=t.y-Math.round(n.y),a=n.height,o=i<a/2,s=!o,c=a/4,l=i>c&&i<a-c;return{x:r,inTopHalf:o,inBottomHalf:s,inMiddle:l,atTop:!l&&o,atBottom:!l&&s}}function Sc(e,t,n,r){return e?e.isInternal?r.atTop?[t,e]:r.inMiddle?[e,e]:[e,n]:r.inTopHalf?[t,e]:[e,n]:[t,null]}function Cc(e,t){return{parentId:e||null,index:t}}function wc(e,t){return{type:`line`,index:e,level:t}}function Tc(e){return{type:`highlight`,id:e}}function Ec(e,t){let n=e;for(;n.parent&&n.level>t;)n=n.parent;return{parentId:n.parent?.id||null,index:Ct(n)+1}}function Dc(e){let t=xc(e.element,e.offset),n=e.indent,r=Math.round(Math.max(0,t.x-n)/n),{node:i,nextNode:a,prevNode:o}=e,[s,c]=Sc(i,o,a,t);if(i&&i.isInternal&&t.inMiddle)return{drop:Cc(i.id,null),cursor:Tc(i.id)};if(!s)return{drop:Cc(c?.parent?.id,0),cursor:wc(0,0)};if(yt(s)){let e=vt(r,c?.level||0,s.level);return{drop:Ec(s,e),cursor:wc(s.rowIndex+1,e)}}if(bt(s)){let e=vt(r,c?.level||0,s.level);return{drop:Ec(s,e),cursor:wc(s.rowIndex+1,e)}}if(xt(s)){let e=vt(r,0,s.level+1);return e>s.level?{drop:Cc(s.id,0),cursor:wc(s.rowIndex+1,e)}:{drop:Ec(s,e),cursor:wc(s.rowIndex+1,e)}}return{drop:Cc(s?.id,0),cursor:wc(s.rowIndex+1,s.level+1)}}function Oc(e,t){let n=W(),[r,i]=ps(()=>({accept:`NODE`,canDrop:()=>n.canDrop(),hover:(r,i)=>{let a=i.getClientOffset();if(!e.current||!a)return;let{cursor:o,drop:s}=Dc({element:e.current,offset:a,indent:n.indent,node:t,prevNode:t.prev,nextNode:t.next});s&&n.dispatch(dn.hovering(s.parentId,s.index)),i.canDrop()?o&&n.showCursor(o):n.hideCursor()},drop:(e,t)=>{if(!t.canDrop())return null;n.drop()}}),[t,e.current,n.props]);return i}function kc(e){let t=W(),n=t.at(e);if(!n)throw Error(`Could not find node for index: ${e}`);return(0,V.useMemo)(()=>{let r=n.clone();return t.visibleNodes[e]=r,r},[...Object.values(n.state),n])}var Ac=V.memo(function({index:e,style:t}){gt(),ft();let n=W(),r=kc(e),i=(0,V.useRef)(null),a=bc(r),o=Oc(i,r),s=(0,V.useCallback)(e=>{i.current=e,o(e)},[o]),c=n.indent*r.level,l=(0,V.useMemo)(()=>({paddingLeft:c}),[c]),u=(0,V.useMemo)(()=>Object.assign(Object.assign({},t),{top:parseFloat(t.top)+(n.props.padding??n.props.paddingTop??0),minWidth:`max-content`}),[t,n.props.padding,n.props.paddingTop]),d={role:`treeitem`,"aria-level":r.level+1,"aria-selected":r.isSelected,"aria-expanded":r.isOpen,style:u,tabIndex:-1,className:n.props.rowClassName};(0,V.useEffect)(()=>{var e;!r.isEditing&&r.isFocused&&((e=i.current)==null||e.focus({preventScroll:!0}))},[r.isEditing,r.isFocused,i.current]);let f=n.renderNode,p=n.renderRow;return(0,H.jsx)(p,{node:r,innerRef:s,attrs:d,children:(0,H.jsx)(f,{node:r,tree:n,style:l,dragHandle:a})})}),jc=``,Mc=null;function Nc(){gt();let e=W();return(0,H.jsx)(`div`,{role:`tree`,"aria-label":e.props[`aria-label`],"aria-labelledby":e.props[`aria-labelledby`],"aria-multiselectable":!e.props.disableMultiSelection||void 0,style:{height:e.height,width:e.width,minHeight:0,minWidth:0},onContextMenu:e.props.onContextMenu,onClick:e.props.onClick,tabIndex:0,onFocus:t=>{t.currentTarget.contains(t.relatedTarget)||e.onFocus()},onBlur:t=>{t.currentTarget.contains(t.relatedTarget)||e.onBlur()},onKeyDown:t=>{if(e.isEditing)return;if(t.key===`Backspace`){if(!e.props.onDelete)return;let t=Array.from(e.selectedIds);if(t.length>1){let n=e.mostRecentNode;for(;n&&n.isSelected;)n=n.nextSibling;n||=e.lastNode,e.focus(n,{scroll:!1}),e.delete(Array.from(t))}else{let t=e.focusedNode;if(t){let n=t.nextSibling,r=t.parent;e.focus(n||r,{scroll:!1}),e.delete(t)}}return}if(t.key===`Tab`&&!t.shiftKey){t.preventDefault(),Dt(t.currentTarget);return}if(t.key===`Tab`&&t.shiftKey){t.preventDefault(),Ot(t.currentTarget);return}if(t.key===`ArrowDown`){t.preventDefault();let n=e.nextNode;if(t.metaKey){e.select(e.focusedNode),e.activate(e.focusedNode);return}else if(!t.shiftKey||e.props.disableMultiSelection){e.focus(n);return}else{if(!n)return;let t=e.focusedNode;t?t.isSelected?e.selectContiguous(n):e.selectMulti(n):e.focus(e.firstNode);return}}if(t.key===`ArrowUp`){t.preventDefault();let n=e.prevNode;if(!t.shiftKey||e.props.disableMultiSelection){e.focus(n);return}else{if(!n)return;let t=e.focusedNode;t?t.isSelected?e.selectContiguous(n):e.selectMulti(n):e.focus(e.lastNode);return}}if(t.key===`ArrowRight`){let t=e.focusedNode;if(!t)return;t.isInternal&&t.isOpen?e.focus(e.nextNode):t.isInternal&&e.open(t.id);return}if(t.key===`ArrowLeft`){let t=e.focusedNode;if(!t||t.isRoot)return;t.isInternal&&t.isOpen?e.close(t.id):t.parent?.isRoot||e.focus(t.parent);return}if(t.key===`a`&&(t.metaKey||t.ctrlKey)&&!e.props.disableMultiSelection){t.preventDefault(),e.selectAll();return}if(t.key===`a`&&!t.metaKey&&!t.ctrlKey&&e.props.onCreate){e.createLeaf();return}if(t.key===`A`&&!t.metaKey&&!t.ctrlKey){if(!e.props.onCreate)return;e.createInternal();return}if(t.key===`Home`){t.preventDefault(),e.focus(e.firstNode);return}if(t.key===`End`){t.preventDefault(),e.focus(e.lastNode);return}if(t.key===`Enter`){let t=e.focusedNode;if(!t||!t.isEditable||!e.props.onRename)return;setTimeout(()=>{t&&e.edit(t)});return}if(t.key===` `){t.preventDefault();let n=e.focusedNode;if(!n)return;n.isLeaf?(n.select(),n.activate()):n.toggle();return}if(t.key===`*`){let t=e.focusedNode;if(!t)return;e.openSiblings(t);return}if(t.key===`PageUp`){t.preventDefault(),e.pageUp();return}t.key===`PageDown`&&(t.preventDefault(),e.pageDown()),clearTimeout(Mc),jc+=t.key,Mc=setTimeout(()=>{jc=``},600);let n=e.visibleNodes.find(e=>{let t=e.data.name;return typeof t==`string`?t.toLowerCase().startsWith(jc):!1});n&&e.focus(n.id)},children:(0,H.jsx)(Pc,{})})}function Pc(){let e=W(),t={className:e.props.className,outerRef:e.listEl,itemCount:e.visibleNodes.length,height:e.height,width:e.width,overscanCount:e.overscanCount,itemKey:t=>e.visibleNodes[t]?.id||t,outerElementType:e.props.outerElementType??Xn,innerElementType:e.props.innerElementType??$n,onScroll:e.props.onScroll,onItemsRendered:e.onItemsRendered.bind(e)};return typeof e.props.rowHeight==`function`?(0,H.jsx)(Kn,Object.assign({},t,{itemSize:e.rowHeightAt,ref:e.list,children:Ac})):(0,H.jsx)(qn,Object.assign({},t,{itemSize:e.rowHeight,ref:e.list,children:Ac}))}function Fc(e){return e.isFiltered?Lc(e.root,e.isMatch.bind(e)):Ic(e.root)}function Ic(e){let t=[];function n(e){var r;e.level>=0&&t.push(e),e.isOpen&&((r=e.children)==null||r.forEach(n))}return n(e),t.forEach(Rc),t}function Lc(e,t){let n={},r=[];function i(e){if(!e.isRoot&&t(e)){n[e.id]=!0;let t=e.parent;for(;t;)n[t.id]=!0,t=t.parent}if(e.children)for(let t of e.children)i(t)}function a(e){var t;e.level>=0&&n[e.id]&&r.push(e),e.isOpen&&((t=e.children)==null||t.forEach(a))}return i(e),a(e),r.forEach(Rc),r}function Rc(e,t){e.rowIndex=t}var zc=e=>e.reduce((e,t,n)=>(e[t.id]=n,e),{}),Bc=function(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})},{safeRun:Q}=_t,Vc=class e{constructor(e,t,n,r){this.store=e,this.props=t,this.list=n,this.listEl=r,this.visibleStartIndex=0,this.visibleStopIndex=0,this.rowOffsets=null,this.rowHeightAt=e=>{let t=this.props.rowHeight;if(typeof t==`function`){let n=this.at(e);return n?t(n):this.rowHeight}return t??24},this.rowTopPosition=e=>{if(typeof this.props.rowHeight!=`function`)return e*this.rowHeight;let t=this.getRowOffsets();return t[Math.max(0,Math.min(e,t.length-1))]},this.redrawList=(e=0)=>{this.rowOffsets=null;let t=this.list.current;t&&`resetAfterIndex`in t&&t.resetAfterIndex(Math.max(0,e))},this.root=Zt(this),this.visibleNodes=Fc(this),this.idToIndex=zc(this.visibleNodes)}update(e){this.props=e,this.root=Zt(this),this.visibleNodes=Fc(this),this.idToIndex=zc(this.visibleNodes),this.rowOffsets=null;let t=this.list.current;t&&`resetAfterIndex`in t&&t.resetAfterIndex(0,!1)}dispatch(e){return this.store.dispatch(e)}get state(){return this.store.getState()}get openState(){return this.state.nodes.open.unfiltered}get width(){return this.props.width??300}get height(){return this.props.height??500}get indent(){return this.props.indent??24}get rowHeight(){return typeof this.props.rowHeight==`number`?this.props.rowHeight:24}getRowOffsets(){if(this.rowOffsets)return this.rowOffsets;let e=[0];for(let t=0;t<this.visibleNodes.length;t++)e.push(e[t]+this.rowHeightAt(t));return this.rowOffsets=e,e}get overscanCount(){return this.props.overscanCount??1}get searchTerm(){return(this.props.searchTerm||``).trim()}get matchFn(){let e=this.props.searchMatch??((e,t)=>JSON.stringify(Object.values(e.data)).toLocaleLowerCase().includes(t.toLocaleLowerCase()));return t=>e(t,this.searchTerm)}accessChildren(e){return Mt(e,this.props.childrenAccessor||`children`)??null}accessId(e){let t=Mt(e,this.props.idAccessor||`id`);if(!t)throw Error(`Data must contain an 'id' property or props.idAccessor must return a string`);return t}identify(e){return typeof e==`string`?e:e instanceof Qt?e.id:Mt(e,this.props.idAccessor||`id`)}identifyNull(e){return e==null?null:this.identify(e)}get firstNode(){return this.visibleNodes[0]??null}get lastNode(){return this.visibleNodes[this.visibleNodes.length-1]??null}get focusedNode(){return this.get(this.state.nodes.focus.id)??null}get mostRecentNode(){return this.get(this.state.nodes.selection.mostRecent)??null}get nextNode(){let e=this.indexOf(this.focusedNode);return e===null?null:this.at(e+1)}get prevNode(){let e=this.indexOf(this.focusedNode);return e===null?null:this.at(e-1)}get(e){return e&&e in this.idToIndex&&this.visibleNodes[this.idToIndex[e]]||null}at(e){return this.visibleNodes[e]||null}nodesBetween(e,t){if(e===null||t===null)return[];let n=this.indexOf(e)??0,r=this.indexOf(t);if(r===null)return[];let i=Math.min(n,r),a=Math.max(n,r);return this.visibleNodes.slice(i,a+1)}indexOf(e){let t=this.identifyNull(e);return t?this.idToIndex[t]:null}get editingId(){return this.state.nodes.edit.id}createInternal(){return this.create({type:`internal`})}createLeaf(){return this.create({type:`leaf`})}create(){return Bc(this,arguments,void 0,function*(e={}){let t=e.parentId===void 0?Vt(this):e.parentId,n=e.index??Rt(this),r=e.type??`leaf`,i=yield Q(this.props.onCreate,{type:r,parentId:t,index:n,parentNode:this.get(t)});i&&(this.focus(i),setTimeout(()=>{this.edit(i).then(()=>{this.select(i),this.activate(i)})}))})}delete(e){return Bc(this,void 0,void 0,function*(){if(!e)return;let t=(Array.isArray(e)?e:[e]).map(e=>this.identify(e)),n=t.map(e=>this.get(e)).filter(e=>!!e),r=n.length?Math.min(...n.map(e=>e.rowIndex??0)):0;yield Q(this.props.onDelete,{nodes:n,ids:t}),this.redrawList(r)})}edit(t){let n=this.identify(t);return this.resolveEdit({cancelled:!0}),this.scrollTo(n),this.dispatch($t(n)),this.redrawList(this.get(n)?.rowIndex??0),new Promise(t=>{e.editPromise=t})}submit(e,t){return Bc(this,void 0,void 0,function*(){if(!e)return;let n=this.identify(e);yield Q(this.props.onRename,{id:n,name:t,node:this.get(n)}),this.dispatch($t(null)),this.resolveEdit({cancelled:!1,value:t}),this.redrawList(this.get(n)?.rowIndex??0),setTimeout(()=>this.onFocus())})}reset(){this.dispatch($t(null)),this.resolveEdit({cancelled:!0}),this.redrawList(),setTimeout(()=>this.onFocus())}activate(e){let t=this.get(this.identifyNull(e));t&&Q(this.props.onActivate,t)}resolveEdit(t){let n=e.editPromise;n&&n(t),e.editPromise=null}get selectedIds(){return this.state.nodes.selection.ids}get selectedNodes(){let e=[];for(let t of Array.from(this.selectedIds)){let n=this.get(t);n&&e.push(n)}return e}focus(e,t={}){e&&(this.props.selectionFollowsFocus?this.select(e):(this.dispatch(tn(this.identify(e))),t.scroll!==!1&&this.scrollTo(e),this.focusedNode&&Q(this.props.onFocus,this.focusedNode)))}pageUp(){let e=this.visibleStartIndex,t=this.visibleStopIndex-e,n=this.focusedNode?.rowIndex??0;n=n>e?e:Math.max(e-t,0),this.focus(this.at(n))}pageDown(){let e=this.visibleStartIndex,t=this.visibleStopIndex,n=t-e,r=this.focusedNode?.rowIndex??0;r=r<t?t:Math.min(r+n,this.visibleNodes.length-1),this.focus(this.at(r))}select(e,t={}){if(!e)return;let n=t.focus!==!1,r=this.identify(e);n&&this.dispatch(tn(r)),this.get(r)?.isSelectable&&this.setSelection({ids:[r],anchor:r,mostRecent:r}),this.scrollTo(r,t.align),this.focusedNode&&n&&Q(this.props.onFocus,this.focusedNode)}deselect(e){if(!e)return;let t=this.identify(e);this.dispatch(ln.remove(t)),Q(this.props.onSelect,this.selectedNodes)}selectMulti(e,t={}){let n=this.get(this.identifyNull(e));if(!n)return;let r=t.focus!==!1;r&&this.dispatch(tn(n.id)),n.isSelectable&&(this.dispatch(ln.add(n.id)),this.dispatch(ln.anchor(n.id)),this.dispatch(ln.mostRecent(n.id))),this.scrollTo(n,t.align),this.focusedNode&&r&&Q(this.props.onFocus,this.focusedNode),Q(this.props.onSelect,this.selectedNodes)}selectContiguous(e){if(!e)return;let t=this.identify(e);if(this.dispatch(tn(t)),this.get(t)?.isSelectable){let{anchor:e,mostRecent:n}=this.state.nodes.selection,r=this.filterSelectableNodes(this.nodesBetween(e,this.identifyNull(t)));this.dispatch(ln.remove(this.nodesBetween(e,n))),this.dispatch(ln.add(r)),this.dispatch(ln.mostRecent(t))}this.scrollTo(t),this.focusedNode&&Q(this.props.onFocus,this.focusedNode),Q(this.props.onSelect,this.selectedNodes)}deselectAll(){this.setSelection({ids:[],anchor:null,mostRecent:null})}selectAll(){let e=this.filterSelectableNodes(Object.keys(this.idToIndex));this.setSelection({ids:e,anchor:e[0]??null,mostRecent:e[e.length-1]??null}),this.dispatch(tn(this.lastNode?.id)),this.focusedNode&&Q(this.props.onFocus,this.focusedNode)}filterSelectableNodes(e){return e.map(e=>this.get(this.identify(e))).filter(e=>!!e&&e.isSelectable)}setSelection(e){let t=new Set(e.ids?.map(e=>this.identify(e))),n=this.identifyNull(e.anchor),r=this.identifyNull(e.mostRecent);this.dispatch(ln.set({ids:t,anchor:n,mostRecent:r})),Q(this.props.onSelect,this.selectedNodes)}get cursorParentId(){let{cursor:e}=this.state.dnd;switch(e.type){case`highlight`:return e.id;default:return null}}get cursorOverFolder(){return this.state.dnd.cursor.type===`highlight`}get dragNodes(){return this.state.dnd.dragIds.map(e=>this.get(e)).filter(e=>!!e)}get dragNode(){return this.get(this.state.nodes.drag.id)}get dragDestinationParent(){return this.get(this.state.nodes.drag.destinationParentId)}get dragDestinationIndex(){return this.state.nodes.drag.destinationIndex}canDrop(){if(this.isFiltered)return!1;let e=this.get(this.state.dnd.parentId)??this.root,t=this.dragNodes,n=this.props.disableDrop;for(let n of t)if(!n||!e||n.isInternal&&St(e,n))return!1;return typeof n==`function`?!n({parentNode:e,dragNodes:this.dragNodes,index:this.state.dnd.index||0}):typeof n==`string`?!e.data[n]:typeof n==`boolean`?!n:!0}drop(){let{parentId:e,index:t,dragIds:n}=this.state.dnd;Q(this.props.onMove,{dragIds:n,parentId:e===`__REACT_ARBORIST_INTERNAL_ROOT__`?null:e,index:t===null?0:t,dragNodes:this.dragNodes,parentNode:this.get(e)}),this.open(e)}hideCursor(){this.dispatch(dn.cursor({type:`none`}))}showCursor(e){this.dispatch(dn.cursor(e))}open(e,t=!0){let n=this.identifyNull(e);n&&(this.isOpen(n)||(this.dispatch(an.open(n,this.isFiltered)),t&&this.redrawList(this.get(n)?.rowIndex??0),Q(this.props.onToggle,n)))}close(e,t=!0){let n=this.identifyNull(e);n&&this.isOpen(n)&&(this.dispatch(an.close(n,this.isFiltered)),t&&this.redrawList(this.get(n)?.rowIndex??0),Q(this.props.onToggle,n))}toggle(e){let t=this.identifyNull(e);if(t)return this.isOpen(t)?this.close(t):this.open(t)}openParents(e){let t=this.identifyNull(e);if(!t)return;let n=Tt(this.root,t)?.parent;for(;n;)this.open(n.id,!1),n=n.parent;this.redrawList()}openSiblings(e){let t=e.parent;if(!t)this.toggle(e.id);else if(t.children){let n=e.isOpen;for(let e of t.children)e.isInternal&&(n?this.close(e.id,!1):this.open(e.id,!1));this.redrawList(),this.scrollTo(this.focusedNode)}}openAll(){Et(this.root,e=>{e.isInternal&&this.open(e.id,!1)}),this.redrawList()}closeAll(){Et(this.root,e=>{e.isInternal&&this.close(e.id,!1)}),this.redrawList()}scrollTo(e,t=`smart`){if(!e)return;let n=this.identify(e);return this.openParents(n),Lt(()=>n in this.idToIndex).then(()=>{var e;let r=this.idToIndex[n];r!==void 0&&((e=this.list.current)==null||e.scrollToItem(r,t))}).catch(()=>{})}get isEditing(){return this.state.nodes.edit.id!==null}get isFiltered(){return!!this.props.searchTerm?.trim()}get hasFocus(){return this.state.nodes.focus.treeFocused}get hasNoSelection(){return this.state.nodes.selection.ids.size===0}get hasOneSelection(){return this.state.nodes.selection.ids.size===1}get hasMultipleSelections(){return this.state.nodes.selection.ids.size>1}isSelected(e){return e?this.state.nodes.selection.ids.has(e):!1}isOpen(e){if(!e)return!1;if(e===`__REACT_ARBORIST_INTERNAL_ROOT__`)return!0;let t=this.props.openByDefault??!0;return this.isFiltered?this.state.nodes.open.filtered[e]??!0:this.state.nodes.open.unfiltered[e]??t}isEditable(e){return this.isActionPossible(e,this.props.disableEdit)}isDraggable(e){return this.isActionPossible(e,this.props.disableDrag)}isSelectable(e){return this.isActionPossible(e,this.props.disableSelect)}isActionPossible(e,t=()=>!1){return!Mt(e,t)}isDragging(e){let t=this.identifyNull(e);return t?this.state.nodes.drag.id===t:!1}isFocused(e){return this.hasFocus&&this.state.nodes.focus.id===e}isMatch(e){return this.matchFn(e)}willReceiveDrop(e){let t=this.identifyNull(e);if(!t)return!1;let{destinationParentId:n,destinationIndex:r}=this.state.nodes.drag;return t===n&&r===null}onFocus(){let e=this.focusedNode||this.firstNode;e&&this.dispatch(tn(e.id))}onBlur(){this.dispatch(nn())}onItemsRendered(e){this.visibleStartIndex=e.visibleStartIndex,this.visibleStopIndex=e.visibleStopIndex}get renderContainer(){return this.props.renderContainer||Nc}get renderRow(){return this.props.renderRow||Kt}get renderNode(){return this.props.children||qt}get renderDragPreview(){return this.props.renderDragPreview||gn}get renderCursor(){return this.props.renderCursor||Gt}};function $(e){return`Minified Redux error #${e}; visit https://redux.js.org/Errors?code=${e} for the full message or use the non-minified dev environment for full errors. `}var Hc=typeof Symbol==`function`&&Symbol.observable||`@@observable`,Uc=()=>Math.random().toString(36).substring(7).split(``).join(`.`),Wc={INIT:`@@redux/INIT${Uc()}`,REPLACE:`@@redux/REPLACE${Uc()}`,PROBE_UNKNOWN_ACTION:()=>`@@redux/PROBE_UNKNOWN_ACTION${Uc()}`};function Gc(e){if(typeof e!=`object`||!e)return!1;let t=e;for(;Object.getPrototypeOf(t)!==null;)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t||Object.getPrototypeOf(e)===null}function Kc(e,t,n){if(typeof e!=`function`)throw Error($(2));if(typeof t==`function`&&typeof n==`function`||typeof n==`function`&&typeof arguments[3]==`function`)throw Error($(0));if(typeof t==`function`&&n===void 0&&(n=t,t=void 0),n!==void 0){if(typeof n!=`function`)throw Error($(1));return n(Kc)(e,t)}let r=e,i=t,a=new Map,o=a,s=0,c=!1;function l(){o===a&&(o=new Map,a.forEach((e,t)=>{o.set(t,e)}))}function u(){if(c)throw Error($(3));return i}function d(e){if(typeof e!=`function`)throw Error($(4));if(c)throw Error($(5));let t=!0;l();let n=s++;return o.set(n,e),function(){if(t){if(c)throw Error($(6));t=!1,l(),o.delete(n),a=null}}}function f(e){if(!Gc(e))throw Error($(7));if(e.type===void 0)throw Error($(8));if(typeof e.type!=`string`)throw Error($(17));if(c)throw Error($(9));try{c=!0,i=r(i,e)}finally{c=!1}return(a=o).forEach(e=>{e()}),e}function p(e){if(typeof e!=`function`)throw Error($(10));r=e,f({type:Wc.REPLACE})}function m(){let e=d;return{subscribe(t){if(typeof t!=`object`||!t)throw Error($(11));function n(){let e=t;e.next&&e.next(u())}return n(),{unsubscribe:e(n)}},[Hc](){return this}}}return f({type:Wc.INIT}),{dispatch:f,subscribe:d,getState:u,replaceReducer:p,[Hc]:m}}function qc(e){Object.keys(e).forEach(t=>{let n=e[t];if(n(void 0,{type:Wc.INIT})===void 0)throw Error($(12));if(n(void 0,{type:Wc.PROBE_UNKNOWN_ACTION()})===void 0)throw Error($(13))})}function Jc(e){let t=Object.keys(e),n={};for(let r=0;r<t.length;r++){let i=t[r];typeof e[i]==`function`&&(n[i]=e[i])}let r=Object.keys(n),i;try{qc(n)}catch(e){i=e}return function(e={},t){if(i)throw i;let a=!1,o={};for(let i=0;i<r.length;i++){let s=r[i],c=n[s],l=e[s],u=c(l,t);if(u===void 0)throw t&&t.type,Error($(14));o[s]=u,a||=u!==l}return a||=r.length!==Object.keys(e).length,a?o:e}}function Yc(e=cn().nodes.drag,t){switch(t.type){case`DND_DRAG_START`:return Object.assign(Object.assign({},e),{id:t.id,selectedIds:t.dragIds});case`DND_DRAG_END`:return Object.assign(Object.assign({},e),{id:null,destinationParentId:null,destinationIndex:null,selectedIds:[]});case`DND_HOVERING`:return t.parentId!==e.destinationParentId||t.index!=e.destinationIndex?Object.assign(Object.assign({},e),{destinationParentId:t.parentId,destinationIndex:t.index}):e;default:return e}}var Xc=Jc({nodes:Jc({focus:rn,edit:en,open:sn,selection:un,drag:Yc}),dnd:fn}),Zc=lt(),Qc=cn();function $c({treeProps:e,imperativeHandle:t,children:n}){let r=(0,V.useRef)(null),i=(0,V.useRef)(null),a=(0,V.useRef)(Kc(Xc,cn(e))),o=(0,Zc.useSyncExternalStore)(a.current.subscribe,a.current.getState,()=>Qc),s=(0,V.useMemo)(()=>new Vc(a.current,e,r,i),[]),c=(0,V.useRef)(0);return(0,V.useMemo)(()=>{c.current+=1,s.update(e)},Object.values(e)),(0,V.useMemo)(()=>{c.current+=1,s.update(s.props)},[o.nodes.open]),(0,V.useImperativeHandle)(t,()=>s),(0,V.useEffect)(()=>{s.props.selection?s.select(s.props.selection,{focus:!1}):s.deselectAll()},[s.props.selection]),(0,V.useEffect)(()=>{s.props.searchTerm||a.current.dispatch(an.clear(!0))},[s.props.searchTerm]),(0,H.jsx)(ut.Provider,{value:s,children:(0,H.jsx)(ht.Provider,{value:c.current,children:(0,H.jsx)(dt.Provider,{value:o.nodes,children:(0,H.jsx)(pt.Provider,{value:o.dnd,children:(0,H.jsx)(Ca,Object.assign({},e.dndManager?{manager:e.dndManager}:{backend:e.dndBackend||_c,options:{rootElement:s.props.dndRootElement||void 0}},{children:n}))})})})})}function el(){let e=W(),[,t]=ps(()=>({accept:`NODE`,canDrop:(t,n)=>n.isOver({shallow:!0})?e.canDrop():!1,hover:(t,n)=>{if(!n.isOver({shallow:!0}))return;let r=n.getClientOffset();if(!e.listEl.current||!r)return;let{cursor:i,drop:a}=Dc({element:e.listEl.current,offset:r,indent:e.indent,node:null,prevNode:e.visibleNodes[e.visibleNodes.length-1],nextNode:null});a&&e.dispatch(dn.hovering(a.parentId,a.index)),n.canDrop()?i&&e.showCursor(i):e.hideCursor()},drop:(t,n)=>{if(!n.isOver({shallow:!0})||!n.canDrop())return null;e.drop()}}),[e]);t(e.listEl)}function tl(e){return el(),e.children}function nl(){return(0,H.jsx)(H.Fragment,{children:(0,H.jsx)(W().props.renderContainer||Nc,{})})}function rl(){let e=W(),{offset:t,mouse:n,item:r,isDragging:i}=bs(e=>({offset:e.getSourceClientOffset(),mouse:e.getClientOffset(),item:e.getItem(),isDragging:e.isDragging()}));return(0,H.jsx)(e.props.renderDragPreview||gn,{offset:t,mouse:n,id:r?.id||null,dragIds:r?.dragIds||[],isDragging:i})}function il(e={}){let t=e.idAccessor??`id`,n=e.childrenAccessor??`children`;return{getId:typeof t==`function`?t:e=>e[t],getChildren:typeof n==`function`?n:e=>e[n],childrenKey:typeof n==`string`?n:`children`}}var al=class{constructor(e,t={}){this.accessors=il(t),this.root=ol(e,this.accessors)}get data(){return this.root.children?.map(e=>e.data)??[]}create(e){let t=e.parentId?this.find(e.parentId):this.root;if(!t)return null;t.addChild(e.data,e.index)}move(e){let t=this.find(e.id),n=e.parentId?this.find(e.parentId):this.root;!t||!n||(n.addChild(t.data,e.index),t.drop())}update(e){let t=this.find(e.id);t&&t.update(e.changes)}drop(e){let t=this.find(e.id);t&&t.drop()}find(e,t=this.root){if(!t)return null;if(t.id===e)return t;if(t.children){for(let n of t.children){let t=this.find(e,n);if(t)return t}return null}return null}};function ol(e,t){let n=new cl({},null,t,`ROOT`);return n.children=e.map(e=>sl(e,n,t)),n}function sl(e,t,n){let r=new cl(e,t,n),i=n.getChildren(e);return i&&(r.children=i.map(e=>sl(e,r,n))),r}var cl=class{constructor(e,t,n,r){this.data=e,this.parent=t,this.accessors=n,this.id=r??n.getId(e)}hasParent(){return!!this.parent}get childIndex(){return this.hasParent()?this.parent.children.indexOf(this):-1}addChild(e,t){let n=sl(e,this,this.accessors);this.children=this.children??[],this.children.splice(t,0,n);let r=this.accessors.childrenKey,i=this.data;i[r]=i[r]??[],i[r].splice(t,0,e)}removeChild(e){var t,n;(t=this.children)==null||t.splice(e,1),(n=this.data[this.accessors.childrenKey])==null||n.splice(e,1)}update(e){if(this.hasParent()){let t=this.childIndex;this.parent.addChild(Object.assign(Object.assign({},this.data),e),t),this.drop()}}drop(){this.hasParent()&&this.parent.removeChild(this.childIndex)}},ll=0;function ul(e,t={}){let[n,r]=(0,V.useState)(e),i=t.idAccessor,a=t.childrenAccessor,o=(0,V.useMemo)(()=>new al(n,{idAccessor:i,childrenAccessor:a}),[n,i,a]),s=e=>{for(let t of e.dragIds)o.move({id:t,parentId:e.parentId,index:e.index});r(o.data)},c=({name:e,id:t})=>{o.update({id:t,changes:{name:e}}),r(o.data)},l=typeof i==`string`?i:`id`,u=typeof a==`string`?a:`children`;return[n,{onMove:s,onRename:c,onCreate:({parentId:e,index:t,type:n})=>{if(typeof i==`function`)throw Error("React Arborist => initialData can't create nodes when idAccessor is a function: the generated id can't be written under a key the accessor reads. Use a string idAccessor, or the controlled `data` prop with your own onCreate.");if(n===`internal`&&typeof a==`function`)throw Error("React Arborist => initialData can't create folder nodes when childrenAccessor is a function: the new children array can't be written under a key the accessor reads. Use a string childrenAccessor, or the controlled `data` prop with your own onCreate.");let s={[l]:`simple-tree-id-${ll++}`,name:``};return n===`internal`&&(s[u]=[]),o.create({parentId:e,index:t,data:s}),r(o.data),s},onDelete:e=>{e.ids.forEach(e=>o.drop({id:e})),r(o.data)}}]}function dl(e){if(e.initialData&&e.data)throw Error(`React Arborist Tree => Provide either a data or initialData prop, but not both.`);if(e.initialData&&(e.onCreate||e.onDelete||e.onMove||e.onRename))throw Error(`React Arborist Tree => You passed the initialData prop along with a data handler.
11
- Use the data prop if you want to provide your own handlers.`);if(e.initialData){let[t,n]=ul(e.initialData,{idAccessor:e.idAccessor,childrenAccessor:e.childrenAccessor});return Object.assign(Object.assign(Object.assign({},e),n),{data:t})}else return e}function fl(e,t){return(0,H.jsxs)($c,{treeProps:dl(e),imperativeHandle:t,children:[(0,H.jsx)(tl,{children:(0,H.jsx)(nl,{})}),(0,H.jsx)(rl,{})]})}var pl=(0,V.forwardRef)(fl),ml=[0,80,180,300,520,900,1200],hl=[80,180,360],gl=new Set([`ArrowDown`,`ArrowUp`,`ArrowLeft`,`ArrowRight`,`Home`,`End`,`PageUp`,`PageDown`,`Enter`,` `,`F2`,`Delete`,`Backspace`,`ContextMenu`]);function _l(e,t){return t.top<e.top?t.top-e.top:t.bottom>e.bottom?t.bottom-e.bottom:0}function vl(e){return e.focusRow&&!e.operationActive&&!e.activeElementIsSearchInput&&!e.searchInputValue}function yl(e){return e.activeElementIsSearchInput&&!!e.searchInputValue}function bl(e){return e.requestedSelect||!e.searchInputValue}function xl(e){return gl.has(e)}function Sl(e){return e.rows.find(t=>t.path===e.lastFocusedPath)?.path??e.rows.find(e=>e.selected)?.path??e.rows[0]?.path??null}function Cl(e){return e.selectedPath??e.targetPath??e.focusedPath??e.lastFocusedPath??null}function wl(e,t){return Math.max(1,Math.floor(Math.max(0,e)/Math.max(1,t))-1)}function Tl(e){if(e.rowCount<=0)return-1;let t=Math.max(0,Math.min(e.currentIndex,e.rowCount-1))+(e.key===`PageUp`?-1:1)*Math.max(1,e.pageSize);return Math.max(0,Math.min(t,e.rowCount-1))}function El(e){if(e.nodeType!==`directory`)return!1;let t=e.selectedRow.path===e.nodePath&&e.selectedRow.type===`directory`&&e.selectedRow.expanded===!0;return e.nodeOpen||t||e.openDirectoryPaths.has(e.nodePath)}function Dl(e){let t=!e.metaKey&&!e.ctrlKey&&!e.shiftKey;return e.nodeType===`directory`&&t?`toggle-directory`:e.nodeType===`file`&&t?`open-file`:`select`}function Ol(e){return e.nodeType===`directory`?e.nodeOpen?`close-directory`:`open-directory`:e.nodeType===`file`?`open-file`:`none`}function kl(e,t=30,n=0,r=25){return e+t+n+r}function Al(e,t,n=1){return e<t+n}function jl(e,t,n,r=1){return e.find(e=>e.bottom>t+r&&e.top<n)?.path??``}function Ml(e,t,n){if(!e)return[];let r=new Map(t.map(e=>[e.path,e.top]));return x(e).filter(e=>{let t=r.get(e);return typeof t==`number`&&t<n})}function Nl(e){return!e.visible&&e.directoryNodes.length===0?[]:e.directoryNodes.map(e=>({kind:`directory`,key:e.path,node:e}))}function Pl(e){return e.map(e=>e.displayName??e.name).filter(Boolean).join(`/`)}function Fl(e){if(!e)return()=>{};let t=e.scrollTop,n=()=>{e.scrollTop=t};return n(),window.requestAnimationFrame(n),window.setTimeout(n,0),window.setTimeout(n,80),window.setTimeout(n,180),n}function Il(e,t,n){let r=We(e.node.descendantGitStatus);return(0,H.jsxs)(`button`,{type:`button`,className:`code-file-row directory code-file-sticky-row`,style:He(h(e.node.path)),title:e.node.path,onClick:t=>{t.preventDefault(),t.stopPropagation(),n(e.node)},children:[(0,H.jsx)(`span`,{className:`code-file-chevron expanded`,"aria-hidden":`true`,children:(0,H.jsx)(B,{})}),(0,H.jsx)(`span`,{className:`code-file-name`,children:e.node.displayName??e.node.name}),r&&(0,H.jsx)(`span`,{className:r,title:Ve(`git`,t)})]},e.key)}function Ll({copy:e,items:t,onFocusDirectory:n}){if(t.length===0)return null;let r=t.filter(e=>e.kind===`directory`),i=r[r.length-1];return(0,H.jsx)(`div`,{className:`code-file-sticky-shell`,children:(0,H.jsxs)(`div`,{className:`code-file-sticky-stack`,"data-testid":`code-file-sticky-stack`,"aria-label":e.stickyFolderPath,children:[(0,H.jsx)(`div`,{className:`code-file-sticky-expanded-rows`,children:r.map(t=>Il(t,e,n))}),i&&(0,H.jsxs)(`button`,{type:`button`,className:`code-file-row directory code-file-sticky-row code-file-sticky-compact-row`,style:He(0),title:i.node.path,onClick:e=>{e.preventDefault(),e.stopPropagation(),n(i.node)},children:[(0,H.jsx)(`span`,{className:`code-file-chevron expanded`,"aria-hidden":`true`,children:(0,H.jsx)(B,{})}),(0,H.jsx)(`span`,{className:`code-file-name`,children:Pl(r.map(e=>e.node))})]})]})})}function Rl({agentId:e,copy:t,fileOperation:n,inputRef:r,item:i,onCancel:a,onInputName:o,onSubmit:s}){return(0,V.useLayoutEffect)(()=>{let e=r.current;e&&(e.focus({preventScroll:!0}),document.activeElement===e&&e.setSelectionRange(0,rt(n)))},[n.item?.path,r]),(0,H.jsx)(`form`,{className:`code-file-inline-operation`,"data-testid":`code-file-inline-operation`,style:{gridColumn:`3 / -1`},autoComplete:`off`,onPointerDown:e=>e.stopPropagation(),onMouseDown:e=>e.stopPropagation(),onClick:e=>e.stopPropagation(),onSubmit:e=>{e.preventDefault(),e.stopPropagation(),s()},children:(0,H.jsx)(`input`,{id:`code-file-operation-input`,"data-testid":`code-file-operation-input`,name:`farming-file-${e}-rename`,type:`text`,inputMode:`text`,ref:r,defaultValue:n.name,"aria-label":t.renameEntry(i.name),autoComplete:`off`,"aria-autocomplete":`none`,autoCapitalize:`none`,autoCorrect:`off`,autoFocus:!0,spellCheck:!1,enterKeyHint:`done`,"data-lpignore":`true`,"data-1p-ignore":`true`,"data-bwignore":`true`,"data-form-type":`other`,onInput:e=>{o(e.currentTarget.value)},onKeyDown:e=>{if(e.key===`Escape`){e.preventDefault(),e.stopPropagation(),a();return}e.key===`Enter`&&(e.preventDefault(),e.stopPropagation(),s())}})})}function zl({copy:e,item:t,viewState:n}){let{directoryDotClassName:r,directoryDotTitleKind:i,fileChangedClassName:a,fileChangedTitleKind:o,fileOpening:s,isDirectory:c,showDirectoryDot:l,visibleGitStatus:u,visibleGitStatusClassName:d,visibleGitStatusLabel:f}=n;return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`span`,{className:`code-file-name`,children:t.displayName??t.name}),t.symbolicLink&&(0,H.jsx)(`span`,{className:`code-file-symbolic-link`,"aria-hidden":`true`,children:`↷`}),s&&(0,H.jsx)(`span`,{className:`code-file-open-spinner`,title:e.loading,"aria-hidden":`true`}),!s&&l&&(0,H.jsx)(`span`,{className:r,title:Ve(i,e)}),!s&&!c&&f&&(0,H.jsx)(`span`,{className:d,title:e.gitStatus(u||``),children:f}),!s&&!c&&!f&&a&&(0,H.jsx)(`span`,{className:a,title:Ve(o,e)})]})}function Bl(e){e?.focus({preventScroll:!0})}function Vl({isDirectory:e,item:t,lastFocusedFilePathRef:n,node:r,treeViewportRef:i,onCancelPendingFileFocus:a,onFocusFileTreeTarget:o,onOpenFileContextMenu:s,onOpenFilePath:c,onToggleDirectory:l}){let u=(0,V.useCallback)(()=>{Bl(i.current?.querySelector(`[role="tree"]`))},[i]),d=(0,V.useCallback)(e=>{e.preventDefault(),e.stopPropagation(),a(),n.current=t.path,r.select(),s(e.clientX,e.clientY,t)},[t,n,r,a,s]),f=(0,V.useCallback)(n=>{e||n.button!==0||n.metaKey||n.ctrlKey||n.shiftKey||c(t.path,{transient:!0})},[e,t.path,c]);return{handleRowClick:(0,V.useCallback)(s=>{a(),n.current=t.path;let d=Dl({nodeType:t.type,metaKey:s.metaKey,ctrlKey:s.ctrlKey,shiftKey:s.shiftKey}),f=e?Fl(i.current?.closest(`.code-project-list`)):null;if(d===`toggle-directory`){s.preventDefault(),s.stopPropagation();let e=l(t.path);r.select(),r.focus(),u(),e?r.open():r.close(),o(t),f?.();return}if(d===`open-file`&&s.detail===0&&c(t.path,{transient:!0}),r.handleClick(s),r.focus(),u(),s.shiftKey){Bl(s.currentTarget),f?.();return}o(t),f?.()},[u,e,t,n,r,a,o,c,l,i]),handleRowContextMenu:d,handleRowMouseDown:f}}function Hl({activeFilePath:e,agentId:t,copy:n,editorDirtyFilePaths:r,editorExternalChangedFilePaths:i,fileOperation:a,fileOperationInputRef:o,lastFocusedFilePathRef:s,locatedFilePath:c,node:l,openFilePendingPath:u,treeViewportRef:d,onCancelPendingFileFocus:f,onCloseFileOperation:p,onFocusFileTreeTarget:m,onOpenFileContextMenu:h,onOpenFilePath:g,onRememberFileOperationName:_,onToggleDirectory:v,onSubmitFileOperation:y}){let b=l.data,x=Ke({activeFilePath:e,editorDirtyFilePaths:r,editorExternalChangedFilePaths:i,openFilePendingPath:u,item:b,isFocused:l.isFocused,isOpen:l.isOpen,isSelected:l.isSelected}),{chevronState:S,isDirectory:C}=x,w=`${x.rowClasses} ${c===b.path?`located`:``}`.trim(),T=C?``:R(b.path),E=a?.kind===`rename`&&a.item?.path===b.path?a:null,{handleRowClick:D,handleRowContextMenu:O,handleRowMouseDown:k}=Vl({isDirectory:C,item:b,lastFocusedFilePathRef:s,node:l,treeViewportRef:d,onCancelPendingFileFocus:f,onFocusFileTreeTarget:m,onOpenFileContextMenu:h,onOpenFilePath:g,onToggleDirectory:v});return(0,H.jsxs)(`div`,{className:w,style:He(l.level),"data-testid":`code-file-row`,"data-file-path":b.path,"data-file-type":b.type,"data-tree-level":l.level,"aria-label":b.path,title:b.linkTarget?`${b.path} ↷ ${b.linkTarget}`:b.linkError?`${b.path} (${b.linkError})`:void 0,tabIndex:-1,"aria-expanded":C?l.isOpen:void 0,onContextMenu:O,onMouseDown:k,onClick:D,children:[(0,H.jsx)(`span`,{className:`code-file-chevron ${S}`,"aria-hidden":`true`,children:S===`expanded`?(0,H.jsx)(B,{}):S===`collapsed`?(0,H.jsx)(z,{}):null}),!C&&(0,H.jsx)(`img`,{className:`code-file-type-icon file`,src:T,alt:``,"aria-hidden":`true`}),E?(0,H.jsx)(Rl,{agentId:t,copy:n,fileOperation:E,inputRef:o,item:b,onCancel:p,onInputName:_,onSubmit:y}):(0,H.jsx)(zl,{copy:n,item:b,viewState:x})]})}function Ul({activeFilePath:e,agentId:t,copy:n,editorDirtyFilePaths:r,editorExternalChangedFilePaths:i,fileOperation:a,fileOperationInputRef:o,handleTreeKeyDownCapture:s,lastFocusedFilePathRef:c,locatedFilePath:l,openFilePendingPath:u,renderFileTreeRow:d,rowHeight:f,stickyContextItems:p,treeData:m,treeHeight:h,treeRef:g,treeViewportRef:_,visibleTreeRowCount:v,onCancelPendingFileFocus:y,onCloseFileOperation:b,onFocusFileTreeTarget:x,onFocusStickyDirectory:S,onOpenFileContextMenu:C,onOpenFilePath:w,onRememberFileOperationName:T,onToggleDirectory:E,onSubmitFileOperation:D,onToggleTreeNode:O,onTreeFocus:k,onTreeSelect:A,onUpdateFileOperationName:j}){let M=(0,V.useCallback)(e=>{e.target?.closest(`[data-file-path]`)||(e.preventDefault(),y(),C(e.clientX,e.clientY,null))},[y,C]),N=(0,V.useCallback)(({node:s})=>(0,H.jsx)(Hl,{activeFilePath:e,agentId:t,copy:n,editorDirtyFilePaths:r,editorExternalChangedFilePaths:i,fileOperation:a,fileOperationInputRef:o,lastFocusedFilePathRef:c,locatedFilePath:l,node:s,openFilePendingPath:u,treeViewportRef:_,onCancelPendingFileFocus:y,onCloseFileOperation:b,onFocusFileTreeTarget:x,onOpenFileContextMenu:C,onOpenFilePath:w,onRememberFileOperationName:T,onToggleDirectory:E,onSubmitFileOperation:D,onUpdateFileOperationName:j}),[e,t,n,r,i,a,o,c,l,y,b,x,C,w,T,D,E,j,u,_]);return(0,H.jsxs)(`div`,{className:`code-file-tree-viewport`,ref:_,"data-visible-row-count":v,style:{height:h},onKeyDownCapture:s,onContextMenu:M,children:[(0,H.jsx)(Ll,{copy:n,items:p,onFocusDirectory:S}),(0,H.jsx)(pl,{ref:g,data:m,idAccessor:`id`,childrenAccessor:`children`,rowHeight:f,indent:0,height:h,width:`100%`,overscanCount:v,openByDefault:!1,selectionFollowsFocus:!0,className:`code-file-tree`,rowClassName:`code-file-tree-row`,renderRow:d,onToggle:O,onFocus:k,onSelect:A,disableDrag:!0,disableEdit:!0,disableDrop:!0,children:N})]})}function Wl({copy:e,agentLaunchOptions:t,fileMenu:n,fileMenuRef:r,openFileError:i,rootDirectoryError:a,rootDirectoryHasItems:o,rootDirectoryLoading:s,search:c,searchActions:l,tree:u,onCloseFileMenu:d,onCloseFileMenuWithFocusRestore:f,onCopyFileMenuPath:p,onCopyFileMenuShareUrl:m,onOpenNewAgentFromFileMenu:h,onRefreshFileMenuTarget:g,onStartAgentFromFileMenu:_,onStartFileMenuOperation:v,readOnly:y=!1}){return(0,H.jsxs)(H.Fragment,{children:[s&&!o&&(0,H.jsx)(`div`,{className:`code-file-status`,style:He(0),children:e.loading}),a&&(0,H.jsx)(`div`,{className:`code-file-status error`,style:He(0),children:a}),i&&!c.active&&(0,H.jsx)(`div`,{className:`code-file-status error`,"data-testid":`code-file-open-error`,style:He(0),children:i}),c.active&&(0,H.jsx)(ze,{activeMatchIndex:c.activeMatchIndex,anchorRef:c.anchorRef,containerRef:c.resultsRef,copy:e,error:c.error,jumpTarget:c.jumpTarget,listboxId:c.listboxId,loading:c.loading,matches:c.matches,openFileError:i,query:c.query,showIgnoredSearch:!c.includeIgnored,timeoutMs:c.timeoutMs,truncated:c.truncated,onOpenJumpQuery:l.onOpenJumpQuery,onOpenMatch:l.onOpenMatch,onSearchIgnored:l.onSearchIgnored,onSelectMatchIndex:l.onSelectMatchIndex}),(0,H.jsx)(Ul,{...u,copy:e}),(0,H.jsx)(st,{agentId:u.agentId,copy:e,agentLaunchOptions:t,fileMenu:n,fileOperation:u.fileOperation,fileMenuRef:r,fileOperationInputRef:u.fileOperationInputRef,onCloseFileMenu:d,onCloseFileMenuWithFocusRestore:f,onCloseFileOperation:u.onCloseFileOperation,onCopyFileMenuPath:p,onCopyFileMenuShareUrl:m,onOpenNewAgent:h,onRefreshFileMenuTarget:g,onRememberFileOperationName:u.onRememberFileOperationName,onStartAgent:_,onStartFileMenuOperation:v,onSubmitFileOperation:u.onSubmitFileOperation,onUpdateFileOperationName:u.onUpdateFileOperationName,readOnly:y})]})}function Gl({copy:e,filesCollapsed:t,refreshStatus:n,search:r,onCancelPendingFileFocus:i,onFileSearchKeyDown:a,onSearchQueryChange:o,onRefreshFiles:s,onToggleFilesCollapsed:c}){let l=n===`refreshing`?e.refreshingFiles:n===`success`?e.filesRefreshed:n===`error`?e.filesRefreshFailed:e.refreshFiles;return(0,H.jsxs)(`div`,{className:`code-files-header ${t?`collapsed`:``}`,children:[(0,H.jsxs)(`div`,{className:`code-files-heading`,children:[(0,H.jsxs)(`button`,{type:`button`,className:`code-files-title`,"aria-expanded":!t,onClick:c,children:[(0,H.jsx)(`span`,{className:`code-file-section-chevron ${t?`collapsed`:`expanded`}`,"aria-hidden":`true`,children:t?(0,H.jsx)(z,{}):(0,H.jsx)(B,{})}),(0,H.jsx)(`span`,{children:e.files})]}),(0,H.jsx)(`button`,{type:`button`,className:`code-files-refresh`,"data-testid":`code-files-refresh`,"data-refresh-status":n,title:l,"aria-label":l,"aria-busy":n===`refreshing`,disabled:n===`refreshing`,onClick:s,children:(0,H.jsx)(`span`,{className:`code-files-refresh-glyph`,"aria-hidden":`true`,children:n===`success`?(0,H.jsx)(fe,{}):n===`error`?(0,H.jsx)(de,{}):`↻`})}),(0,H.jsx)(`span`,{className:`code-visually-hidden`,role:`status`,"aria-live":`polite`,children:n===`idle`?``:l})]}),!t&&(0,H.jsxs)(`label`,{className:`code-file-search-box`,children:[(0,H.jsx)(`span`,{className:`code-file-search-icon`,"aria-hidden":`true`}),(0,H.jsx)(`input`,{ref:r.inputRef,type:`search`,name:`farming-file-search`,inputMode:`search`,autoComplete:`off`,autoCorrect:`off`,autoCapitalize:`none`,spellCheck:!1,enterKeyHint:`search`,"data-lpignore":`true`,"data-1p-ignore":`true`,"data-bwignore":`true`,"data-form-type":`other`,value:r.query,onChange:e=>{i(),o(e.target.value)},onFocus:i,onPointerDown:e=>{i(),L()&&(e.preventDefault(),e.currentTarget.focus({preventScroll:!0}))},onMouseDown:i,onKeyDownCapture:a,placeholder:e.searchOrPathLine,"aria-label":e.searchFilesOrJump,"aria-autocomplete":`list`,"aria-controls":r.active?r.listboxId:void 0,"aria-expanded":r.active,"aria-activedescendant":r.activeOptionId,role:`combobox`})]})]})}var Kl=o(),ql=[`#ffb000`,`#dc267f`,`#994f00`,`#40b0a6`,`#b66dff`],Jl=`#2188ff`;function Yl(e){return{...e}}function Xl(e,t){for(let n of e.references??[]){let e=t.get(n.id);if(e!==void 0)return e}}function Zl(e,t,n=new Map){let r=-1,i=[];for(let a of e){let o=a.id===t?`HEAD`:`node`,s=(i[i.length-1]?.outputSwimlanes??[]).map(Yl),c=[],l=!1;if(a.parentIds.length>0)for(let e of s){if(e.id===a.id){l||=(c.push({id:a.parentIds[0],color:Xl(a,n)??e.color}),!0);continue}c.push(Yl(e))}for(let t=+!!l;t<a.parentIds.length;t+=1){let i;if(t===0)i=Xl(a,n);else{let r=e.find(e=>e.id===a.parentIds[t]);i=r?Xl(r,n):void 0}i||=(r=(r+1)%ql.length,ql[r]),c.push({id:a.parentIds[t],color:i})}i.push({historyItem:a,kind:o,inputSwimlanes:s,outputSwimlanes:c})}return i}var Ql=5,$l=4,eu=2,tu=`http://www.w3.org/2000/svg`;function nu(e,t=1){let n=document.createElementNS(tu,`path`);return n.setAttribute(`fill`,`none`),n.setAttribute(`stroke`,e),n.setAttribute(`stroke-width`,String(t)),n.setAttribute(`stroke-linecap`,`round`),n}function ru(e,t,n,r,i=!1){let a=document.createElementNS(tu,`circle`);return a.setAttribute(`cx`,String(11*(e+1))),a.setAttribute(`cy`,`11`),a.setAttribute(`r`,String(t)),a.setAttribute(`stroke`,r),a.setAttribute(`stroke-width`,String(n)),a.setAttribute(`fill`,i?r:`var(--code-git-history-node-bg, #f6f7f3)`),a}function iu(e,t,n,r,i=1){let a=nu(r,i);return a.setAttribute(`d`,`M ${e} ${t} V ${n}`),a}function au(e,t){for(let n=e.length-1;n>=0;--n)if(e[n].id===t)return n;return-1}function ou(e){let t=document.createElementNS(tu,`svg`);t.classList.add(`code-git-history-graph-svg`),t.setAttribute(`aria-hidden`,`true`),t.setAttribute(`focusable`,`false`);let{historyItem:n,inputSwimlanes:r,outputSwimlanes:i}=e,a=r.findIndex(e=>e.id===n.id),o=a===-1?r.length:a,s=o<i.length?i[o].color:o<r.length?r[o].color:Jl,c=0;for(let e=0;e<r.length;e+=1){let a=r[e],s=a.color;if(a.id===n.id){if(e!==o){let n=nu(s);n.setAttribute(`d`,[`M ${11*(e+1)} 0`,`A 11 11 0 0 1 ${11*e} 11`,`H ${11*(o+1)}`].join(` `)),t.append(n)}else c+=1;continue}if(c<i.length&&a.id===i[c].id){if(e===c)t.append(iu(11*(e+1),0,22,s));else{let n=nu(s);n.setAttribute(`d`,[`M ${11*(e+1)} 0`,`V 6`,`A ${Ql} ${Ql} 0 0 1 ${11*(e+1)-Ql} ${22/2}`,`H ${11*(c+1)+Ql}`,`A ${Ql} ${Ql} 0 0 0 ${11*(c+1)} ${22/2+Ql}`,`V 22`].join(` `)),t.append(n)}c+=1}}for(let e=1;e<n.parentIds.length;e+=1){let r=au(i,n.parentIds[e]);if(r===-1)continue;let a=nu(i[r].color);a.setAttribute(`d`,[`M ${11*r} ${22/2}`,`A 11 11 0 0 1 ${11*(r+1)} 22`,`M ${11*r} ${22/2}`,`H ${11*(o+1)}`].join(` `)),t.append(a)}a!==-1&&t.append(iu(11*(o+1),0,22/2,r[a].color)),n.parentIds.length>0&&t.append(iu(11*(o+1),22/2,22,s)),e.kind===`HEAD`?(t.append(ru(o,$l+3,eu,s)),t.append(ru(o,eu,1,s,!0))):n.parentIds.length>1?(t.append(ru(o,$l+2,eu,s)),t.append(ru(o,$l-1,eu,s))):t.append(ru(o,$l+1,eu,s));let l=11*(Math.max(r.length,i.length,1)+1);return t.setAttribute(`width`,String(l)),t.setAttribute(`height`,`22`),t.setAttribute(`viewBox`,`0 0 ${l} 22`),t}function su(e,t=22){let n=document.createElementNS(tu,`svg`);n.classList.add(`code-git-history-graph-placeholder-svg`),n.setAttribute(`aria-hidden`,`true`),n.setAttribute(`focusable`,`false`);for(let r=0;r<e.length;r+=1)n.append(iu(11*(r+1),0,t,e[r].color));let r=11*(Math.max(e.length,1)+1);return n.setAttribute(`width`,String(r)),n.setAttribute(`height`,String(t)),n.setAttribute(`viewBox`,`0 0 ${r} ${t}`),n}var cu=(0,V.memo)(function({viewModel:e}){let t=(0,V.useRef)(null);return(0,V.useLayoutEffect)(()=>{let n=t.current;n&&n.replaceChildren(ou(e))},[e]),(0,H.jsx)(`span`,{ref:t,className:`code-git-history-graph`,"aria-hidden":`true`})}),lu=(0,V.memo)(function({columns:e}){let t=(0,V.useRef)(null);return(0,V.useLayoutEffect)(()=>{let n=t.current;if(!n)return;let r=()=>{let t=Math.max(22,Math.round(n.getBoundingClientRect().height));n.replaceChildren(su(e,t))};if(r(),typeof ResizeObserver>`u`)return;let i=new ResizeObserver(r);return i.observe(n),()=>i.disconnect()},[e]),(0,H.jsx)(`span`,{ref:t,className:`code-git-history-graph-placeholder`,"aria-hidden":`true`})}),uu=50,du=20;function fu(e){if(!e)return``;let t=new Date(e);if(!Number.isFinite(t.getTime()))return``;let n=e=>String(e).padStart(2,`0`);return`${t.getFullYear()}-${n(t.getMonth()+1)}-${n(t.getDate())} ${n(t.getHours())}:${n(t.getMinutes())}`}function pu(e,t){let n=new Set(e.map(e=>e.id));return[...e,...t.filter(e=>!n.has(e.id))]}function mu(e){return e.previousPath?`${e.previousPath} → ${e.path}`:e.path}function hu(e){let t=e.message.trim();return!t||t===e.subject?``:t.startsWith(e.subject)?t.slice(e.subject.length).trim():t}function gu({agentId:e,copy:t,projectId:n}){let[r,a]=(0,V.useState)(!0),[o,s]=(0,V.useState)(null),[c,l]=(0,V.useState)(`current`),[u,d]=(0,V.useState)(!1),[f,p]=(0,V.useState)(``),[m,h]=(0,V.useState)(``),[g,_]=(0,V.useState)(``),[v,y]=(0,V.useState)(null),[b,x]=(0,V.useState)(!1),[S,C]=(0,V.useState)(``),[w,T]=(0,V.useState)(null),E=(0,V.useRef)(null),D=(0,V.useRef)(null),O=(0,V.useRef)(new Map),k=(0,V.useRef)(null),A=(0,V.useRef)(null),j=(0,V.useCallback)(()=>{D.current?.abort(),D.current=null,h(``),_(``),y(null),x(!1),C(``),T(null)},[]);(0,V.useEffect)(()=>(E.current?.abort(),D.current?.abort(),E.current=null,D.current=null,O.current.clear(),a(!0),s(null),l(`current`),d(!1),p(``),h(``),_(``),y(null),x(!1),C(``),()=>{E.current?.abort(),D.current?.abort()}),[e,n]),(0,V.useEffect)(()=>{if(!w)return;let e=e=>{let t=e.target;t&&(k.current?.contains(t)||A.current?.contains(t))||T(null)},t=e=>{e.key===`Escape`&&(e.preventDefault(),T(null),k.current?.focus())};return window.addEventListener(`pointerdown`,e,!0),window.addEventListener(`keydown`,t,!0),()=>{window.removeEventListener(`pointerdown`,e,!0),window.removeEventListener(`keydown`,t,!0)}},[w]);let M=(0,V.useCallback)(async(t,n,r=c)=>{E.current?.abort();let i=new AbortController;E.current=i,d(!0),p(``);try{let a=await ie(e,{limit:uu,skip:t,scope:r,signal:i.signal});if(i.signal.aborted)return;s(e=>n||!e?a:{...a,items:pu(e.items,a.items)})}catch(e){if(i.signal.aborted)return;p(e instanceof Error?e.message:`Git history request failed`)}finally{E.current===i&&(E.current=null,d(!1))}},[e,c]),N=(0,V.useCallback)(async(t,n)=>{let r=`${t.id}:${n||`root`}`,i=O.current.get(r);if(D.current?.abort(),i){y(i),x(!1),C(``);return}let a=new AbortController;D.current=a,y(null),x(!0),C(``);try{let i=await F(e,t.id,{parent:n||void 0,signal:a.signal});if(a.signal.aborted)return;if(O.current.set(r,i),O.current.size>du){let e=O.current.keys().next().value;e&&O.current.delete(e)}y(i)}catch(e){if(a.signal.aborted)return;C(e instanceof Error?e.message:`Commit changes request failed`)}finally{D.current===a&&(D.current=null,x(!1))}},[e]),ee=()=>{a(e=>(e&&!o&&!u&&M(0,!0),!e))},P=()=>{O.current.clear(),j(),M(0,!0)},te=e=>{T(null),e!==c&&(l(e),s(null),O.current.clear(),j(),M(0,!0,e))},ne=()=>{T(e=>{if(e)return null;let t=k.current?.getBoundingClientRect();return t?{x:Math.max(8,Math.min(window.innerWidth-132-8,t.right-132)),y:t.bottom+66+8<=window.innerHeight?t.bottom+3:Math.max(8,t.top-66-3)}:null})},re=e=>{if(m===e.id){j();return}let t=e.parentIds[0]||``;h(e.id),_(t),N(e,t)},I=(e,t)=>{_(t),N(e,t)},ae=(t,n,r)=>{if(!n)return;let a=new URLSearchParams({agentId:e,base:n,head:t.id});r&&a.append(`path`,r),window.open(i(`/review?${a.toString()}`),`_blank`,`noopener,noreferrer`)},L=(0,V.useMemo)(()=>Zl(o?.items??[],o?.head),[o?.head,o?.items]);return(0,H.jsxs)(`section`,{className:`code-git-history-section ${r?`collapsed`:``}`,"data-testid":`code-git-history-section`,"data-project-id":n,"aria-label":t.gitHistory,children:[(0,H.jsxs)(`div`,{className:`code-git-history-header`,children:[(0,H.jsxs)(`button`,{type:`button`,className:`code-git-history-title`,"aria-expanded":!r,onClick:ee,children:[(0,H.jsx)(`span`,{className:`code-file-section-chevron ${r?`collapsed`:`expanded`}`,"aria-hidden":`true`,children:r?(0,H.jsx)(z,{}):(0,H.jsx)(B,{})}),(0,H.jsx)(`span`,{children:t.gitHistory})]}),!r&&(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(`button`,{ref:k,type:`button`,className:`code-git-history-scope`,"aria-label":t.gitHistoryView,title:t.gitHistoryView,"aria-haspopup":`menu`,"aria-expanded":w?!0:void 0,disabled:u,onClick:ne,children:[(0,H.jsx)(`span`,{children:c===`current`?t.gitHistoryCurrentScope:t.gitHistoryAllScope}),(0,H.jsx)(B,{"aria-hidden":`true`})]}),w&&typeof document<`u`&&(0,Kl.createPortal)((0,H.jsx)(`div`,{ref:A,className:`code-git-history-scope-menu`,"data-testid":`code-git-history-scope-menu`,role:`menu`,"aria-label":t.gitHistoryView,style:{left:w.x,top:w.y},children:[[`current`,t.gitHistoryCurrentBranch],[`all`,t.gitHistoryAllBranches]].map(([e,t])=>(0,H.jsxs)(`button`,{type:`button`,role:`menuitemradio`,"aria-checked":c===e,onClick:()=>te(e),children:[(0,H.jsx)(`span`,{className:`code-git-history-scope-check`,"aria-hidden":`true`,children:c===e&&(0,H.jsx)(fe,{})}),(0,H.jsx)(`span`,{children:t})]},e))}),document.body),(0,H.jsx)(`button`,{type:`button`,className:`code-git-history-refresh ${u?`loading`:``}`,title:t.refresh,"aria-label":t.refresh,disabled:u,onClick:P,children:`↻`})]})]}),!r&&(0,H.jsxs)(`div`,{className:`code-git-history-body`,children:[u&&!o&&(0,H.jsx)(`div`,{className:`code-git-history-status`,children:t.loading}),f&&(0,H.jsx)(`div`,{className:`code-git-history-status error`,children:f}),o&&!o.isGitRepo&&(0,H.jsx)(`div`,{className:`code-git-history-status`,children:t.gitHistoryNotRepository}),o?.isGitRepo&&o.items.length===0&&!u&&(0,H.jsx)(`div`,{className:`code-git-history-status`,children:t.gitHistoryEmpty}),L.map(e=>{let n=e.historyItem,r=m===n.id,i=fu(n.timestamp),a=hu(n),s=n.references.filter(e=>e.category!==`head`&&!(c===`current`&&o?.branch&&e.name===o.branch));return(0,H.jsxs)(`div`,{className:`code-git-history-entry ${r?`selected`:``}`,"data-testid":`code-git-history-entry`,"data-commit-id":n.id,children:[(0,H.jsxs)(`button`,{type:`button`,className:`code-git-history-commit`,"aria-expanded":r,title:`${n.message||n.subject}\n${n.id}\n${n.author}${i?` · ${i}`:``}`,onClick:()=>re(n),children:[(0,H.jsx)(cu,{viewModel:e}),(0,H.jsxs)(`span`,{className:`code-git-history-commit-content`,children:[(0,H.jsx)(`span`,{className:`code-git-history-subject`,children:n.subject||n.displayId}),(0,H.jsxs)(`span`,{className:`code-git-history-footer`,children:[(0,H.jsxs)(`span`,{className:`code-git-history-meta`,children:[(0,H.jsx)(`span`,{className:`code-git-history-hash`,children:n.displayId}),n.author&&(0,H.jsx)(`span`,{children:n.author}),i&&n.timestamp!==void 0&&(0,H.jsx)(`time`,{dateTime:new Date(n.timestamp).toISOString(),children:i})]}),s.length>0&&(0,H.jsxs)(`span`,{className:`code-git-history-references`,"aria-label":s.map(e=>e.name).join(`, `),children:[s.slice(0,1).map(e=>(0,H.jsx)(`span`,{className:`code-git-history-reference ${e.category}`,title:e.name,children:e.name},e.id)),s.length>1&&(0,H.jsxs)(`span`,{className:`code-git-history-reference-more`,children:[`+`,s.length-1]})]})]})]})]}),r&&(0,H.jsxs)(`div`,{className:`code-git-history-details`,"data-testid":`code-git-history-details`,children:[(0,H.jsx)(lu,{columns:e.outputSwimlanes}),(0,H.jsxs)(`div`,{className:`code-git-history-details-content`,children:[(n.parentIds.length>1||n.parentIds.length===0)&&(0,H.jsx)(`div`,{className:`code-git-history-details-header`,children:n.parentIds.length>1?(0,H.jsxs)(`label`,{className:`code-git-history-parent-select`,children:[(0,H.jsx)(`span`,{children:t.gitHistoryParent}),(0,H.jsx)(`select`,{value:g,onChange:e=>I(n,e.target.value),children:n.parentIds.map((e,t)=>(0,H.jsxs)(`option`,{value:e,children:[t+1,`: `,e.slice(0,8)]},e))})]}):(0,H.jsx)(`span`,{className:`code-git-history-root-label`,children:t.gitHistoryRootCommit})}),a&&(0,H.jsxs)(`div`,{className:`code-git-history-message`,children:[(0,H.jsx)(`span`,{className:`code-git-history-message-label`,children:t.gitHistoryCommitMessage}),(0,H.jsx)(`span`,{className:`code-git-history-message-body`,children:a})]}),b&&(0,H.jsx)(`div`,{className:`code-git-history-status compact`,children:t.loading}),S&&(0,H.jsx)(`div`,{className:`code-git-history-status compact error`,children:S}),v&&(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(`div`,{className:`code-git-history-change-summary-row`,children:[(0,H.jsx)(`span`,{className:`code-git-history-change-summary`,children:t.gitHistoryCommitChanges(v.items.length)}),v.comparisonBase&&(0,H.jsxs)(`button`,{type:`button`,className:`code-git-history-review`,"aria-label":t.gitHistoryReviewCommit,title:t.gitHistoryReviewCommit,onClick:()=>ae(n,v.comparisonBase),children:[(0,H.jsx)(`span`,{children:t.reviewChanges}),(0,H.jsx)(ue,{})]})]}),v.items.length===0&&(0,H.jsx)(`div`,{className:`code-git-history-status compact`,children:t.gitHistoryNoChanges}),(0,H.jsx)(`div`,{className:`code-git-history-change-list`,children:v.items.map(e=>v.comparisonBase?(0,H.jsxs)(`button`,{type:`button`,className:`code-git-history-change`,title:mu(e),onClick:()=>ae(n,v.comparisonBase,e.path),children:[(0,H.jsx)(`img`,{src:R(e.path),alt:``,"aria-hidden":`true`}),(0,H.jsx)(`span`,{className:`code-git-history-change-path`,children:e.path}),e.previousPath&&(0,H.jsxs)(`span`,{className:`code-git-history-change-previous`,children:[`← `,e.previousPath]}),(0,H.jsx)(`span`,{className:`code-git-history-change-status ${e.status}`,children:e.statusLabel})]},`${e.status}:${e.path}`):(0,H.jsxs)(`div`,{className:`code-git-history-change static`,title:mu(e),children:[(0,H.jsx)(`img`,{src:R(e.path),alt:``,"aria-hidden":`true`}),(0,H.jsx)(`span`,{className:`code-git-history-change-path`,children:e.path}),(0,H.jsx)(`span`,{className:`code-git-history-change-status ${e.status}`,children:e.statusLabel})]},`${e.status}:${e.path}`))}),v.truncated&&(0,H.jsx)(`div`,{className:`code-git-history-status compact`,children:t.gitHistoryChangesTruncated})]})]})]})]},n.id)}),o?.hasMore&&(0,H.jsx)(`button`,{type:`button`,className:`code-git-history-load-more`,disabled:u||o.nextSkip===null,onClick:()=>{o.nextSkip!==null&&M(o.nextSkip,!1)},children:u?t.loading:t.gitHistoryLoadMore})]})]})}function _u(e){return e.split(`/`).filter(Boolean).pop()||e}function vu({activeFilePath:e,collapsed:t,copy:n,files:r,projectId:i,onCloseOpenFile:a,onOpenFileContextMenu:o,onSelectOpenFile:s,onToggleCollapsed:c}){let l=(0,V.useRef)(null),u=(0,V.useRef)(null),d=Math.min(r.length,7),f=(0,V.useMemo)(()=>({"--code-open-editors-visible-rows":d,"--code-open-editors-list-max-height":`${d*28}px`}),[d]);return(0,V.useEffect)(()=>{if(t)return;let e=l.current,n=u.current;if(!e||!n)return;let r=n.offsetTop,i=r+n.offsetHeight;r<e.scrollTop?e.scrollTop=r:i>e.scrollTop+e.clientHeight&&(e.scrollTop=i-e.clientHeight)},[e,t,r.length]),r.length===0?null:(0,H.jsxs)(`div`,{className:`code-open-editors ${t?`collapsed`:``}`,"data-testid":`code-open-editors`,"data-project-id":i,"data-open-editor-count":r.length,"data-visible-editor-count":d,style:f,children:[(0,H.jsx)(`div`,{className:`code-open-editors-header`,children:(0,H.jsxs)(`button`,{type:`button`,className:`code-open-editors-title`,"aria-expanded":!t,onClick:c,children:[(0,H.jsx)(`span`,{className:`code-file-section-chevron ${t?`collapsed`:`expanded`}`,"aria-hidden":`true`,children:t?(0,H.jsx)(z,{}):(0,H.jsx)(B,{})}),(0,H.jsx)(`span`,{children:n.openEditors})]})}),!t&&(0,H.jsx)(`div`,{ref:l,className:`code-open-editors-list`,children:r.map(t=>{let r=e===t.path,i=pe(t);return(0,H.jsxs)(`div`,{ref:r?u:void 0,className:`code-open-editor-row ${r?`active`:``}`,"data-testid":`code-open-editor-row`,"data-file-path":t.path,title:t.path,onContextMenu:e=>{o&&(e.preventDefault(),o(e.clientX,e.clientY,t))},children:[(0,H.jsxs)(`button`,{type:`button`,className:`code-open-editor-main`,onClick:()=>s?.(t.agentId,t.path),children:[(0,H.jsx)(`img`,{className:`code-file-type-icon file`,src:R(t.path),alt:``,"aria-hidden":`true`}),(0,H.jsx)(`span`,{className:`code-open-editor-name`,children:_u(t.path)}),(0,H.jsx)(`span`,{className:`code-open-editor-path`,children:w(t.path)}),i&&(0,H.jsx)(`span`,{className:`code-open-editor-state ${i}`,title:i===`external`?n.changedOnDisk:n.unsavedChanges})]}),a&&(0,H.jsx)(`button`,{type:`button`,className:`code-open-editor-close`,"aria-label":n.closeFile(t.path),title:n.closeFile(t.path),onClick:()=>a(t.agentId,t.path,t.workspaceRoot)})]},t.key)})})]})}function yu({activeFilePath:e,activeSearchOptionId:t,agentId:n,agentLaunchOptions:r,copy:i,editorDirtyFilePaths:a,editorExternalChangedFilePaths:o,fileMenu:s,fileMenuRef:c,fileOperation:l,fileOperationInputRef:u,fileSearch:d,fileSearchInputRef:f,fileSearchListboxId:p,fileSearchResultsRef:m,filesCollapsed:h,handleFileSearchKeyDown:g,handleTreeKeyDownCapture:_,lastFocusedFilePathRef:v,locatedFilePath:y,openEditorsCollapsed:b,openFileError:x,openFilePendingPath:S,projectId:C,renderFileTreeRow:w,rootDirectoryError:T,rootDirectoryHasItems:E,rootDirectoryLoading:D,rowHeight:O,readOnly:k=!1,stickyContextItems:A,treeData:j,treeHeight:M,treeRef:N,treeViewportRef:ee,visibleTreeRowCount:P,onCancelPendingFileFocus:te,onCloseFileMenuWithFocusRestore:ne,onCloseFileMenuWithoutFocus:re,onCloseFileOperation:ie,onCloseOpenFile:F,onCopyFileMenuPath:I,onCopyFileMenuShareUrl:ae,onFocusFileTreeTarget:L,onFocusStickyDirectory:R,onOpenFileContextMenu:oe,onOpenFileJumpQuery:se,onOpenFilePath:ce,onOpenFileSearchMatch:le,onOpenNewAgentFromFileMenu:ue,onRefreshFileMenuTarget:de,onRememberFileOperationName:z,onSearchQueryChange:fe,onSelectOpenFile:B,onSelectSearchMatchIndex:pe,onToggleDirectory:me,onStartAgentFromFileMenu:H,onStartFileMenuOperation:he,onSubmitFileOperation:ge,onToggleFilesCollapsed:_e,onToggleOpenEditorsCollapsed:ve,onToggleTreeNode:ye,onTreeFocus:be,onTreeSelect:xe,onUpdateFileOperationName:Se}){let Ce=(0,V.useMemo)(()=>({active:d.active,activeOptionId:t,inputRef:f,listboxId:p,query:d.query}),[t,d.active,d.query,f,p]),we=(0,V.useMemo)(()=>({active:d.active,activeMatchIndex:d.activeMatchIndex,anchorRef:f,error:d.error,includeIgnored:d.includeIgnored,jumpTarget:d.jumpTarget,listboxId:p,loading:d.loading,matches:d.matches,query:d.query,resultsRef:m,timeoutMs:d.timeoutMs,truncated:d.truncated}),[d.active,d.activeMatchIndex,d.error,d.includeIgnored,f,d.jumpTarget,d.loading,d.matches,d.query,d.timeoutMs,d.truncated,p,m]),Te=(0,V.useMemo)(()=>({onOpenJumpQuery:se,onOpenMatch:le,onSearchIgnored:d.searchIgnored,onSelectMatchIndex:pe}),[se,le,d.searchIgnored,pe]),Ee=(0,V.useMemo)(()=>({activeFilePath:e,agentId:n,editorDirtyFilePaths:a,editorExternalChangedFilePaths:o,fileOperation:l,fileOperationInputRef:u,handleTreeKeyDownCapture:_,lastFocusedFilePathRef:v,locatedFilePath:y,openFilePendingPath:S,renderFileTreeRow:w,rowHeight:O,stickyContextItems:A,treeData:j,treeHeight:M,treeRef:N,treeViewportRef:ee,visibleTreeRowCount:P,onCancelPendingFileFocus:te,onCloseFileOperation:ie,onFocusFileTreeTarget:L,onFocusStickyDirectory:R,onOpenFileContextMenu:oe,onOpenFilePath:ce,onRememberFileOperationName:z,onToggleDirectory:me,onSubmitFileOperation:ge,onToggleTreeNode:ye,onTreeFocus:be,onTreeSelect:xe,onUpdateFileOperationName:Se}),[e,n,a,o,l,u,_,v,y,S,w,O,A,j,M,N,ee,P,te,ie,L,R,oe,ce,z,me,ge,ye,be,xe,Se]);return{bodySearch:we,bodySearchActions:Te,bodyTree:Ee,fileMenu:s,fileMenuRef:c,filesCollapsed:h,headerSearch:Ce,openEditors:{activeFilePath:e,collapsed:b,copy:i,projectId:C,onCloseOpenFile:F,onSelectOpenFile:B,onToggleCollapsed:ve},sectionBody:{copy:i,agentLaunchOptions:r,fileMenu:s,fileMenuRef:c,openFileError:x,rootDirectoryError:T,rootDirectoryHasItems:E,rootDirectoryLoading:D,search:we,searchActions:Te,tree:Ee,onCloseFileMenu:re,onCloseFileMenuWithFocusRestore:ne,onCopyFileMenuPath:I,onCopyFileMenuShareUrl:ae,onOpenNewAgentFromFileMenu:ue,onRefreshFileMenuTarget:de,onStartAgentFromFileMenu:H,onStartFileMenuOperation:he,readOnly:k},sectionHeader:{copy:i,filesCollapsed:h,search:Ce,onCancelPendingFileFocus:te,onFileSearchKeyDown:g,onSearchQueryChange:fe,onToggleFilesCollapsed:_e}}}var bu=200,xu=15e3,Su={error:null,items:[],loaded:!1,loading:!1,truncated:!1};function Cu(e,t){let[n,r]=(0,V.useState)(Su),i=(0,V.useRef)(null),a=(0,V.useRef)(0),o=(0,V.useRef)(new Map),s=(0,V.useRef)(t),c=(0,V.useCallback)(()=>{if(!e)return i.current?.abort(),a.current+=1,r(Su),Promise.resolve(!0);i.current?.abort();let t=new AbortController,n=!1,o=window.setTimeout(()=>{n=!0,t.abort()},xu);i.current=t;let s=a.current+1;return a.current=s,r(e=>({...e,error:null,loading:!0})),re(e,{limit:bu,signal:t.signal}).then(e=>a.current===s?(r({error:null,items:e.items,loaded:!0,loading:!1,truncated:e.truncated}),!0):!1).catch(e=>(!n&&t.signal.aborted||a.current!==s||r(t=>({...t,error:n?`File refresh timed out`:e instanceof Error?e.message:`Failed to refresh changes`,loaded:!0,loading:!1})),!1)).finally(()=>window.clearTimeout(o))},[e]);return(0,V.useEffect)(()=>{s.current=t},[t]),(0,V.useEffect)(()=>{o.current=d(s.current),c()},[e,c]),(0,V.useEffect)(()=>{let e=o.current,n=d(t);o.current=n,l(e,n)&&c()},[e,t,c]),(0,V.useEffect)(()=>()=>{i.current?.abort()},[]),{...n,refreshChanges:c}}var wu=50,Tu=60,Eu=6e3,Du=80,Ou=100,ku=2;function Au(e){e?.focus({preventScroll:!0})}function ju(){let e=document.activeElement;return e instanceof Element&&!!e.closest(`.code-file-monaco, .monaco-editor`)}function Mu(e,t){let n=e.getBoundingClientRect(),r=t.closest(`.code-project-group`),i=t.closest(`.code-files-section`),a=[r?.querySelector(`.code-project-row`),r?.querySelector(`.code-agents-section`),r?.querySelector(`[data-testid="code-open-editors"]`),i?.querySelector(`.code-files-header`),i?.querySelector(`.code-file-sticky-stack`)].reduce((e,t)=>{if(!t)return e;let r=t.getBoundingClientRect();return r.height<=0||r.bottom<=n.top||r.top>=n.bottom?e:Math.max(e,r.bottom)},n.top);return{top:Math.min(a,n.bottom),bottom:n.bottom}}function Nu(e,t=!1){let n=e.closest(`.code-project-list`);if(!n)return;let r=Mu(n,e),i=e.getBoundingClientRect();n.scrollTop+=t?i.top-r.top-6:_l(r,i)}function Pu({treeRef:e,treeViewportRef:t,fileSearchInputRef:n,fileOperationActiveRef:r,lastFocusedFilePathRef:i,treeData:a,isDirectoryLoaded:o,loadMissingDirectories:s,openDirectoriesInLayout:c,refreshTreeLayout:l}){let u=(0,V.useRef)(null),d=(0,V.useRef)([]),f=(0,V.useRef)(null),p=(0,V.useRef)([]),h=(0,V.useRef)([]),g=(0,V.useRef)([]),_=(0,V.useRef)([]),v=(0,V.useRef)(0),[y,b]=(0,V.useState)(null),S=(0,V.useRef)(null),C=(0,V.useRef)(a),w=(0,V.useRef)(o);(0,V.useEffect)(()=>{C.current=a},[a]),(0,V.useEffect)(()=>{w.current=o},[o]);let T=(0,V.useCallback)(()=>{b(null),S.current!==null&&(window.clearTimeout(S.current),S.current=null)},[]),D=(0,V.useCallback)(e=>{document.body.classList.contains(`code-file-location-dismissed`)||(T(),b(e),S.current=window.setTimeout(T,Eu))},[T]),O=(0,V.useCallback)(()=>{u.current!==null&&(window.cancelAnimationFrame(u.current),u.current=null),d.current.forEach(e=>window.clearTimeout(e)),d.current=[]},[]),k=(0,V.useCallback)(()=>{f.current!==null&&(window.cancelAnimationFrame(f.current),f.current=null),p.current.forEach(e=>window.clearTimeout(e)),p.current=[]},[]),j=(0,V.useCallback)(()=>{h.current.forEach(e=>window.clearTimeout(e)),h.current=[]},[]),M=(0,V.useCallback)(()=>{v.current+=1,k(),j(),g.current.forEach(e=>window.cancelAnimationFrame(e)),g.current=[],_.current.forEach(e=>window.clearTimeout(e)),_.current=[]},[j,k]),N=(0,V.useCallback)(()=>{O(),M(),T()},[O,M,T]),ee=(0,V.useCallback)((i,a=!1,o=!1)=>{k(),j();let s=!1,c=()=>{let e=0,n=0,r=()=>{n+=1;let a=Array.from(t.current?.querySelectorAll(`[data-file-path]`)??[]).find(e=>e.dataset.filePath===i)??null;if(e=a?.classList.contains(`selected`)===!0?e+1:0,a&&e>=ku){h.current=[],D(i);return}n>=Ou||(h.current=[window.setTimeout(r,Du)])};r()},l=()=>{let e=n.current,s=vl({focusRow:a,operationActive:r.current,activeElementIsSearchInput:document.activeElement===e,searchInputValue:e?.value}),c=Array.from(t.current?.querySelectorAll(`[data-file-path]`)??[]).find(e=>e.dataset.filePath===i);c&&(c.scrollIntoView({block:`nearest`}),Nu(c,o),s&&Au(c.closest(`[role="tree"]`)))},u=()=>{let t=e.current;if(a&&!s){s=!0,t?.get(i)?.select();let e=t?.scrollTo(i,o?`start`:`smart`);e&&e.then(()=>{window.requestAnimationFrame(l)})}l()};u(),f.current=window.requestAnimationFrame(()=>{u(),f.current=window.requestAnimationFrame(u)}),hl.forEach(e=>{let t=window.setTimeout(u,e);p.current.push(t)}),o&&c()},[j,k,r,n,D,e,t]),P=(0,V.useCallback)((t,n=0,r=!1,i)=>{let a=i??v.current+1;i===void 0&&(v.current=a);let o=()=>v.current===a,s=e.current,u=C.current,d=E(u,t,r),f=A(u,t)??t,p=m(u,f),h=!!s;if(c(d),r&&(p?.type!==`directory`||!w.current(t))&&(h=!1),s&&(d.forEach(e=>{s.get(e)?s.open(e):h=!1}),r&&s.get(f)&&s.open(f),s.get(f)||(h=!1)),!h&&n<Tu){let e=window.setTimeout(()=>{_.current=_.current.filter(t=>t!==e),o()&&P(t,n+1,r,a)},wu);_.current.push(e);return}(e=>{let t=window.requestAnimationFrame(()=>{g.current=g.current.filter(e=>e!==t),o()&&e()});g.current.push(t)})(()=>{o()&&(d.forEach(t=>e.current?.open(t)),l(d),ee(f,!0,r))})},[c,l,ee,e]),te=(0,V.useCallback)(async e=>{await s([``,...x(e)]),P(e)},[s,P]),ne=(0,V.useCallback)(async(e,t)=>{t===`directory`&&(document.body.classList.remove(`code-file-location-dismissed`),T()),await s([``,...x(e),...t===`directory`&&e?[e]:[]]),P(e,0,t===`directory`)},[T,s,P]),re=(0,V.useCallback)(()=>{N();let e=(e=!1)=>{let t=n.current;t&&(yl({activeElementIsSearchInput:document.activeElement===t,searchInputValue:t.value})||(t.focus(),bl({requestedSelect:e,searchInputValue:t.value})&&t.select()))};e(!0),u.current=window.requestAnimationFrame(()=>e(!1)),ml.forEach(t=>{let n=window.setTimeout(()=>e(!1),t);d.current.push(n)})},[N,n]),ie=(0,V.useCallback)(()=>{N();let r=()=>{if(n.current?.value)return;n.current?.blur();let r=t.current?.querySelector(`[role="tree"]`),a=Array.from(t.current?.querySelectorAll(`[data-file-path]`)??[]),o=Sl({lastFocusedPath:i.current,rows:a.map(e=>({path:e.dataset.filePath??``,selected:e.classList.contains(`selected`)})).filter(e=>e.path)});if(o&&a.find(e=>e.dataset.filePath===o)&&o){i.current=o,e.current?.get(o)?.select(),Au(r);return}Au(r)};r(),f.current=window.requestAnimationFrame(r),hl.forEach(e=>{let t=window.setTimeout(r,e);p.current.push(t)})},[N,n,i,e,t]),F=(0,V.useCallback)(n=>{k();let r=()=>{if(!ju()){if(n){e.current?.get(n)?.select();let r=Array.from(t.current?.querySelectorAll(`[data-file-path]`)??[]).find(e=>e.dataset.filePath===n);if(Au(r?.closest(`[role="tree"]`)??t.current?.querySelector(`[role="tree"]`)),r){r.scrollIntoView({block:`nearest`}),Nu(r);return}}Au(t.current?.querySelector(`[role="tree"]`))}};r(),f.current=window.requestAnimationFrame(()=>{f.current=null,r()}),[80,180,360].forEach(e=>{let t=window.setTimeout(r,e);p.current.push(t)})},[k,e,t]),I=(0,V.useCallback)(e=>{F(e?.path??null)},[F]);return(0,V.useEffect)(()=>{if(!y)return;let e=e=>{let t=e.target;(t instanceof Element?t.closest(`[data-file-path]`):null)?.dataset.filePath!==y&&(document.body.classList.add(`code-file-location-dismissed`),T())};return document.addEventListener(`pointerdown`,e,!0),document.addEventListener(`keydown`,e,!0),()=>{document.removeEventListener(`pointerdown`,e,!0),document.removeEventListener(`keydown`,e,!0)}},[T,y]),(0,V.useEffect)(()=>()=>{N(),T()},[N,T]),{cancelPendingFileFocus:N,focusFileSearchInput:re,focusFileTreeFromSearch:ie,focusFileTreePath:F,focusFileTreeTarget:I,locatedFilePath:y,revealExplorerPath:ne,revealFilePath:te}}var Fu=15e3;function Iu(e){return e.replace(/^\/+|\/+$/g,``)}function Lu(e,t=e){let[n,r]=(0,V.useState)({}),i=(0,V.useRef)({}),a=(0,V.useRef)(new Map),o=(0,V.useRef)(new Map),s=(0,V.useRef)(0),c=(0,V.useCallback)((t=``)=>{if(!e)return Promise.resolve(null);let n=Iu(t),i=a.current.get(n);if(i)return i;let l=s.current;r(e=>({...e,[n]:{items:e[n]?.items??[],loading:!0,error:null}}));let u=null;return u=(async()=>{let t=new AbortController,i=!1,d=window.setTimeout(()=>{i=!0,t.abort()},Fu);try{let i=await I(e,n,{signal:t.signal});if(s.current!==l)return null;if(r(e=>({...e,[n]:{items:i.items,loading:!1,error:null,gitStatusPending:i.gitStatusPending}})),i.gitStatusPending&&!o.current.has(n)){let e=window.setTimeout(()=>{o.current.delete(n),c(n)},2e3);o.current.set(n,e)}return i}catch(e){return s.current===l&&r(t=>({...t,[n]:{items:t[n]?.items??[],loading:!1,error:i?`File refresh timed out`:e instanceof Error?e.message:`Failed to load directory`}})),null}finally{window.clearTimeout(d),u&&a.current.get(n)===u&&a.current.delete(n)}})(),a.current.set(n,u),u},[e]),l=(0,V.useCallback)(e=>{let t=Iu(e),n=i.current[t];return!n||n.loading||n.error?c(t):Promise.resolve({path:t,items:n.items,gitStatusPending:n.gitStatusPending})},[c]);return(0,V.useEffect)(()=>{i.current=n},[n]),(0,V.useEffect)(()=>{s.current+=1,a.current.clear(),o.current.forEach(e=>window.clearTimeout(e)),o.current.clear()},[e,t]),(0,V.useEffect)(()=>{r({}),i.current={}},[e,t]),(0,V.useEffect)(()=>()=>{a.current.clear(),o.current.forEach(e=>window.clearTimeout(e)),o.current.clear()},[]),(0,V.useMemo)(()=>({directories:n,loadDirectory:c,ensureDirectoryLoaded:l}),[n,l,c])}var Ru=12,zu=6;function Bu(e){let t=e.lastIndexOf(`/`);return t<0?``:e.slice(0,t)}function Vu(e){return e.split(`/`).filter(Boolean).length}function Hu(e,t=e){let n=t||``,{directories:r,loadDirectory:i,ensureDirectoryLoaded:a}=Lu(e,t),[o,s]=(0,V.useState)(()=>new Set(N(n).openDirectoryPaths??[])),c=(0,V.useRef)(o),l=(0,V.useRef)(n),u=(0,V.useRef)(new Map),d=(0,V.useRef)(``),p=(0,V.useMemo)(()=>C(r[``]?.items??[],r),[r]),m=(0,V.useMemo)(()=>Math.max(1,f(p,o)),[o,p]),h=(0,V.useCallback)((e,t)=>{let n=c.current;if(n.has(e)===t)return;let r=new Set(n);t?r.add(e):r.delete(e),c.current=r,s(r)},[]),g=(0,V.useCallback)(e=>c.current.has(e),[]),_=(0,V.useCallback)(e=>{if(e.length===0)return;let t=new Set(c.current),n=!1;e.forEach(e=>{!e||t.has(e)||(t.add(e),n=!0)}),n&&(c.current=t,s(t))},[]),v=(0,V.useCallback)(()=>i(``),[i]),y=(0,V.useCallback)(e=>{let t=e.filter(e=>!r[e]);return Promise.all(t.map(e=>i(e)))},[r,i]),b=(0,V.useCallback)(e=>{let t=r[e];return!!(t&&!t.loading&&!t.error)},[r]),x=(0,V.useCallback)(e=>{let t=new Set([``]);e.forEach(e=>{let n=String(e??``).replace(/^\/+|\/+$/g,``);for(t.add(n);n;)n=Bu(n),t.add(n)});let n=Array.from(t).sort((e,t)=>Vu(e)-Vu(t)||e.localeCompare(t));return(async()=>{let e=new Map,t=new Set,r=!0,a=0;for(;a<n.length;){let o=Vu(n[a]),s=[];for(;a<n.length&&Vu(n[a])===o;)s.push(n[a]),a+=1;let c=s.filter(n=>{if(!n)return!0;if(Array.from(t).some(e=>n===e||n.startsWith(`${e}/`)))return!1;let i=Bu(n),a=e.get(i);return a===null?(r=!1,!1):a&&!a.items.some(e=>e.type===`directory`&&e.path===n)?(t.add(n),!1):!0}),l=0,u=Array.from({length:Math.min(zu,c.length)},async()=>{for(;l<c.length;){let t=c[l];l+=1;let n=await i(t);e.set(t,n),n||(r=!1)}});await Promise.all(u)}if(t.size>0){let e=Array.from(t),n=new Set(Array.from(c.current).filter(t=>!e.some(e=>t===e||t.startsWith(`${e}/`))));c.current=n,s(n)}return r})()},[i]),S=(0,V.useCallback)(e=>{let t=u.current.get(e);if(t)return t;let n;return n=(async()=>{let t=e;for(let e=0;e<Ru;e+=1){let e=await a(t),n=e?.items.length===1&&e.items[0]?.type===`directory`?e.items[0]:null;if(!n)return;t=n.path}})().finally(()=>{u.current.get(e)===n&&u.current.delete(e)}),u.current.set(e,n),n},[a]);return(0,V.useEffect)(()=>{u.current.clear()},[e]),(0,V.useEffect)(()=>{l.current===n&&j(n,{openDirectoryPaths:Array.from(o)})},[n,o]),(0,V.useEffect)(()=>{if(l.current===n)return;l.current=n,d.current=``;let e=N(n).openDirectoryPaths??[],t=new Set(e);c.current=t,s(t)},[n]),(0,V.useEffect)(()=>{if(o.size===0)return;let e=`${n}:${Array.from(o).join(`
12
- `)}`;d.current!==e&&(d.current=e,v(),y(Array.from(o)))},[y,v,n,o]),(0,V.useMemo)(()=>({directories:r,treeData:p,openDirectoryPaths:o,visibleTreeRowCount:m,loadRootDirectory:v,ensureDirectoryLoaded:a,isDirectoryLoaded:b,loadMissingDirectories:y,refreshDirectories:x,hydrateCompactDirectoryChains:S,isDirectoryOpen:g,setDirectoryOpen:h,openDirectoriesInLayout:_}),[r,a,S,g,b,y,v,_,o,x,h,p,m])}function Uu({agentId:e,agentLaunchOptionCount:t=0,cancelPendingFileFocus:n,clearFileOperation:r,focusFileTreeTarget:a,refreshDirectories:o,projectWorkspace:s,shareLinkFailed:c,setOpenFileError:l,startFileOperation:u}){let d=(0,V.useRef)(null),[f,p]=(0,V.useState)(null),m=(0,V.useCallback)(()=>{p(null)},[]),h=(0,V.useCallback)((e,i,a)=>{n(),l(null),r(),p({...U(e,i,a,window.innerWidth,window.innerHeight,t),item:a})},[t,n,r,l]),g=(0,V.useCallback)((e=!1)=>{let t=f?.item??null;p(null),e&&a(t)},[f?.item,a]),_=(0,V.useCallback)(()=>{g(!1)},[g]),v=(0,V.useCallback)(()=>{g(!0)},[g]),y=(0,V.useCallback)((e,t=f?.item??null)=>{n(),p(null),u(e,t)},[n,f?.item,u]),b=(0,V.useCallback)(()=>{e&&(o([et(f?.item??null)]),p(null))},[e,f?.item,o]);return{fileMenu:f,fileMenuRef:d,clearFileMenu:m,closeFileMenuWithFocusRestore:v,closeFileMenuWithoutFocus:_,copyFileMenuPath:(0,V.useCallback)(async()=>{let e=f?.item;if(e){p(null),l(null);try{await navigator.clipboard?.writeText(e.path)}catch{l(`Copy failed`)}}},[f?.item,l]),copyFileMenuShareUrl:(0,V.useCallback)(async()=>{let t=f?.item;if(!(!e||!t||t.type!==`file`&&t.type!==`directory`)){p(null),l(null);try{let n=t.type===`directory`?{kind:`folder`,agentId:e,folderPath:t.path,absolutePath:D(s,t.path),projectLabel:k(s)}:{kind:`file`,agentId:e,filePath:t.path,absolutePath:D(s,t.path),projectLabel:k(s)},r=await fetch(i(`/api/share/qr-ticket`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({target:n})}),a=await r.json();if(!r.ok||!a.longUrl||!await M(a.longUrl))throw Error(a.error||c)}catch(e){l(e instanceof Error?e.message:c)}}},[e,f?.item,s,l,c]),fileMenuTargetDirectory:(0,V.useCallback)((e=f?.item??null)=>et(e),[f?.item]),openFileContextMenu:h,refreshFileMenuTarget:b,startFileMenuOperation:y}}var Wu=220;function Gu({agentId:e,onClearSearch:t,onOpenFile:n,onRevealFilePath:r,onSelectOpenFile:i}){let a=(0,V.useRef)(0),o=(0,V.useRef)(null),[s,c]=(0,V.useState)(null),[l,d]=(0,V.useState)(null),f=(0,V.useCallback)(()=>{o.current!==null&&(window.clearTimeout(o.current),o.current=null),d(null)},[]),p=(0,V.useCallback)((e,t)=>{f(),o.current=window.setTimeout(()=>{a.current===e&&d(t),o.current=null},Wu)},[f]);return(0,V.useEffect)(()=>()=>{o.current!==null&&(window.clearTimeout(o.current),o.current=null)},[]),{openFileError:s,openFilePendingPath:l,openFilePath:(0,V.useCallback)(async(o,s)=>{if(!e)return;let l=a.current+1;if(a.current=l,c(null),i?.(e,o,s)){f(),t(),v(s)&&r(o);return}p(l,o);try{let i=await ce(e,o);if(a.current!==l)return;f(),n(e,i,s),t(),v(s)&&r(o)}catch(r){if(a.current!==l)return;if(f(),s&&r instanceof oe&&r.status===404&&u(s)){n(e,ee(o,s),s),t();return}c(r instanceof Error?r.message:`Failed to open file`)}},[e,f,t,n,r,i,p]),setOpenFileError:c}}function Ku({agentId:e,fileOperationActiveRef:t,ensureDirectoryLoaded:n,focusFileTreePath:r,onDeleteEntries:i,onMoveEntries:a,onOpenFile:o,onWorkspaceChange:s,refreshDirectories:l,setOpenFileError:u}){let d=(0,V.useRef)(null),f=(0,V.useRef)(``),[m,h]=(0,V.useState)(null),g=(0,V.useCallback)(()=>{t.current=!1,h(null)},[]),_=(0,V.useCallback)((e,n)=>{if(n?.readOnly&&!(n.symbolicLink&&(e===`rename`||e===`delete`)))return;let r=nt(e,n);f.current=r.name,t.current=!0,u(null),h(r)},[u]),v=(0,V.useCallback)(()=>{let e=m?.item??null;g(),r(e?.path??null)},[g,m?.item,r]),y=(0,V.useCallback)(e=>{f.current=e},[]),b=(0,V.useCallback)(e=>{f.current=e,h(t=>t&&{...t,name:e})},[]),x=(0,V.useCallback)(async()=>{if(!e||!m)return;let t=m.kind===`delete`?m:{...m,name:f.current},d=it(t);if(!(t.kind!==`delete`&&!d)){u(null);try{if(t.kind===`new-file`||t.kind===`new-folder`){let i=await ae(e,t.parentPath,d,t.kind===`new-folder`?`directory`:`file`);l([t.parentPath]),i.entry.type===`directory`&&(n(i.entry.path),r(i.entry.path)),i.file&&o(e,i.file),s?.(),g();return}if(t.kind===`rename`&&t.item){let n=await te(e,t.item.path,d);l(p(n)),a(e,[n]),s?.(),g(),r(S(n));return}if(t.kind===`delete`&&t.item){let n=await ne(e,t.item.path);l(c(n)),i(e,[n]),s?.(),g(),r(P(n))}}catch(e){u(e instanceof Error?e.message:`File operation failed`)}}},[e,g,n,m,r,i,a,o,s,l,u]);return(0,V.useEffect)(()=>{if(!m)return;let e=e=>{e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),v())};return document.addEventListener(`keydown`,e,!0),()=>{document.removeEventListener(`keydown`,e,!0)}},[v,m]),{fileOperation:m,fileOperationActiveRef:t,fileOperationInputRef:d,clearFileOperation:g,closeFileOperation:v,rememberFileOperationName:y,startFileOperation:_,submitFileOperation:x,updateFileOperationName:b}}var qu=3e3;function Ju(e){let[t,n]=(0,V.useState)(``),[r,i]=(0,V.useState)([]),[a,o]=(0,V.useState)(!1),[s,c]=(0,V.useState)(null),[l,u]=(0,V.useState)(0),[d,f]=(0,V.useState)(!1),[p,m]=(0,V.useState)(qu),[h,g]=(0,V.useState)(!1),_=(0,V.useRef)(0),v=t.trim().length>0,y=(0,V.useMemo)(()=>v?Ce(t):null,[v,t]),b=r.length>0?Math.min(l,r.length-1):-1,x=b>=0?r[b]??null:null,S=(0,V.useCallback)(()=>{_.current+=1,n(``),i([]),c(null),u(0),f(!1),m(qu),g(!1),o(!1)},[]),C=(0,V.useCallback)(e=>{g(!1),n(e)},[]),w=(0,V.useCallback)(()=>{g(!0)},[]),T=(0,V.useCallback)(()=>{r.length!==0&&u(e=>Math.min(e+1,r.length-1))},[r.length]),E=(0,V.useCallback)(()=>{r.length!==0&&u(e=>Math.max(e-1,0))},[r.length]),D=(0,V.useCallback)(e=>{u(Math.max(0,Math.min(e,Math.max(r.length-1,0))))},[r.length]);return(0,V.useEffect)(()=>{let n=t.trim(),r=_.current+1;if(_.current=r,u(0),!e||!n||Ce(n)){i([]),o(!1),c(null),f(!1);return}o(!0),c(null);let a=new AbortController,s=window.setTimeout(()=>{le(e,n,{includeIgnored:h,limit:60,signal:a.signal}).then(e=>{_.current===r&&(i(e.matches),f(e.truncated),m(e.timeoutMs??qu),o(!1))}).catch(e=>{_.current===r&&(e instanceof DOMException&&e.name===`AbortError`||(i([]),f(!1),c(e instanceof Error?e.message:`Search failed`),o(!1)))})},180);return()=>{window.clearTimeout(s),a.abort()}},[e,h,t]),(0,V.useEffect)(()=>{u(e=>Math.min(e,Math.max(r.length-1,0)))},[r.length]),(0,V.useMemo)(()=>({query:t,setQuery:C,matches:r,loading:a,error:s,selectMatchIndex:D,truncated:d,timeoutMs:p,includeIgnored:h,active:v,jumpTarget:y,activeMatchIndex:b,selectedMatch:x,clear:S,searchIgnored:w,selectNext:T,selectPrevious:E}),[v,b,S,s,y,a,r,h,w,t,D,T,E,x,d,p])}function Yu({fileMenuOpen:e,fileOperationActive:t,fileSearch:n,fileSearchResultsRef:r,filesCollapsed:i,focusFileTreeFromSearch:a,listboxId:o,onOpenFilePath:s,onRevealDirectoryPath:c}){let l=De({active:n.active,activeMatchIndex:n.activeMatchIndex,jumpTarget:n.jumpTarget,listboxId:o}),u=(0,V.useCallback)(e=>{if(e.kind===`path`&&e.entryType===`directory`){c(e.path),n.clear();return}let t=Te(e);s(t.path,t.target),n.clear()},[n,s,c]),d=(0,V.useCallback)(e=>{let t=Ee(e);return t?(s(t.path,t.target),n.clear(),!0):!1},[n,s]),f=(0,V.useCallback)(e=>{if(e.key===`Escape`){e.preventDefault(),e.stopPropagation(),n.clear(),a();return}if(e.key===`ArrowDown`){if(n.matches.length===0)return;e.preventDefault(),n.selectNext();return}if(e.key===`ArrowUp`){if(n.matches.length===0)return;e.preventDefault(),n.selectPrevious();return}if(e.key!==`Enter`||(e.preventDefault(),e.stopPropagation(),d(e.currentTarget.value)))return;let t=n.selectedMatch??n.matches[0];t&&u(t)},[n,a,d,u]);return(0,V.useEffect)(()=>{if(!n.active||n.matches.length===0)return;let e=r.current,t=e?.querySelector(`.code-file-search-result.active`);if(!e||!t)return;let i=t.offsetTop,a=i+t.offsetHeight;i<e.scrollTop?e.scrollTop=i:a>e.scrollTop+e.clientHeight&&(e.scrollTop=a-e.clientHeight)},[n.active,n.activeMatchIndex,n.matches.length,r]),(0,V.useEffect)(()=>{if(i||!n.active||e||t)return;let r=e=>{e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),n.clear(),a())};return document.addEventListener(`keydown`,r,!0),()=>{document.removeEventListener(`keydown`,r,!0)}},[e,t,n,i,a]),{activeOptionId:l,handleFileSearchKeyDown:f,openFileJumpQuery:d,openFileSearchMatch:u}}function Xu({agentId:e,workspaceKey:t,clearFileMenu:n,clearFileOperation:r,clearFileSearch:i,focusFileSearchInput:a,focusSearchRequest:o,loadRootDirectory:s,openFilesCount:c,refreshTreeLayout:l,revealExplorerPath:u,revealRequest:d,rootDirectoryLoaded:f,setFileSearchQuery:p,setOpenFileError:m,treeData:h}){let[g,_]=(0,V.useState)(()=>N(t).filesCollapsed??!0),[v,y]=(0,V.useState)(!0),b=(0,V.useRef)(null),x=(0,V.useRef)(t),S=(0,V.useCallback)(()=>{let e=!g;e?(n(),r(),i()):f||s(),_(e)},[n,r,i,g,s,f]),C=(0,V.useCallback)(()=>{y(e=>!e)},[]);return(0,V.useEffect)(()=>{m(null),n(),r(),i()},[e,n,r,i,m]),(0,V.useEffect)(()=>{if(d){if(_(!1),!f){s();return}b.current!==d.requestId&&(b.current=d.requestId,u(d.path,d.kind))}},[s,u,d,f]),(0,V.useEffect)(()=>{o&&(_(!1),f||s(),typeof o.query==`string`&&p(o.query),a())},[a,o,s,f,p]),(0,V.useEffect)(()=>{c===0&&y(!0)},[c]),(0,V.useEffect)(()=>{x.current===t&&j(t,{filesCollapsed:g})},[g,t]),(0,V.useEffect)(()=>{x.current!==t&&(x.current=t,_(N(t).filesCollapsed??!0))},[t]),(0,V.useEffect)(()=>{!g&&!f&&s()},[g,s,f]),(0,V.useEffect)(()=>{g||l()},[g,l,h]),{filesCollapsed:g,openEditorsCollapsed:v,toggleFilesCollapsed:S,toggleOpenEditorsCollapsed:C}}function Zu(e,t){let n=t.closest(`.code-project-group`),r=n?.querySelector(`.code-project-row`),i=n?.querySelector(`.code-agents-section`),a=n?.querySelector(`[data-testid="code-open-editors"]`);return kl(e.getBoundingClientRect().top,r?.getBoundingClientRect().height??30,(i?.getBoundingClientRect().height??0)+(a?.getBoundingClientRect().height??0),25)}function Qu({filesCollapsed:e,focusFileTreePath:t,lastFocusedFilePathRef:n,openDirectoryPaths:r,refreshTreeLayout:i,resetKey:a,treeData:o,treeViewportRef:s}){let[c,l]=(0,V.useState)([]),[u,d]=(0,V.useState)(!1),f=(0,V.useMemo)(()=>c.map(e=>m(o,e)).filter(e=>!!e),[c,o]),p=(0,V.useMemo)(()=>Nl({visible:u,directoryNodes:f}),[u,f]),h=(0,V.useCallback)(()=>{l(e=>e.length===0?e:[]),d(!1)},[]),g=(0,V.useCallback)(()=>{let t=s.current,n=t?.closest(`.code-project-list`);if(!t||!n||e){h();return}let r=n.getBoundingClientRect(),i=Zu(n,t),a=t.getBoundingClientRect(),o=Array.from(t.querySelectorAll(`[data-file-path]`)).flatMap(e=>{let t=e.dataset.filePath;if(!t)return[];let n=e.getBoundingClientRect();return[{path:t,top:n.top,bottom:n.bottom}]}),c=jl(o,i,r.bottom);if(!c){h();return}d(Al(a.top,i));let u=Ml(c,o,i);l(e=>e.length===u.length&&e.every((e,t)=>e===u[t])?e:u)},[h,e,s]),_=(0,V.useCallback)(e=>{n.current=e.path,t(e.path)},[t,n]);return(0,V.useEffect)(()=>{h()},[h,a]),(0,V.useEffect)(()=>{if(e){h();return}i();let t=window.requestAnimationFrame(()=>i()),n=window.setTimeout(i,80),r=window.setTimeout(i,180);return()=>{window.cancelAnimationFrame(t),window.clearTimeout(n),window.clearTimeout(r)}},[h,e,r,i,o]),(0,V.useEffect)(()=>{if(e)return;let t=s.current?.closest(`.code-project-list`),n=0,r=()=>{n||=window.requestAnimationFrame(()=>{n=0,g()})};return g(),window.setTimeout(g,80),t?.addEventListener(`scroll`,r,{passive:!0}),window.addEventListener(`resize`,r),()=>{n&&window.cancelAnimationFrame(n),t?.removeEventListener(`scroll`,r),window.removeEventListener(`resize`,r)}},[e,r,g,o,s]),{focusStickyDirectory:_,stickyContextItems:p}}function $u({rowHeight:e,visibleTreeRowCount:t,openDirectoryPaths:n,treeData:r,hydrateCompactDirectoryChains:i,isDirectoryOpen:a,setDirectoryOpen:o}){let s=(0,V.useRef)(void 0),c=(0,V.useRef)(null),l=(0,V.useRef)(null),u=(0,V.useRef)(new Set),d=(0,V.useRef)(new Set),f=Math.max(e,t*e),p=(0,V.useCallback)(e=>{if(e.length===0)return!1;let t=s.current;if(!t)return!1;let n=!1;return e.forEach(e=>{!e||!t.get(e)||u.current.has(e)||t.isOpen(e)||(t.open(e,!1),n=!0)}),n},[]),m=(0,V.useCallback)((e=[])=>{let t=()=>{p(e),s.current?.redrawList()};t(),window.requestAnimationFrame(t),window.setTimeout(t,80)},[p]),h=(0,V.useCallback)((e,t)=>{t?(u.current.delete(e),d.current.delete(e)):(u.current.add(e),d.current.delete(e)),o(e,t)},[o]),g=(0,V.useCallback)(e=>{let t=!a(e);return h(e,t),t},[a,h]);(0,V.useEffect)(()=>{u.current.forEach(e=>{if(!n.has(e)){d.current.add(e);return}d.current.has(e)&&(u.current.delete(e),d.current.delete(e))})},[n]),(0,V.useEffect)(()=>{let e=Array.from(n);if(e.length===0)return;let t=()=>{p(e)&&s.current?.redrawList()};t();let r=window.requestAnimationFrame(t),i=window.setTimeout(t,80),a=window.setTimeout(t,180);return()=>{window.cancelAnimationFrame(r),window.clearTimeout(i),window.clearTimeout(a)}},[n,p,r]);let _=(0,V.useCallback)(({attrs:e,innerRef:t,children:n})=>{let{style:r,className:i,...a}=e;return(0,V.createElement)(`div`,{...a,ref:t,style:{...r,minWidth:`100%`,width:`100%`},className:`code-file-tree-row-frame ${i??``}`.trim()},n)},[]);return{treeRef:s,treeViewportRef:c,lastFocusedFilePathRef:l,treeHeight:f,handleTreeToggle:(0,V.useCallback)(e=>{Fl(c.current?.closest(`.code-project-list`)),a(e)?i(e).finally(()=>m([e])):m()},[i,a,m]),refreshTreeLayout:m,rememberFocusedTreeNode:(0,V.useCallback)(e=>{e&&(l.current=e.data.path)},[]),rememberSelectedTreeNodes:(0,V.useCallback)(e=>{let t=e[e.length-1];t&&(l.current=t.data.path)},[]),renderFileTreeRow:_,setTreePathOpen:h,toggleTreePathOpen:g}}function ed({treeRef:e,treeViewportRef:t,lastFocusedFilePathRef:n,fileOperation:r,openDirectoryPaths:i,cancelPendingFileFocus:a,closeFileOperation:o,focusFileSearchInput:s,focusFileTreePath:c,focusFileTreeTarget:l,openFileContextMenu:u,openFilePath:d,setDirectoryOpen:f,startFileOperation:p,toggleDirectoryOpen:m}){let h=(0,V.useCallback)(()=>t.current?.closest(`.code-project-list`)??null,[t]),g=(0,V.useCallback)(()=>{let e=t.current,n=(e?.querySelector(`[data-file-path]`))?.getBoundingClientRect().height||24;return wl((h()??e)?.getBoundingClientRect().height??n,n)},[h,t]),_=(0,V.useCallback)((e,t=!0)=>{Fl(h()),t&&f(e.data.path,!0),e.open(),n.current=e.data.path,l(e.data)},[l,n,h,f]),v=(0,V.useCallback)((t,r,i=!0)=>{Fl(h()),i&&f(t,!1),r?r.close():e.current?.close(t),n.current=t,r?l(r.data):c(t)},[c,l,n,h,f,e]),y=(0,V.useCallback)(c=>{if(c.defaultPrevented||c.altKey)return;if((c.ctrlKey||c.metaKey)&&!c.shiftKey&&c.key.toLowerCase()===`p`){c.preventDefault(),c.stopPropagation(),s();return}if(c.ctrlKey||c.metaKey)return;let f=e.current,h=c.target;if(r&&c.key===`Escape`&&h?.closest(`.code-file-inline-operation`)){c.preventDefault(),c.stopPropagation(),o();return}if(h?.closest(`input, textarea, [contenteditable="true"], .code-file-inline-operation`))return;xl(c.key)&&a();let y=h?.closest(`[data-file-path]`)?.dataset.filePath,b=y?void 0:t.current?.querySelector(`[data-file-path].selected`),x={path:b?.dataset.filePath,type:b?.dataset.fileType,expanded:b?.getAttribute(`aria-expanded`)===`true`},S=f?.focusedNode&&!f.focusedNode.isRoot?f.focusedNode:null,C=Cl({targetPath:y,selectedPath:x.path,focusedPath:S?.data.path,lastFocusedPath:n.current}),w=C?f?.get(C):f?.focusedNode??f?.mostRecentNode;if(!w||w.isRoot)return;if(n.current=w.data.path,c.key===`ContextMenu`||c.shiftKey&&c.key===`F10`){c.preventDefault(),c.stopPropagation();let e=(c.target?.closest(`[data-file-path]`))?.getBoundingClientRect();u(e?e.left+24:24,e?e.top+e.height:24,w.data);return}if(c.shiftKey)return;if(c.key===`ArrowDown`||c.key===`ArrowUp`){c.preventDefault(),c.stopPropagation();let e=c.key===`ArrowDown`?w.next:w.prev;if(!e||e.isRoot)return;e.focus(),e.select(),n.current=e.data.path;return}if(c.key===`Home`||c.key===`End`){c.preventDefault(),c.stopPropagation();let e=f?.visibleNodes.filter(e=>!e.isRoot)??[],t=c.key===`Home`?e[0]:e[e.length-1];if(!t)return;t.focus(),t.select(),n.current=t.data.path,l(t.data);return}if(c.key===`PageUp`||c.key===`PageDown`){c.preventDefault(),c.stopPropagation();let e=f?.visibleNodes.filter(e=>!e.isRoot)??[],t=Tl({currentIndex:e.findIndex(e=>e.id===w.id),key:c.key,pageSize:g(),rowCount:e.length}),r=t>=0?e[t]:null;if(!r)return;r.focus(),r.select(),n.current=r.data.path,l(r.data);return}if(c.key===`F2`){c.preventDefault(),c.stopPropagation(),p(`rename`,w.data);return}if(c.key===`Delete`||c.key===`Backspace`){c.preventDefault(),c.stopPropagation(),p(`delete`,w.data);return}if(c.key===`ArrowRight`){if(w.data.type!==`directory`)return;if(c.preventDefault(),c.stopPropagation(),!w.isOpen){_(w);return}let e=w.children?.[0]??null;e&&(e.select(),e.focus(),n.current=e.data.path,l(e.data));return}if(c.key===`ArrowLeft`){if(c.preventDefault(),c.stopPropagation(),El({nodePath:w.data.path,nodeType:w.data.type,nodeOpen:w.isOpen,selectedRow:x,openDirectoryPaths:i})){v(w.data.path,w);return}let e=w.parent;e&&!e.isRoot&&(e.select(),e.focus(),n.current=e.data.path,l(e.data));return}if(c.key!==`Enter`&&c.key!==` `)return;c.preventDefault(),c.stopPropagation();let T=w.data.type===`directory`?m(w.data.path)?`open-directory`:`close-directory`:Ol({nodeType:w.data.type,nodeOpen:w.isOpen});if(T===`close-directory`){v(w.data.path,w,!1);return}if(T===`open-directory`){_(w,!1);return}T===`open-file`&&(n.current=w.data.path,d(w.data.path))},[a,o,v,r,s,l,n,_,i,u,d,g,p,m,e,t]);return(0,V.useEffect)(()=>{let n=n=>{if(n.key!==`ArrowLeft`||n.altKey||n.ctrlKey||n.metaKey)return;let r=t.current,i=document.activeElement;if(!r||!(i instanceof Element)||!r.contains(i))return;let a=r.querySelector(`[data-file-path].selected`),o=a?.dataset.filePath;if(!o||a?.dataset.fileType!==`directory`||a.getAttribute(`aria-expanded`)!==`true`)return;n.preventDefault(),n.stopPropagation();let s=e.current?.get(o);v(o,s)};return window.addEventListener(`keydown`,n,!0),()=>{window.removeEventListener(`keydown`,n,!0)}},[v,e,t]),{handleTreeKeyDownCapture:y}}var td=24,nd=350,rd=1400,id=new Set;function ad(e){return e.replace(/[^a-zA-Z0-9_-]+/g,`-`)||`root`}function od(e,t){let n=e.replace(/\/+$/,``)||`/`,r=t.replace(/^\/+|\/+$/g,``);return r?n===`/`?`/${r}`:`${n}/${r}`:n}function sd(e){return e.split(`/`).filter(Boolean).pop()||e}function cd(e){return{id:e.path,name:sd(e.path),path:e.path,type:`file`,size:0,mtimeMs:0}}function ld({projectId:e,projectWorkspace:t,agentId:n,agentLaunchOptions:r,activeFilePath:i,revealRequest:a,focusSearchRequest:o,editorDirtyFilePaths:s=id,editorExternalChangedFilePaths:c=id,openFiles:l=[],onOpenFile:u,onSelectOpenFile:d,onCloseOpenFile:f,onNewAgent:p,onStartAgent:m,onMoveEntries:h,onDeleteEntries:g,onRefreshOpenFiles:_,onFilesCollapsedChange:v,readOnly:b=!1,copy:x}){let{directories:S,treeData:C,openDirectoryPaths:w,visibleTreeRowCount:T,loadRootDirectory:E,ensureDirectoryLoaded:D,isDirectoryLoaded:O,loadMissingDirectories:k,refreshDirectories:A,hydrateCompactDirectoryChains:j,isDirectoryOpen:M,setDirectoryOpen:N,openDirectoriesInLayout:ee}=Hu(n,e),P=(0,V.useRef)(!1),te=(0,V.useRef)(null),ne=(0,V.useRef)(null),re=(0,V.useRef)(null),ie=(0,V.useRef)(!1),F=(0,V.useRef)(0),I=(0,V.useRef)(null),[ae,L]=(0,V.useState)(`idle`),R=Ju(n),oe=`code-file-search-results-${ad(e)}`,{treeRef:se,treeViewportRef:ce,lastFocusedFilePathRef:le,treeHeight:ue,handleTreeToggle:de,refreshTreeLayout:z,rememberFocusedTreeNode:fe,rememberSelectedTreeNodes:B,renderFileTreeRow:pe,setTreePathOpen:me,toggleTreePathOpen:he}=$u({rowHeight:td,visibleTreeRowCount:T,openDirectoryPaths:w,treeData:C,hydrateCompactDirectoryChains:j,isDirectoryOpen:M,setDirectoryOpen:N}),{cancelPendingFileFocus:ge,focusFileSearchInput:_e,focusFileTreeFromSearch:ve,focusFileTreePath:ye,focusFileTreeTarget:be,locatedFilePath:xe,revealExplorerPath:Ce,revealFilePath:we}=Pu({treeRef:se,treeViewportRef:ce,fileSearchInputRef:te,fileOperationActiveRef:P,lastFocusedFilePathRef:le,treeData:C,isDirectoryLoaded:O,loadMissingDirectories:k,openDirectoriesInLayout:ee,refreshTreeLayout:z}),Te=R.clear,{openFileError:Ee,openFilePendingPath:De,openFilePath:Oe,setOpenFileError:ke}=Gu({agentId:n,onClearSearch:Te,onOpenFile:u,onRevealFilePath:we,onSelectOpenFile:d}),Ae=Cu(b?null:n,l),[je,Me]=(0,V.useState)(!0),Ne=(0,V.useCallback)(()=>{if(ie.current)return;ie.current=!0;let e=F.current+1;F.current=e,I.current!==null&&(window.clearTimeout(I.current),I.current=null),L(`refreshing`),ke(null);let r=[``,...w],i=new Promise(e=>{window.setTimeout(e,nd)});(async()=>{let a=!1;try{let e=await Ae.refreshChanges(),[o,s]=await Promise.all([A(r),n&&_?_(n,t):Promise.resolve(!0)]);await i,a=e&&o&&s}catch{await i}F.current===e&&(ie.current=!1,L(a?`success`:`error`),a&&(I.current=window.setTimeout(()=>{F.current===e&&L(`idle`),I.current=null},rd)))})()},[n,Ae.refreshChanges,_,w,t,A,ke]);(0,V.useEffect)(()=>{F.current+=1,ie.current=!1,I.current!==null&&(window.clearTimeout(I.current),I.current=null),L(`idle`)},[n,e]),(0,V.useEffect)(()=>()=>{F.current+=1,I.current!==null&&window.clearTimeout(I.current)},[]),(0,V.useEffect)(()=>{Me(!0)},[n]);let Pe=(0,V.useCallback)(()=>{Me(e=>!e)},[]),Fe=(0,V.useCallback)(e=>{Oe(e.path,{...y(e),transient:!0})},[Oe]),{fileOperation:Ie,fileOperationInputRef:Le,clearFileOperation:Re,closeFileOperation:ze,rememberFileOperationName:Be,startFileOperation:Ve,submitFileOperation:He,updateFileOperationName:Ue}=Ku({agentId:n,fileOperationActiveRef:P,ensureDirectoryLoaded:D,focusFileTreePath:ye,onDeleteEntries:g,onMoveEntries:h,onOpenFile:u,onWorkspaceChange:Ae.refreshChanges,refreshDirectories:A,setOpenFileError:ke}),{fileMenu:We,fileMenuRef:Ge,clearFileMenu:Ke,closeFileMenuWithFocusRestore:qe,closeFileMenuWithoutFocus:Je,copyFileMenuPath:Ye,copyFileMenuShareUrl:Xe,fileMenuTargetDirectory:Ze,openFileContextMenu:Qe,refreshFileMenuTarget:$e,startFileMenuOperation:et}=Uu({agentId:n,agentLaunchOptionCount:r.length,cancelPendingFileFocus:ge,clearFileOperation:Re,focusFileTreeTarget:be,projectWorkspace:t,refreshDirectories:A,shareLinkFailed:x.shareLinkFailed,setOpenFileError:ke,startFileOperation:Ve}),tt=(0,V.useCallback)(e=>{ke(null),R.setQuery(e)},[R.setQuery,ke]),nt=(0,V.useCallback)(()=>od(t,Ze()),[Ze,t]),rt=(0,V.useCallback)(()=>{p&&(Je(),p(t))},[Je,p,t]),it=(0,V.useCallback)(e=>{if(!m)return;let n=nt();Je(),m(e,n,n===t?void 0:{projectWorkspace:t})},[Je,nt,m,t]),at=(0,V.useCallback)((e,t,n)=>{Qe(e,t,cd(n))},[Qe]),{filesCollapsed:U,openEditorsCollapsed:ot,toggleFilesCollapsed:ct,toggleOpenEditorsCollapsed:lt}=Xu({agentId:n,workspaceKey:e,clearFileMenu:Ke,clearFileOperation:Re,clearFileSearch:Te,focusFileSearchInput:_e,focusSearchRequest:o,loadRootDirectory:E,openFilesCount:l.length,refreshTreeLayout:z,revealExplorerPath:Ce,revealRequest:a,rootDirectoryLoaded:!!(S[``]&&!S[``].loading),setFileSearchQuery:R.setQuery,setOpenFileError:ke,treeData:C});(0,V.useEffect)(()=>{v?.(U)},[U,v]);let ut=(0,V.useMemo)(()=>l.length===0?{"--code-open-editors-sticky-height":`0px`}:ot?{"--code-open-editors-sticky-height":`25px`}:{"--code-open-editors-sticky-height":`${25+Math.min(l.length,7)*28}px`},[ot,l.length]);(0,V.useEffect)(()=>{!i||U||!S[``]||re.current!==i&&(re.current=i,we(i))},[i,S,U,we]);let{focusStickyDirectory:W,stickyContextItems:dt}=Qu({filesCollapsed:U,focusFileTreePath:ye,lastFocusedFilePathRef:le,openDirectoryPaths:w,refreshTreeLayout:z,resetKey:n,treeData:C,treeViewportRef:ce}),{activeOptionId:ft,handleFileSearchKeyDown:pt,openFileJumpQuery:mt,openFileSearchMatch:ht}=Yu({fileMenuOpen:!!We,fileOperationActive:!!Ie,fileSearch:R,fileSearchResultsRef:ne,filesCollapsed:U,focusFileTreeFromSearch:ve,listboxId:oe,onOpenFilePath:Oe,onRevealDirectoryPath:e=>Ce(e,`directory`)}),{handleTreeKeyDownCapture:gt}=ed({treeRef:se,treeViewportRef:ce,lastFocusedFilePathRef:le,fileOperation:Ie,openDirectoryPaths:w,cancelPendingFileFocus:ge,closeFileOperation:ze,focusFileSearchInput:_e,focusFileTreePath:ye,focusFileTreeTarget:be,openFileContextMenu:Qe,openFilePath:Oe,setDirectoryOpen:me,startFileOperation:et,toggleDirectoryOpen:he}),_t=yu({activeFilePath:i,activeSearchOptionId:ft,agentId:n??``,agentLaunchOptions:r,copy:x,editorDirtyFilePaths:s,editorExternalChangedFilePaths:c,fileMenu:We,fileMenuRef:Ge,fileOperation:Ie,fileOperationInputRef:Le,fileSearch:R,fileSearchInputRef:te,fileSearchListboxId:oe,fileSearchResultsRef:ne,filesCollapsed:U,handleFileSearchKeyDown:pt,handleTreeKeyDownCapture:gt,lastFocusedFilePathRef:le,locatedFilePath:xe,openEditorsCollapsed:ot,openFileError:Ee,openFilePendingPath:De,projectId:e,renderFileTreeRow:pe,rootDirectoryError:S[``]?.error??null,rootDirectoryHasItems:!!S[``]?.items.length,rootDirectoryLoading:!!S[``]?.loading,rowHeight:td,readOnly:b,stickyContextItems:dt,treeData:C,treeHeight:ue,treeRef:se,treeViewportRef:ce,visibleTreeRowCount:T,onCancelPendingFileFocus:ge,onCloseFileMenuWithFocusRestore:qe,onCloseFileMenuWithoutFocus:Je,onCloseFileOperation:ze,onCloseOpenFile:f,onCopyFileMenuPath:Ye,onCopyFileMenuShareUrl:Xe,onFocusFileTreeTarget:be,onFocusStickyDirectory:W,onOpenFileContextMenu:Qe,onOpenFileJumpQuery:mt,onOpenFilePath:Oe,onOpenFileSearchMatch:ht,onOpenNewAgentFromFileMenu:rt,onRefreshFileMenuTarget:$e,onRememberFileOperationName:Be,onSearchQueryChange:tt,onSelectOpenFile:d,onSelectSearchMatchIndex:R.selectMatchIndex,onToggleDirectory:he,onStartAgentFromFileMenu:it,onStartFileMenuOperation:et,onSubmitFileOperation:He,onToggleFilesCollapsed:ct,onToggleOpenEditorsCollapsed:lt,onToggleTreeNode:de,onTreeFocus:fe,onTreeSelect:B,onUpdateFileOperationName:Ue});return n?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(vu,{..._t.openEditors,files:l,onOpenFileContextMenu:at}),(0,H.jsxs)(`div`,{className:`code-files-section ${U?`collapsed`:``}`,"data-testid":`code-files-section`,"data-project-id":e,style:ut,children:[(0,H.jsx)(Gl,{..._t.sectionHeader,refreshStatus:ae,onRefreshFiles:Ne}),!U&&(0,H.jsxs)(H.Fragment,{children:[!b&&(0,H.jsx)(Se,{activeFilePath:i,agentId:n,changes:Ae,collapsed:je,copy:x,projectId:e,refreshing:ae===`refreshing`,onOpenChange:Fe,onToggleCollapsed:Pe}),!b&&(0,H.jsx)(gu,{agentId:n,copy:x,projectId:e}),(0,H.jsx)(Wl,{..._t.sectionBody})]})]}),U&&(0,H.jsx)(st,{agentId:n,copy:x,agentLaunchOptions:r,fileMenu:We,fileOperation:Ie,fileMenuRef:Ge,fileOperationInputRef:Le,onCloseFileMenu:Je,onCloseFileMenuWithFocusRestore:qe,onCloseFileOperation:ze,onCopyFileMenuPath:Ye,onCopyFileMenuShareUrl:Xe,onOpenNewAgent:rt,onRefreshFileMenuTarget:$e,onRememberFileOperationName:Be,onStartAgent:it,onStartFileMenuOperation:et,onSubmitFileOperation:He,onUpdateFileOperationName:Ue,readOnly:b})]}):null}export{ld as ProjectFilesSection};
11
+ Use the data prop if you want to provide your own handlers.`);if(e.initialData){let[t,n]=ul(e.initialData,{idAccessor:e.idAccessor,childrenAccessor:e.childrenAccessor});return Object.assign(Object.assign(Object.assign({},e),n),{data:t})}else return e}function fl(e,t){return(0,H.jsxs)($c,{treeProps:dl(e),imperativeHandle:t,children:[(0,H.jsx)(tl,{children:(0,H.jsx)(nl,{})}),(0,H.jsx)(rl,{})]})}var pl=(0,V.forwardRef)(fl),ml=[0,80,180,300,520,900,1200],hl=[80,180,360],gl=new Set([`ArrowDown`,`ArrowUp`,`ArrowLeft`,`ArrowRight`,`Home`,`End`,`PageUp`,`PageDown`,`Enter`,` `,`F2`,`Delete`,`Backspace`,`ContextMenu`]);function _l(e,t){return t.top<e.top?t.top-e.top:t.bottom>e.bottom?t.bottom-e.bottom:0}function vl(e){return e.focusRow&&!e.operationActive&&!e.activeElementIsSearchInput&&!e.searchInputValue}function yl(e){return e.activeElementIsSearchInput&&!!e.searchInputValue}function bl(e){return e.requestedSelect||!e.searchInputValue}function xl(e){return gl.has(e)}function Sl(e){return e.rows.find(t=>t.path===e.lastFocusedPath)?.path??e.rows.find(e=>e.selected)?.path??e.rows[0]?.path??null}function Cl(e){return e.selectedPath??e.targetPath??e.focusedPath??e.lastFocusedPath??null}function wl(e,t){return Math.max(1,Math.floor(Math.max(0,e)/Math.max(1,t))-1)}function Tl(e){if(e.rowCount<=0)return-1;let t=Math.max(0,Math.min(e.currentIndex,e.rowCount-1))+(e.key===`PageUp`?-1:1)*Math.max(1,e.pageSize);return Math.max(0,Math.min(t,e.rowCount-1))}function El(e){if(e.nodeType!==`directory`)return!1;let t=e.selectedRow.path===e.nodePath&&e.selectedRow.type===`directory`&&e.selectedRow.expanded===!0;return e.nodeOpen||t||e.openDirectoryPaths.has(e.nodePath)}function Dl(e){let t=!e.metaKey&&!e.ctrlKey&&!e.shiftKey;return e.nodeType===`directory`&&t?`toggle-directory`:e.nodeType===`file`&&t?`open-file`:`select`}function Ol(e){return e.nodeType===`directory`?e.nodeOpen?`close-directory`:`open-directory`:e.nodeType===`file`?`open-file`:`none`}function kl(e,t=30,n=0,r=25){return e+t+n+r}function Al(e,t,n=1){return e<t+n}function jl(e,t,n,r=1){return e.find(e=>e.bottom>t+r&&e.top<n)?.path??``}function Ml(e,t,n){if(!e)return[];let r=new Map(t.map(e=>[e.path,e.top]));return x(e).filter(e=>{let t=r.get(e);return typeof t==`number`&&t<n})}function Nl(e){return!e.visible&&e.directoryNodes.length===0?[]:e.directoryNodes.map(e=>({kind:`directory`,key:e.path,node:e}))}function Pl(e){return e.map(e=>e.displayName??e.name).filter(Boolean).join(`/`)}function Fl(e){if(!e)return()=>{};let t=e.scrollTop,n=()=>{e.scrollTop=t};return n(),window.requestAnimationFrame(n),window.setTimeout(n,0),window.setTimeout(n,80),window.setTimeout(n,180),n}function Il(e,t,n){let r=We(e.node.descendantGitStatus);return(0,H.jsxs)(`button`,{type:`button`,className:`code-file-row directory code-file-sticky-row`,style:He(h(e.node.path)),title:e.node.path,onClick:t=>{t.preventDefault(),t.stopPropagation(),n(e.node)},children:[(0,H.jsx)(`span`,{className:`code-file-chevron expanded`,"aria-hidden":`true`,children:(0,H.jsx)(z,{})}),(0,H.jsx)(`span`,{className:`code-file-name`,children:e.node.displayName??e.node.name}),r&&(0,H.jsx)(`span`,{className:r,title:Ve(`git`,t)})]},e.key)}function Ll({copy:e,items:t,onFocusDirectory:n}){if(t.length===0)return null;let r=t.filter(e=>e.kind===`directory`),i=r[r.length-1];return(0,H.jsx)(`div`,{className:`code-file-sticky-shell`,children:(0,H.jsxs)(`div`,{className:`code-file-sticky-stack`,"data-testid":`code-file-sticky-stack`,"aria-label":e.stickyFolderPath,children:[(0,H.jsx)(`div`,{className:`code-file-sticky-expanded-rows`,children:r.map(t=>Il(t,e,n))}),i&&(0,H.jsxs)(`button`,{type:`button`,className:`code-file-row directory code-file-sticky-row code-file-sticky-compact-row`,style:He(0),title:i.node.path,onClick:e=>{e.preventDefault(),e.stopPropagation(),n(i.node)},children:[(0,H.jsx)(`span`,{className:`code-file-chevron expanded`,"aria-hidden":`true`,children:(0,H.jsx)(z,{})}),(0,H.jsx)(`span`,{className:`code-file-name`,children:Pl(r.map(e=>e.node))})]})]})})}function Rl({agentId:e,copy:t,fileOperation:n,inputRef:r,item:i,onCancel:a,onInputName:o,onSubmit:s}){return(0,V.useLayoutEffect)(()=>{let e=r.current;e&&(e.focus({preventScroll:!0}),document.activeElement===e&&e.setSelectionRange(0,rt(n)))},[n.item?.path,r]),(0,H.jsx)(`form`,{className:`code-file-inline-operation`,"data-testid":`code-file-inline-operation`,style:{gridColumn:`3 / -1`},autoComplete:`off`,onPointerDown:e=>e.stopPropagation(),onMouseDown:e=>e.stopPropagation(),onClick:e=>e.stopPropagation(),onSubmit:e=>{e.preventDefault(),e.stopPropagation(),s()},children:(0,H.jsx)(`input`,{id:`code-file-operation-input`,"data-testid":`code-file-operation-input`,name:`farming-file-${e}-rename`,type:`text`,inputMode:`text`,ref:r,defaultValue:n.name,"aria-label":t.renameEntry(i.name),autoComplete:`off`,"aria-autocomplete":`none`,autoCapitalize:`none`,autoCorrect:`off`,autoFocus:!0,spellCheck:!1,enterKeyHint:`done`,"data-lpignore":`true`,"data-1p-ignore":`true`,"data-bwignore":`true`,"data-form-type":`other`,onInput:e=>{o(e.currentTarget.value)},onKeyDown:e=>{if(e.key===`Escape`){e.preventDefault(),e.stopPropagation(),a();return}e.key===`Enter`&&(e.preventDefault(),e.stopPropagation(),s())}})})}function zl({copy:e,item:t,viewState:n}){let{directoryDotClassName:r,directoryDotTitleKind:i,fileChangedClassName:a,fileChangedTitleKind:o,fileOpening:s,isDirectory:c,showDirectoryDot:l,visibleGitStatus:u,visibleGitStatusClassName:d,visibleGitStatusLabel:f}=n;return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`span`,{className:`code-file-name`,children:t.displayName??t.name}),t.symbolicLink&&(0,H.jsx)(`span`,{className:`code-file-symbolic-link`,"aria-hidden":`true`,children:`↷`}),s&&(0,H.jsx)(`span`,{className:`code-file-open-spinner`,title:e.loading,"aria-hidden":`true`}),!s&&l&&(0,H.jsx)(`span`,{className:r,title:Ve(i,e)}),!s&&!c&&f&&(0,H.jsx)(`span`,{className:d,title:e.gitStatus(u||``),children:f}),!s&&!c&&!f&&a&&(0,H.jsx)(`span`,{className:a,title:Ve(o,e)})]})}function Bl(e){e?.focus({preventScroll:!0})}function Vl({isDirectory:e,item:t,lastFocusedFilePathRef:n,node:r,treeViewportRef:i,onCancelPendingFileFocus:a,onFocusFileTreeTarget:o,onOpenFileContextMenu:s,onOpenFilePath:c,onToggleDirectory:l}){let u=(0,V.useCallback)(()=>{Bl(i.current?.querySelector(`[role="tree"]`))},[i]),d=(0,V.useCallback)(e=>{e.preventDefault(),e.stopPropagation(),a(),n.current=t.path,r.select(),s(e.clientX,e.clientY,t)},[t,n,r,a,s]),f=(0,V.useCallback)(n=>{e||n.button!==0||n.metaKey||n.ctrlKey||n.shiftKey||c(t.path,{transient:!0})},[e,t.path,c]);return{handleRowClick:(0,V.useCallback)(s=>{a(),n.current=t.path;let d=Dl({nodeType:t.type,metaKey:s.metaKey,ctrlKey:s.ctrlKey,shiftKey:s.shiftKey}),f=e?Fl(i.current?.closest(`.code-project-list`)):null;if(d===`toggle-directory`){s.preventDefault(),s.stopPropagation();let e=l(t.path);r.select(),r.focus(),u(),e?r.open():r.close(),o(t),f?.();return}if(d===`open-file`&&s.detail===0&&c(t.path,{transient:!0}),r.handleClick(s),r.focus(),u(),s.shiftKey){Bl(s.currentTarget),f?.();return}o(t),f?.()},[u,e,t,n,r,a,o,c,l,i]),handleRowContextMenu:d,handleRowMouseDown:f}}function Hl({activeFilePath:e,agentId:t,copy:n,editorDirtyFilePaths:r,editorExternalChangedFilePaths:i,fileOperation:a,fileOperationInputRef:o,lastFocusedFilePathRef:s,locatedFilePath:c,node:l,openFilePendingPath:u,treeViewportRef:d,onCancelPendingFileFocus:f,onCloseFileOperation:p,onFocusFileTreeTarget:m,onOpenFileContextMenu:h,onOpenFilePath:g,onRememberFileOperationName:_,onToggleDirectory:v,onSubmitFileOperation:y}){let b=l.data,x=Ke({activeFilePath:e,editorDirtyFilePaths:r,editorExternalChangedFilePaths:i,openFilePendingPath:u,item:b,isFocused:l.isFocused,isOpen:l.isOpen,isSelected:l.isSelected}),{chevronState:S,isDirectory:C}=x,w=`${x.rowClasses} ${c===b.path?`located`:``}`.trim(),T=C?``:R(b.path),E=a?.kind===`rename`&&a.item?.path===b.path?a:null,{handleRowClick:D,handleRowContextMenu:O,handleRowMouseDown:k}=Vl({isDirectory:C,item:b,lastFocusedFilePathRef:s,node:l,treeViewportRef:d,onCancelPendingFileFocus:f,onFocusFileTreeTarget:m,onOpenFileContextMenu:h,onOpenFilePath:g,onToggleDirectory:v});return(0,H.jsxs)(`div`,{className:w,style:He(l.level),"data-testid":`code-file-row`,"data-file-path":b.path,"data-file-type":b.type,"data-tree-level":l.level,"aria-label":b.path,title:b.linkTarget?`${b.path} ↷ ${b.linkTarget}`:b.linkError?`${b.path} (${b.linkError})`:void 0,tabIndex:-1,"aria-expanded":C?l.isOpen:void 0,onContextMenu:O,onMouseDown:k,onClick:D,children:[(0,H.jsx)(`span`,{className:`code-file-chevron ${S}`,"aria-hidden":`true`,children:S===`expanded`?(0,H.jsx)(z,{}):S===`collapsed`?(0,H.jsx)(B,{}):null}),!C&&(0,H.jsx)(`img`,{className:`code-file-type-icon file`,src:T,alt:``,"aria-hidden":`true`}),E?(0,H.jsx)(Rl,{agentId:t,copy:n,fileOperation:E,inputRef:o,item:b,onCancel:p,onInputName:_,onSubmit:y}):(0,H.jsx)(zl,{copy:n,item:b,viewState:x})]})}function Ul({activeFilePath:e,agentId:t,copy:n,editorDirtyFilePaths:r,editorExternalChangedFilePaths:i,fileOperation:a,fileOperationInputRef:o,handleTreeKeyDownCapture:s,lastFocusedFilePathRef:c,locatedFilePath:l,openFilePendingPath:u,renderFileTreeRow:d,rowHeight:f,stickyContextItems:p,treeData:m,treeHeight:h,treeRef:g,treeViewportRef:_,visibleTreeRowCount:v,onCancelPendingFileFocus:y,onCloseFileOperation:b,onFocusFileTreeTarget:x,onFocusStickyDirectory:S,onOpenFileContextMenu:C,onOpenFilePath:w,onRememberFileOperationName:T,onToggleDirectory:E,onSubmitFileOperation:D,onToggleTreeNode:O,onTreeFocus:k,onTreeSelect:A,onUpdateFileOperationName:j}){let M=(0,V.useCallback)(e=>{e.target?.closest(`[data-file-path]`)||(e.preventDefault(),y(),C(e.clientX,e.clientY,null))},[y,C]),N=(0,V.useCallback)(({node:s})=>(0,H.jsx)(Hl,{activeFilePath:e,agentId:t,copy:n,editorDirtyFilePaths:r,editorExternalChangedFilePaths:i,fileOperation:a,fileOperationInputRef:o,lastFocusedFilePathRef:c,locatedFilePath:l,node:s,openFilePendingPath:u,treeViewportRef:_,onCancelPendingFileFocus:y,onCloseFileOperation:b,onFocusFileTreeTarget:x,onOpenFileContextMenu:C,onOpenFilePath:w,onRememberFileOperationName:T,onToggleDirectory:E,onSubmitFileOperation:D,onUpdateFileOperationName:j}),[e,t,n,r,i,a,o,c,l,y,b,x,C,w,T,D,E,j,u,_]);return(0,H.jsxs)(`div`,{className:`code-file-tree-viewport`,ref:_,"data-visible-row-count":v,style:{height:h},onKeyDownCapture:s,onContextMenu:M,children:[(0,H.jsx)(Ll,{copy:n,items:p,onFocusDirectory:S}),(0,H.jsx)(pl,{ref:g,data:m,idAccessor:`id`,childrenAccessor:`children`,rowHeight:f,indent:0,height:h,width:`100%`,overscanCount:v,openByDefault:!1,selectionFollowsFocus:!0,className:`code-file-tree`,rowClassName:`code-file-tree-row`,renderRow:d,onToggle:O,onFocus:k,onSelect:A,disableDrag:!0,disableEdit:!0,disableDrop:!0,children:N})]})}function Wl({copy:e,agentLaunchOptions:t,fileMenu:n,fileMenuRef:r,openFileError:i,rootDirectoryError:a,rootDirectoryHasItems:o,rootDirectoryLoading:s,search:c,searchActions:l,tree:u,onCloseFileMenu:d,onCloseFileMenuWithFocusRestore:f,onCopyFileMenuPath:p,onCopyFileMenuShareUrl:m,onOpenNewAgentFromFileMenu:h,onRefreshFileMenuTarget:g,onStartAgentFromFileMenu:_,onStartFileMenuOperation:v,readOnly:y=!1}){return(0,H.jsxs)(H.Fragment,{children:[s&&!o&&(0,H.jsx)(`div`,{className:`code-file-status`,style:He(0),children:e.loading}),a&&(0,H.jsx)(`div`,{className:`code-file-status error`,style:He(0),children:a}),i&&!c.active&&(0,H.jsx)(`div`,{className:`code-file-status error`,"data-testid":`code-file-open-error`,style:He(0),children:i}),c.active&&(0,H.jsx)(ze,{activeMatchIndex:c.activeMatchIndex,anchorRef:c.anchorRef,containerRef:c.resultsRef,copy:e,error:c.error,jumpTarget:c.jumpTarget,listboxId:c.listboxId,loading:c.loading,matches:c.matches,openFileError:i,query:c.query,showIgnoredSearch:!c.includeIgnored,timeoutMs:c.timeoutMs,truncated:c.truncated,onOpenJumpQuery:l.onOpenJumpQuery,onOpenMatch:l.onOpenMatch,onSearchIgnored:l.onSearchIgnored,onSelectMatchIndex:l.onSelectMatchIndex}),(0,H.jsx)(Ul,{...u,copy:e}),(0,H.jsx)(st,{agentId:u.agentId,copy:e,agentLaunchOptions:t,fileMenu:n,fileOperation:u.fileOperation,fileMenuRef:r,fileOperationInputRef:u.fileOperationInputRef,onCloseFileMenu:d,onCloseFileMenuWithFocusRestore:f,onCloseFileOperation:u.onCloseFileOperation,onCopyFileMenuPath:p,onCopyFileMenuShareUrl:m,onOpenNewAgent:h,onRefreshFileMenuTarget:g,onRememberFileOperationName:u.onRememberFileOperationName,onStartAgent:_,onStartFileMenuOperation:v,onSubmitFileOperation:u.onSubmitFileOperation,onUpdateFileOperationName:u.onUpdateFileOperationName,readOnly:y})]})}function Gl({copy:e,filesCollapsed:t,refreshStatus:n,search:r,onCancelPendingFileFocus:i,onFileSearchKeyDown:a,onSearchQueryChange:o,onRefreshFiles:s,onToggleFilesCollapsed:c}){let l=n===`refreshing`?e.refreshingFiles:n===`success`?e.filesRefreshed:n===`error`?e.filesRefreshFailed:e.refreshFiles;return(0,H.jsxs)(`div`,{className:`code-files-header ${t?`collapsed`:``}`,children:[(0,H.jsxs)(`div`,{className:`code-files-heading`,children:[(0,H.jsxs)(`button`,{type:`button`,className:`code-files-title`,"aria-expanded":!t,onClick:c,children:[(0,H.jsx)(`span`,{className:`code-file-section-chevron ${t?`collapsed`:`expanded`}`,"aria-hidden":`true`,children:t?(0,H.jsx)(B,{}):(0,H.jsx)(z,{})}),(0,H.jsx)(`span`,{children:e.files})]}),(0,H.jsx)(`button`,{type:`button`,className:`code-files-refresh`,"data-testid":`code-files-refresh`,"data-refresh-status":n,title:l,"aria-label":l,"aria-busy":n===`refreshing`,disabled:n===`refreshing`,onClick:s,children:(0,H.jsx)(`span`,{className:`code-files-refresh-glyph`,"aria-hidden":`true`,children:n===`success`?(0,H.jsx)(de,{}):n===`error`?(0,H.jsx)(ue,{}):`↻`})}),(0,H.jsx)(`span`,{className:`code-visually-hidden`,role:`status`,"aria-live":`polite`,children:n===`idle`?``:l})]}),!t&&(0,H.jsxs)(`label`,{className:`code-file-search-box`,children:[(0,H.jsx)(`span`,{className:`code-file-search-icon`,"aria-hidden":`true`}),(0,H.jsx)(`input`,{ref:r.inputRef,type:`search`,name:`farming-file-search`,inputMode:`search`,autoComplete:`off`,autoCorrect:`off`,autoCapitalize:`none`,spellCheck:!1,enterKeyHint:`search`,"data-lpignore":`true`,"data-1p-ignore":`true`,"data-bwignore":`true`,"data-form-type":`other`,value:r.query,onChange:e=>{i(),o(e.target.value)},onFocus:i,onPointerDown:e=>{i(),L()&&(e.preventDefault(),e.currentTarget.focus({preventScroll:!0}))},onMouseDown:i,onKeyDownCapture:a,placeholder:e.searchOrPathLine,"aria-label":e.searchFilesOrJump,"aria-autocomplete":`list`,"aria-controls":r.active?r.listboxId:void 0,"aria-expanded":r.active,"aria-activedescendant":r.activeOptionId,role:`combobox`})]})]})}var Kl=o(),ql=[`#ffb000`,`#dc267f`,`#994f00`,`#40b0a6`,`#b66dff`],Jl=`#2188ff`;function Yl(e){return{...e}}function Xl(e,t){for(let n of e.references??[]){let e=t.get(n.id);if(e!==void 0)return e}}function Zl(e,t,n=new Map){let r=-1,i=[];for(let a of e){let o=a.id===t?`HEAD`:`node`,s=(i[i.length-1]?.outputSwimlanes??[]).map(Yl),c=[],l=!1;if(a.parentIds.length>0)for(let e of s){if(e.id===a.id){l||=(c.push({id:a.parentIds[0],color:Xl(a,n)??e.color}),!0);continue}c.push(Yl(e))}for(let t=+!!l;t<a.parentIds.length;t+=1){let i;if(t===0)i=Xl(a,n);else{let r=e.find(e=>e.id===a.parentIds[t]);i=r?Xl(r,n):void 0}i||=(r=(r+1)%ql.length,ql[r]),c.push({id:a.parentIds[t],color:i})}i.push({historyItem:a,kind:o,inputSwimlanes:s,outputSwimlanes:c})}return i}var Ql=5,$l=4,eu=2,tu=`http://www.w3.org/2000/svg`;function nu(e,t=1){let n=document.createElementNS(tu,`path`);return n.setAttribute(`fill`,`none`),n.setAttribute(`stroke`,e),n.setAttribute(`stroke-width`,String(t)),n.setAttribute(`stroke-linecap`,`round`),n}function ru(e,t,n,r,i=!1){let a=document.createElementNS(tu,`circle`);return a.setAttribute(`cx`,String(11*(e+1))),a.setAttribute(`cy`,`11`),a.setAttribute(`r`,String(t)),a.setAttribute(`stroke`,r),a.setAttribute(`stroke-width`,String(n)),a.setAttribute(`fill`,i?r:`var(--code-git-history-node-bg, #f6f7f3)`),a}function iu(e,t,n,r,i=1){let a=nu(r,i);return a.setAttribute(`d`,`M ${e} ${t} V ${n}`),a}function au(e,t){for(let n=e.length-1;n>=0;--n)if(e[n].id===t)return n;return-1}function ou(e){let t=document.createElementNS(tu,`svg`);t.classList.add(`code-git-history-graph-svg`),t.setAttribute(`aria-hidden`,`true`),t.setAttribute(`focusable`,`false`);let{historyItem:n,inputSwimlanes:r,outputSwimlanes:i}=e,a=r.findIndex(e=>e.id===n.id),o=a===-1?r.length:a,s=o<i.length?i[o].color:o<r.length?r[o].color:Jl,c=0;for(let e=0;e<r.length;e+=1){let a=r[e],s=a.color;if(a.id===n.id){if(e!==o){let n=nu(s);n.setAttribute(`d`,[`M ${11*(e+1)} 0`,`A 11 11 0 0 1 ${11*e} 11`,`H ${11*(o+1)}`].join(` `)),t.append(n)}else c+=1;continue}if(c<i.length&&a.id===i[c].id){if(e===c)t.append(iu(11*(e+1),0,22,s));else{let n=nu(s);n.setAttribute(`d`,[`M ${11*(e+1)} 0`,`V 6`,`A ${Ql} ${Ql} 0 0 1 ${11*(e+1)-Ql} ${22/2}`,`H ${11*(c+1)+Ql}`,`A ${Ql} ${Ql} 0 0 0 ${11*(c+1)} ${22/2+Ql}`,`V 22`].join(` `)),t.append(n)}c+=1}}for(let e=1;e<n.parentIds.length;e+=1){let r=au(i,n.parentIds[e]);if(r===-1)continue;let a=nu(i[r].color);a.setAttribute(`d`,[`M ${11*r} ${22/2}`,`A 11 11 0 0 1 ${11*(r+1)} 22`,`M ${11*r} ${22/2}`,`H ${11*(o+1)}`].join(` `)),t.append(a)}a!==-1&&t.append(iu(11*(o+1),0,22/2,r[a].color)),n.parentIds.length>0&&t.append(iu(11*(o+1),22/2,22,s)),e.kind===`HEAD`?(t.append(ru(o,$l+3,eu,s)),t.append(ru(o,eu,1,s,!0))):n.parentIds.length>1?(t.append(ru(o,$l+2,eu,s)),t.append(ru(o,$l-1,eu,s))):t.append(ru(o,$l+1,eu,s));let l=11*(Math.max(r.length,i.length,1)+1);return t.setAttribute(`width`,String(l)),t.setAttribute(`height`,`22`),t.setAttribute(`viewBox`,`0 0 ${l} 22`),t}function su(e,t=22){let n=document.createElementNS(tu,`svg`);n.classList.add(`code-git-history-graph-placeholder-svg`),n.setAttribute(`aria-hidden`,`true`),n.setAttribute(`focusable`,`false`);for(let r=0;r<e.length;r+=1)n.append(iu(11*(r+1),0,t,e[r].color));let r=11*(Math.max(e.length,1)+1);return n.setAttribute(`width`,String(r)),n.setAttribute(`height`,String(t)),n.setAttribute(`viewBox`,`0 0 ${r} ${t}`),n}var cu=(0,V.memo)(function({viewModel:e}){let t=(0,V.useRef)(null);return(0,V.useLayoutEffect)(()=>{let n=t.current;n&&n.replaceChildren(ou(e))},[e]),(0,H.jsx)(`span`,{ref:t,className:`code-git-history-graph`,"aria-hidden":`true`})}),lu=(0,V.memo)(function({columns:e}){let t=(0,V.useRef)(null);return(0,V.useLayoutEffect)(()=>{let n=t.current;if(!n)return;let r=()=>{let t=Math.max(22,Math.round(n.getBoundingClientRect().height));n.replaceChildren(su(e,t))};if(r(),typeof ResizeObserver>`u`)return;let i=new ResizeObserver(r);return i.observe(n),()=>i.disconnect()},[e]),(0,H.jsx)(`span`,{ref:t,className:`code-git-history-graph-placeholder`,"aria-hidden":`true`})}),uu=50,du=20;function fu(e){if(!e)return``;let t=new Date(e);if(!Number.isFinite(t.getTime()))return``;let n=e=>String(e).padStart(2,`0`);return`${t.getFullYear()}-${n(t.getMonth()+1)}-${n(t.getDate())} ${n(t.getHours())}:${n(t.getMinutes())}`}function pu(e,t){let n=new Set(e.map(e=>e.id));return[...e,...t.filter(e=>!n.has(e.id))]}function mu(e){return e.previousPath?`${e.previousPath} → ${e.path}`:e.path}function hu(e){let t=e.message.trim();return!t||t===e.subject?``:t.startsWith(e.subject)?t.slice(e.subject.length).trim():t}function gu({agentId:e,copy:t,projectId:n,projectWorkspace:r}){let[a,o]=(0,V.useState)(!0),[s,c]=(0,V.useState)(null),[l,u]=(0,V.useState)(`current`),[d,f]=(0,V.useState)(!1),[p,m]=(0,V.useState)(``),[h,g]=(0,V.useState)(``),[_,v]=(0,V.useState)(``),[y,b]=(0,V.useState)(null),[x,S]=(0,V.useState)(!1),[C,w]=(0,V.useState)(``),[T,E]=(0,V.useState)(null),D=(0,V.useRef)(null),O=(0,V.useRef)(null),k=(0,V.useRef)(new Map),A=(0,V.useRef)(null),j=(0,V.useRef)(null),M=(0,V.useCallback)(()=>{O.current?.abort(),O.current=null,g(``),v(``),b(null),S(!1),w(``),E(null)},[]);(0,V.useEffect)(()=>(D.current?.abort(),O.current?.abort(),D.current=null,O.current=null,k.current.clear(),o(!0),c(null),u(`current`),f(!1),m(``),g(``),v(``),b(null),S(!1),w(``),()=>{D.current?.abort(),O.current?.abort()}),[e,n]),(0,V.useEffect)(()=>{if(!T)return;let e=e=>{let t=e.target;t&&(A.current?.contains(t)||j.current?.contains(t))||E(null)},t=e=>{e.key===`Escape`&&(e.preventDefault(),E(null),A.current?.focus())};return window.addEventListener(`pointerdown`,e,!0),window.addEventListener(`keydown`,t,!0),()=>{window.removeEventListener(`pointerdown`,e,!0),window.removeEventListener(`keydown`,t,!0)}},[T]);let N=(0,V.useCallback)(async(t,n,r=l)=>{D.current?.abort();let i=new AbortController;D.current=i,f(!0),m(``);try{let a=await ie(e,{limit:uu,skip:t,scope:r,signal:i.signal});if(i.signal.aborted)return;c(e=>n||!e?a:{...a,items:pu(e.items,a.items)})}catch(e){if(i.signal.aborted)return;m(e instanceof Error?e.message:`Git history request failed`)}finally{D.current===i&&(D.current=null,f(!1))}},[e,l]),ee=(0,V.useCallback)(async(t,n)=>{let r=`${t.id}:${n||`root`}`,i=k.current.get(r);if(O.current?.abort(),i){b(i),S(!1),w(``);return}let a=new AbortController;O.current=a,b(null),S(!0),w(``);try{let i=await F(e,t.id,{parent:n||void 0,signal:a.signal});if(a.signal.aborted)return;if(k.current.set(r,i),k.current.size>du){let e=k.current.keys().next().value;e&&k.current.delete(e)}b(i)}catch(e){if(a.signal.aborted)return;w(e instanceof Error?e.message:`Commit changes request failed`)}finally{O.current===a&&(O.current=null,S(!1))}},[e]),P=()=>{o(e=>(e&&!s&&!d&&N(0,!0),!e))},te=()=>{k.current.clear(),M(),N(0,!0)},ne=e=>{E(null),e!==l&&(u(e),c(null),k.current.clear(),M(),N(0,!0,e))},re=()=>{E(e=>{if(e)return null;let t=A.current?.getBoundingClientRect();return t?{x:Math.max(8,Math.min(window.innerWidth-132-8,t.right-132)),y:t.bottom+66+8<=window.innerHeight?t.bottom+3:Math.max(8,t.top-66-3)}:null})},I=e=>{if(h===e.id){M();return}let t=e.parentIds[0]||``;g(e.id),v(t),ee(e,t)},ae=(e,t)=>{v(t),ee(e,t)},L=(e,t,n)=>{if(!t)return;let a=new URLSearchParams({root:r,base:t,head:e.id});n&&a.append(`path`,n),window.open(i(`/review?${a.toString()}`),`_blank`,`noopener,noreferrer`)},oe=(0,V.useMemo)(()=>Zl(s?.items??[],s?.head),[s?.head,s?.items]);return(0,H.jsxs)(`section`,{className:`code-git-history-section ${a?`collapsed`:``}`,"data-testid":`code-git-history-section`,"data-project-id":n,"aria-label":t.gitHistory,children:[(0,H.jsxs)(`div`,{className:`code-git-history-header`,children:[(0,H.jsxs)(`button`,{type:`button`,className:`code-git-history-title`,"aria-expanded":!a,onClick:P,children:[(0,H.jsx)(`span`,{className:`code-file-section-chevron ${a?`collapsed`:`expanded`}`,"aria-hidden":`true`,children:a?(0,H.jsx)(B,{}):(0,H.jsx)(z,{})}),(0,H.jsx)(`span`,{children:t.gitHistory})]}),!a&&(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(`button`,{ref:A,type:`button`,className:`code-git-history-scope`,"aria-label":t.gitHistoryView,title:t.gitHistoryView,"aria-haspopup":`menu`,"aria-expanded":T?!0:void 0,disabled:d,onClick:re,children:[(0,H.jsx)(`span`,{children:l===`current`?t.gitHistoryCurrentScope:t.gitHistoryAllScope}),(0,H.jsx)(z,{"aria-hidden":`true`})]}),T&&typeof document<`u`&&(0,Kl.createPortal)((0,H.jsx)(`div`,{ref:j,className:`code-git-history-scope-menu`,"data-testid":`code-git-history-scope-menu`,role:`menu`,"aria-label":t.gitHistoryView,style:{left:T.x,top:T.y},children:[[`current`,t.gitHistoryCurrentBranch],[`all`,t.gitHistoryAllBranches]].map(([e,t])=>(0,H.jsxs)(`button`,{type:`button`,role:`menuitemradio`,"aria-checked":l===e,onClick:()=>ne(e),children:[(0,H.jsx)(`span`,{className:`code-git-history-scope-check`,"aria-hidden":`true`,children:l===e&&(0,H.jsx)(de,{})}),(0,H.jsx)(`span`,{children:t})]},e))}),document.body),(0,H.jsx)(`button`,{type:`button`,className:`code-git-history-refresh ${d?`loading`:``}`,title:t.refresh,"aria-label":t.refresh,disabled:d,onClick:te,children:`↻`})]})]}),!a&&(0,H.jsxs)(`div`,{className:`code-git-history-body`,children:[d&&!s&&(0,H.jsx)(`div`,{className:`code-git-history-status`,children:t.loading}),p&&(0,H.jsx)(`div`,{className:`code-git-history-status error`,children:p}),s&&!s.isGitRepo&&(0,H.jsx)(`div`,{className:`code-git-history-status`,children:t.gitHistoryNotRepository}),s?.isGitRepo&&s.items.length===0&&!d&&(0,H.jsx)(`div`,{className:`code-git-history-status`,children:t.gitHistoryEmpty}),oe.map(e=>{let n=e.historyItem,r=h===n.id,i=fu(n.timestamp),a=hu(n),o=n.references.filter(e=>e.category!==`head`&&!(l===`current`&&s?.branch&&e.name===s.branch));return(0,H.jsxs)(`div`,{className:`code-git-history-entry ${r?`selected`:``}`,"data-testid":`code-git-history-entry`,"data-commit-id":n.id,children:[(0,H.jsxs)(`button`,{type:`button`,className:`code-git-history-commit`,"aria-expanded":r,title:`${n.message||n.subject}\n${n.id}\n${n.author}${i?` · ${i}`:``}`,onClick:()=>I(n),children:[(0,H.jsx)(cu,{viewModel:e}),(0,H.jsxs)(`span`,{className:`code-git-history-commit-content`,children:[(0,H.jsx)(`span`,{className:`code-git-history-subject`,children:n.subject||n.displayId}),(0,H.jsxs)(`span`,{className:`code-git-history-footer`,children:[(0,H.jsxs)(`span`,{className:`code-git-history-meta`,children:[(0,H.jsx)(`span`,{className:`code-git-history-hash`,children:n.displayId}),n.author&&(0,H.jsx)(`span`,{children:n.author}),i&&n.timestamp!==void 0&&(0,H.jsx)(`time`,{dateTime:new Date(n.timestamp).toISOString(),children:i})]}),o.length>0&&(0,H.jsxs)(`span`,{className:`code-git-history-references`,"aria-label":o.map(e=>e.name).join(`, `),children:[o.slice(0,1).map(e=>(0,H.jsx)(`span`,{className:`code-git-history-reference ${e.category}`,title:e.name,children:e.name},e.id)),o.length>1&&(0,H.jsxs)(`span`,{className:`code-git-history-reference-more`,children:[`+`,o.length-1]})]})]})]})]}),r&&(0,H.jsxs)(`div`,{className:`code-git-history-details`,"data-testid":`code-git-history-details`,children:[(0,H.jsx)(lu,{columns:e.outputSwimlanes}),(0,H.jsxs)(`div`,{className:`code-git-history-details-content`,children:[(n.parentIds.length>1||n.parentIds.length===0)&&(0,H.jsx)(`div`,{className:`code-git-history-details-header`,children:n.parentIds.length>1?(0,H.jsxs)(`label`,{className:`code-git-history-parent-select`,children:[(0,H.jsx)(`span`,{children:t.gitHistoryParent}),(0,H.jsx)(`select`,{value:_,onChange:e=>ae(n,e.target.value),children:n.parentIds.map((e,t)=>(0,H.jsxs)(`option`,{value:e,children:[t+1,`: `,e.slice(0,8)]},e))})]}):(0,H.jsx)(`span`,{className:`code-git-history-root-label`,children:t.gitHistoryRootCommit})}),a&&(0,H.jsxs)(`div`,{className:`code-git-history-message`,children:[(0,H.jsx)(`span`,{className:`code-git-history-message-label`,children:t.gitHistoryCommitMessage}),(0,H.jsx)(`span`,{className:`code-git-history-message-body`,children:a})]}),x&&(0,H.jsx)(`div`,{className:`code-git-history-status compact`,children:t.loading}),C&&(0,H.jsx)(`div`,{className:`code-git-history-status compact error`,children:C}),y&&(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(`div`,{className:`code-git-history-change-summary-row`,children:[(0,H.jsx)(`span`,{className:`code-git-history-change-summary`,children:t.gitHistoryCommitChanges(y.items.length)}),y.comparisonBase&&(0,H.jsxs)(`button`,{type:`button`,className:`code-git-history-review`,"aria-label":t.gitHistoryReviewCommit,title:t.gitHistoryReviewCommit,onClick:()=>L(n,y.comparisonBase),children:[(0,H.jsx)(`span`,{children:t.reviewChanges}),(0,H.jsx)(fe,{})]})]}),y.items.length===0&&(0,H.jsx)(`div`,{className:`code-git-history-status compact`,children:t.gitHistoryNoChanges}),(0,H.jsx)(`div`,{className:`code-git-history-change-list`,children:y.items.map(e=>y.comparisonBase?(0,H.jsxs)(`button`,{type:`button`,className:`code-git-history-change`,title:mu(e),onClick:()=>L(n,y.comparisonBase,e.path),children:[(0,H.jsx)(`img`,{src:R(e.path),alt:``,"aria-hidden":`true`}),(0,H.jsx)(`span`,{className:`code-git-history-change-path`,children:e.path}),e.previousPath&&(0,H.jsxs)(`span`,{className:`code-git-history-change-previous`,children:[`← `,e.previousPath]}),(0,H.jsx)(`span`,{className:`code-git-history-change-status ${e.status}`,children:e.statusLabel})]},`${e.status}:${e.path}`):(0,H.jsxs)(`div`,{className:`code-git-history-change static`,title:mu(e),children:[(0,H.jsx)(`img`,{src:R(e.path),alt:``,"aria-hidden":`true`}),(0,H.jsx)(`span`,{className:`code-git-history-change-path`,children:e.path}),(0,H.jsx)(`span`,{className:`code-git-history-change-status ${e.status}`,children:e.statusLabel})]},`${e.status}:${e.path}`))}),y.truncated&&(0,H.jsx)(`div`,{className:`code-git-history-status compact`,children:t.gitHistoryChangesTruncated})]})]})]})]},n.id)}),s?.hasMore&&(0,H.jsx)(`button`,{type:`button`,className:`code-git-history-load-more`,disabled:d||s.nextSkip===null,onClick:()=>{s.nextSkip!==null&&N(s.nextSkip,!1)},children:d?t.loading:t.gitHistoryLoadMore})]})]})}function _u(e){return e.split(`/`).filter(Boolean).pop()||e}function vu({activeFilePath:e,collapsed:t,copy:n,files:r,projectId:i,onCloseOpenFile:a,onOpenFileContextMenu:o,onSelectOpenFile:s,onToggleCollapsed:c}){let l=(0,V.useRef)(null),u=(0,V.useRef)(null),d=Math.min(r.length,7),f=(0,V.useMemo)(()=>({"--code-open-editors-visible-rows":d,"--code-open-editors-list-max-height":`${d*28}px`}),[d]);return(0,V.useEffect)(()=>{if(t)return;let e=l.current,n=u.current;if(!e||!n)return;let r=n.offsetTop,i=r+n.offsetHeight;r<e.scrollTop?e.scrollTop=r:i>e.scrollTop+e.clientHeight&&(e.scrollTop=i-e.clientHeight)},[e,t,r.length]),r.length===0?null:(0,H.jsxs)(`div`,{className:`code-open-editors ${t?`collapsed`:``}`,"data-testid":`code-open-editors`,"data-project-id":i,"data-open-editor-count":r.length,"data-visible-editor-count":d,style:f,children:[(0,H.jsx)(`div`,{className:`code-open-editors-header`,children:(0,H.jsxs)(`button`,{type:`button`,className:`code-open-editors-title`,"aria-expanded":!t,onClick:c,children:[(0,H.jsx)(`span`,{className:`code-file-section-chevron ${t?`collapsed`:`expanded`}`,"aria-hidden":`true`,children:t?(0,H.jsx)(B,{}):(0,H.jsx)(z,{})}),(0,H.jsx)(`span`,{children:n.openEditors})]})}),!t&&(0,H.jsx)(`div`,{ref:l,className:`code-open-editors-list`,children:r.map(t=>{let r=e===t.path,i=pe(t);return(0,H.jsxs)(`div`,{ref:r?u:void 0,className:`code-open-editor-row ${r?`active`:``}`,"data-testid":`code-open-editor-row`,"data-file-path":t.path,title:t.path,onContextMenu:e=>{o&&(e.preventDefault(),o(e.clientX,e.clientY,t))},children:[(0,H.jsxs)(`button`,{type:`button`,className:`code-open-editor-main`,onClick:()=>s?.(t.agentId,t.path),children:[(0,H.jsx)(`img`,{className:`code-file-type-icon file`,src:R(t.path),alt:``,"aria-hidden":`true`}),(0,H.jsx)(`span`,{className:`code-open-editor-name`,children:_u(t.path)}),(0,H.jsx)(`span`,{className:`code-open-editor-path`,children:w(t.path)}),i&&(0,H.jsx)(`span`,{className:`code-open-editor-state ${i}`,title:i===`external`?n.changedOnDisk:n.unsavedChanges})]}),a&&(0,H.jsx)(`button`,{type:`button`,className:`code-open-editor-close`,"aria-label":n.closeFile(t.path),title:n.closeFile(t.path),onClick:()=>a(t.agentId,t.path,t.workspaceRoot)})]},t.key)})})]})}function yu({activeFilePath:e,activeSearchOptionId:t,agentId:n,agentLaunchOptions:r,copy:i,editorDirtyFilePaths:a,editorExternalChangedFilePaths:o,fileMenu:s,fileMenuRef:c,fileOperation:l,fileOperationInputRef:u,fileSearch:d,fileSearchInputRef:f,fileSearchListboxId:p,fileSearchResultsRef:m,filesCollapsed:h,handleFileSearchKeyDown:g,handleTreeKeyDownCapture:_,lastFocusedFilePathRef:v,locatedFilePath:y,openEditorsCollapsed:b,openFileError:x,openFilePendingPath:S,projectId:C,renderFileTreeRow:w,rootDirectoryError:T,rootDirectoryHasItems:E,rootDirectoryLoading:D,rowHeight:O,readOnly:k=!1,stickyContextItems:A,treeData:j,treeHeight:M,treeRef:N,treeViewportRef:ee,visibleTreeRowCount:P,onCancelPendingFileFocus:te,onCloseFileMenuWithFocusRestore:ne,onCloseFileMenuWithoutFocus:re,onCloseFileOperation:ie,onCloseOpenFile:F,onCopyFileMenuPath:I,onCopyFileMenuShareUrl:ae,onFocusFileTreeTarget:L,onFocusStickyDirectory:R,onOpenFileContextMenu:oe,onOpenFileJumpQuery:se,onOpenFilePath:ce,onOpenFileSearchMatch:le,onOpenNewAgentFromFileMenu:ue,onRefreshFileMenuTarget:z,onRememberFileOperationName:de,onSearchQueryChange:B,onSelectOpenFile:fe,onSelectSearchMatchIndex:pe,onToggleDirectory:me,onStartAgentFromFileMenu:H,onStartFileMenuOperation:he,onSubmitFileOperation:ge,onToggleFilesCollapsed:_e,onToggleOpenEditorsCollapsed:ve,onToggleTreeNode:ye,onTreeFocus:be,onTreeSelect:xe,onUpdateFileOperationName:Se}){let Ce=(0,V.useMemo)(()=>({active:d.active,activeOptionId:t,inputRef:f,listboxId:p,query:d.query}),[t,d.active,d.query,f,p]),we=(0,V.useMemo)(()=>({active:d.active,activeMatchIndex:d.activeMatchIndex,anchorRef:f,error:d.error,includeIgnored:d.includeIgnored,jumpTarget:d.jumpTarget,listboxId:p,loading:d.loading,matches:d.matches,query:d.query,resultsRef:m,timeoutMs:d.timeoutMs,truncated:d.truncated}),[d.active,d.activeMatchIndex,d.error,d.includeIgnored,f,d.jumpTarget,d.loading,d.matches,d.query,d.timeoutMs,d.truncated,p,m]),Te=(0,V.useMemo)(()=>({onOpenJumpQuery:se,onOpenMatch:le,onSearchIgnored:d.searchIgnored,onSelectMatchIndex:pe}),[se,le,d.searchIgnored,pe]),Ee=(0,V.useMemo)(()=>({activeFilePath:e,agentId:n,editorDirtyFilePaths:a,editorExternalChangedFilePaths:o,fileOperation:l,fileOperationInputRef:u,handleTreeKeyDownCapture:_,lastFocusedFilePathRef:v,locatedFilePath:y,openFilePendingPath:S,renderFileTreeRow:w,rowHeight:O,stickyContextItems:A,treeData:j,treeHeight:M,treeRef:N,treeViewportRef:ee,visibleTreeRowCount:P,onCancelPendingFileFocus:te,onCloseFileOperation:ie,onFocusFileTreeTarget:L,onFocusStickyDirectory:R,onOpenFileContextMenu:oe,onOpenFilePath:ce,onRememberFileOperationName:de,onToggleDirectory:me,onSubmitFileOperation:ge,onToggleTreeNode:ye,onTreeFocus:be,onTreeSelect:xe,onUpdateFileOperationName:Se}),[e,n,a,o,l,u,_,v,y,S,w,O,A,j,M,N,ee,P,te,ie,L,R,oe,ce,de,me,ge,ye,be,xe,Se]);return{bodySearch:we,bodySearchActions:Te,bodyTree:Ee,fileMenu:s,fileMenuRef:c,filesCollapsed:h,headerSearch:Ce,openEditors:{activeFilePath:e,collapsed:b,copy:i,projectId:C,onCloseOpenFile:F,onSelectOpenFile:fe,onToggleCollapsed:ve},sectionBody:{copy:i,agentLaunchOptions:r,fileMenu:s,fileMenuRef:c,openFileError:x,rootDirectoryError:T,rootDirectoryHasItems:E,rootDirectoryLoading:D,search:we,searchActions:Te,tree:Ee,onCloseFileMenu:re,onCloseFileMenuWithFocusRestore:ne,onCopyFileMenuPath:I,onCopyFileMenuShareUrl:ae,onOpenNewAgentFromFileMenu:ue,onRefreshFileMenuTarget:z,onStartAgentFromFileMenu:H,onStartFileMenuOperation:he,readOnly:k},sectionHeader:{copy:i,filesCollapsed:h,search:Ce,onCancelPendingFileFocus:te,onFileSearchKeyDown:g,onSearchQueryChange:B,onToggleFilesCollapsed:_e}}}var bu=200,xu=15e3,Su={error:null,items:[],loaded:!1,loading:!1,truncated:!1};function Cu(e,t){let[n,r]=(0,V.useState)(Su),i=(0,V.useRef)(null),a=(0,V.useRef)(0),o=(0,V.useRef)(new Map),s=(0,V.useRef)(t),c=(0,V.useCallback)(()=>{if(!e)return i.current?.abort(),a.current+=1,r(Su),Promise.resolve(!0);i.current?.abort();let t=new AbortController,n=!1,o=window.setTimeout(()=>{n=!0,t.abort()},xu);i.current=t;let s=a.current+1;return a.current=s,r(e=>({...e,error:null,loading:!0})),re(e,{limit:bu,signal:t.signal}).then(e=>a.current===s?(r({error:null,items:e.items,loaded:!0,loading:!1,truncated:e.truncated}),!0):!1).catch(e=>(!n&&t.signal.aborted||a.current!==s||r(t=>({...t,error:n?`File refresh timed out`:e instanceof Error?e.message:`Failed to refresh changes`,loaded:!0,loading:!1})),!1)).finally(()=>window.clearTimeout(o))},[e]);return(0,V.useEffect)(()=>{s.current=t},[t]),(0,V.useEffect)(()=>{o.current=d(s.current),c()},[e,c]),(0,V.useEffect)(()=>{let e=o.current,n=d(t);o.current=n,l(e,n)&&c()},[e,t,c]),(0,V.useEffect)(()=>()=>{i.current?.abort()},[]),{...n,refreshChanges:c}}var wu=50,Tu=60,Eu=6e3,Du=80,Ou=100,ku=2;function Au(e){e?.focus({preventScroll:!0})}function ju(){let e=document.activeElement;return e instanceof Element&&!!e.closest(`.code-file-monaco, .monaco-editor`)}function Mu(e,t){let n=e.getBoundingClientRect(),r=t.closest(`.code-project-group`),i=t.closest(`.code-files-section`),a=[r?.querySelector(`.code-project-row`),r?.querySelector(`.code-agents-section`),r?.querySelector(`[data-testid="code-open-editors"]`),i?.querySelector(`.code-files-header`),i?.querySelector(`.code-file-sticky-stack`)].reduce((e,t)=>{if(!t)return e;let r=t.getBoundingClientRect();return r.height<=0||r.bottom<=n.top||r.top>=n.bottom?e:Math.max(e,r.bottom)},n.top);return{top:Math.min(a,n.bottom),bottom:n.bottom}}function Nu(e,t=!1){let n=e.closest(`.code-project-list`);if(!n)return;let r=Mu(n,e),i=e.getBoundingClientRect();n.scrollTop+=t?i.top-r.top-6:_l(r,i)}function Pu({treeRef:e,treeViewportRef:t,fileSearchInputRef:n,fileOperationActiveRef:r,lastFocusedFilePathRef:i,treeData:a,isDirectoryLoaded:o,loadMissingDirectories:s,openDirectoriesInLayout:c,refreshTreeLayout:l}){let u=(0,V.useRef)(null),d=(0,V.useRef)([]),f=(0,V.useRef)(null),p=(0,V.useRef)([]),h=(0,V.useRef)([]),g=(0,V.useRef)([]),_=(0,V.useRef)([]),v=(0,V.useRef)(0),[y,b]=(0,V.useState)(null),S=(0,V.useRef)(null),C=(0,V.useRef)(a),w=(0,V.useRef)(o);(0,V.useEffect)(()=>{C.current=a},[a]),(0,V.useEffect)(()=>{w.current=o},[o]);let T=(0,V.useCallback)(()=>{b(null),S.current!==null&&(window.clearTimeout(S.current),S.current=null)},[]),D=(0,V.useCallback)(e=>{document.body.classList.contains(`code-file-location-dismissed`)||(T(),b(e),S.current=window.setTimeout(T,Eu))},[T]),O=(0,V.useCallback)(()=>{u.current!==null&&(window.cancelAnimationFrame(u.current),u.current=null),d.current.forEach(e=>window.clearTimeout(e)),d.current=[]},[]),k=(0,V.useCallback)(()=>{f.current!==null&&(window.cancelAnimationFrame(f.current),f.current=null),p.current.forEach(e=>window.clearTimeout(e)),p.current=[]},[]),j=(0,V.useCallback)(()=>{h.current.forEach(e=>window.clearTimeout(e)),h.current=[]},[]),M=(0,V.useCallback)(()=>{v.current+=1,k(),j(),g.current.forEach(e=>window.cancelAnimationFrame(e)),g.current=[],_.current.forEach(e=>window.clearTimeout(e)),_.current=[]},[j,k]),N=(0,V.useCallback)(()=>{O(),M(),T()},[O,M,T]),ee=(0,V.useCallback)((i,a=!1,o=!1)=>{k(),j();let s=!1,c=()=>{let e=0,n=0,r=()=>{n+=1;let a=Array.from(t.current?.querySelectorAll(`[data-file-path]`)??[]).find(e=>e.dataset.filePath===i)??null;if(e=a?.classList.contains(`selected`)===!0?e+1:0,a&&e>=ku){h.current=[],D(i);return}n>=Ou||(h.current=[window.setTimeout(r,Du)])};r()},l=()=>{let e=n.current,s=vl({focusRow:a,operationActive:r.current,activeElementIsSearchInput:document.activeElement===e,searchInputValue:e?.value}),c=Array.from(t.current?.querySelectorAll(`[data-file-path]`)??[]).find(e=>e.dataset.filePath===i);c&&(c.scrollIntoView({block:`nearest`}),Nu(c,o),s&&Au(c.closest(`[role="tree"]`)))},u=()=>{let t=e.current;if(a&&!s){s=!0,t?.get(i)?.select();let e=t?.scrollTo(i,o?`start`:`smart`);e&&e.then(()=>{window.requestAnimationFrame(l)})}l()};u(),f.current=window.requestAnimationFrame(()=>{u(),f.current=window.requestAnimationFrame(u)}),hl.forEach(e=>{let t=window.setTimeout(u,e);p.current.push(t)}),o&&c()},[j,k,r,n,D,e,t]),P=(0,V.useCallback)((t,n=0,r=!1,i)=>{let a=i??v.current+1;i===void 0&&(v.current=a);let o=()=>v.current===a,s=e.current,u=C.current,d=E(u,t,r),f=A(u,t)??t,p=m(u,f),h=!!s;if(c(d),r&&(p?.type!==`directory`||!w.current(t))&&(h=!1),s&&(d.forEach(e=>{s.get(e)?s.open(e):h=!1}),r&&s.get(f)&&s.open(f),s.get(f)||(h=!1)),!h&&n<Tu){let e=window.setTimeout(()=>{_.current=_.current.filter(t=>t!==e),o()&&P(t,n+1,r,a)},wu);_.current.push(e);return}(e=>{let t=window.requestAnimationFrame(()=>{g.current=g.current.filter(e=>e!==t),o()&&e()});g.current.push(t)})(()=>{o()&&(d.forEach(t=>e.current?.open(t)),l(d),ee(f,!0,r))})},[c,l,ee,e]),te=(0,V.useCallback)(async e=>{await s([``,...x(e)]),P(e)},[s,P]),ne=(0,V.useCallback)(async(e,t)=>{t===`directory`&&(document.body.classList.remove(`code-file-location-dismissed`),T()),await s([``,...x(e),...t===`directory`&&e?[e]:[]]),P(e,0,t===`directory`)},[T,s,P]),re=(0,V.useCallback)(()=>{N();let e=(e=!1)=>{let t=n.current;t&&(yl({activeElementIsSearchInput:document.activeElement===t,searchInputValue:t.value})||(t.focus(),bl({requestedSelect:e,searchInputValue:t.value})&&t.select()))};e(!0),u.current=window.requestAnimationFrame(()=>e(!1)),ml.forEach(t=>{let n=window.setTimeout(()=>e(!1),t);d.current.push(n)})},[N,n]),ie=(0,V.useCallback)(()=>{N();let r=()=>{if(n.current?.value)return;n.current?.blur();let r=t.current?.querySelector(`[role="tree"]`),a=Array.from(t.current?.querySelectorAll(`[data-file-path]`)??[]),o=Sl({lastFocusedPath:i.current,rows:a.map(e=>({path:e.dataset.filePath??``,selected:e.classList.contains(`selected`)})).filter(e=>e.path)});if(o&&a.find(e=>e.dataset.filePath===o)&&o){i.current=o,e.current?.get(o)?.select(),Au(r);return}Au(r)};r(),f.current=window.requestAnimationFrame(r),hl.forEach(e=>{let t=window.setTimeout(r,e);p.current.push(t)})},[N,n,i,e,t]),F=(0,V.useCallback)(n=>{k();let r=()=>{if(!ju()){if(n){e.current?.get(n)?.select();let r=Array.from(t.current?.querySelectorAll(`[data-file-path]`)??[]).find(e=>e.dataset.filePath===n);if(Au(r?.closest(`[role="tree"]`)??t.current?.querySelector(`[role="tree"]`)),r){r.scrollIntoView({block:`nearest`}),Nu(r);return}}Au(t.current?.querySelector(`[role="tree"]`))}};r(),f.current=window.requestAnimationFrame(()=>{f.current=null,r()}),[80,180,360].forEach(e=>{let t=window.setTimeout(r,e);p.current.push(t)})},[k,e,t]),I=(0,V.useCallback)(e=>{F(e?.path??null)},[F]);return(0,V.useEffect)(()=>{if(!y)return;let e=e=>{let t=e.target;(t instanceof Element?t.closest(`[data-file-path]`):null)?.dataset.filePath!==y&&(document.body.classList.add(`code-file-location-dismissed`),T())};return document.addEventListener(`pointerdown`,e,!0),document.addEventListener(`keydown`,e,!0),()=>{document.removeEventListener(`pointerdown`,e,!0),document.removeEventListener(`keydown`,e,!0)}},[T,y]),(0,V.useEffect)(()=>()=>{N(),T()},[N,T]),{cancelPendingFileFocus:N,focusFileSearchInput:re,focusFileTreeFromSearch:ie,focusFileTreePath:F,focusFileTreeTarget:I,locatedFilePath:y,revealExplorerPath:ne,revealFilePath:te}}var Fu=15e3;function Iu(e){return e.replace(/^\/+|\/+$/g,``)}function Lu(e,t=e){let[n,r]=(0,V.useState)({}),i=(0,V.useRef)({}),a=(0,V.useRef)(new Map),o=(0,V.useRef)(new Map),s=(0,V.useRef)(0),c=(0,V.useCallback)((t=``)=>{if(!e)return Promise.resolve(null);let n=Iu(t),i=a.current.get(n);if(i)return i;let l=s.current;r(e=>({...e,[n]:{items:e[n]?.items??[],loading:!0,error:null}}));let u=null;return u=(async()=>{let t=new AbortController,i=!1,d=window.setTimeout(()=>{i=!0,t.abort()},Fu);try{let i=await I(e,n,{signal:t.signal});if(s.current!==l)return null;if(r(e=>({...e,[n]:{items:i.items,loading:!1,error:null,gitStatusPending:i.gitStatusPending}})),i.gitStatusPending&&!o.current.has(n)){let e=window.setTimeout(()=>{o.current.delete(n),c(n)},2e3);o.current.set(n,e)}return i}catch(e){return s.current===l&&r(t=>({...t,[n]:{items:t[n]?.items??[],loading:!1,error:i?`File refresh timed out`:e instanceof Error?e.message:`Failed to load directory`}})),null}finally{window.clearTimeout(d),u&&a.current.get(n)===u&&a.current.delete(n)}})(),a.current.set(n,u),u},[e]),l=(0,V.useCallback)(e=>{let t=Iu(e),n=i.current[t];return!n||n.loading||n.error?c(t):Promise.resolve({path:t,items:n.items,gitStatusPending:n.gitStatusPending})},[c]);return(0,V.useEffect)(()=>{i.current=n},[n]),(0,V.useEffect)(()=>{s.current+=1,a.current.clear(),o.current.forEach(e=>window.clearTimeout(e)),o.current.clear()},[e,t]),(0,V.useEffect)(()=>{r({}),i.current={}},[e,t]),(0,V.useEffect)(()=>()=>{a.current.clear(),o.current.forEach(e=>window.clearTimeout(e)),o.current.clear()},[]),(0,V.useMemo)(()=>({directories:n,loadDirectory:c,ensureDirectoryLoaded:l}),[n,l,c])}var Ru=12,zu=6;function Bu(e){let t=e.lastIndexOf(`/`);return t<0?``:e.slice(0,t)}function Vu(e){return e.split(`/`).filter(Boolean).length}function Hu(e,t=e){let n=t||``,{directories:r,loadDirectory:i,ensureDirectoryLoaded:a}=Lu(e,t),[o,s]=(0,V.useState)(()=>new Set(N(n).openDirectoryPaths??[])),c=(0,V.useRef)(o),l=(0,V.useRef)(n),u=(0,V.useRef)(new Map),d=(0,V.useRef)(``),p=(0,V.useMemo)(()=>C(r[``]?.items??[],r),[r]),m=(0,V.useMemo)(()=>Math.max(1,f(p,o)),[o,p]),h=(0,V.useCallback)((e,t)=>{let n=c.current;if(n.has(e)===t)return;let r=new Set(n);t?r.add(e):r.delete(e),c.current=r,s(r)},[]),g=(0,V.useCallback)(e=>c.current.has(e),[]),_=(0,V.useCallback)(e=>{if(e.length===0)return;let t=new Set(c.current),n=!1;e.forEach(e=>{!e||t.has(e)||(t.add(e),n=!0)}),n&&(c.current=t,s(t))},[]),v=(0,V.useCallback)(()=>i(``),[i]),y=(0,V.useCallback)(e=>{let t=e.filter(e=>!r[e]);return Promise.all(t.map(e=>i(e)))},[r,i]),b=(0,V.useCallback)(e=>{let t=r[e];return!!(t&&!t.loading&&!t.error)},[r]),x=(0,V.useCallback)(e=>{let t=new Set([``]);e.forEach(e=>{let n=String(e??``).replace(/^\/+|\/+$/g,``);for(t.add(n);n;)n=Bu(n),t.add(n)});let n=Array.from(t).sort((e,t)=>Vu(e)-Vu(t)||e.localeCompare(t));return(async()=>{let e=new Map,t=new Set,r=!0,a=0;for(;a<n.length;){let o=Vu(n[a]),s=[];for(;a<n.length&&Vu(n[a])===o;)s.push(n[a]),a+=1;let c=s.filter(n=>{if(!n)return!0;if(Array.from(t).some(e=>n===e||n.startsWith(`${e}/`)))return!1;let i=Bu(n),a=e.get(i);return a===null?(r=!1,!1):a&&!a.items.some(e=>e.type===`directory`&&e.path===n)?(t.add(n),!1):!0}),l=0,u=Array.from({length:Math.min(zu,c.length)},async()=>{for(;l<c.length;){let t=c[l];l+=1;let n=await i(t);e.set(t,n),n||(r=!1)}});await Promise.all(u)}if(t.size>0){let e=Array.from(t),n=new Set(Array.from(c.current).filter(t=>!e.some(e=>t===e||t.startsWith(`${e}/`))));c.current=n,s(n)}return r})()},[i]),S=(0,V.useCallback)(e=>{let t=u.current.get(e);if(t)return t;let n;return n=(async()=>{let t=e;for(let e=0;e<Ru;e+=1){let e=await a(t),n=e?.items.length===1&&e.items[0]?.type===`directory`?e.items[0]:null;if(!n)return;t=n.path}})().finally(()=>{u.current.get(e)===n&&u.current.delete(e)}),u.current.set(e,n),n},[a]);return(0,V.useEffect)(()=>{u.current.clear()},[e]),(0,V.useEffect)(()=>{l.current===n&&j(n,{openDirectoryPaths:Array.from(o)})},[n,o]),(0,V.useEffect)(()=>{if(l.current===n)return;l.current=n,d.current=``;let e=N(n).openDirectoryPaths??[],t=new Set(e);c.current=t,s(t)},[n]),(0,V.useEffect)(()=>{if(o.size===0)return;let e=`${n}:${Array.from(o).join(`
12
+ `)}`;d.current!==e&&(d.current=e,v(),y(Array.from(o)))},[y,v,n,o]),(0,V.useMemo)(()=>({directories:r,treeData:p,openDirectoryPaths:o,visibleTreeRowCount:m,loadRootDirectory:v,ensureDirectoryLoaded:a,isDirectoryLoaded:b,loadMissingDirectories:y,refreshDirectories:x,hydrateCompactDirectoryChains:S,isDirectoryOpen:g,setDirectoryOpen:h,openDirectoriesInLayout:_}),[r,a,S,g,b,y,v,_,o,x,h,p,m])}function Uu({agentId:e,agentLaunchOptionCount:t=0,cancelPendingFileFocus:n,clearFileOperation:r,focusFileTreeTarget:a,refreshDirectories:o,projectWorkspace:s,shareLinkFailed:c,setOpenFileError:l,startFileOperation:u}){let d=(0,V.useRef)(null),[f,p]=(0,V.useState)(null),m=(0,V.useCallback)(()=>{p(null)},[]),h=(0,V.useCallback)((e,i,a)=>{n(),l(null),r(),p({...U(e,i,a,window.innerWidth,window.innerHeight,t),item:a})},[t,n,r,l]),g=(0,V.useCallback)((e=!1)=>{let t=f?.item??null;p(null),e&&a(t)},[f?.item,a]),_=(0,V.useCallback)(()=>{g(!1)},[g]),v=(0,V.useCallback)(()=>{g(!0)},[g]),y=(0,V.useCallback)((e,t=f?.item??null)=>{n(),p(null),u(e,t)},[n,f?.item,u]),b=(0,V.useCallback)(()=>{e&&(o([et(f?.item??null)]),p(null))},[e,f?.item,o]);return{fileMenu:f,fileMenuRef:d,clearFileMenu:m,closeFileMenuWithFocusRestore:v,closeFileMenuWithoutFocus:_,copyFileMenuPath:(0,V.useCallback)(async()=>{let e=f?.item;if(e){p(null),l(null);try{await navigator.clipboard?.writeText(e.path)}catch{l(`Copy failed`)}}},[f?.item,l]),copyFileMenuShareUrl:(0,V.useCallback)(async()=>{let t=f?.item;if(!(!e||!t||t.type!==`file`&&t.type!==`directory`)){p(null),l(null);try{let n=t.type===`directory`?{kind:`folder`,agentId:e,folderPath:t.path,absolutePath:D(s,t.path),projectLabel:k(s)}:{kind:`file`,agentId:e,filePath:t.path,absolutePath:D(s,t.path),projectLabel:k(s)},r=await fetch(i(`/api/share/qr-ticket`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({target:n})}),a=await r.json();if(!r.ok||!a.longUrl||!await M(a.longUrl))throw Error(a.error||c)}catch(e){l(e instanceof Error?e.message:c)}}},[e,f?.item,s,l,c]),fileMenuTargetDirectory:(0,V.useCallback)((e=f?.item??null)=>et(e),[f?.item]),openFileContextMenu:h,refreshFileMenuTarget:b,startFileMenuOperation:y}}var Wu=220;function Gu({agentId:e,onClearSearch:t,onOpenFile:n,onRevealFilePath:r,onSelectOpenFile:i}){let a=(0,V.useRef)(0),o=(0,V.useRef)(null),[s,c]=(0,V.useState)(null),[l,d]=(0,V.useState)(null),f=(0,V.useCallback)(()=>{o.current!==null&&(window.clearTimeout(o.current),o.current=null),d(null)},[]),p=(0,V.useCallback)((e,t)=>{f(),o.current=window.setTimeout(()=>{a.current===e&&d(t),o.current=null},Wu)},[f]);return(0,V.useEffect)(()=>()=>{o.current!==null&&(window.clearTimeout(o.current),o.current=null)},[]),{openFileError:s,openFilePendingPath:l,openFilePath:(0,V.useCallback)(async(o,s)=>{if(!e)return;let l=a.current+1;if(a.current=l,c(null),i?.(e,o,s)){f(),t(),v(s)&&r(o);return}p(l,o);try{let i=await ce(e,o);if(a.current!==l)return;f(),n(e,i,s),t(),v(s)&&r(o)}catch(r){if(a.current!==l)return;if(f(),s&&r instanceof oe&&r.status===404&&u(s)){n(e,ee(o,s),s),t();return}c(r instanceof Error?r.message:`Failed to open file`)}},[e,f,t,n,r,i,p]),setOpenFileError:c}}function Ku({agentId:e,fileOperationActiveRef:t,ensureDirectoryLoaded:n,focusFileTreePath:r,onDeleteEntries:i,onMoveEntries:a,onOpenFile:o,onWorkspaceChange:s,refreshDirectories:l,setOpenFileError:u}){let d=(0,V.useRef)(null),f=(0,V.useRef)(``),[m,h]=(0,V.useState)(null),g=(0,V.useCallback)(()=>{t.current=!1,h(null)},[]),_=(0,V.useCallback)((e,n)=>{if(n?.readOnly&&!(n.symbolicLink&&(e===`rename`||e===`delete`)))return;let r=nt(e,n);f.current=r.name,t.current=!0,u(null),h(r)},[u]),v=(0,V.useCallback)(()=>{let e=m?.item??null;g(),r(e?.path??null)},[g,m?.item,r]),y=(0,V.useCallback)(e=>{f.current=e},[]),b=(0,V.useCallback)(e=>{f.current=e,h(t=>t&&{...t,name:e})},[]),x=(0,V.useCallback)(async()=>{if(!e||!m)return;let t=m.kind===`delete`?m:{...m,name:f.current},d=it(t);if(!(t.kind!==`delete`&&!d)){u(null);try{if(t.kind===`new-file`||t.kind===`new-folder`){let i=await ae(e,t.parentPath,d,t.kind===`new-folder`?`directory`:`file`);l([t.parentPath]),i.entry.type===`directory`&&(n(i.entry.path),r(i.entry.path)),i.file&&o(e,i.file),s?.(),g();return}if(t.kind===`rename`&&t.item){let n=await te(e,t.item.path,d);l(p(n)),a(e,[n]),s?.(),g(),r(S(n));return}if(t.kind===`delete`&&t.item){let n=await ne(e,t.item.path);l(c(n)),i(e,[n]),s?.(),g(),r(P(n))}}catch(e){u(e instanceof Error?e.message:`File operation failed`)}}},[e,g,n,m,r,i,a,o,s,l,u]);return(0,V.useEffect)(()=>{if(!m)return;let e=e=>{e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),v())};return document.addEventListener(`keydown`,e,!0),()=>{document.removeEventListener(`keydown`,e,!0)}},[v,m]),{fileOperation:m,fileOperationActiveRef:t,fileOperationInputRef:d,clearFileOperation:g,closeFileOperation:v,rememberFileOperationName:y,startFileOperation:_,submitFileOperation:x,updateFileOperationName:b}}var qu=3e3;function Ju(e){let[t,n]=(0,V.useState)(``),[r,i]=(0,V.useState)([]),[a,o]=(0,V.useState)(!1),[s,c]=(0,V.useState)(null),[l,u]=(0,V.useState)(0),[d,f]=(0,V.useState)(!1),[p,m]=(0,V.useState)(qu),[h,g]=(0,V.useState)(!1),_=(0,V.useRef)(0),v=t.trim().length>0,y=(0,V.useMemo)(()=>v?Ce(t):null,[v,t]),b=r.length>0?Math.min(l,r.length-1):-1,x=b>=0?r[b]??null:null,S=(0,V.useCallback)(()=>{_.current+=1,n(``),i([]),c(null),u(0),f(!1),m(qu),g(!1),o(!1)},[]),C=(0,V.useCallback)(e=>{g(!1),n(e)},[]),w=(0,V.useCallback)(()=>{g(!0)},[]),T=(0,V.useCallback)(()=>{r.length!==0&&u(e=>Math.min(e+1,r.length-1))},[r.length]),E=(0,V.useCallback)(()=>{r.length!==0&&u(e=>Math.max(e-1,0))},[r.length]),D=(0,V.useCallback)(e=>{u(Math.max(0,Math.min(e,Math.max(r.length-1,0))))},[r.length]);return(0,V.useEffect)(()=>{let n=t.trim(),r=_.current+1;if(_.current=r,u(0),!e||!n||Ce(n)){i([]),o(!1),c(null),f(!1);return}o(!0),c(null);let a=new AbortController,s=window.setTimeout(()=>{le(e,n,{includeIgnored:h,limit:60,signal:a.signal}).then(e=>{_.current===r&&(i(e.matches),f(e.truncated),m(e.timeoutMs??qu),o(!1))}).catch(e=>{_.current===r&&(e instanceof DOMException&&e.name===`AbortError`||(i([]),f(!1),c(e instanceof Error?e.message:`Search failed`),o(!1)))})},180);return()=>{window.clearTimeout(s),a.abort()}},[e,h,t]),(0,V.useEffect)(()=>{u(e=>Math.min(e,Math.max(r.length-1,0)))},[r.length]),(0,V.useMemo)(()=>({query:t,setQuery:C,matches:r,loading:a,error:s,selectMatchIndex:D,truncated:d,timeoutMs:p,includeIgnored:h,active:v,jumpTarget:y,activeMatchIndex:b,selectedMatch:x,clear:S,searchIgnored:w,selectNext:T,selectPrevious:E}),[v,b,S,s,y,a,r,h,w,t,D,T,E,x,d,p])}function Yu({fileMenuOpen:e,fileOperationActive:t,fileSearch:n,fileSearchResultsRef:r,filesCollapsed:i,focusFileTreeFromSearch:a,listboxId:o,onOpenFilePath:s,onRevealDirectoryPath:c}){let l=De({active:n.active,activeMatchIndex:n.activeMatchIndex,jumpTarget:n.jumpTarget,listboxId:o}),u=(0,V.useCallback)(e=>{if(e.kind===`path`&&e.entryType===`directory`){c(e.path),n.clear();return}let t=Te(e);s(t.path,t.target),n.clear()},[n,s,c]),d=(0,V.useCallback)(e=>{let t=Ee(e);return t?(s(t.path,t.target),n.clear(),!0):!1},[n,s]),f=(0,V.useCallback)(e=>{if(e.key===`Escape`){e.preventDefault(),e.stopPropagation(),n.clear(),a();return}if(e.key===`ArrowDown`){if(n.matches.length===0)return;e.preventDefault(),n.selectNext();return}if(e.key===`ArrowUp`){if(n.matches.length===0)return;e.preventDefault(),n.selectPrevious();return}if(e.key!==`Enter`||(e.preventDefault(),e.stopPropagation(),d(e.currentTarget.value)))return;let t=n.selectedMatch??n.matches[0];t&&u(t)},[n,a,d,u]);return(0,V.useEffect)(()=>{if(!n.active||n.matches.length===0)return;let e=r.current,t=e?.querySelector(`.code-file-search-result.active`);if(!e||!t)return;let i=t.offsetTop,a=i+t.offsetHeight;i<e.scrollTop?e.scrollTop=i:a>e.scrollTop+e.clientHeight&&(e.scrollTop=a-e.clientHeight)},[n.active,n.activeMatchIndex,n.matches.length,r]),(0,V.useEffect)(()=>{if(i||!n.active||e||t)return;let r=e=>{e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),n.clear(),a())};return document.addEventListener(`keydown`,r,!0),()=>{document.removeEventListener(`keydown`,r,!0)}},[e,t,n,i,a]),{activeOptionId:l,handleFileSearchKeyDown:f,openFileJumpQuery:d,openFileSearchMatch:u}}function Xu({agentId:e,workspaceKey:t,clearFileMenu:n,clearFileOperation:r,clearFileSearch:i,focusFileSearchInput:a,focusSearchRequest:o,loadRootDirectory:s,openFilesCount:c,refreshTreeLayout:l,revealExplorerPath:u,revealRequest:d,rootDirectoryLoaded:f,setFileSearchQuery:p,setOpenFileError:m,treeData:h}){let[g,_]=(0,V.useState)(()=>N(t).filesCollapsed??!0),[v,y]=(0,V.useState)(!0),b=(0,V.useRef)(null),x=(0,V.useRef)(t),S=(0,V.useCallback)(()=>{let e=!g;e?(n(),r(),i()):f||s(),_(e)},[n,r,i,g,s,f]),C=(0,V.useCallback)(()=>{y(e=>!e)},[]);return(0,V.useEffect)(()=>{m(null),n(),r(),i()},[e,n,r,i,m]),(0,V.useEffect)(()=>{if(d){if(_(!1),!f){s();return}b.current!==d.requestId&&(b.current=d.requestId,u(d.path,d.kind))}},[s,u,d,f]),(0,V.useEffect)(()=>{o&&(_(!1),f||s(),typeof o.query==`string`&&p(o.query),a())},[a,o,s,f,p]),(0,V.useEffect)(()=>{c===0&&y(!0)},[c]),(0,V.useEffect)(()=>{x.current===t&&j(t,{filesCollapsed:g})},[g,t]),(0,V.useEffect)(()=>{x.current!==t&&(x.current=t,_(N(t).filesCollapsed??!0))},[t]),(0,V.useEffect)(()=>{!g&&!f&&s()},[g,s,f]),(0,V.useEffect)(()=>{g||l()},[g,l,h]),{filesCollapsed:g,openEditorsCollapsed:v,toggleFilesCollapsed:S,toggleOpenEditorsCollapsed:C}}function Zu(e,t){let n=t.closest(`.code-project-group`),r=n?.querySelector(`.code-project-row`),i=n?.querySelector(`.code-agents-section`),a=n?.querySelector(`[data-testid="code-open-editors"]`);return kl(e.getBoundingClientRect().top,r?.getBoundingClientRect().height??30,(i?.getBoundingClientRect().height??0)+(a?.getBoundingClientRect().height??0),25)}function Qu({filesCollapsed:e,focusFileTreePath:t,lastFocusedFilePathRef:n,openDirectoryPaths:r,refreshTreeLayout:i,resetKey:a,treeData:o,treeViewportRef:s}){let[c,l]=(0,V.useState)([]),[u,d]=(0,V.useState)(!1),f=(0,V.useMemo)(()=>c.map(e=>m(o,e)).filter(e=>!!e),[c,o]),p=(0,V.useMemo)(()=>Nl({visible:u,directoryNodes:f}),[u,f]),h=(0,V.useCallback)(()=>{l(e=>e.length===0?e:[]),d(!1)},[]),g=(0,V.useCallback)(()=>{let t=s.current,n=t?.closest(`.code-project-list`);if(!t||!n||e){h();return}let r=n.getBoundingClientRect(),i=Zu(n,t),a=t.getBoundingClientRect(),o=Array.from(t.querySelectorAll(`[data-file-path]`)).flatMap(e=>{let t=e.dataset.filePath;if(!t)return[];let n=e.getBoundingClientRect();return[{path:t,top:n.top,bottom:n.bottom}]}),c=jl(o,i,r.bottom);if(!c){h();return}d(Al(a.top,i));let u=Ml(c,o,i);l(e=>e.length===u.length&&e.every((e,t)=>e===u[t])?e:u)},[h,e,s]),_=(0,V.useCallback)(e=>{n.current=e.path,t(e.path)},[t,n]);return(0,V.useEffect)(()=>{h()},[h,a]),(0,V.useEffect)(()=>{if(e){h();return}i();let t=window.requestAnimationFrame(()=>i()),n=window.setTimeout(i,80),r=window.setTimeout(i,180);return()=>{window.cancelAnimationFrame(t),window.clearTimeout(n),window.clearTimeout(r)}},[h,e,r,i,o]),(0,V.useEffect)(()=>{if(e)return;let t=s.current?.closest(`.code-project-list`),n=0,r=()=>{n||=window.requestAnimationFrame(()=>{n=0,g()})};return g(),window.setTimeout(g,80),t?.addEventListener(`scroll`,r,{passive:!0}),window.addEventListener(`resize`,r),()=>{n&&window.cancelAnimationFrame(n),t?.removeEventListener(`scroll`,r),window.removeEventListener(`resize`,r)}},[e,r,g,o,s]),{focusStickyDirectory:_,stickyContextItems:p}}function $u({rowHeight:e,visibleTreeRowCount:t,openDirectoryPaths:n,treeData:r,hydrateCompactDirectoryChains:i,isDirectoryOpen:a,setDirectoryOpen:o}){let s=(0,V.useRef)(void 0),c=(0,V.useRef)(null),l=(0,V.useRef)(null),u=(0,V.useRef)(new Set),d=(0,V.useRef)(new Set),f=Math.max(e,t*e),p=(0,V.useCallback)(e=>{if(e.length===0)return!1;let t=s.current;if(!t)return!1;let n=!1;return e.forEach(e=>{!e||!t.get(e)||u.current.has(e)||t.isOpen(e)||(t.open(e,!1),n=!0)}),n},[]),m=(0,V.useCallback)((e=[])=>{let t=()=>{p(e),s.current?.redrawList()};t(),window.requestAnimationFrame(t),window.setTimeout(t,80)},[p]),h=(0,V.useCallback)((e,t)=>{t?(u.current.delete(e),d.current.delete(e)):(u.current.add(e),d.current.delete(e)),o(e,t)},[o]),g=(0,V.useCallback)(e=>{let t=!a(e);return h(e,t),t},[a,h]);(0,V.useEffect)(()=>{u.current.forEach(e=>{if(!n.has(e)){d.current.add(e);return}d.current.has(e)&&(u.current.delete(e),d.current.delete(e))})},[n]),(0,V.useEffect)(()=>{let e=Array.from(n);if(e.length===0)return;let t=()=>{p(e)&&s.current?.redrawList()};t();let r=window.requestAnimationFrame(t),i=window.setTimeout(t,80),a=window.setTimeout(t,180);return()=>{window.cancelAnimationFrame(r),window.clearTimeout(i),window.clearTimeout(a)}},[n,p,r]);let _=(0,V.useCallback)(({attrs:e,innerRef:t,children:n})=>{let{style:r,className:i,...a}=e;return(0,V.createElement)(`div`,{...a,ref:t,style:{...r,minWidth:`100%`,width:`100%`},className:`code-file-tree-row-frame ${i??``}`.trim()},n)},[]);return{treeRef:s,treeViewportRef:c,lastFocusedFilePathRef:l,treeHeight:f,handleTreeToggle:(0,V.useCallback)(e=>{Fl(c.current?.closest(`.code-project-list`)),a(e)?i(e).finally(()=>m([e])):m()},[i,a,m]),refreshTreeLayout:m,rememberFocusedTreeNode:(0,V.useCallback)(e=>{e&&(l.current=e.data.path)},[]),rememberSelectedTreeNodes:(0,V.useCallback)(e=>{let t=e[e.length-1];t&&(l.current=t.data.path)},[]),renderFileTreeRow:_,setTreePathOpen:h,toggleTreePathOpen:g}}function ed({treeRef:e,treeViewportRef:t,lastFocusedFilePathRef:n,fileOperation:r,openDirectoryPaths:i,cancelPendingFileFocus:a,closeFileOperation:o,focusFileSearchInput:s,focusFileTreePath:c,focusFileTreeTarget:l,openFileContextMenu:u,openFilePath:d,setDirectoryOpen:f,startFileOperation:p,toggleDirectoryOpen:m}){let h=(0,V.useCallback)(()=>t.current?.closest(`.code-project-list`)??null,[t]),g=(0,V.useCallback)(()=>{let e=t.current,n=(e?.querySelector(`[data-file-path]`))?.getBoundingClientRect().height||24;return wl((h()??e)?.getBoundingClientRect().height??n,n)},[h,t]),_=(0,V.useCallback)((e,t=!0)=>{Fl(h()),t&&f(e.data.path,!0),e.open(),n.current=e.data.path,l(e.data)},[l,n,h,f]),v=(0,V.useCallback)((t,r,i=!0)=>{Fl(h()),i&&f(t,!1),r?r.close():e.current?.close(t),n.current=t,r?l(r.data):c(t)},[c,l,n,h,f,e]),y=(0,V.useCallback)(c=>{if(c.defaultPrevented||c.altKey)return;if((c.ctrlKey||c.metaKey)&&!c.shiftKey&&c.key.toLowerCase()===`p`){c.preventDefault(),c.stopPropagation(),s();return}if(c.ctrlKey||c.metaKey)return;let f=e.current,h=c.target;if(r&&c.key===`Escape`&&h?.closest(`.code-file-inline-operation`)){c.preventDefault(),c.stopPropagation(),o();return}if(h?.closest(`input, textarea, [contenteditable="true"], .code-file-inline-operation`))return;xl(c.key)&&a();let y=h?.closest(`[data-file-path]`)?.dataset.filePath,b=y?void 0:t.current?.querySelector(`[data-file-path].selected`),x={path:b?.dataset.filePath,type:b?.dataset.fileType,expanded:b?.getAttribute(`aria-expanded`)===`true`},S=f?.focusedNode&&!f.focusedNode.isRoot?f.focusedNode:null,C=Cl({targetPath:y,selectedPath:x.path,focusedPath:S?.data.path,lastFocusedPath:n.current}),w=C?f?.get(C):f?.focusedNode??f?.mostRecentNode;if(!w||w.isRoot)return;if(n.current=w.data.path,c.key===`ContextMenu`||c.shiftKey&&c.key===`F10`){c.preventDefault(),c.stopPropagation();let e=(c.target?.closest(`[data-file-path]`))?.getBoundingClientRect();u(e?e.left+24:24,e?e.top+e.height:24,w.data);return}if(c.shiftKey)return;if(c.key===`ArrowDown`||c.key===`ArrowUp`){c.preventDefault(),c.stopPropagation();let e=c.key===`ArrowDown`?w.next:w.prev;if(!e||e.isRoot)return;e.focus(),e.select(),n.current=e.data.path;return}if(c.key===`Home`||c.key===`End`){c.preventDefault(),c.stopPropagation();let e=f?.visibleNodes.filter(e=>!e.isRoot)??[],t=c.key===`Home`?e[0]:e[e.length-1];if(!t)return;t.focus(),t.select(),n.current=t.data.path,l(t.data);return}if(c.key===`PageUp`||c.key===`PageDown`){c.preventDefault(),c.stopPropagation();let e=f?.visibleNodes.filter(e=>!e.isRoot)??[],t=Tl({currentIndex:e.findIndex(e=>e.id===w.id),key:c.key,pageSize:g(),rowCount:e.length}),r=t>=0?e[t]:null;if(!r)return;r.focus(),r.select(),n.current=r.data.path,l(r.data);return}if(c.key===`F2`){c.preventDefault(),c.stopPropagation(),p(`rename`,w.data);return}if(c.key===`Delete`||c.key===`Backspace`){c.preventDefault(),c.stopPropagation(),p(`delete`,w.data);return}if(c.key===`ArrowRight`){if(w.data.type!==`directory`)return;if(c.preventDefault(),c.stopPropagation(),!w.isOpen){_(w);return}let e=w.children?.[0]??null;e&&(e.select(),e.focus(),n.current=e.data.path,l(e.data));return}if(c.key===`ArrowLeft`){if(c.preventDefault(),c.stopPropagation(),El({nodePath:w.data.path,nodeType:w.data.type,nodeOpen:w.isOpen,selectedRow:x,openDirectoryPaths:i})){v(w.data.path,w);return}let e=w.parent;e&&!e.isRoot&&(e.select(),e.focus(),n.current=e.data.path,l(e.data));return}if(c.key!==`Enter`&&c.key!==` `)return;c.preventDefault(),c.stopPropagation();let T=w.data.type===`directory`?m(w.data.path)?`open-directory`:`close-directory`:Ol({nodeType:w.data.type,nodeOpen:w.isOpen});if(T===`close-directory`){v(w.data.path,w,!1);return}if(T===`open-directory`){_(w,!1);return}T===`open-file`&&(n.current=w.data.path,d(w.data.path))},[a,o,v,r,s,l,n,_,i,u,d,g,p,m,e,t]);return(0,V.useEffect)(()=>{let n=n=>{if(n.key!==`ArrowLeft`||n.altKey||n.ctrlKey||n.metaKey)return;let r=t.current,i=document.activeElement;if(!r||!(i instanceof Element)||!r.contains(i))return;let a=r.querySelector(`[data-file-path].selected`),o=a?.dataset.filePath;if(!o||a?.dataset.fileType!==`directory`||a.getAttribute(`aria-expanded`)!==`true`)return;n.preventDefault(),n.stopPropagation();let s=e.current?.get(o);v(o,s)};return window.addEventListener(`keydown`,n,!0),()=>{window.removeEventListener(`keydown`,n,!0)}},[v,e,t]),{handleTreeKeyDownCapture:y}}var td=24,nd=350,rd=1400,id=new Set;function ad(e){return e.replace(/[^a-zA-Z0-9_-]+/g,`-`)||`root`}function od(e,t){let n=e.replace(/\/+$/,``)||`/`,r=t.replace(/^\/+|\/+$/g,``);return r?n===`/`?`/${r}`:`${n}/${r}`:n}function sd(e){return e.split(`/`).filter(Boolean).pop()||e}function cd(e){return{id:e.path,name:sd(e.path),path:e.path,type:`file`,size:0,mtimeMs:0}}function ld({projectId:e,projectWorkspace:t,agentId:n,agentLaunchOptions:r,activeFilePath:i,revealRequest:a,focusSearchRequest:o,editorDirtyFilePaths:s=id,editorExternalChangedFilePaths:c=id,openFiles:l=[],onOpenFile:u,onSelectOpenFile:d,onCloseOpenFile:f,onNewAgent:p,onStartAgent:m,onMoveEntries:h,onDeleteEntries:g,onRefreshOpenFiles:_,onFilesCollapsedChange:v,readOnly:b=!1,copy:x}){let{directories:S,treeData:C,openDirectoryPaths:w,visibleTreeRowCount:T,loadRootDirectory:E,ensureDirectoryLoaded:D,isDirectoryLoaded:O,loadMissingDirectories:k,refreshDirectories:A,hydrateCompactDirectoryChains:j,isDirectoryOpen:M,setDirectoryOpen:N,openDirectoriesInLayout:ee}=Hu(n,e),P=(0,V.useRef)(!1),te=(0,V.useRef)(null),ne=(0,V.useRef)(null),re=(0,V.useRef)(null),ie=(0,V.useRef)(!1),F=(0,V.useRef)(0),I=(0,V.useRef)(null),[ae,L]=(0,V.useState)(`idle`),R=Ju(n),oe=`code-file-search-results-${ad(e)}`,{treeRef:se,treeViewportRef:ce,lastFocusedFilePathRef:le,treeHeight:ue,handleTreeToggle:z,refreshTreeLayout:de,rememberFocusedTreeNode:B,rememberSelectedTreeNodes:fe,renderFileTreeRow:pe,setTreePathOpen:me,toggleTreePathOpen:he}=$u({rowHeight:td,visibleTreeRowCount:T,openDirectoryPaths:w,treeData:C,hydrateCompactDirectoryChains:j,isDirectoryOpen:M,setDirectoryOpen:N}),{cancelPendingFileFocus:ge,focusFileSearchInput:_e,focusFileTreeFromSearch:ve,focusFileTreePath:ye,focusFileTreeTarget:be,locatedFilePath:xe,revealExplorerPath:Ce,revealFilePath:we}=Pu({treeRef:se,treeViewportRef:ce,fileSearchInputRef:te,fileOperationActiveRef:P,lastFocusedFilePathRef:le,treeData:C,isDirectoryLoaded:O,loadMissingDirectories:k,openDirectoriesInLayout:ee,refreshTreeLayout:de}),Te=R.clear,{openFileError:Ee,openFilePendingPath:De,openFilePath:Oe,setOpenFileError:ke}=Gu({agentId:n,onClearSearch:Te,onOpenFile:u,onRevealFilePath:we,onSelectOpenFile:d}),Ae=Cu(b?null:n,l),[je,Me]=(0,V.useState)(!0),Ne=(0,V.useCallback)(()=>{if(ie.current)return;ie.current=!0;let e=F.current+1;F.current=e,I.current!==null&&(window.clearTimeout(I.current),I.current=null),L(`refreshing`),ke(null);let r=[``,...w],i=new Promise(e=>{window.setTimeout(e,nd)});(async()=>{let a=!1;try{let e=await Ae.refreshChanges(),[o,s]=await Promise.all([A(r),n&&_?_(n,t):Promise.resolve(!0)]);await i,a=e&&o&&s}catch{await i}F.current===e&&(ie.current=!1,L(a?`success`:`error`),a&&(I.current=window.setTimeout(()=>{F.current===e&&L(`idle`),I.current=null},rd)))})()},[n,Ae.refreshChanges,_,w,t,A,ke]);(0,V.useEffect)(()=>{F.current+=1,ie.current=!1,I.current!==null&&(window.clearTimeout(I.current),I.current=null),L(`idle`)},[n,e]),(0,V.useEffect)(()=>()=>{F.current+=1,I.current!==null&&window.clearTimeout(I.current)},[]),(0,V.useEffect)(()=>{Me(!0)},[n]);let Pe=(0,V.useCallback)(()=>{Me(e=>!e)},[]),Fe=(0,V.useCallback)(e=>{Oe(e.path,{...y(e),transient:!0})},[Oe]),{fileOperation:Ie,fileOperationInputRef:Le,clearFileOperation:Re,closeFileOperation:ze,rememberFileOperationName:Be,startFileOperation:Ve,submitFileOperation:He,updateFileOperationName:Ue}=Ku({agentId:n,fileOperationActiveRef:P,ensureDirectoryLoaded:D,focusFileTreePath:ye,onDeleteEntries:g,onMoveEntries:h,onOpenFile:u,onWorkspaceChange:Ae.refreshChanges,refreshDirectories:A,setOpenFileError:ke}),{fileMenu:We,fileMenuRef:Ge,clearFileMenu:Ke,closeFileMenuWithFocusRestore:qe,closeFileMenuWithoutFocus:Je,copyFileMenuPath:Ye,copyFileMenuShareUrl:Xe,fileMenuTargetDirectory:Ze,openFileContextMenu:Qe,refreshFileMenuTarget:$e,startFileMenuOperation:et}=Uu({agentId:n,agentLaunchOptionCount:r.length,cancelPendingFileFocus:ge,clearFileOperation:Re,focusFileTreeTarget:be,projectWorkspace:t,refreshDirectories:A,shareLinkFailed:x.shareLinkFailed,setOpenFileError:ke,startFileOperation:Ve}),tt=(0,V.useCallback)(e=>{ke(null),R.setQuery(e)},[R.setQuery,ke]),nt=(0,V.useCallback)(()=>od(t,Ze()),[Ze,t]),rt=(0,V.useCallback)(()=>{p&&(Je(),p(t))},[Je,p,t]),it=(0,V.useCallback)(e=>{if(!m)return;let n=nt();Je(),m(e,n,n===t?void 0:{projectWorkspace:t})},[Je,nt,m,t]),at=(0,V.useCallback)((e,t,n)=>{Qe(e,t,cd(n))},[Qe]),{filesCollapsed:U,openEditorsCollapsed:ot,toggleFilesCollapsed:ct,toggleOpenEditorsCollapsed:lt}=Xu({agentId:n,workspaceKey:e,clearFileMenu:Ke,clearFileOperation:Re,clearFileSearch:Te,focusFileSearchInput:_e,focusSearchRequest:o,loadRootDirectory:E,openFilesCount:l.length,refreshTreeLayout:de,revealExplorerPath:Ce,revealRequest:a,rootDirectoryLoaded:!!(S[``]&&!S[``].loading),setFileSearchQuery:R.setQuery,setOpenFileError:ke,treeData:C});(0,V.useEffect)(()=>{v?.(U)},[U,v]);let ut=(0,V.useMemo)(()=>l.length===0?{"--code-open-editors-sticky-height":`0px`}:ot?{"--code-open-editors-sticky-height":`25px`}:{"--code-open-editors-sticky-height":`${25+Math.min(l.length,7)*28}px`},[ot,l.length]);(0,V.useEffect)(()=>{!i||U||!S[``]||re.current!==i&&(re.current=i,we(i))},[i,S,U,we]);let{focusStickyDirectory:W,stickyContextItems:dt}=Qu({filesCollapsed:U,focusFileTreePath:ye,lastFocusedFilePathRef:le,openDirectoryPaths:w,refreshTreeLayout:de,resetKey:n,treeData:C,treeViewportRef:ce}),{activeOptionId:ft,handleFileSearchKeyDown:pt,openFileJumpQuery:mt,openFileSearchMatch:ht}=Yu({fileMenuOpen:!!We,fileOperationActive:!!Ie,fileSearch:R,fileSearchResultsRef:ne,filesCollapsed:U,focusFileTreeFromSearch:ve,listboxId:oe,onOpenFilePath:Oe,onRevealDirectoryPath:e=>Ce(e,`directory`)}),{handleTreeKeyDownCapture:gt}=ed({treeRef:se,treeViewportRef:ce,lastFocusedFilePathRef:le,fileOperation:Ie,openDirectoryPaths:w,cancelPendingFileFocus:ge,closeFileOperation:ze,focusFileSearchInput:_e,focusFileTreePath:ye,focusFileTreeTarget:be,openFileContextMenu:Qe,openFilePath:Oe,setDirectoryOpen:me,startFileOperation:et,toggleDirectoryOpen:he}),_t=yu({activeFilePath:i,activeSearchOptionId:ft,agentId:n??``,agentLaunchOptions:r,copy:x,editorDirtyFilePaths:s,editorExternalChangedFilePaths:c,fileMenu:We,fileMenuRef:Ge,fileOperation:Ie,fileOperationInputRef:Le,fileSearch:R,fileSearchInputRef:te,fileSearchListboxId:oe,fileSearchResultsRef:ne,filesCollapsed:U,handleFileSearchKeyDown:pt,handleTreeKeyDownCapture:gt,lastFocusedFilePathRef:le,locatedFilePath:xe,openEditorsCollapsed:ot,openFileError:Ee,openFilePendingPath:De,projectId:e,renderFileTreeRow:pe,rootDirectoryError:S[``]?.error??null,rootDirectoryHasItems:!!S[``]?.items.length,rootDirectoryLoading:!!S[``]?.loading,rowHeight:td,readOnly:b,stickyContextItems:dt,treeData:C,treeHeight:ue,treeRef:se,treeViewportRef:ce,visibleTreeRowCount:T,onCancelPendingFileFocus:ge,onCloseFileMenuWithFocusRestore:qe,onCloseFileMenuWithoutFocus:Je,onCloseFileOperation:ze,onCloseOpenFile:f,onCopyFileMenuPath:Ye,onCopyFileMenuShareUrl:Xe,onFocusFileTreeTarget:be,onFocusStickyDirectory:W,onOpenFileContextMenu:Qe,onOpenFileJumpQuery:mt,onOpenFilePath:Oe,onOpenFileSearchMatch:ht,onOpenNewAgentFromFileMenu:rt,onRefreshFileMenuTarget:$e,onRememberFileOperationName:Be,onSearchQueryChange:tt,onSelectOpenFile:d,onSelectSearchMatchIndex:R.selectMatchIndex,onToggleDirectory:he,onStartAgentFromFileMenu:it,onStartFileMenuOperation:et,onSubmitFileOperation:He,onToggleFilesCollapsed:ct,onToggleOpenEditorsCollapsed:lt,onToggleTreeNode:z,onTreeFocus:B,onTreeSelect:fe,onUpdateFileOperationName:Ue});return n?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(vu,{..._t.openEditors,files:l,onOpenFileContextMenu:at}),(0,H.jsxs)(`div`,{className:`code-files-section ${U?`collapsed`:``}`,"data-testid":`code-files-section`,"data-project-id":e,style:ut,children:[(0,H.jsx)(Gl,{..._t.sectionHeader,refreshStatus:ae,onRefreshFiles:Ne}),!U&&(0,H.jsxs)(H.Fragment,{children:[!b&&(0,H.jsx)(Se,{activeFilePath:i,projectWorkspace:t,changes:Ae,collapsed:je,copy:x,projectId:e,refreshing:ae===`refreshing`,onOpenChange:Fe,onToggleCollapsed:Pe}),!b&&(0,H.jsx)(gu,{agentId:n,copy:x,projectId:e,projectWorkspace:t}),(0,H.jsx)(Wl,{..._t.sectionBody})]})]}),U&&(0,H.jsx)(st,{agentId:n,copy:x,agentLaunchOptions:r,fileMenu:We,fileOperation:Ie,fileMenuRef:Ge,fileOperationInputRef:Le,onCloseFileMenu:Je,onCloseFileMenuWithFocusRestore:qe,onCloseFileOperation:ze,onCopyFileMenuPath:Ye,onCopyFileMenuShareUrl:Xe,onOpenNewAgent:rt,onRefreshFileMenuTarget:$e,onRememberFileOperationName:Be,onStartAgent:it,onStartFileMenuOperation:et,onSubmitFileOperation:He,onUpdateFileOperationName:Ue,readOnly:b})]}):null}export{ld as ProjectFilesSection};