march-cli 0.1.42 → 0.1.46

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 (48) hide show
  1. package/package.json +1 -1
  2. package/src/agent/code-search/cache.mjs +16 -7
  3. package/src/agent/code-search/engine.mjs +9 -2
  4. package/src/agent/code-search/retrieval/resilient-vectorizer.mjs +59 -0
  5. package/src/agent/code-search/retrieval/safetensors.mjs +16 -10
  6. package/src/agent/code-search/scanner.mjs +11 -5
  7. package/src/agent/code-search/tool.mjs +11 -5
  8. package/src/agent/model-payload-dumper.mjs +1 -1
  9. package/src/agent/runner/payload/provider-payload-transform.mjs +59 -0
  10. package/src/agent/runner/recall/mid-turn-recall-bridge.mjs +23 -0
  11. package/src/agent/runner.mjs +28 -27
  12. package/src/agent/runtime/remote-ui-client.mjs +1 -1
  13. package/src/agent/runtime/resource/context-resource-loader.mjs +17 -0
  14. package/src/agent/runtime/runtime-factory.mjs +5 -1
  15. package/src/agent/runtime/state/runner-state.mjs +10 -3
  16. package/src/agent/runtime/ui-event-bridge.mjs +2 -2
  17. package/src/agent/turn/turn-runner.mjs +35 -24
  18. package/src/cli/fallback-ui.mjs +2 -2
  19. package/src/cli/repl-loop.mjs +9 -8
  20. package/src/cli/startup/app-runtime.mjs +4 -2
  21. package/src/cli/tui/input/mouse-selection-controller.mjs +19 -0
  22. package/src/cli/tui/output/selectable-copy.mjs +3 -3
  23. package/src/cli/tui/output/timeline-block-restore.mjs +1 -1
  24. package/src/cli/tui/output-buffer.mjs +18 -0
  25. package/src/cli/tui/recall-rendering.mjs +38 -9
  26. package/src/cli/tui/selection/ansi-range.mjs +88 -0
  27. package/src/cli/tui/selection-screen.mjs +31 -99
  28. package/src/cli/turn/turn-input-preparer.mjs +15 -6
  29. package/src/cli/ui.mjs +2 -2
  30. package/src/cli/workspace/tui-timeline-projection.mjs +1 -1
  31. package/src/context/engine.mjs +15 -5
  32. package/src/context/system-core/base.md +1 -1
  33. package/src/memory/markdown/markdown-format.mjs +0 -17
  34. package/src/memory/markdown/markdown-recall.mjs +11 -19
  35. package/src/memory/markdown/semantic-preload.mjs +26 -0
  36. package/src/memory/markdown/semantic-recall.mjs +169 -0
  37. package/src/memory/markdown/sqlite-index.mjs +1 -13
  38. package/src/memory/markdown-store.mjs +34 -54
  39. package/src/web-ui/dist/assets/{index-BQtl1uQs.css → index-BG1Pxf1k.css} +1 -1
  40. package/src/web-ui/dist/assets/{index-DrlJis_D.js → index-C0xOHlDz.js} +1 -1
  41. package/src/web-ui/dist/index.html +2 -2
  42. package/src/web-ui/runtime-host.mjs +18 -3
  43. package/src/web-ui/src/components/timeline/TimelineBlocks.tsx +27 -0
  44. package/src/web-ui/src/model.ts +18 -0
  45. package/src/web-ui/src/runtime/client.ts +2 -1
  46. package/src/web-ui/src/runtime/runtimeTimeline.ts +5 -0
  47. package/src/web-ui/src/styles/shell.css +7 -0
  48. package/src/web-ui/src/timelineAdapter.ts +2 -0
@@ -1842,4 +1842,4 @@ Error generating stack: `+e.message+`
1842
1842
  }`}function bt(e){return`${vt}
1843
1843
  @layer unsafe {
1844
1844
  ${e}
1845
- }`}var xt=new WeakMap;function St(e){let t=xt.get(e);if(t!=null)return t;let n=document.createElement(`div`);n.setAttribute(T,`true`);let r=document.createElement(`div`);r.style.position=`relative`,r.style.height=`200%`,n.appendChild(r),e.appendChild(n);let i=Math.max(n.offsetWidth-n.clientWidth,0);return n.remove(),xt.set(e,i),i}function Ct(e,t){if(!e.isConnected)return;let n=St(t);if(n==null)return;let r=t.querySelector(`style[${E}]`),i=r instanceof HTMLStyleElement?r:document.createElement(`style`);r instanceof HTMLStyleElement||(i.setAttribute(E,``),t.appendChild(i)),i.textContent=`:host { ${D}: ${n}px; }`}var wt;function Tt(e){if(typeof CSSStyleSheet<`u`&&typeof CSSStyleSheet.prototype.replaceSync==`function`&&`adoptedStyleSheets`in e){wt??(wt=new CSSStyleSheet,wt.replaceSync(yt(_t)));let t=!1;try{e.adoptedStyleSheets=[wt],t=!0}catch{}if(t){e.querySelector(`style[${C}]`)?.remove();return}}if(e.querySelector(`style[data-file-tree-style]`)==null){let t=document.createElement(`style`);t.setAttribute(C,``),t.textContent=yt(_t),e.prepend(t)}}function Et(e,t){Dt(e,t),Tt(t),Ct(e,t)}function Dt(e,t){let n=e.querySelector(`template[shadowrootmode="open"], template[data-file-tree-shadowrootmode="open"]`);n instanceof HTMLTemplateElement&&(t.childNodes.length>0||(t.appendChild(n.content.cloneNode(!0)),n.hasAttribute(`shadowrootmode`)&&n.remove()))}if(typeof HTMLElement<`u`&&customElements.get(`file-tree-container`)==null){class e extends HTMLElement{constructor(){super()}connectedCallback(){let e=this.shadowRoot??this.attachShadow({mode:`open`});Et(this,e)}}if(customElements.define(S,e),typeof document<`u`)for(let e of Array.from(document.querySelectorAll(S)))e instanceof HTMLElement&&Et(e,e.shadowRoot??e.attachShadow({mode:`open`}))}var Ot=5,kt=1<<Ot,At=kt*4;function jt(){return{childIdByNameId:new Map,childIds:[],childPositionById:new Map,childVisibleChunkSums:null,totalChildSubtreeNodeCount:0,totalChildVisibleSubtreeCount:0}}function Mt(){return{childIdByNameId:null,childIds:[],childPositionById:null,childVisibleChunkSums:null,totalChildSubtreeNodeCount:0,totalChildVisibleSubtreeCount:0}}function Nt(e,t){if(t.childIdByNameId!=null)return t.childIdByNameId;let n=new Map;for(let r of t.childIds){let t=e[r];t!=null&&n.set(t.nameId,r)}return t.childIdByNameId=n,n}function Pt(e){if(e.childPositionById!=null)return e.childPositionById;let t=new Map;for(let n=0;n<e.childIds.length;n++){let r=e.childIds[n];r!=null&&t.set(r,n)}return e.childPositionById=t,t}function Ft(e,t){e.childPositionById!=null&&e.childPositionById.set(t,e.childIds.length),e.childIds.push(t)}function It(e,t){if(e.childPositionById!=null)for(let n=t;n<e.childIds.length;n++){let t=e.childIds[n];t!=null&&e.childPositionById.set(t,n)}}function Lt(e,t){let n=0,r=0;for(let i of t.childIds){let t=e[i];t!=null&&(n+=t.subtreeNodeCount,r+=t.visibleSubtreeCount)}t.totalChildSubtreeNodeCount=n,t.totalChildVisibleSubtreeCount=r,Vt(e,t)}function Rt(e,t,n,r){if(e.totalChildSubtreeNodeCount+=n,e.totalChildVisibleSubtreeCount+=r,e.childVisibleChunkSums==null||r===0)return;let i=Pt(e).get(t);if(i===void 0)return;let a=i>>Ot;e.childVisibleChunkSums[a]+=r}function zt(e,t,n){let r=t.childVisibleChunkSums;if(r!=null){let i=n,a=0;for(let o of r){if(i<o){let r=Ht(e,t,a,i);return{...r,childVisibleIndex:n-r.localVisibleIndex}}i-=o,a+=kt}throw Error(`Visible child index ${String(n)} is out of range`)}let i=n;for(let r=0;r<t.childIds.length;r++){let a=t.childIds[r];if(a==null)continue;let o=e[a];if(o!=null){if(i<o.visibleSubtreeCount)return{childIndex:r,childVisibleIndex:n-i,localVisibleIndex:i};i-=o.visibleSubtreeCount}}throw Error(`Visible child index ${String(n)} is out of range`)}function Bt(e,t,n){let r=0,i=t.childVisibleChunkSums,a=0;if(i!=null){let e=n>>Ot;for(let t=0;t<e;t+=1)r+=i[t]??0;a=e<<Ot}for(let i=a;i<n;i+=1){let n=t.childIds[i];if(n==null)continue;let a=e[n];a!=null&&(r+=a.visibleSubtreeCount)}return r}function Vt(e,t){if(t.childIds.length<At){t.childVisibleChunkSums=null;return}let n=Math.ceil(t.childIds.length/kt),r=new Int32Array(n);for(let n=0;n<t.childIds.length;n++){let i=t.childIds[n];if(i==null)continue;let a=e[i];a!=null&&(r[n>>Ot]+=a.visibleSubtreeCount)}t.childVisibleChunkSums=r}function Ht(e,t,n,r){let i=Math.min(t.childIds.length,n+kt),a=r;for(let r=n;r<i;r++){let n=t.childIds[r];if(n==null)continue;let i=e[n];if(i!=null){if(a<i.visibleSubtreeCount)return{childIndex:r,localVisibleIndex:a};a-=i.visibleSubtreeCount}}throw Error(`Visible child index ${String(r)} is out of range`)}var Ut=7,R=3,Wt=1<<R,Gt=4;function Kt(e,t,n=0){return e<<Gt|n<<R|t}function qt(e){return e.depthAndFlags>>>Gt}function Jt(e){return(e.depthAndFlags&Wt)>>R}function z(e){return(e.depthAndFlags&Wt)!==0}function Yt(e){return e.depthAndFlags&Ut}function B(e,t){return(Yt(e)&t)!==0}function Xt(e,t){e.depthAndFlags|=t}function Zt(e,t){e.depthAndFlags=Kt(t,Yt(e),Jt(e))}var Qt=Symbol(`benchmarkInstrumentation`);function $t(e,t){return t==null||Object.defineProperty(e,Qt,{configurable:!0,enumerable:!1,value:t,writable:!1}),e}function en(e){return e==null?null:e[Qt]??null}function V(e,t,n){return e==null?n():e.measurePhase(t,n)}function tn(e,t,n){!Number.isFinite(n)||e==null||e.setCounter(t,n)}function nn(e){return e>=48&&e<=57}function rn(e){let t=[],n=0,r=0;for(;r<e.length;){for(;r<e.length&&!nn(e.charCodeAt(r));)r+=1;if(r>=e.length)break;r>n&&t.push(e.slice(n,r));let i=0;for(;r<e.length&&nn(e.charCodeAt(r));)i=i*10+(e.charCodeAt(r)-48),r+=1;t.push(i),n=r}return(n<e.length||t.length===0)&&t.push(e.slice(n)),t}function an(e){let t=e.toLowerCase();return{lowerValue:t,tokens:rn(t)}}function on(e,t){let n=Math.min(e.length,t.length);for(let r=0;r<n;r++){let n=e[r],i=t[r];if(n===i)continue;if(typeof n==`number`&&typeof i==`number`)return n<i?-1:1;let a=String(n),o=String(i);if(a!==o)return a<o?-1:1}return e.length===t.length?0:e.length<t.length?-1:1}function sn(e,t){if(e.tokens.length===1&&t.tokens.length===1&&typeof e.tokens[0]==`string`&&typeof t.tokens[0]==`string`)return e.lowerValue===t.lowerValue?0:e.lowerValue<t.lowerValue?-1:1;let n=on(e.tokens,t.tokens);return n===0?e.lowerValue===t.lowerValue?0:e.lowerValue<t.lowerValue?-1:1:n}function cn(e,t,n){let r=sn(n(e),n(t));return r===0?e===t?0:e<t?-1:1:r}function ln(e,t){return cn(e,t,an)}function un(e,t){return t===e.segments.length-1?+!!e.isDirectory:1}function dn(e,t){let n=Math.min(e.segments.length,t.segments.length);for(let r=0;r<n;r++){let n=e.segments[r],i=t.segments[r];if(n===i)continue;let a=un(e,r);return a===un(t,r)?ln(n,i):a===1?-1:1}return e.segments.length===t.segments.length?e.isDirectory===t.isDirectory?0:e.isDirectory?-1:1:e.segments.length<t.segments.length?-1:1}function fn(e,t){return dn(e,t)}function pn(e,t,n){let r=e=>{let t=n.get(e);if(t!=null)return t;let r=an(e);return n.set(e,r),r},i=Math.min(e.segments.length,t.segments.length);for(let n=0;n<i;n++){let i=e.segments[n],a=t.segments[n];if(i===a)continue;let o=un(e,n);return o===un(t,n)?cn(i,a,r):o===1?-1:1}return e.segments.length===t.segments.length?e.isDirectory===t.isDirectory?0:e.isDirectory?-1:1:e.segments.length<t.segments.length?-1:1}function mn(e,t){let n=e.sortKeyById[t];if(n!==void 0)return n;let r=e.valueById[t],i=an(r);return e.sortKeyById[t]=i,i}function hn(e={}){return{flattenEmptyDirectories:e.flattenEmptyDirectories!==!1,sort:e.sort??`default`}}function gn(e){let t=e.length>0&&e.charCodeAt(e.length-1)===47,n=t?e.length-1:e.length,r=[],i=0;for(let t=0;t<n;t++)e.charCodeAt(t)===47&&(r.push(e.slice(i,t)),i=t+1);return r.push(e.slice(i,n)),{hasTrailingSlash:t,segments:r}}function _n(e){let{hasTrailingSlash:t,segments:n}=gn(e);return{basename:n[n.length-1]??``,isDirectory:t,path:e,segments:n}}function vn(e){if(e.length===0)return{requiresDirectory:!1,segments:[]};let{hasTrailingSlash:t,segments:n}=gn(e);return{requiresDirectory:t,segments:n}}var yn=``;function bn(){let e=new Map;return e.set(yn,0),{idByValue:e,valueById:[yn],sortKeyById:[an(yn)]}}function xn(e,t){let n=e.idByValue.get(t);if(n!==void 0)return n;let r=e.valueById.length;return e.idByValue.set(t,r),e.valueById.push(t),r}function Sn(e,t){let n=e.valueById[t];if(n===void 0)throw Error(`Unknown segment ID: ${String(t)}`);return n}var Cn=Symbol(`pathStorePreparedInputKind`);function wn(e,t){return e[Cn]=t,e}function Tn(e){return{basename:e.basename,depth:e.segments.length,isDirectory:e.isDirectory,path:e.path,segments:e.segments}}function En(e,t,n){return n===`default`?fn(e,t):n(Tn(e),Tn(t))}function Dn(){return{depthAndFlags:Kt(0,3,1),nameId:0,parentId:0,subtreeNodeCount:1,visibleSubtreeCount:1}}function On(e,t){let n=Math.min(e.length,t.length);for(let r=0;r<n;r++)if(e[r]!==t[r])return r;return n}function kn(e){return e.isDirectory?e.segments.length:e.segments.length-1}function An(e){return Array.isArray(e)&&e.every(e=>typeof e==`object`&&!!e&&typeof e.path==`string`&&Array.isArray(e.segments)&&typeof e.basename==`string`&&typeof e.isDirectory==`boolean`)}function jn(e){return Array.isArray(e)&&e.every(e=>typeof e==`string`)}function Mn(e,t={}){return Rn(e,t).map(e=>e.path)}function Nn(e,t={}){let n=Rn(e,t);return wn({paths:n.map(e=>e.path),preparedPaths:n},`prepared`)}function Pn(e){let t=e.length,n=!1;for(let r=0;r<t;r+=1){let t=e[r];if(t.length>0&&t.charCodeAt(t.length-1)===47){n=!0;break}}return wn({paths:e,presortedPaths:e,presortedPathsContainDirectories:n},`presorted`)}function Fn(e){let t=e,n=t.preparedPaths;if(t[Cn]===`prepared`&&n!=null)return n;if(!An(n))throw Error(`preparedInput must come from PathStore.prepareInput()`);return n}function In(e){let t=e;return t[Cn]===`presorted`&&t.presortedPaths!=null||jn(t.presortedPaths)?t.presortedPaths:null}function Ln(e){let t=e;return typeof t.presortedPathsContainDirectories==`boolean`?t.presortedPathsContainDirectories:null}function Rn(e,t={}){let n=hn(t),r=en(t);tn(r,`workload.inputFiles`,e.length);let i=V(r,`store.preparePathEntries.parse`,()=>e.map(e=>_n(e)));return V(r,`store.preparePathEntries.sort`,()=>i.sort((e,t)=>En(e,t,n.sort))),i}var zn=class{directories=new Map;directoryStack=[0];presortedDirectoryNodeIds=[];initialExpandedPathSet;createdDirectoriesAllExpanded=!1;createdDirectoryCount=0;lastPreparedPath=null;nodes=[Dn()];options;instrumentation;segmentSortKeyCache=new Map;segmentTable=bn();hasDeferredDirectoryIndexes=!1;constructor(e={}){this.instrumentation=en(e),this.options=hn(e);let t=e.initialExpandedPaths??null;if(t==null||t.length===0)this.initialExpandedPathSet=null;else{let e=new Set,n=t.length;for(let r=0;r<n;r+=1){let n=t[r],i=n.length;e.add(i>0&&n.charCodeAt(i-1)===47?n.slice(0,i-1):n)}this.initialExpandedPathSet=e,this.createdDirectoriesAllExpanded=!0}this.directories.set(0,jt())}appendPaths(e){return V(this.instrumentation,`store.builder.appendPaths.parse`,()=>this.appendPreparedPaths(e.map(e=>_n(e))))}appendPreparedPaths(e,t=!0){return this.createdDirectoriesAllExpanded=!1,V(this.instrumentation,`store.builder.appendPreparedPaths`,()=>{for(let n of e)this.appendPreparedPath(n,t)}),this}appendPresortedPaths(e,t=null){return V(this.instrumentation,`store.builder.appendPresortedPaths`,()=>{if(t===!1){this.appendPresortedFilePaths(e);return}this.createdDirectoriesAllExpanded=!1;let n=null,r=0,i=this.nodes,a=this.segmentTable,o=a.idByValue,s=a.valueById,c=this.directoryStack,l=0,u=``,d=0;for(let t of e){if(n===t)throw Error(`Duplicate path: "${t}"`);let e=t.length>0&&t.charCodeAt(t.length-1)===47,a=e?t.length-1:t.length,f=0,p=0;if(n!=null)if(u.length>0&&t.length>u.length&&t.startsWith(u))f=d,p=u.length;else{let r=Math.min(a,n.length),i=!0;for(let e=0;e<r;e++){let r=t.charCodeAt(e);if(r!==n.charCodeAt(e)){i=!1;break}r===47&&(f++,p=e+1)}i&&e&&r===a&&n.length>a&&n.charCodeAt(a)===47&&(f++,p=a+1)}l=f,r=f;let m=p,h=t.indexOf(`/`,m);for(;h>=0&&h<a;){let e=c[l];if(e===void 0)throw Error(`Directory stack underflow while building the path store`);r++;let n=t.slice(m,h),a=o.get(n);a===void 0&&(a=s.length,o.set(n,a),s.push(n));let u=i.length;i.push({depthAndFlags:Kt(r,0,1),nameId:a,parentId:e,subtreeNodeCount:1,visibleSubtreeCount:1}),this.recordCreatedDirectoryPath(t.slice(0,h)),l++,c[l]=u,m=h+1,h=t.indexOf(`/`,m)}if(e){if(m<a){let e=c[l];if(e===void 0)throw Error(`Unable to resolve directory parent for "${t}"`);r++;let n=t.slice(m,a),u=o.get(n);u===void 0&&(u=s.length,o.set(n,u),s.push(n));let d=i.length;i.push({depthAndFlags:Kt(r,0,1),nameId:u,parentId:e,subtreeNodeCount:1,visibleSubtreeCount:1}),l++,c[l]=d}let e=c[l];if(e===void 0)throw Error(`Unable to resolve directory node for "${t}"`);this.promoteDirectoryToExplicit(e,t)}else{let e=c[l];if(e===void 0)throw Error(`Unable to resolve file parent for "${t}"`);let n=t.slice(m),a=o.get(n);a===void 0&&(a=s.length,o.set(n,a),s.push(n)),i.push({depthAndFlags:Kt(r+1,0),nameId:a,parentId:e,subtreeNodeCount:1,visibleSubtreeCount:1})}m!==u.length&&(u=t.substring(0,m),d=r),n=t}c.length=l+1,n!=null&&(this.lastPreparedPath=_n(n)),this.hasDeferredDirectoryIndexes=!0}),this}appendPresortedFilePaths(e){let t=null,n=0,r=this.nodes,i=this.segmentTable,a=i.idByValue,o=i.valueById,s=this.directoryStack,c=0,l=``,u=0;for(let i of e){if(t===i)throw Error(`Duplicate path: "${i}"`);let e=i.length,d=0,f=0;if(t!=null)if(l.length>0&&i.length>l.length&&i.startsWith(l))d=u,f=l.length;else{let n=Math.min(e,t.length);for(let e=0;e<n;e++){let n=i.charCodeAt(e);if(n!==t.charCodeAt(e))break;n===47&&(d++,f=e+1)}}c=d,n=d;let p=f,m=i.indexOf(`/`,p);for(;m>=0;){let e=s[c];if(e===void 0)throw Error(`Directory stack underflow while building the path store`);n++;let t=i.slice(p,m),l=a.get(t);l===void 0&&(l=o.length,a.set(t,l),o.push(t));let u=r.length;r.push({depthAndFlags:Kt(n,0,1),nameId:l,parentId:e,subtreeNodeCount:1,visibleSubtreeCount:1}),this.recordCreatedDirectoryPath(i.slice(0,m)),this.presortedDirectoryNodeIds.push(u),c++,s[c]=u,p=m+1,m=i.indexOf(`/`,p)}let h=s[c];if(h===void 0)throw Error(`Unable to resolve file parent for "${i}"`);let g=i.slice(p),_=a.get(g);_===void 0&&(_=o.length,a.set(g,_),o.push(g)),r.push({depthAndFlags:Kt(n+1,0),nameId:_,parentId:h,subtreeNodeCount:1,visibleSubtreeCount:1}),p!==l.length&&(l=i.substring(0,p),u=n),t=i}s.length=c+1,t!=null&&(this.lastPreparedPath=_n(t)),this.hasDeferredDirectoryIndexes=!0}finish(e={}){let t=e.skipSubtreeCountPass===!0;return this.hasDeferredDirectoryIndexes?(V(this.instrumentation,`store.builder.buildDirectoryIndexes`,()=>this.buildPresortedFinish(t)),this.hasDeferredDirectoryIndexes=!1):t||V(this.instrumentation,`store.builder.computeSubtreeCounts`,()=>this.computeSubtreeCounts(0)),{directories:this.directories,nodes:this.nodes,options:this.options,rootId:0,segmentTable:this.segmentTable,presortedDirectoryNodeIds:this.presortedDirectoryNodeIds.length>0?this.presortedDirectoryNodeIds:null}}didMatchAllInitialExpandedPaths(){return this.createdDirectoriesAllExpanded&&this.initialExpandedPathSet!=null&&this.createdDirectoryCount===this.initialExpandedPathSet.size}appendPreparedPath(e,t){if(this.hasDeferredDirectoryIndexes&&=(this.buildDirectoryIndexes(),!1),this.lastPreparedPath!=null){if(e.path===this.lastPreparedPath.path)throw Error(`Duplicate path: "${e.path}"`);if(t&&(this.options.sort===`default`?pn(this.lastPreparedPath,e,this.segmentSortKeyCache):En(this.lastPreparedPath,e,this.options.sort))>0)throw Error(`Builder input must be sorted before appendPaths(): "${e.path}"`)}let n=this.lastPreparedPath,r=kn(e),i=n==null?0:kn(n),a=n==null?0:On(n.segments,e.segments),o=Math.min(a,r,i);this.directoryStack.length=o+1;for(let n=o;n<r;n++){let r=this.directoryStack[this.directoryStack.length-1];if(r===void 0)throw Error(`Directory stack underflow while building the path store`);let i=t?this.getOrCreateDirectoryChild(r,e.segments[n]):this.createDirectoryChild(r,e.segments[n]);this.directoryStack.push(i)}if(e.isDirectory){let t=this.directoryStack[this.directoryStack.length-1];if(t===void 0)throw Error(`Unable to resolve directory node for "${e.path}"`);this.promoteDirectoryToExplicit(t,e.path),this.lastPreparedPath=e;return}let s=this.directoryStack[this.directoryStack.length-1];if(s===void 0)throw Error(`Unable to resolve file parent for "${e.path}"`);t?this.createFileChild(s,e.basename,e.path):this.createFileChildUnchecked(s,e.basename),this.lastPreparedPath=e}recordCreatedDirectoryPath(e){!this.createdDirectoriesAllExpanded||this.initialExpandedPathSet==null||(this.createdDirectoryCount+=1,this.initialExpandedPathSet.has(e)||(this.createdDirectoriesAllExpanded=!1))}createFileChild(e,t,n){let r=xn(this.segmentTable,t),i=this.getDirectoryIndex(e),a=i.childIdByNameId;if(a!=null&&a.get(r)!==void 0)throw Error(`Path collides with an existing entry: "${n}"`);let o=this.nodes[e];if(o===void 0)throw Error(`Unknown parent node ID: ${String(e)}`);let s=this.nodes.length;return this.nodes.push({depthAndFlags:Kt(qt(o)+1,0),nameId:r,parentId:e,subtreeNodeCount:1,visibleSubtreeCount:1}),a?.set(r,s),Ft(i,s),s}createFileChildUnchecked(e,t){let n=xn(this.segmentTable,t),r=this.getDirectoryIndex(e),i=this.nodes[e];if(i===void 0)throw Error(`Unknown parent node ID: ${String(e)}`);let a=this.nodes.length;return this.nodes.push({depthAndFlags:Kt(qt(i)+1,0),nameId:n,parentId:e,subtreeNodeCount:1,visibleSubtreeCount:1}),r.childIdByNameId!=null&&r.childIdByNameId.set(n,a),Ft(r,a),a}getOrCreateDirectoryChild(e,t){let n=xn(this.segmentTable,t),r=this.getDirectoryIndex(e);if(r.childIdByNameId!=null){let e=r.childIdByNameId.get(n);if(e!==void 0){let n=this.nodes[e];if(n!=null&&!z(n))throw Error(`Path collides with an existing file while creating directory "${t}"`);return e}}let i=this.nodes[e];if(i===void 0)throw Error(`Unknown parent node ID: ${String(e)}`);let a=this.nodes.length;return this.nodes.push({depthAndFlags:Kt(qt(i)+1,0,1),nameId:n,parentId:e,subtreeNodeCount:1,visibleSubtreeCount:1}),r.childIdByNameId!=null&&r.childIdByNameId.set(n,a),Ft(r,a),this.directories.set(a,jt()),a}createDirectoryChild(e,t){let n=xn(this.segmentTable,t),r=this.getDirectoryIndex(e),i=this.nodes[e];if(i===void 0)throw Error(`Unknown parent node ID: ${String(e)}`);let a=this.nodes.length;return this.nodes.push({depthAndFlags:Kt(qt(i)+1,0,1),nameId:n,parentId:e,subtreeNodeCount:1,visibleSubtreeCount:1}),r.childIdByNameId!=null&&r.childIdByNameId.set(n,a),Ft(r,a),this.directories.set(a,jt()),a}promoteDirectoryToExplicit(e,t){let n=this.nodes[e];if(n===void 0)throw Error(`Unknown directory node ID: ${String(e)}`);if(!z(n))throw Error(`Path is not a directory: "${t}"`);if(B(n,1))throw Error(`Duplicate path: "${t}"`);Xt(n,1)}getDirectoryIndex(e){let t=this.directories.get(e);if(t!==void 0)return t;throw Error(`Unknown directory child index for node ${String(e)}`)}buildPresortedFinish(e){let t=this.nodes,n=this.directories;n.set(0,Mt());let r=-1,i=null;for(let e=1;e<t.length;e++){let a=t[e];if(a==null)continue;if(z(a)){let t=Mt();n.set(e,t),r=e,i=t}let o;a.parentId===r?o=i:(o=n.get(a.parentId),r=a.parentId,i=o??null),o?.childIds.push(e)}if(!e)for(let e=t.length-1;e>=1;e--){let n=t[e];if(n==null)continue;let r=t[n.parentId];r!=null&&(r.subtreeNodeCount+=n.subtreeNodeCount,r.visibleSubtreeCount+=n.visibleSubtreeCount)}}buildDirectoryIndexes(){let e=this.nodes;for(let t=1;t<e.length;t++){let n=e[t];if(n==null)continue;z(n)&&this.directories.set(t,jt());let r=this.directories.get(n.parentId);r!=null&&(r.childIdByNameId!=null&&r.childIdByNameId.set(n.nameId,t),Ft(r,t))}}computeSubtreeCounts(e){let t=this.nodes[e];if(t===void 0)throw Error(`Unknown node ID: ${String(e)}`);if(!z(t))return t.subtreeNodeCount=1,t.visibleSubtreeCount=1,1;let n=this.getDirectoryIndex(e),r=1;for(let e of n.childIds)r+=this.computeSubtreeCounts(e);return Lt(this.nodes,n),t.subtreeNodeCount=r,t.visibleSubtreeCount=r,r}};function Bn(e,t=`closed`,n=null){let r=Hn(t);return{activeNodeCount:e.nodes.length-1,collapsedDirectoryIds:new Set,collapseNewDirectoriesByDefault:!1,defaultExpansion:r,directoriesOpenByDefault:r===`open`,hasCollapsedDirectoryOverrides:!1,directoryLoadInfoById:new Map,expandedDirectoryIds:new Set,instrumentation:n,listeners:new Map,pathCacheByNodeId:new Map([[e.rootId,{path:``,version:0}]]),pathCacheVersion:0,snapshot:e,transactionStack:[]}}function Vn(){return{affectedAncestorIds:new Set,affectedNodeIds:new Set,events:[]}}function Hn(e){if(typeof e!=`number`)return e;if(!Number.isInteger(e)||e<0)throw Error(`initialExpansion must be "open", "closed", or a non-negative integer depth. Received: ${String(e)}`);return e}function Un(e,t){return B(t,2)||e.defaultExpansion===`open`?!0:e.defaultExpansion===`closed`?!1:qt(t)<=e.defaultExpansion}function Wn(e,t,n=e.snapshot.nodes[t]){return n==null||!z(n)?!1:e.directoriesOpenByDefault&&!e.hasCollapsedDirectoryOverrides?!0:e.collapsedDirectoryIds.has(t)?!1:e.expandedDirectoryIds.has(t)?!0:Un(e,n)}function Gn(e,t,n,r=e.snapshot.nodes[t]){if(r==null||!z(r))return;let i=Un(e,r);if(n){if(i){e.collapsedDirectoryIds.delete(t),e.hasCollapsedDirectoryOverrides=e.collapsedDirectoryIds.size>0;return}e.expandedDirectoryIds.add(t);return}if(i){e.collapsedDirectoryIds.add(t),e.hasCollapsedDirectoryOverrides=!0;return}e.expandedDirectoryIds.delete(t)}function Kn(e,t){let n=e.directoryLoadInfoById.get(t);if(n!=null)return n;let r={activeAttemptId:null,errorMessage:null,nextAttemptId:1,state:`loaded`};return e.directoryLoadInfoById.set(t,r),r}function qn(e,t){return e.directoryLoadInfoById.get(t)?.state??`loaded`}function Jn(e,t){let n=Kn(e,t);if(n.state===`loading`&&n.activeAttemptId!=null)return{attemptId:n.activeAttemptId,nodeId:t,reused:!0};let r=n.nextAttemptId;return n.activeAttemptId=r,n.errorMessage=null,n.nextAttemptId+=1,n.state=`loading`,{attemptId:r,nodeId:t,reused:!1}}function Yn(e,t){let n=Kn(e,t);n.activeAttemptId=null,n.errorMessage=null,n.state=`unloaded`}function Xn(e,t,n){let r=e.directoryLoadInfoById.get(t);return r==null||r.activeAttemptId!==n?!1:(r.activeAttemptId=null,r.errorMessage=null,r.state=`loaded`,!0)}function Zn(e,t,n){return e.directoryLoadInfoById.get(t)?.activeAttemptId===n}function Qn(e,t,n,r){let i=e.directoryLoadInfoById.get(t);return i==null||i.activeAttemptId!==n?!1:(i.activeAttemptId=null,i.errorMessage=r??null,i.state=`error`,!0)}function $n(e,t){e.directoryLoadInfoById.delete(t)}function er(e,t,n){let r=n,i=e.listeners.get(t);return i==null?e.listeners.set(t,new Set([r])):i.add(r),()=>{let n=e.listeners.get(t);n!=null&&(n.delete(r),n.size===0&&e.listeners.delete(t))}}function tr(e){return{affectedAncestorIds:e.affectedAncestorIds??[],affectedNodeIds:e.affectedNodeIds??[],canonicalChanged:!0,operation:`add`,path:e.path,projectionChanged:e.projectionChanged,visibleCountDelta:null}}function nr(e){return{affectedAncestorIds:e.affectedAncestorIds??[],affectedNodeIds:e.affectedNodeIds??[],canonicalChanged:!0,operation:`remove`,path:e.path,projectionChanged:e.projectionChanged,recursive:e.recursive,visibleCountDelta:null}}function rr(e){return{affectedAncestorIds:e.affectedAncestorIds??[],affectedNodeIds:e.affectedNodeIds??[],canonicalChanged:!0,from:e.from,operation:`move`,projectionChanged:e.projectionChanged,to:e.to,visibleCountDelta:null}}function ir(e){return{affectedAncestorIds:e.affectedAncestorIds??[],affectedNodeIds:e.affectedNodeIds??[],canonicalChanged:!1,operation:`expand`,path:e.path,projectionChanged:!0,visibleCountDelta:null}}function ar(e){return{affectedAncestorIds:e.affectedAncestorIds??[],affectedNodeIds:e.affectedNodeIds??[],canonicalChanged:!1,operation:`collapse`,path:e.path,projectionChanged:!0,visibleCountDelta:null}}function or(e){return{affectedAncestorIds:e.affectedAncestorIds??[],affectedNodeIds:e.affectedNodeIds??[],canonicalChanged:!1,operation:`mark-directory-unloaded`,path:e.path,projectionChanged:e.projectionChanged,visibleCountDelta:null}}function sr(e){return{affectedAncestorIds:e.affectedAncestorIds??[],affectedNodeIds:e.affectedNodeIds??[],attemptId:e.attemptId,canonicalChanged:!1,operation:`begin-child-load`,path:e.path,projectionChanged:e.projectionChanged,reused:e.reused,visibleCountDelta:null}}function cr(e){return{affectedAncestorIds:e.affectedAncestorIds??[],affectedNodeIds:e.affectedNodeIds??[],attemptId:e.attemptId,canonicalChanged:e.childEvents.some(e=>e.canonicalChanged),childEvents:e.childEvents,operation:`apply-child-patch`,path:e.path,projectionChanged:e.projectionChanged,visibleCountDelta:null}}function lr(e){return{affectedAncestorIds:e.affectedAncestorIds??[],affectedNodeIds:e.affectedNodeIds??[],attemptId:e.attemptId,canonicalChanged:!1,operation:`complete-child-load`,path:e.path,projectionChanged:e.projectionChanged,stale:e.stale,visibleCountDelta:null}}function ur(e){return{affectedAncestorIds:e.affectedAncestorIds??[],affectedNodeIds:e.affectedNodeIds??[],attemptId:e.attemptId,canonicalChanged:!1,errorMessage:e.errorMessage,operation:`fail-child-load`,path:e.path,projectionChanged:e.projectionChanged,stale:e.stale,visibleCountDelta:null}}function dr(e){return{activeNodeCountAfter:e.activeNodeCountAfter,activeNodeCountBefore:e.activeNodeCountBefore,affectedAncestorIds:e.affectedAncestorIds??[],affectedNodeIds:e.affectedNodeIds??[],cachedPathEntryCountAfter:e.cachedPathEntryCountAfter,cachedPathEntryCountBefore:e.cachedPathEntryCountBefore,canonicalChanged:!1,idsPreserved:e.idsPreserved,loadInfoEntryCountAfter:e.loadInfoEntryCountAfter,loadInfoEntryCountBefore:e.loadInfoEntryCountBefore,mode:e.mode,operation:`cleanup`,projectionChanged:e.projectionChanged,reclaimedCachedPathEntryCount:e.reclaimedCachedPathEntryCount,reclaimedLoadInfoEntryCount:e.reclaimedLoadInfoEntryCount,reclaimedNodeSlotCount:e.reclaimedNodeSlotCount,reclaimedSegmentCount:e.reclaimedSegmentCount,segmentCountAfter:e.segmentCountAfter,segmentCountBefore:e.segmentCountBefore,totalNodeSlotCountAfter:e.totalNodeSlotCountAfter,totalNodeSlotCountBefore:e.totalNodeSlotCountBefore,visibleCountDelta:null}}function fr(e,t,n){return{...n,visibleCountDelta:Cr(e)-t}}function pr(e,t){let n=Cr(e),r=Vn();e.transactionStack.push(r);try{t()}catch(t){throw gr(e,r,!1),t}gr(e,r,!0,Cr(e)-n)}function mr(e,t){let n=e.instrumentation;if(n==null){hr(e,t);return}V(n,`store.events.record`,()=>hr(e,t))}function hr(e,t){let n=e.transactionStack[e.transactionStack.length-1]??null;if(n==null){xr(e,t);return}n.events.push(t),br(n,t)}function gr(e,t,n,r=null){if(e.transactionStack.pop()!==t)throw Error(`Transaction stack underflow`);if(!n)return;let i=e.transactionStack[e.transactionStack.length-1]??null;if(i!=null){let n=e.instrumentation;n==null?yr(i,t):V(n,`store.events.batch.merge`,()=>yr(i,t));return}let a=_r(t,r),o=e.instrumentation;if(o==null){xr(e,a);return}V(o,`store.events.batch.commit`,()=>xr(e,a))}function _r(e,t){return{affectedAncestorIds:[...e.affectedAncestorIds],affectedNodeIds:[...e.affectedNodeIds],canonicalChanged:e.events.some(e=>e.canonicalChanged),events:[...e.events],operation:`batch`,projectionChanged:e.events.some(e=>e.projectionChanged),visibleCountDelta:t}}function vr(e,t){for(let n of t.affectedAncestorIds)e.affectedAncestorIds.add(n);for(let n of t.affectedNodeIds)e.affectedNodeIds.add(n)}function yr(e,t){for(let n of t.events)e.events.push(n);vr(e,t)}function br(e,t){for(let n of t.affectedNodeIds)e.affectedNodeIds.add(n);for(let n of t.affectedAncestorIds)e.affectedAncestorIds.add(n)}function xr(e,t){let n=e.instrumentation;if(n==null){Sr(e,t);return}V(n,`store.events.emit`,()=>Sr(e,t))}function Sr(e,t){e.listeners.get(t.operation)?.forEach(e=>e(t)),e.listeners.get(`*`)?.forEach(e=>e(t))}function Cr(e){return e.snapshot.nodes[e.snapshot.rootId]?.visibleSubtreeCount??0}function wr(e,t){if(e.snapshot.options.flattenEmptyDirectories!==!0)return null;let n=e.snapshot.nodes[t];if(n==null||!z(n)||B(n,2))return null;let r=e.snapshot.directories.get(t);if(r==null||r.childIds.length!==1)return null;let i=r.childIds[0];if(i==null)return null;let a=e.snapshot.nodes[i];return a==null||!z(a)?null:i}function Tr(e,t){let n=t;for(;;){let t=wr(e,n);if(t==null)return n;n=t}}function Er(e,t){let n=[t],r=t;for(;;){let t=wr(e,r);if(t==null)return n;n.push(t),r=t}}function Dr(e,t){let n=t==null?e.snapshot.rootId:Ir(e,t);return n==null?[]:Rr(e,n)}function Or(e,t){let n=_n(t),r=n.isDirectory?n.segments:n.segments.slice(0,-1),i=$r(e,Qr(e,r)),{createdNodeIds:a,directoryId:o}=zr(e,r),s=new Set(a),c=o;if(n.isDirectory){let n=W(e,o);if(B(n,1))throw Error(`Path already exists: "${t}"`);Xt(n,1),e.pathCacheByNodeId.set(o,{path:t,version:e.pathCacheVersion}),s.add(o)}else c=Vr(e,o,n.basename),s.add(c);Nr(e,o);let l=$r(e,o);return tr({affectedAncestorIds:Fr(e,c),affectedNodeIds:[...s],path:t,projectionChanged:ei(i,l)})}function kr(e,t,n){let r=Ir(e,t);if(r==null)throw Error(`Path does not exist: "${t}"`);let i=W(e,r);if(B(i,2))throw Error(`The root node cannot be removed`);if(z(i)&&U(e,r).childIds.length>0&&n.recursive!==!0)throw Error(`Cannot remove a non-empty directory without recursive: "${t}"`);let a=i.parentId,o=$r(e,a),s=Xr(e,r);Wr(e,a,r,i.nameId),Zr(e,a),Nr(e,a);let c=$r(e,a);return nr({affectedAncestorIds:Fr(e,a),affectedNodeIds:s,path:t,projectionChanged:ei(o,c),recursive:n.recursive===!0})}function Ar(e,t,n,r){let i=Ir(e,t);if(i==null)throw Error(`Source path does not exist: "${t}"`);let a=W(e,i);if(B(a,2))throw Error(`The root node cannot be moved`);let o=r.collision??`error`,s=Jr(e,i,n),c=$r(e,a.parentId),l=$r(e,s.parentId),u=Sn(e.snapshot.segmentTable,a.nameId),d=xn(e.snapshot.segmentTable,s.basename);if(s.parentId===a.parentId&&u===s.basename)return null;if(z(a)&&ii(e,i,s.parentId))throw Error(`Cannot move a directory into one of its descendants`);let f=Nt(e.snapshot.nodes,U(e,s.parentId)).get(d),p=s.existingNodeId??f??null;if(p!=null&&p!==i&&Yr(e,p,o,Jt(a))===`skip`)return null;let m=a.parentId;Wr(e,m,i,a.nameId),a.parentId=s.parentId,a.nameId=d,e.pathCacheByNodeId.delete(i),ri(e,i),Ur(e,s.parentId,i),Zr(e,m),e.pathCacheVersion++,Nr(e,m),s.parentId!==m&&Nr(e,s.parentId);let h=$r(e,m),g=$r(e,s.parentId);return rr({affectedAncestorIds:[...new Set([...Fr(e,m),...Fr(e,s.parentId)])],affectedNodeIds:[i],from:t,projectionChanged:ti([c,l],[h,g]),to:H(e,i)})}function jr(e,t){let n=e.pathCacheByNodeId.get(t);return n!=null&&n.version===e.pathCacheVersion?n.path:null}function Mr(e,t,n){return e.pathCacheByNodeId.set(t,{path:n,version:e.pathCacheVersion}),n}function H(e,t){let n=W(e,t),r=jr(e,t);if(r!=null)return r;if(B(n,2))return Mr(e,t,``);let i=H(e,n.parentId),a=Sn(e.snapshot.segmentTable,n.nameId),o=i.length===0?a:`${i}${a}`;return Mr(e,t,z(n)?`${o}/`:o)}function Nr(e,t){let n=e.instrumentation;if(n==null){oi(e,t);return}V(n,`store.recomputeCountsUpwardFrom`,()=>oi(e,t))}function Pr(e,t){let n=[[t,0]],{nodes:r,directories:i}=e.snapshot;for(;n.length>0;){let t=n[n.length-1],a=t[0],o=r[a];if(o==null||!z(o)){ai(e,a,o,!0),n.pop();continue}let s=i.get(a);if(s==null||t[1]>=s.childIds.length){ai(e,a,o,!0),n.pop();continue}let c=s.childIds[t[1]++];n.push([c,0])}}function Fr(e,t){let n=[],r=t;for(;r!=null;){let t=W(e,r);if(n.push(r),r===e.snapshot.rootId)break;r=t.parentId}return n}function Ir(e,t){if(t.length===0)return e.snapshot.rootId;let n=vn(t);return Lr(e,n.segments,n.requiresDirectory)}function Lr(e,t,n){let r=e.snapshot.rootId;for(let n of t){let t=e.snapshot.segmentTable.idByValue.get(n);if(t===void 0)return null;let i=U(e,r),a=Nt(e.snapshot.nodes,i).get(t);if(a===void 0)return null;r=a}let i=W(e,r);return n&&!z(i)?null:r}function U(e,t){let n=e.snapshot.directories.get(t);if(n===void 0)throw Error(`Unknown directory child index for node ${String(t)}`);return n}function W(e,t){let n=e.snapshot.nodes[t];if(n===void 0||B(n,4))throw Error(`Unknown node ID: ${String(t)}`);return n}function Rr(e,t){let n=e.snapshot.nodes[t];if(n===void 0||B(n,4))return[];if(!z(n))return[H(e,t)];if(U(e,t).childIds.length===0)return B(n,1)&&!B(n,2)?[H(e,t)]:[];let r=[],i=[{childIndex:0,nodeId:t}];for(;i.length>0;){let t=i[i.length-1];if(t==null)break;let n=e.snapshot.nodes[t.nodeId];if(n===void 0||B(n,4)){i.pop();continue}if(!z(n)){r.push(H(e,t.nodeId)),i.pop();continue}let a=U(e,t.nodeId);if(a.childIds.length===0){B(n,1)&&!B(n,2)&&r.push(H(e,t.nodeId)),i.pop();continue}let o=a.childIds[t.childIndex];if(o==null){i.pop();continue}t.childIndex++,i.push({childIndex:0,nodeId:o})}return r}function zr(e,t){let n=[],r=e.snapshot.rootId;for(let i of t){let t=xn(e.snapshot.segmentTable,i),a=U(e,r),o=Nt(e.snapshot.nodes,a).get(t);if(o!==void 0){if(!z(W(e,o)))throw Error(`Cannot create a directory that collides with an existing file: "${i}"`);r=o;continue}r=Br(e,r,t),n.push(r)}return{createdNodeIds:n,directoryId:r}}function Br(e,t,n){let r=W(e,t),i=e.snapshot.nodes.length;return e.snapshot.nodes.push({depthAndFlags:Kt(qt(r)+1,0,1),nameId:n,parentId:t,subtreeNodeCount:1,visibleSubtreeCount:1}),e.snapshot.directories.set(i,jt()),Ur(e,t,i),e.collapseNewDirectoriesByDefault&&(e.collapsedDirectoryIds.add(i),e.hasCollapsedDirectoryOverrides=!0),e.activeNodeCount++,i}function Vr(e,t,n){let r=xn(e.snapshot.segmentTable,n),i=U(e,t);if(Nt(e.snapshot.nodes,i).has(r))throw Error(`Path already exists: "${ci(e,t,n)}"`);let a=W(e,t),o=e.snapshot.nodes.length;return e.snapshot.nodes.push({depthAndFlags:Kt(qt(a)+1,0),nameId:r,parentId:t,subtreeNodeCount:1,visibleSubtreeCount:1}),Ur(e,t,o),e.activeNodeCount++,o}function Hr(e,t,n){let r=0,i=t.childIds.length;for(;r<i;){let a=r+i>>>1,o=t.childIds[a];if(o==null){i=a;continue}Gr(e,n,o)<0?i=a:r=a+1}return r}function Ur(e,t,n){let r=U(e,t),i=W(e,n);Nt(e.snapshot.nodes,r).set(i.nameId,n),Rt(r,n,i.subtreeNodeCount,i.visibleSubtreeCount);let a=Hr(e,r,n);r.childIds.splice(a,0,n),It(r,a),Vt(e.snapshot.nodes,r)}function Wr(e,t,n,r){let i=U(e,t),a=Pt(i),o=a.get(n)??-1;Nt(e.snapshot.nodes,i).delete(r),a.delete(n);let s=e.snapshot.nodes[n];s!=null&&Rt(i,n,-s.subtreeNodeCount,-s.visibleSubtreeCount),o>=0&&(i.childIds.splice(o,1),It(i,o),Vt(e.snapshot.nodes,i))}function Gr(e,t,n){let r=e.snapshot.options.sort;return r===`default`?Kr(e,t,n):r(qr(e,t),qr(e,n))}function Kr(e,t,n){let r=W(e,t),i=W(e,n),a=z(r);if(a!==z(i))return a?-1:1;let o=sn(mn(e.snapshot.segmentTable,r.nameId),mn(e.snapshot.segmentTable,i.nameId));if(o!==0)return o;let s=Sn(e.snapshot.segmentTable,r.nameId),c=Sn(e.snapshot.segmentTable,i.nameId);return s===c?t<n?-1:1:s<c?-1:1}function qr(e,t){let n=W(e,t),r=H(e,t),i=z(n),a=i?r.slice(0,-1):r;return{basename:Sn(e.snapshot.segmentTable,n.nameId),depth:qt(n),isDirectory:i,path:r,segments:a.length===0?[]:a.split(`/`)}}function Jr(e,t,n){let r=W(e,t),i=Ir(e,n);if(i!=null){let t=W(e,i);if(z(t))return{basename:Sn(e.snapshot.segmentTable,r.nameId),existingNodeId:null,parentId:i};let a=vn(n).segments;return{basename:a[a.length-1]??``,existingNodeId:i,parentId:t.parentId}}let a=vn(n),o=a.segments[a.segments.length-1]??``,s=a.segments.slice(0,-1),c=s.length===0?e.snapshot.rootId:Lr(e,s,!0);if(c==null)throw Error(`Destination parent does not exist: "${n}"`);return{basename:o,existingNodeId:null,parentId:c}}function Yr(e,t,n,r){if(n===`skip`)return`skip`;if(n===`error`)throw Error(`Destination already exists: "${H(e,t)}"`);let i=W(e,t);if(Jt(i)!==r)throw Error(`replace collision requires the same source and destination kinds`);if(z(i)&&U(e,t).childIds.length>0)throw Error(`replace collision does not support non-empty directories`);let a=i.parentId,o=i.nameId;return Xr(e,t),Wr(e,a,t,o),Zr(e,a),Nr(e,a),`handled`}function Xr(e,t){let n=[],r=[{nodeId:t,visitedChildren:!1}];for(;r.length>0;){let t=r.pop();if(t==null)break;let i=W(e,t.nodeId);if(t.visitedChildren||!z(i)){z(i)&&e.snapshot.directories.delete(t.nodeId),Xt(i,4),e.pathCacheByNodeId.delete(t.nodeId),e.collapsedDirectoryIds.delete(t.nodeId)&&(e.hasCollapsedDirectoryOverrides=e.collapsedDirectoryIds.size>0),e.expandedDirectoryIds.delete(t.nodeId),$n(e,t.nodeId),e.activeNodeCount--,n.push(t.nodeId);continue}r.push({nodeId:t.nodeId,visitedChildren:!0});let a=U(e,t.nodeId);for(let e=a.childIds.length-1;e>=0;e--){let t=a.childIds[e];t!=null&&r.push({nodeId:t,visitedChildren:!1})}}return n}function Zr(e,t){let n=t;for(;n!=null;){let t=W(e,n);if(!z(t)||B(t,2)||U(e,n).childIds.length>0)return;Xt(t,1),n=t.parentId===n?null:t.parentId}}function Qr(e,t){let n=e.snapshot.rootId;for(let r of t){let t=e.snapshot.segmentTable.idByValue.get(r);if(t==null)break;let i=Nt(e.snapshot.nodes,U(e,n)).get(t);if(i==null||!z(W(e,i)))break;n=i}return n}function $r(e,t){let n=ni(e,t);if(n==null)return null;let r=Tr(e,n),i=W(e,r),a=n===r?null:Er(e,n).map(t=>H(e,t));return JSON.stringify({flattenedSegmentPaths:a,hasChildren:U(e,r).childIds.length>0,path:H(e,r),terminalKind:Jt(i)})}function ei(e,t){return ti([e],[t])}function ti(e,t){for(let n=0;n<e.length;n+=1){let r=e[n],i=t[n];if(r==null||i==null||r!==i)return!0}return!1}function ni(e,t){let n=t;for(;n!=null;){let t=W(e,n);if(!z(t)||B(t,2))return null;if(!Wn(e,n,t))return n;n=t.parentId}return null}function ri(e,t){let n=W(e,t);if(Zt(n,(t===e.snapshot.rootId?-1:qt(W(e,n.parentId)))+1),!z(n))return;let r=U(e,t);for(let t of r.childIds)ri(e,t)}function ii(e,t,n){let r=n;for(;r!=null;){if(r===t)return!0;let n=W(e,r);if(r===e.snapshot.rootId)return!1;r=n.parentId}return!1}function ai(e,t,n=W(e,t),r=!1){let i=e.instrumentation;if(i==null){si(e,t,n,r);return}V(i,`store.recomputeNodeCounts`,()=>si(e,t,n,r))}function oi(e,t){let n=t;for(;n!=null;){let t=W(e,n),r=t.subtreeNodeCount,i=t.visibleSubtreeCount;if(ai(e,n,t),n===e.snapshot.rootId)return;let a=t.subtreeNodeCount-r,o=t.visibleSubtreeCount-i,s=t.parentId;(a!==0||o!==0)&&Rt(U(e,s),n,a,o),n=s}}function si(e,t,n,r){if(!z(n)){n.subtreeNodeCount=1,n.visibleSubtreeCount=1;return}let i=U(e,t);if(r){let t=e.instrumentation;t==null?Lt(e.snapshot.nodes,i):V(t,`store.recomputeNodeCounts.rebuildChildAggregates`,()=>Lt(e.snapshot.nodes,i))}let a=1+i.totalChildSubtreeNodeCount,o=i.totalChildVisibleSubtreeCount;if(n.subtreeNodeCount=a,B(n,2)){n.visibleSubtreeCount=o;return}n.visibleSubtreeCount=wr(e,t)==null?Wn(e,t,n)?1+o:1:o}function ci(e,t,n){let r=H(e,t);return r.length===0?n:`${r}${n}`}function li(e){return e!=null&&!B(e,4)}function ui(e,t){let n=e.snapshot.nodes[t];return!li(n)||!z(n)||B(n,2)?null:n}function di(e){let t=0;for(let[n,r]of e.pathCacheByNodeId)r.version===e.pathCacheVersion&&li(e.snapshot.nodes[n])&&(t+=1);return t}function fi(e){return Math.max(0,e.valueById.length-1)}function pi(e){return{activeNodeCount:e.activeNodeCount,cachedPathEntryCount:di(e),loadInfoEntryCount:e.directoryLoadInfoById.size,segmentCount:fi(e.snapshot.segmentTable),totalNodeSlotCount:Math.max(0,e.snapshot.nodes.length-1)}}function mi(e,t,n,r){return{activeNodeCountAfter:r.activeNodeCount,activeNodeCountBefore:n.activeNodeCount,cachedPathEntryCountAfter:r.cachedPathEntryCount,cachedPathEntryCountBefore:n.cachedPathEntryCount,idsPreserved:t,loadInfoEntryCountAfter:r.loadInfoEntryCount,loadInfoEntryCountBefore:n.loadInfoEntryCount,mode:e,reclaimedCachedPathEntryCount:n.cachedPathEntryCount-r.cachedPathEntryCount,reclaimedLoadInfoEntryCount:n.loadInfoEntryCount-r.loadInfoEntryCount,reclaimedNodeSlotCount:n.totalNodeSlotCount-r.totalNodeSlotCount,reclaimedSegmentCount:n.segmentCount-r.segmentCount,segmentCountAfter:r.segmentCount,segmentCountBefore:n.segmentCount,totalNodeSlotCountAfter:r.totalNodeSlotCount,totalNodeSlotCountBefore:n.totalNodeSlotCount}}function hi(e){let t=[],n=[];for(let n of e.collapsedDirectoryIds)ui(e,n)!=null&&t.push(H(e,n));for(let t of e.expandedDirectoryIds)ui(e,t)!=null&&n.push(H(e,t));return{collapsedPaths:t,expandedPaths:n}}function gi(e){let t=[];for(let[n,r]of e.directoryLoadInfoById)ui(e,n)==null||qn(e,n)===`loaded`||t.push({info:{activeAttemptId:null,errorMessage:r.errorMessage,nextAttemptId:r.nextAttemptId,state:r.state},path:H(e,n)});return t}function _i(e,t){e.collapsedDirectoryIds.clear(),e.hasCollapsedDirectoryOverrides=!1,e.expandedDirectoryIds.clear();for(let n of t.expandedPaths){let t=Ir(e,n);t!=null&&Gn(e,t,!0,W(e,t))}for(let n of t.collapsedPaths){let t=Ir(e,n);t!=null&&Gn(e,t,!1,W(e,t))}}function vi(e,t){e.directoryLoadInfoById.clear();for(let n of t){let t=Ir(e,n.path);t!=null&&ui(e,t)!=null&&e.directoryLoadInfoById.set(t,{activeAttemptId:null,errorMessage:n.info.errorMessage,nextAttemptId:n.info.nextAttemptId,state:n.info.state})}}function yi(e){e.pathCacheVersion+=1,e.pathCacheByNodeId.clear(),e.pathCacheByNodeId.set(e.snapshot.rootId,{path:``,version:e.pathCacheVersion})}function bi(e){let t=e.snapshot.segmentTable,n=bn();for(let r of e.snapshot.nodes)if(li(r)){if(B(r,2)){r.nameId=0;continue}r.nameId=xn(n,Sn(t,r.nameId))}e.snapshot.segmentTable=n}function xi(e){for(let[t,n]of e.snapshot.directories){let r=e.snapshot.nodes[t];if(!li(r)||!z(r)){e.snapshot.directories.delete(t);continue}let i=n.childIds.filter(n=>{let r=e.snapshot.nodes[n];return li(r)&&r.parentId===t});n.childIds=i,n.childIdByNameId=new Map(i.map(t=>[W(e,t).nameId,t])),n.childPositionById=new Map(i.map((e,t)=>[e,t])),Lt(e.snapshot.nodes,n)}}function Si(e){let t=e.snapshot.nodes.length-1;for(;t>e.snapshot.rootId;){let n=e.snapshot.nodes[t];if(li(n))break;--t}e.snapshot.nodes.length=t+1}function Ci(e){let t=hi(e),n=gi(e);V(e.instrumentation,`store.cleanup.stable.clearPathCaches`,()=>yi(e)),V(e.instrumentation,`store.cleanup.stable.rebuildSegmentTable`,()=>bi(e)),V(e.instrumentation,`store.cleanup.stable.rebuildDirectoryIndexes`,()=>xi(e)),V(e.instrumentation,`store.cleanup.stable.trimTrailingRemovedNodeSlots`,()=>Si(e)),V(e.instrumentation,`store.cleanup.stable.restoreExpansionOverrides`,()=>_i(e,t)),V(e.instrumentation,`store.cleanup.stable.restoreDirectoryLoadInfos`,()=>vi(e,n)),V(e.instrumentation,`store.cleanup.stable.recomputeCounts`,()=>Pr(e,e.snapshot.rootId))}function wi(e){let t=hi(e),n=gi(e),r=V(e.instrumentation,`store.cleanup.aggressive.listPaths`,()=>Dr(e)),i=$t({...e.snapshot.options},e.instrumentation),a=V(e.instrumentation,`store.cleanup.aggressive.rebuildSnapshot`,()=>{let e=new zn(i);return e.appendPaths(r),e.finish()});e.snapshot=a,e.activeNodeCount=a.nodes.length-1,e.pathCacheByNodeId=new Map([[a.rootId,{path:``,version:0}]]),e.pathCacheVersion=0,V(e.instrumentation,`store.cleanup.aggressive.restoreExpansionOverrides`,()=>_i(e,t)),V(e.instrumentation,`store.cleanup.aggressive.restoreDirectoryLoadInfos`,()=>vi(e,n)),V(e.instrumentation,`store.cleanup.aggressive.recomputeCounts`,()=>Pr(e,e.snapshot.rootId))}function Ti(e){for(let t of e.directoryLoadInfoById.values())if(t.state===`loading`&&t.activeAttemptId!=null)return!0;return!1}function Ei(e,t){let n=pi(e);t===`stable`?V(e.instrumentation,`store.cleanup.stable`,()=>Ci(e)):V(e.instrumentation,`store.cleanup.aggressive`,()=>wi(e));let r=pi(e);return mi(t,t===`stable`,n,r)}var Di=64;function Oi(e,t){let n=t+2;if(n<=e.length)return e;let r=e.length;for(;r<n;)r*=2;let i=new Int32Array(r);return i.fill(-1),i.set(e),i}function ki(e){return W(e,e.snapshot.rootId).visibleSubtreeCount}function Ai(e,t,n,r){let i=W(e,t.terminalNodeId),a=Math.max(1,i.visibleSubtreeCount);return Math.min(r-1,n+a-1)}function ji(e,t,n,r){return{ancestorPaths:r,index:t.index,posInSet:t.posInSet,row:Ji(e,t.cursor),setSize:t.setSize,subtreeEndIndex:Ai(e,t.cursor,t.index,n)}}function Mi(e,t,n,r,i,a){let o=U(e,t),{childIndex:s,childVisibleIndex:c,localVisibleIndex:l}=zt(e.snapshot.nodes,o,n),u=o.childIds[s];if(u==null)throw Error(`Visible index ${String(n)} is out of range`);return Ni(e,u,l,r+c,i+1,s,o.childIds.length,a)}function Ni(e,t,n,r,i,a,o,s){if(!z(W(e,t))){if(n===0)return{ancestors:s,cursor:{headNodeId:t,terminalNodeId:t,visibleDepth:i},index:r,posInSet:a,setSize:o};throw Error(`Visible index ${String(n)} is out of range for file`)}let c=G(e,t,i);if(n===0)return{ancestors:s,cursor:c,index:r,posInSet:a,setSize:o};let l=W(e,c.terminalNodeId);if(!z(l)||!Wn(e,c.terminalNodeId,l))throw Error(`Visible index ${String(n)} is out of range for collapsed directory`);return Mi(e,c.terminalNodeId,n-1,r+1,c.visibleDepth,[...s,{cursor:c,index:r,posInSet:a,setSize:o}])}function Pi(e,t){let n=ki(e);if(t<0||t>=n)return null;let r=Mi(e,e.snapshot.rootId,t,0,-1,[]),i=r.ancestors.map(t=>H(e,t.cursor.terminalNodeId)),a=null;return{ancestorPaths:i,get ancestorRows(){if(a!=null)return a;let t=[],i=[];for(let a of r.ancestors){let r=ji(e,a,n,[...i]);t.push(r),i.push(r.row.path)}return a=t,a},index:r.index,posInSet:r.posInSet,row:Ji(e,r.cursor),setSize:r.setSize,subtreeEndIndex:Ai(e,r.cursor,r.index,n)}}function Fi(e,t,n){let r=e.instrumentation,i=ki(e);if(i<=0||n<t)return[];let a=Math.max(0,Math.min(t,i-1)),o=Math.max(a,Math.min(n,i-1));if(r==null){if(a===0)return qi(e,o+1);let t=[],n=Vi(e,a);for(let r=a;r<=o&&n!=null;r++){let r=Ji(e,n);t.push(r),n=Wi(e,n)}return t}let s=[],c=0,l=0,u=V(r,`store.getVisibleSlice.selectFirstRow`,()=>Vi(e,a));for(let t=a;t<=o&&u!=null;t++){let t=V(r,`store.getVisibleSlice.materializeRow`,()=>Ji(e,u));s.push(t),t.isFlattened&&(c++,l+=t.flattenedSegments?.length??0),u=V(r,`store.getVisibleSlice.advanceCursor`,()=>Wi(e,u))}return tn(r,`workload.visibleRowsRead`,s.length),tn(r,`workload.flattenedRowsRead`,c),tn(r,`workload.flattenedSegmentsRead`,l),s}function Ii(e,t=ki(e)){let n=e.instrumentation;return n==null?Ki(e,t):V(n,`store.getVisibleTreeProjection`,()=>Ki(e,t))}function Li(e){return Gi(Ii(e))}function Ri(e,t){let n=Ir(e,t);if(n==null||n===e.snapshot.rootId||z(W(e,n))&&Tr(e,n)!==n)return null;let r=0,i=n,{nodes:a,rootId:o}=e.snapshot;for(;i!==o;){let t=W(e,i).parentId,n=U(e,t),s=Pt(n).get(i);if(s==null)throw Error(`Child ${String(i)} was not found in its parent index`);if(r+=Bt(a,n,s),t!==o){let n=W(e,t),a=wr(e,t);if(!Wn(e,t,n)&&a!==i)return null;Tr(e,t)===t&&(r+=1)}i=t}return r}function zi(e,t){let n=Ir(e,t);if(n==null)throw Error(`Path does not exist: "${t}"`);let r=W(e,n);if(!z(r))throw Error(`Path is not a directory: "${t}"`);return Wn(e,n,r)?null:(Gn(e,n,!0,r),Nr(e,n),ir({affectedAncestorIds:Fr(e,n),affectedNodeIds:[n],path:t,projectionChanged:!0}))}function Bi(e,t){let n=Ir(e,t);if(n==null)throw Error(`Path does not exist: "${t}"`);let r=W(e,n);if(!z(r))throw Error(`Path is not a directory: "${t}"`);return Wn(e,n,r)?(Gn(e,n,!1,r),Nr(e,n),ar({affectedAncestorIds:Fr(e,n),affectedNodeIds:[n],path:t,projectionChanged:!0})):null}function Vi(e,t){return t<0||t>=ki(e)?null:Hi(e,e.snapshot.rootId,t,-1)}function Hi(e,t,n,r){let i=U(e,t),a=e.instrumentation,{childIndex:o,localVisibleIndex:s}=a==null?zt(e.snapshot.nodes,i,n):V(a,`store.getVisibleSlice.selectChildIndex`,()=>zt(e.snapshot.nodes,i,n)),c=i.childIds[o];if(c!=null)return Ui(e,c,s,r+1);throw Error(`Visible index ${String(n)} is out of range`)}function Ui(e,t,n,r){if(!z(W(e,t))){if(n===0)return{headNodeId:t,terminalNodeId:t,visibleDepth:r};throw Error(`Visible index ${String(n)} is out of range for file`)}let i=G(e,t,r);if(n===0)return i;let a=W(e,i.terminalNodeId);if(!z(a)||!Wn(e,i.terminalNodeId,a))throw Error(`Visible index ${String(n)} is out of range for collapsed directory`);return Hi(e,i.terminalNodeId,n-1,i.visibleDepth)}function G(e,t,n){return z(W(e,t))?e.instrumentation==null?{headNodeId:t,terminalNodeId:Tr(e,t),visibleDepth:n}:{headNodeId:t,terminalNodeId:V(e.instrumentation,`store.getVisibleSlice.flatten.resolveTerminalDirectory`,()=>Tr(e,t)),visibleDepth:n}:{headNodeId:t,terminalNodeId:t,visibleDepth:n}}function K(e,t){let n=W(e,t);if(!z(n))return!0;let r=n.parentId;return r===e.snapshot.rootId?!0:wr(e,r)!==t}function Wi(e,t){let n=W(e,t.terminalNodeId);if(z(n)){let r=U(e,t.terminalNodeId);if(Wn(e,t.terminalNodeId,n)&&r.childIds.length>0){let n=r.childIds[0];return n==null?null:Ui(e,n,0,t.visibleDepth+1)}}let r=t.terminalNodeId,i=t.visibleDepth;for(;;){let t=W(e,r);if(r===e.snapshot.rootId)return null;let n=t.parentId,a=U(e,n),o=Pt(a).get(r)??-1;if(o<0)throw Error(`Child ${String(r)} was not found in its parent index`);let s=a.childIds[o+1]??null;if(s!=null)return Ui(e,s,0,i);K(e,r)&&i--,r=n}}function Gi(e){let t=e.paths.length,n=Array(t);for(let r=0;r<t;r+=1){let t=e.getParentIndex(r);n[r]={index:r,parentPath:t>=0?e.paths[t]??null:null,path:e.paths[r]??``,posInSet:e.posInSetByIndex[r]??0,setSize:e.setSizeByIndex[r]??0}}return{getParentIndex:e.getParentIndex,rows:n,get visibleIndexByPath(){return e.visibleIndexByPath}}}function Ki(e,t){let n=Array(t),r=new Int32Array(t),i=new Int32Array(t),a=new Int32Array(t),o=new Int32Array(Di);o.fill(-1);let s=0,{nodes:c,directories:l,segmentTable:u}=e.snapshot,d=[[l.get(e.snapshot.rootId),0,-1,``]],f=e.snapshot.options.flattenEmptyDirectories,p=e.pathCacheByNodeId,m=e.pathCacheVersion,h=u.valueById;for(;d.length>0&&s<t;){let t=d[d.length-1],u=t[0];if(t[1]>=u.childIds.length){d.pop();continue}let g=t[1],_=u.childIds[t[1]++],v=c[_],y=t[2]+1,b=t[3];o=Oi(o,y);let x,S=_;if(z(v))S=f?Tr(e,_):_,x=S===_?`${b}${h[v.nameId]}/`:H(e,S);else{let e=p.get(_);x=e!=null&&e.version===m?e.path:`${b}${h[v.nameId]}`}r[s]=o[y],n[s]=x,i[s]=g,a[s]=u.childIds.length,o[y+1]=s,s+=1;let C=c[S];C!=null&&z(C)&&Wn(e,S,C)&&d.push([l.get(S),0,y,x])}s<t&&(n.length=s);let g=r.subarray(0,s),_=i.subarray(0,s),v=a.subarray(0,s),y=null;return{getParentIndex(e){return e<0||e>=s?-1:g[e]??-1},paths:n,posInSetByIndex:_,setSizeByIndex:v,get visibleIndexByPath(){if(y==null){y=new Map;for(let e=0;e<s;e+=1)y.set(n[e]??``,e)}return y}}}function qi(e,t){let n=Array(t),r=0,{nodes:i,directories:a,segmentTable:o}=e.snapshot,s=[[a.get(e.snapshot.rootId),0,-1]],c=o.valueById,l=e.snapshot.options.flattenEmptyDirectories,u=e.pathCacheByNodeId,d=e.pathCacheVersion;for(;s.length>0&&r<t;){let t=s[s.length-1],o=t[0];if(t[1]>=o.childIds.length){s.pop();continue}let f=o.childIds[t[1]++],p=i[f],m=t[2]+1;if(!z(p)){let t=u.get(f);n[r++]={depth:m,flattenedSegments:void 0,hasChildren:!1,id:f,isExpanded:!1,isFlattened:!1,isLoading:!1,kind:`file`,loadState:void 0,name:c[p.nameId],path:t!=null&&t.version===d?t.path:H(e,f)};continue}let h=l?Tr(e,f):f,g={headNodeId:f,terminalNodeId:h,visibleDepth:m};n[r++]=Ji(e,g);let _=i[h];_!=null&&z(_)&&Wn(e,h,_)&&s.push([a.get(h),0,m])}return r<t&&(n.length=r),n}function Ji(e,t){let n=W(e,t.terminalNodeId),r=z(n)?Yi(e,t):null,i=H(e,t.terminalNodeId),a=Sn(e.snapshot.segmentTable,n.nameId),o=z(n)&&U(e,t.terminalNodeId).childIds.length>0,s=t.headNodeId!==t.terminalNodeId,c=e.instrumentation,l=s?c==null?Er(e,t.headNodeId).map(n=>{let r=W(e,n);return{isTerminal:n===t.terminalNodeId,name:Sn(e.snapshot.segmentTable,r.nameId),nodeId:n,path:H(e,n)}}):V(c,`store.getVisibleSlice.flatten.collectSegments`,()=>Er(e,t.headNodeId).map(n=>{let r=W(e,n);return{isTerminal:n===t.terminalNodeId,name:Sn(e.snapshot.segmentTable,r.nameId),nodeId:n,path:H(e,n)}})):void 0;return{depth:t.visibleDepth,flattenedSegments:l,hasChildren:o,id:t.terminalNodeId,isExpanded:z(n)&&Wn(e,t.terminalNodeId,n),isFlattened:s,isLoading:r===`loading`,kind:z(n)?`directory`:`file`,loadState:r==null||r===`loaded`?void 0:r,name:a,path:i}}function Yi(e,t){if(t.headNodeId===t.terminalNodeId)return qn(e,t.terminalNodeId);let n=Er(e,t.headNodeId),r=!1,i=!1;for(let t of n){let n=qn(e,t);if(n===`loading`)return`loading`;if(n===`error`){i=!0;continue}n===`unloaded`&&(r=!0)}return i?`error`:r?`unloaded`:`loaded`}function Xi(e){let{directories:t,nodes:n,options:r,rootId:i,presortedDirectoryNodeIds:a}=e.snapshot,o=r.flattenEmptyDirectories===!0,s=e=>{let r=n[e];if(r==null||!z(r))return;let i=t.get(e);if(i==null)throw Error(`Unknown directory child index for node ${String(e)}`);let a=i.childIds,s=a.length,c=0,l=0;for(let e=0;e<s;e++){let t=a[e];if(t==null)continue;let r=n[t];c+=r.subtreeNodeCount,l+=r.visibleSubtreeCount}i.totalChildSubtreeNodeCount=c,i.totalChildVisibleSubtreeCount=l,s>=128&&Vt(n,i),r.subtreeNodeCount=1+c;let u;if(o&&s===1){let e=n[a[0]];u=e!=null&&z(e)?l:1+l}else u=1+l;r.visibleSubtreeCount=u};if(a!=null)for(let e=a.length-1;e>=0;e--)s(a[e]);else for(let e=n.length-1;e>=1;e--)s(e);let c=n[i],l=t.get(i);if(c==null||l==null)return;let u=l.childIds,d=0,f=0;for(let e=0;e<u.length;e++){let t=u[e];if(t==null)continue;let r=n[t];d+=r.subtreeNodeCount,f+=r.visibleSubtreeCount}l.totalChildSubtreeNodeCount=d,l.totalChildVisibleSubtreeCount=f,Vt(n,l),c.subtreeNodeCount=1+d,c.visibleSubtreeCount=f}function Zi(e){return e.initialExpansion===`open`&&(e.initialExpandedPaths==null||e.initialExpandedPaths.length===0)}var Qi=class e{#e;constructor(e={}){let t=en(e),n=V(t,`store.builder.create`,()=>new zn(e));if(e.preparedInput!=null){let t=In(e.preparedInput);t==null?n.appendPreparedPaths(Fn(e.preparedInput),!1):n.appendPresortedPaths(t,Ln(e.preparedInput))}else{let r=e.paths??[];e.presorted===!0?n.appendPaths(r):n.appendPreparedPaths(V(t,`store.preparePathEntries`,()=>Rn(r,e)))}let r=V(t,`store.builder.finish`,()=>n.finish({skipSubtreeCountPass:!0})),i=V(t,`store.state.detectAllDirectoriesExpanded`,()=>(e.initialExpansion??`closed`)===`closed`&&n.didMatchAllInitialExpandedPaths());this.#e=V(t,`store.state.create`,()=>Bn(r,i?`open`:e.initialExpansion??`closed`,t)),i&&(this.#e.collapseNewDirectoriesByDefault=!0);let a=i?this.#e.snapshot.directories.size-1:V(t,`store.state.initializeExpandedPaths`,()=>this.initializeExpandedPaths(e.initialExpandedPaths));i||Zi(e)||(e.initialExpansion??`closed`)===`closed`&&a===this.#e.snapshot.directories.size-1||(e.initialExpandedPaths?.length??0)>0&&V(t,`store.state.checkAllDirectoriesExpanded`,()=>this.hasAllDirectoriesExpanded())?V(t,`store.state.initializeOpenVisibleCounts`,()=>Xi(this.#e)):V(t,`store.state.recomputeCounts`,()=>Pr(this.#e,this.#e.snapshot.rootId))}static preparePaths(e,t={}){return Mn(e,t)}static prepareInput(e,t={}){return Nn(e,t)}static preparePresortedInput(e){return Pn(e)}list(e){return V(this.#e.instrumentation,`store.list`,()=>Dr(this.#e,e))}add(e){V(this.#e.instrumentation,`store.add`,()=>{let t=ki(this.#e);mr(this.#e,fr(this.#e,t,Or(this.#e,e)))})}remove(e,t={}){V(this.#e.instrumentation,`store.remove`,()=>{let n=ki(this.#e);mr(this.#e,fr(this.#e,n,kr(this.#e,e,t)))})}move(e,t,n={}){V(this.#e.instrumentation,`store.move`,()=>{let r=ki(this.#e),i=Ar(this.#e,e,t,n);i!=null&&mr(this.#e,fr(this.#e,r,i))})}batch(e){pr(this.#e,()=>{if(typeof e==`function`){e(this);return}for(let t of e)switch(t.type){case`add`:this.add(t.path);break;case`remove`:this.remove(t.path,{recursive:t.recursive});break;case`move`:this.move(t.from,t.to,{collision:t.collision});break}})}getVisibleCount(){return V(this.#e.instrumentation,`store.getVisibleCount`,()=>ki(this.#e))}getVisibleSlice(e,t){return V(this.#e.instrumentation,`store.getVisibleSlice`,()=>Fi(this.#e,e,t))}getVisibleRowContext(e){return V(this.#e.instrumentation,`store.getVisibleRowContext`,()=>Pi(this.#e,e))}getVisibleTreeProjection(){return Li(this.#e)}getVisibleTreeProjectionData(e){return Ii(this.#e,e)}getVisibleIndex(e){return V(this.#e.instrumentation,`store.getVisibleIndex`,()=>Ri(this.#e,e))}getPathInfo(e){return V(this.#e.instrumentation,`store.getPathInfo`,()=>{let t=Ir(this.#e,e);if(t==null)return null;let n=W(this.#e,t);return{depth:qt(n),kind:z(n)?`directory`:`file`,path:H(this.#e,t)}})}isExpanded(e){return V(this.#e.instrumentation,`store.isExpanded`,()=>{let t=this.requireDirectoryNodeId(e),n=W(this.#e,t);return Wn(this.#e,t,n)})}expand(e){V(this.#e.instrumentation,`store.expand`,()=>{let t=ki(this.#e),n=zi(this.#e,e);n!=null&&mr(this.#e,fr(this.#e,t,n))})}collapse(e){V(this.#e.instrumentation,`store.collapse`,()=>{let t=ki(this.#e),n=Bi(this.#e,e);n!=null&&mr(this.#e,fr(this.#e,t,n))})}on(e,t){return er(this.#e,e,t)}getDirectoryLoadState(e){let t=this.requireDirectoryNodeId(e);return qn(this.#e,t)}markDirectoryUnloaded(e){V(this.#e.instrumentation,`store.markDirectoryUnloaded`,()=>{let t=this.requireDirectoryNodeId(e);if(U(this.#e,t).childIds.length>0)throw Error(`Cannot mark a directory with known children as unloaded: "${e}"`);let n=ki(this.#e);Yn(this.#e,t),mr(this.#e,fr(this.#e,n,or({affectedAncestorIds:Fr(this.#e,t),affectedNodeIds:[t],path:e,projectionChanged:this.isDirectoryProjectionVisible(t)})))})}beginChildLoad(e){return V(this.#e.instrumentation,`store.beginChildLoad`,()=>{let t=this.requireDirectoryNodeId(e),n=ki(this.#e),r=Jn(this.#e,t);return mr(this.#e,fr(this.#e,n,sr({affectedAncestorIds:Fr(this.#e,t),affectedNodeIds:[t],attemptId:r.attemptId,path:e,projectionChanged:this.isDirectoryProjectionVisible(t),reused:r.reused}))),r})}applyChildPatch(e,t){return V(this.#e.instrumentation,`store.applyChildPatch`,()=>{let n=this.resolveActiveDirectoryNodeId(e.nodeId);if(n==null||qn(this.#e,n)!==`loading`||!Zn(this.#e,n,e.attemptId))return!1;let r=H(this.#e,n);this.validateChildPatch(r,t);let i=ki(this.#e),a=[];for(let e of t.operations){$i(r,e);let t=ki(this.#e);switch(e.type){case`add`:a.push(fr(this.#e,t,Or(this.#e,e.path)));break;case`remove`:a.push(fr(this.#e,t,kr(this.#e,e.path,{recursive:e.recursive})));break;case`move`:{let n=Ar(this.#e,e.from,e.to,{collision:e.collision});n!=null&&a.push(fr(this.#e,t,n));break}}}let o=a.some(e=>e.projectionChanged)||this.isDirectoryProjectionVisible(n);return mr(this.#e,fr(this.#e,i,cr({affectedAncestorIds:Fr(this.#e,n),affectedNodeIds:[n],attemptId:e.attemptId,childEvents:a,path:H(this.#e,n),projectionChanged:o}))),!0})}completeChildLoad(e){return V(this.#e.instrumentation,`store.completeChildLoad`,()=>{let t=this.resolveActiveDirectoryNodeId(e.nodeId);if(t==null)return!1;let n=ki(this.#e),r=Xn(this.#e,t,e.attemptId);return mr(this.#e,fr(this.#e,n,lr({affectedAncestorIds:Fr(this.#e,t),affectedNodeIds:[t],attemptId:e.attemptId,path:H(this.#e,t),projectionChanged:this.isDirectoryProjectionVisible(t),stale:!r}))),r})}failChildLoad(e,t){return V(this.#e.instrumentation,`store.failChildLoad`,()=>{let n=this.resolveActiveDirectoryNodeId(e.nodeId);if(n==null)return!1;let r=ki(this.#e),i=Qn(this.#e,n,e.attemptId,t);return mr(this.#e,fr(this.#e,r,ur({affectedAncestorIds:Fr(this.#e,n),affectedNodeIds:[n],attemptId:e.attemptId,errorMessage:t,path:H(this.#e,n),projectionChanged:this.isDirectoryProjectionVisible(n),stale:!i}))),i})}cleanup(e={}){return V(this.#e.instrumentation,`store.cleanup`,()=>{if(this.#e.transactionStack.length>0)throw Error(`Cleanup cannot run during an open batch or transaction.`);if(Ti(this.#e))throw Error(`Cleanup cannot run while directory loads are active.`);let t=ki(this.#e),n=Ei(this.#e,e.mode??`stable`);return mr(this.#e,fr(this.#e,t,dr({...n,affectedAncestorIds:[],affectedNodeIds:[],projectionChanged:n.idsPreserved===!1}))),n})}getNodeCount(){return this.#e.activeNodeCount}initializeExpandedPaths(e){if(e==null||e.length===0)return 0;let t=0,n=[],r=[],i=0,a=null,o=this.#e.snapshot.segmentTable,s=o.valueById,c=this.#e.snapshot.nodes,l=new Map;for(let u of e){a!=null&&u<a&&(a=null,i=0,n.length=0,r.length=0);let e=u.length>0&&u.charCodeAt(u.length-1)===47?u.length-1:u.length;if(e===0){a=u,i=e,n.length=0,r.length=0;continue}let d=0,f=0;if(a!=null){let t=Math.min(e,i),n=!0;for(let e=0;e<t;e+=1){let t=u.charCodeAt(e);if(t!==a.charCodeAt(e)){n=!1;break}t===47&&(d+=1,f=e+1)}n&&(t===i&&e>t&&u.charCodeAt(t)===47?(d+=1,f=t+1):t===e&&i>t&&a.charCodeAt(t)===47&&(d+=1,f=e+1)),d=Math.min(d,r.length)}let p=d===0?this.#e.snapshot.rootId:r[d-1]??this.#e.snapshot.rootId,m=d,h=!0,g=f;for(;g<=e;){let t=u.indexOf(`/`,g),i=t===-1||t>e?e:t,a=u.slice(g,i),f=U(this.#e,p).childIds,_=m===d?n[m]??0:0,v=_,y,b=l.get(a)??an(a);l.set(a,b);let x=(e,t)=>{for(v=e;v<t;v+=1){let e=f[v],t=c[e],n=s[t.nameId];if(n===a)return y=e,!0;let r=sn(mn(o,t.nameId),b);if(r>0||r===0&&n>a)return!1}return!1};if(!x(_,f.length)&&_>0&&x(0,_),y===void 0){h=!1;break}if(!z(W(this.#e,y))){h=!1;break}if(n[m]=v,r[m]=y,p=y,m+=1,i===e)break;g=i+1}if(a=u,i=e,n.length=m,r.length=m,!h){a=null,i=0,n.length=0,r.length=0;continue}for(let e=d;e<m;e+=1){let n=r[e];if(n==null)continue;let i=W(this.#e,n);Wn(this.#e,n,i)||(Gn(this.#e,n,!0,i),t+=1)}}return t}hasAllDirectoriesExpanded(){for(let e of this.#e.snapshot.directories.keys()){if(e===this.#e.snapshot.rootId)continue;let t=W(this.#e,e);if(!Wn(this.#e,e,t))return!1}return!0}requireDirectoryNodeId(e){let t=Ir(this.#e,e);if(t==null)throw Error(`Path does not exist: "${e}"`);if(!z(W(this.#e,t)))throw Error(`Path is not a directory: "${e}"`);return t}resolveActiveDirectoryNodeId(e){try{if(!z(W(this.#e,e)))throw Error(`Node is not a directory: ${String(e)}`);return e}catch{return null}}isDirectoryProjectionVisible(e){let t=e;for(;t!==this.#e.snapshot.rootId;){let e=W(this.#e,t).parentId;if(e!==this.#e.snapshot.rootId){let n=W(this.#e,e),r=wr(this.#e,e);if(!Wn(this.#e,e,n)&&r!==t)return!1}t=e}return!0}validateChildPatch(t,n){new e({paths:this.list(t),presorted:!0,sort:this.#e.snapshot.options.sort}).batch(n.operations)}};function $i(e,t){switch(t.type){case`add`:case`remove`:if(!t.path.startsWith(e)||t.path===e)throw Error(`Child patch operation must stay within ${e}: "${t.path}"`);break;case`move`:if(!t.from.startsWith(e)||!t.to.startsWith(e)||t.from===e||t.to===e)throw Error(`Child patch move must stay within ${e}: "${t.from}" -> "${t.to}"`);break}}var ea=e=>e.startsWith(`f::`)?e.slice(3):e;function ta(e){let t=e.lastIndexOf(`/`);return t<0?{parentPath:``,baseName:e}:{parentPath:e.slice(0,t),baseName:e.slice(t+1)}}function na(e,t){return e===``?t:`${e}/${t}`}function ra({files:e,path:t,isFolder:n,nextBasename:r}){let i=ea(t),a=r.trim();if(a.length===0)return{error:`Name cannot be empty.`};if(a.includes(`/`))return{error:`Name cannot include "/".`};let{parentPath:o,baseName:s}=ta(i);if(a===s)return{nextFiles:e,sourcePath:i,destinationPath:i,isFolder:n};let c=na(o,a),l=Array(e.length),u=new Set;if(!n){let t=`${c}/`,r=!1;for(let n=0;n<e.length;n++){let a=e[n];if(a!==i&&a.startsWith(t))return{error:`"${c}" already exists.`};let o=a===i?c:a;if(u.has(o))return{error:`"${c}" already exists.`};u.add(o),l[n]=o,a===i&&(r=!0)}return r?{nextFiles:l,sourcePath:i,destinationPath:c,isFolder:n}:{error:`Could not find the selected file to rename.`}}let d=`${i}/`,f=`${c}/`,p=0;for(let t=0;t<e.length;t++){let n=e[t],r=n===i||n.startsWith(d);if(!r&&(n===c||n.startsWith(f)))return{error:`"${c}" already exists.`};let a=r?`${c}${n.slice(i.length)}`:n;if(u.has(a))return{error:`"${c}" already exists.`};u.add(a),l[t]=a,r&&p++}return p===0?{error:`Could not find the selected folder to rename.`}:{nextFiles:l,sourcePath:i,destinationPath:c,isFolder:n}}function ia(e){return e.endsWith(`/`)}function aa(e){let t=e.endsWith(`/`)?e.slice(0,-1):e,n=t.lastIndexOf(`/`),r=n<0?t:t.slice(n+1);return e.endsWith(`/`)?`${r}/`:r}function oa(e){let t=[],n=new Set;for(let r of e)n.has(r)||(n.add(r),t.push(r));let r=new Set;for(let e of t.toSorted((e,t)=>e.length===t.length?e.localeCompare(t):e.length-t.length)){let t=(e.endsWith(`/`)?e.slice(0,-1):e).split(`/`),n=!1;for(let e=0;e<t.length-1;e+=1){let i=`${t.slice(0,e+1).join(`/`)}/`;if(r.has(i)){n=!0;break}}n||r.add(e)}return t.filter(e=>r.has(e))}function sa(e,t){return t.includes(e)?oa(t):[e]}function ca(e,t){return e===t?!0:e==null||t==null?!1:e.kind===t.kind&&e.directoryPath===t.directoryPath&&e.flattenedSegmentPath===t.flattenedSegmentPath&&e.hoveredPath===t.hoveredPath}function la(e,t){return{draggedPaths:e,target:t}}function ua(e,t){if(t.kind!==`directory`||t.directoryPath==null)return!1;for(let n of e)if(ia(n)&&(t.directoryPath===n||t.directoryPath.startsWith(n)))return!0;return!1}function da(e,t){return t.kind===`root`||t.directoryPath==null?aa(e):t.directoryPath}function fa(e,t){let n=e.map(e=>{let n=da(e,t);return n===e?null:{from:e,to:n,type:`move`}}).filter(e=>e!=null);return n.length===0?null:{operations:n,result:{draggedPaths:e,operation:n.length===1?`move`:`batch`,target:t}}}function pa(e,t){if(e===t)return!0;if(e.length!==t.length)return!1;for(let n=0;n<e.length;n+=1)if(e[n]!==t[n])return!1;return!0}function ma(e,t,n){let{paths:r,preparedInput:i}=e;if(i==null){if(r==null)throw Error(`FileTree requires paths or preparedInput`);return{paths:r,preparedInput:void 0}}let a=i.paths;if(r==null)return{paths:a,preparedInput:i};if(!pa(Qi.preparePaths(r,n==null?{}:{sort:n}),a))throw Error(`FileTree ${t} received paths and preparedInput for different path lists`);return{paths:a,preparedInput:i}}function ha(e){return e.operation===`add`||e.operation===`remove`||e.operation===`move`||e.operation===`batch`}function ga(e,t,n){if(e===t)return n;let r=t.endsWith(`/`)?t:`${t}/`;return e.startsWith(r)?`${n.endsWith(`/`)?n:`${n}/`}${e.slice(r.length)}`:e}function _a(e,t){if(e===t)return!0;let n=t.endsWith(`/`)?t:`${t}/`;return e.startsWith(n)}function va(e,t,n=!1){if(e==null)return null;switch(t.operation){case`add`:case`expand`:case`collapse`:case`mark-directory-unloaded`:case`begin-child-load`:case`apply-child-patch`:case`complete-child-load`:case`fail-child-load`:case`cleanup`:return e;case`remove`:return _a(e,t.path)?n?e:null:e;case`move`:return ga(e,t.from,t.to);case`batch`:{let r=e;for(let e of t.events)if(r=va(r,e,n),r==null)return null;return r}}}function ya(e){return{canonicalChanged:e.canonicalChanged,projectionChanged:e.projectionChanged,visibleCountDelta:e.visibleCountDelta}}function ba(e){switch(e.operation){case`add`:return{...ya(e),operation:`add`,path:e.path};case`remove`:return{...ya(e),operation:`remove`,path:e.path,recursive:e.recursive};case`move`:return{...ya(e),from:e.from,operation:`move`,to:e.to}}}function xa(e){return{...ya(e),events:e.events.filter(e=>e.operation===`add`||e.operation===`remove`||e.operation===`move`).map(e=>ba(e)),operation:`batch`}}function Sa(e){switch(e.operation){case`add`:case`remove`:case`move`:return ba(e);case`batch`:return xa(e);default:return null}}function Ca(e,t){if(e.size!==t.length)return!1;for(let n of t)if(!e.has(n))return!1;return!0}function wa(e){let t=e.endsWith(`/`)?e.slice(0,-1):e;if(t.length===0)return[];let n=t.split(`/`);return n.slice(0,-1).map((e,t)=>`${n.slice(0,t+1).join(`/`)}/`)}function Ta(e){return wa(e).at(-1)??null}function Ea(e,t){return t==null?e:e.startsWith(t)?e.slice(t.length):e}function Da(e){return e.endsWith(`/`)}var Oa=e=>e.toLowerCase();function ka(e){let t=e.endsWith(`/`)?e.slice(0,-1):e,n=t.lastIndexOf(`/`);return n<0?t:t.slice(n+1)}function Aa(e){return e.endsWith(`/`)?e.slice(0,-1):e}function ja(e,t){return t&&!e.endsWith(`/`)?`${e}/`:e}var Ma=e=>{let t=e.trim();return t.length===0?``:(t.includes(`\\`)?t.replaceAll(`\\`,`/`):t).toLowerCase()},Na=Symbol(`FILE_TREE_RENAME_VIEW`),Pa=512,Fa=512;function Ia(e){return e===`top`||e===`center`?e:`nearest`}function La(e,t,n){if(e===0)return-1;if(n!=null){let e=t(n);if(e!=null)return e;let r=wa(n);for(let e=r.length-1;e>=0;--e){let n=r[e];if(n==null)continue;let i=t(n);if(i!=null)return i}}return 0}function Ra(e,t,n){if(e.paths.length===0)return{focusedIndex:-1,getParentIndex:e.getParentIndex,paths:e.paths,posInSetByIndex:e.posInSetByIndex,setSizeByIndex:e.setSizeByIndex};if(t==null)return{focusedIndex:0,getParentIndex:e.getParentIndex,paths:e.paths,posInSetByIndex:e.posInSetByIndex,setSizeByIndex:e.setSizeByIndex};let r=n??(t=>e.visibleIndexByPath.get(t)??null);return{focusedIndex:La(e.paths.length,r,t),getParentIndex:e.getParentIndex,paths:e.paths,posInSetByIndex:e.posInSetByIndex,setSizeByIndex:e.setSizeByIndex}}var za=class{#e;#t=new Set;#n=new Map;#r=null;#i=null;#a=new Map;#o=new Map;#s=-1;#c=null;#l=!1;#u=e=>-1;#d=new Map;#f=null;#p=null;#m=null;#h=null;#g=null;#_;#v;#y;#b=[];#x=new Int32Array;#S=new Int32Array;#C=void 0;#w=!1;#T=null;#E=``;#D=!1;#O=new Set;#k=[];#A;#j=null;#M=null;#N=null;#P=null;#F=null;#I=null;#L=null;#R=0;#z=null;#B=new Set;#V=0;#H;#U=0;#W=!1;#G=0;#K;constructor(e){let{dragAndDrop:t,fileTreeSearchMode:n,initialSearchQuery:r,initialSelectedPaths:i,renaming:a,onSearchChange:o,paths:s,preparedInput:c,...l}=e,u=ma({paths:s,preparedInput:c},`constructor`,l.sort);this.#e=l,t!=null&&t!==!1&&(this.#r=t===!0?{}:t),this.#w=a!=null&&a!==!1,a!=null&&a!==!1&&a!==!0&&(this.#C=a.canRename,this.#v=a.onError,this.#_=a.onRename),this.#y=o,this.#A=n??`hide-non-matches`,this.#H=this.#le(u.paths,u.preparedInput);let d=i?.map(e=>this.#Ne(e)).filter(e=>e!=null)??[],f=d.at(-1)??null;d.length>0&&(this.#B=new Set(d),this.#z=f,this.#V=1),this.#je(f,!1),r!=null&&this.#Te(r,!1),this.#K=this.#Re()}destroy(){this.#K?.(),this.#K=null,this.#n.clear(),this.#t.clear(),this.#d.clear(),this.#i=null,this.#he()}focusFirstItem(){this.#be().length>0&&this.#Fe(0)}focusLastItem(){this.#G<=0||(this.#Ie(),this.#Fe(this.#G-1))}focusNextItem(){this.#Ae(1)}focusParentItem(){if(this.#c==null)return;let e=Ta(this.#c);if(e==null)return;let t=this.#Z(e);t>=0&&this.#Fe(t)}focusPath(e){let t=this.#H.getPathInfo(e)?.path??null;if(t==null)return;this.#Ie();let n=this.#Z(t);n>=0&&this.#Fe(n)}scrollToPath(e,t){let n=this.#H.getPathInfo(e)?.path??null;if(n==null)return;this.#Ie();let r=this.#xe(n);r<0||this.#Me(r)!=null&&(t?.focus!==!1&&this.#Fe(r,!1),this.#L={id:this.#R+=1,offset:Ia(t?.offset),visibleIndex:r},this.#De())}focusMountedPathFromInput(e){let t=this.#H.getPathInfo(e)?.path??null;if(t==null)return;let n=this.#Z(t);n>=0&&this.#Fe(n)}focusNearestPath(e){let t=this.resolveNearestVisiblePath(e);if(t==null)return null;let n=this.#Z(t);return n>=0?(this.#Fe(n),this.#be()[n]??t):null}focusPreviousItem(){this.#Ae(-1)}getFocusedIndex(){return this.#s}getFocusedItem(){return this.#c==null?null:this.#Q(this.#c)}getFocusedPath(){return this.#c}getScrollRequest(){return this.#L}clearScrollRequest(e){this.#L?.id===e&&(this.#L=null)}resolveNearestVisiblePath(e){let t=this.#be();if(this.#G===0)return null;if(e==null)return this.#c??t[0]??null;let n=this.#H.getPathInfo(e)?.path??e,r=this.#Z(n);return r>=0?t[r]??n:this.#X(n)??this.#c??t[0]??null}getSelectedPaths(){return[...this.#B]}getSelectionVersion(){return this.#V}getVisibleCount(){return this.#G}getVisibleRows(e,t){if(t<e||this.#G===0)return[];let n=Math.max(0,e),r=Math.min(this.#G-1,t);if(r<n)return[];let i=r-n+1;if(this.#F==null&&!this.#l&&r>=this.#b.length&&i<=Fa){let e=[];for(let t=n;t<=r;t+=1){let n=this.#H.getVisibleRowContext(t);if(n==null)break;e.push(this.#ee(n))}return e}if(!this.#l&&r>=this.#b.length&&this.#Ie(),this.#F!=null){let e=Array.from({length:r-n+1},(e,t)=>this.#Se(n+t)),t=new Map,i=e[0]??-1,a=i;for(let n=1;n<=e.length;n+=1){let r=e[n];if(r!=null&&r===a+1){a=r;continue}if(i>=0&&this.#H.getVisibleSlice(i,a).forEach((e,n)=>{t.set(i+n,e)}),r==null){i=-1,a=-1;continue}i=r,a=r}return Array.from({length:r-n+1},(e,r)=>{let i=n+r,a=this.#Se(i),o=t.get(a),s=this.#b[a];if(o==null||s==null)throw Error(`Missing projection row for filtered visible index ${String(i)}`);return this.#$(o,i,a,{ancestorPaths:this.#re(a),path:s})})}return this.#H.getVisibleSlice(n,r).map((e,t)=>{let r=n+t,i=this.#b[r];if(i==null)throw Error(`Missing projection path for visible index ${String(r)}`);return this.#$(e,r,r,{ancestorPaths:this.#re(r),path:i})})}getStickyRowCandidates(e,t){if(this.#F!=null)return null;if(this.#G===0||e<=0||t<=0)return[];let n=[];for(let r=0;r<this.#G;r+=1){let i=e+r*t,a=Math.min(this.#G-1,Math.floor(i/t)),o=this.#te(a,r)??(a>0?this.#te(a-1,r):void 0);if(o==null)break;n.push({row:this.#ee(o),subtreeEndIndex:o.subtreeEndIndex})}return n}getItem(e){let t=this.#H.getPathInfo(e);return t==null?null:this.#Q(t.path,t)}resolveMountedDirectoryPathFromInput(e){let t=this.#H.getPathInfo(e);return t?.kind===`directory`?t.path:null}toggleMountedDirectoryFromInput(e){let t=this.resolveMountedDirectoryPathFromInput(e);t!=null&&this.#ze(t)}selectAllVisiblePaths(){this.#Ie();let e=[...this.#be()];this.#ae(e,this.#c??this.#z)}selectOnlyPath(e){let t=this.#Ne(e);t!=null&&this.#ae([t],t)}selectOnlyMountedPathFromInput(e){this.#ae([e],e)}selectPath(e){let t=this.#Ne(e);t==null||this.#B.has(t)||this.#ae([...this.#B,t])}deselectPath(e){let t=this.#Ne(e);t==null||!this.#B.has(t)||this.#ae([...this.#B].filter(e=>e!==t))}toggleFocusedSelection(){this.#c!=null&&this.togglePathSelectionFromInput(this.#c)}togglePathSelection(e){let t=this.#Ne(e);if(t!=null){if(this.#B.has(t)){this.deselectPath(t);return}this.selectPath(t)}}togglePathSelectionFromInput(e){let t=this.#Ne(e);if(t!=null){if(this.#B.has(t)){this.#ae([...this.#B].filter(e=>e!==t),t);return}this.#ae([...this.#B,t],t)}}selectPathRange(e,t){let n=this.#Ne(e);if(n==null)return;this.#Ie();let r=this.#z,i=r==null?-1:this.#Ce(r),a=this.#Ce(n);if(i===-1||a===-1){let e=t?[...this.#B,n]:[n];this.#ae(e,n);return}let[o,s]=i<=a?[i,a]:[a,i],c=this.#be().slice(o,s+1),l=t?[...this.#B,...c]:c;this.#ae(l,r)}extendSelectionFromFocused(e){if(this.#c==null)return;let t=this.#s;if(t===-1)return;let n=Math.min(this.#G-1,Math.max(0,t+e));if(n===t)return;!this.#l&&n>=this.#b.length&&this.#Ie();let r=this.#be(),i=r[t]??null,a=r[n]??null;if(i==null||a==null)return;let o=new Set(this.#B);o.has(i)&&o.has(a)?o.delete(i):o.add(a),this.#ae([...o],this.#z??i,!1),this.#Fe(n)}getDragAndDropConfig(){return this.#r}isDragAndDropEnabled(){return this.#r!=null}getDragSession(){return this.#i==null?null:{draggedPaths:[...this.#i.draggedPaths],primaryPath:this.#i.primaryPath,target:this.#i.target==null?null:{...this.#i.target}}}startDrag(e){if(this.#r==null)return!1;let t=this.#Ne(e);if(t==null||this.#M!=null&&this.#M.length>0)return!1;let n=this.getSelectedPaths(),r=sa(t,n);return this.#r.canDrag?.(r)===!1?!1:(n.includes(t)||this.#ae([t],t,!1),this.#Pe(t),this.#i={draggedPaths:r,primaryPath:t,target:null},this.#De(),!0)}setDragTarget(e){let t=this.#i;if(t==null)return;let n=e;if(n!=null){let e=la(t.draggedPaths,n);(ua(t.draggedPaths,n)||this.#r?.canDrop?.(e)===!1)&&(n=null)}ca(t.target,n)||(this.#i={...t,target:n},this.#De())}cancelDrag(){this.#i!=null&&(this.#i=null,this.#De())}completeDrag(){let e=this.#i;if(e==null)return!1;this.#i=null;let t=e.target==null?null:{...e.target};if(t==null)return this.#De(),!1;let n=la(e.draggedPaths,t);if(ua(e.draggedPaths,t)||this.#r?.canDrop?.(n)===!1)return this.#De(),!1;let r=fa(e.draggedPaths,t);if(r==null)return this.#De(),!1;try{if(r.operations.length===1){let e=r.operations[0];if(e==null||e.type!==`move`)throw Error(`Expected a single move operation for one-item drops`);this.#H.move(e.from,e.to,{collision:e.collision})}else this.#ce(r.operations),this.#H.batch(r.operations)}catch(e){return this.#De(),this.#r?.onDropError?.(e instanceof Error?e.message:String(e),n),!1}return this.#r?.onDropComplete?.(r.result),!0}subscribe(e){return this.#t.add(e),e(),()=>{this.#t.delete(e)}}add(e){this.#H.add(e)}remove(e,t={}){this.#H.remove(e,t)}move(e,t,n={}){this.#H.move(e,t,n)}batch(e){this.#H.batch(e)}onMutation(e,t){let n=e,r=t,i=this.#n.get(n);return i??(i=new Set,this.#n.set(n,i)),i.add(r),()=>{let e=this.#n.get(n);e?.delete(r),e?.size===0&&this.#n.delete(n)}}setSearch(e){this.#Te(e,!0)}openSearch(e=``){this.#Te(e,!0)}closeSearch(){this.#Te(null,!0)}isSearchOpen(){return this.#M!==null}getSearchValue(){return this.#M??``}getSearchMatchingPaths(){return this.#k}focusNextSearchMatch(){this.#we(1)}focusPreviousSearchMatch(){this.#we(-1)}startRenaming(e=this.#c??``,t={}){if(!this.#w)return!1;let n=this.#H.getPathInfo(e);if(n==null)return!1;let r=n.path,i=Da(r),a=Aa(r);if(this.#C?.({isFolder:i,path:a})===!1)return!1;for(let e of wa(r))this.#H.isExpanded(e)||this.#H.expand(e);return this.#ae([r],r,!1),this.#M!=null&&(this.#Te(null,!1),this.#y?.(this.#M)),this.#Pe(r),this.#T=r,this.#E=ka(r),this.#D=t.removeIfCanceled??!1,this.#De(),!0}[Na](){return{cancel:()=>{this.#q()},commit:()=>{this.#J()},getPath:()=>this.#T,getValue:()=>this.#E,isActive:()=>this.#T!=null,setValue:e=>{this.#Y(e)}}}#q(){if(this.#T==null)return;let e=this.#T,t=this.#D;if(this.#T=null,this.#E=``,this.#D=!1,t){this.remove(e,Da(e)?{recursive:!0}:void 0);return}this.#Pe(e),this.#De()}#J(){let e=this.#T;if(e==null)return;if(this.#D&&this.#E.trim().length===0){this.#T=null,this.#E=``,this.#D=!1,this.remove(e,Da(e)?{recursive:!0}:void 0);return}let t=Da(e),n=ra({files:this.#H.list(),isFolder:t,nextBasename:this.#E,path:Aa(e)});if(this.#T=null,this.#E=``,this.#D=!1,`error`in n){this.#Pe(e),this.#v?.(n.error),this.#De();return}if(n.sourcePath===n.destinationPath){this.#Pe(e),this.#De();return}this.#_?.({destinationPath:n.destinationPath,isFolder:n.isFolder,sourcePath:n.sourcePath}),this.move(ja(n.sourcePath,t),ja(n.destinationPath,t))}#Y(e){this.#T==null||this.#E===e||(this.#E=e,this.#De())}resetPaths(e,t={}){let n=this.#H.list().length,r=this.#G,i=ma({paths:e,preparedInput:t.preparedInput},`resetPaths`,this.#e.sort),a=this.#le(i.paths,i.preparedInput,t.initialExpandedPaths),o=this.#c,s=this.#T,c=this.getSelectedPaths(),l=this.#z;this.#K?.(),this.#H=a,this.#d.clear(),this.#he();let u=c.map(e=>a.getPathInfo(e)?.path??null).filter(e=>e!=null),d=!Ca(this.#B,u);this.#B=new Set(u),d&&(this.#V+=1),this.#z=l==null?null:a.getPathInfo(l)?.path??null,this.#T=s==null?null:a.getPathInfo(s)?.path??null,this.#T??(this.#E=``,this.#D=!1),this.#je(o,o!=null||u.length>0||this.#z!=null),this.#K=this.#Re(),this.#De(),this.#Oe({canonicalChanged:!0,operation:`reset`,pathCountAfter:i.paths.length,pathCountBefore:n,projectionChanged:!0,usedPreparedInput:t.preparedInput!=null,visibleCountDelta:this.#G-r})}#X(e){this.#Ie();let t=Ta(e),n=Ea(e,t),r=null,i=null;for(let e of this.#be()){if(Ta(e)!==t)continue;let a=Ea(e,t);if(a<n){r=e;continue}if(a>n){i=e;break}}return r??i}#Z(e){let t=this.#Ce(e);if(t!==-1)return t;let n=wa(e);for(let e=n.length-1;e>=0;--e){let t=n[e];if(t==null)continue;let r=this.#Ce(t);if(r!==-1)return r}return this.#be().length>0?0:-1}#Q(e,t){let n=this.#d.get(e);if(n!=null)return n;let r=t??this.#H.getPathInfo(e);if(r==null)return null;let i=r.kind===`directory`?this.#oe(r.path):this.#se(r.path);return this.#d.set(r.path,i),i}#$(e,t,n,r){return{ancestorPaths:r.ancestorPaths,depth:e.depth,flattenedSegments:e.flattenedSegments?.map(e=>({isTerminal:e.isTerminal,name:e.name,path:e.path})),hasChildren:e.hasChildren,index:t,isExpanded:e.isExpanded,isFlattened:e.isFlattened,isFocused:r.path===this.#c,isSelected:this.#B.has(r.path),kind:e.kind,level:e.depth,name:e.name,path:r.path,posInSet:r.posInSet??this.#x[n]??0,setSize:r.setSize??this.#S[n]??0}}#ee(e){return this.#$(e.row,e.index,e.index,{ancestorPaths:e.ancestorPaths,path:e.row.path,posInSet:e.posInSet,setSize:e.setSize})}#te(e,t){let n=this.#H.getVisibleRowContext(e);return n==null?void 0:n.ancestorRows[t]??(t===n.ancestorRows.length&&n.row.kind===`directory`&&n.row.isExpanded?n:void 0)}#ne(e){let t=this.#a.get(e);if(t!=null)return t;let n=this.#u(e),r=n<0?[]:[...this.#ne(n),n];return this.#a.set(e,r),r}#re(e){let t=this.#o.get(e);if(t!=null)return t;let n=this.#ne(e).map(e=>this.#b[e]??``).filter(e=>e!==``);return this.#o.set(e,n),n}#ie(e){this.#H.collapse(e)}#ae(e,t=this.#z,n=!0){let r=[...new Set(e)],i=!Ca(this.#B,r),a=this.#z!==t;!i&&!a||(this.#B=new Set(r),this.#z=t,i&&(this.#V+=1),n&&this.#De())}#oe(e){return{collapse:()=>{this.#ie(e)},deselect:()=>{this.deselectPath(e)},expand:()=>{this.#ke(e)},focus:()=>{this.focusPath(e)},getPath:()=>e,isDirectory:()=>!0,isExpanded:()=>this.#H.isExpanded(e),isFocused:()=>this.#c===e,isSelected:()=>this.#B.has(e),select:()=>{this.selectPath(e)},toggleSelect:()=>{this.togglePathSelection(e)},toggle:()=>{this.#ze(e)}}}#se(e){return{deselect:()=>{this.deselectPath(e)},focus:()=>{this.focusPath(e)},getPath:()=>e,isDirectory:()=>!1,isFocused:()=>this.#c===e,isSelected:()=>this.#B.has(e),select:()=>{this.selectPath(e)},toggleSelect:()=>{this.togglePathSelection(e)}}}#ce(e){let t=this.#H.list();this.#le(t).batch(e)}#le(e,t,n){return new Qi({...this.#e,paths:e,preparedInput:t??void 0,...n===void 0?{}:{initialExpandedPaths:n}})}#ue(){return this.#h??=this.#H.list(),this.#h}#de(){if(this.#m!=null)return this.#m;let e=new Set;for(let t of this.#ue()){e.add(t);for(let n of wa(t))e.add(n)}return this.#m=[...e].sort(),this.#m}#fe(){return this.#g??=this.#ue().map(Oa),this.#g}#pe(){return this.#f??=this.#de().filter(e=>e.endsWith(`/`)),this.#f}#me(){return this.#p??=this.#pe().map(Oa),this.#p}#he(){this.#f=null,this.#p=null,this.#m=null,this.#h=null,this.#g=null}#ge(){return this.#pe().filter(e=>this.#H.isExpanded(e))}#_e(e){let t=new Set(this.#j??[]);if(e)for(let e of this.#B)for(let n of wa(e))t.add(n);this.#ve(t)}#ve(e){this.#W=!0;try{for(let t of this.#pe()){let n=e.has(t),r=this.#H.isExpanded(t);n&&!r?this.#H.expand(t):!n&&r&&this.#H.collapse(t)}}finally{this.#W=!1}}#ye(){if(this.#M==null||this.#M.length===0){this.#k=[],this.#F=null,this.#I=null,this.#P=null,this.#G=this.#U;return}let e=this.#b;if(this.#k=e.filter(e=>this.#O.has(e)),this.#A!==`hide-non-matches`||this.#O.size===0){this.#F=null,this.#I=null,this.#P=null,this.#G=this.#U;return}let t=[],n=[],r=new Map;for(let[i,a]of e.entries())this.#N?.has(a)===!0&&(r.set(a,n.length),t.push(i),n.push(a));this.#F=t,this.#I=n,this.#P=r,this.#G=n.length}#be(){return this.#I??this.#b}#xe(e){return this.#I==null?this.#H.getVisibleIndex(e)??-1:this.#P?.get(e)??-1}#Se(e){return this.#F?.[e]??e}#Ce(e){return this.#P?.get(e)??this.#H.getVisibleIndex(e)??-1}#we(e){let t=this.#k;if(t.length===0)return;let n=this.#c,r=n==null?-1:t.indexOf(n),i=t[r<0?e>0?0:t.length-1:Math.min(t.length-1,Math.max(0,r+e))];i!=null&&this.focusPath(i)}#Te(e,t){let n=e==null?null:Ma(e),r=this.#M;if(r!==n){if(r==null&&n!=null&&(this.#j=this.#ge()),this.#M=n,n==null)this.#_e(!0),this.#j=null,this.#O.clear(),this.#N=null,this.#je(this.#c,!0);else if(n.length===0)this.#_e(!1),this.#O.clear(),this.#N=null,this.#je(this.#c,!0);else{let e=this.#Ee();this.#je(e,!0)}t&&(this.#y?.(this.#M),this.#De())}}#Ee(){if(this.#M==null||this.#M.length===0)return this.#O.clear(),this.#c;let e=this.#M,t=this.#ue(),n=this.#fe(),r=[],i=new Set,a=null;for(let o=0;o<t.length;o+=1){if(!n[o].includes(e))continue;let s=t[o];r.push(s),i.add(s),a??=s}let o=this.#pe(),s=this.#me();for(let t=0;t<o.length;t+=1){if(!s[t].includes(e))continue;let n=o[t];i.has(n)||(r.push(n),i.add(n),a??=n)}this.#O=i;let c=this.#A===`hide-non-matches`&&r.length>0?new Set:null;this.#N=c;let l=this.#A===`expand-matches`?new Set(this.#j??[]):new Set;for(let e of r){c?.add(e),e.endsWith(`/`)&&l.add(e);for(let t of wa(e))l.add(t),c?.add(t)}return this.#ve(l),a??this.#c}#De(){for(let e of this.#t)e()}#Oe(e){this.#n.get(e.operation)?.forEach(t=>{t(e)}),this.#n.get(`*`)?.forEach(t=>{t(e)})}#ke(e){for(let t of wa(e))this.#H.isExpanded(t)||this.#H.expand(t);this.#H.isExpanded(e)||this.#H.expand(e)}#Ae(e){let t=this.#G;if(t===0)return;let n=this.#s===-1?0:this.#s,r=Math.min(t-1,Math.max(0,n+e));(r!==n||this.#s===-1)&&(!this.#l&&this.#F==null&&r>=this.#b.length&&this.#Ie(),this.#Fe(r))}#je(e,t=!0){let n=this.#H.getVisibleCount();this.#U=n;let r=Ra(this.#H.getVisibleTreeProjectionData(t?void 0:Math.min(n,Pa)),e,t?e=>this.#H.getVisibleIndex(e):void 0);this.#a.clear(),this.#o.clear(),this.#l=r.paths.length>=n,this.#u=r.getParentIndex,this.#b=r.paths,this.#x=r.posInSetByIndex,this.#S=r.setSizeByIndex,this.#ye(),this.#s=e==null?this.#be().length>0?0:-1:this.#Z(e),this.#c=this.#s<0?null:this.#Me(this.#s)}#Me(e){return this.#be()[e]??(this.#F==null?this.#H.getVisibleRowContext(e)?.row.path??null:null)}#Ne(e){return this.#H.getPathInfo(e)?.path??null}#Pe(e){if(e==null)return;let t=this.#Z(e);t>=0&&this.#Fe(t,!1)}#Fe(e,t=!0){let n=this.#Me(e);n!=null&&(this.#s===e&&this.#c===n||(this.#s=e,this.#c=n,t&&this.#De()))}#Ie(){this.#l||this.#je(this.#c,!0)}#Le(e){let t=va(this.#T,e);t==null&&this.#T!=null&&(this.#E=``),this.#T=t;let n=va(this.#c,e,!0),r=[...this.#B].map(t=>va(t,e)).filter(e=>e!=null).map(e=>this.#H.getPathInfo(e)?.path??null).filter(e=>e!=null),i=va(this.#z,e),a=i==null?null:this.#H.getPathInfo(i)?.path??null,o=[...new Set(r)];return Ca(this.#B,o)||(this.#B=new Set(o),this.#V+=1),this.#z=a,n}#Re(){return this.#H.on(`*`,e=>{if(this.#W)return;e.canonicalChanged&&(this.#d.clear(),this.#he()),this.#i!=null&&ha(e)&&(this.#i=null);let t=ha(e)?this.#Le(e):this.#c,n=this.#M!=null&&this.#M.length>0?this.#Ee():this.#M===``?this.#c:t,r=this.#M!=null||e.operation!==`expand`&&e.operation!==`collapse`;this.#je(n,r),this.#De();let i=Sa(e);i!=null&&this.#Oe(i)})}#ze(e){if(this.#H.isExpanded(e)){this.#ie(e);return}this.#ke(e)}},Ba=e=>{if(e==null||e.length===0)return`0`;let t=`${e.length}`;for(let n of e)t+=`\0${n.path}\0${n.status}`;return t};function Va(e){let t=e.endsWith(`/`),n=``,r=-1;for(let t=0;t<=e.length;t+=1){if(!(e[t]===`/`||t===e.length)){r===-1&&(r=t);continue}r!==-1&&(n!==``&&(n+=`/`),n+=e.slice(r,t),r=-1)}return n===``?null:{isDirectory:t,path:n}}function Ha(e){let t=e.endsWith(`/`)?e.slice(0,-1):e;if(t.length===0)return[];let n=t.split(`/`);return n.slice(0,-1).map((e,t)=>`${n.slice(0,t+1).join(`/`)}/`)}function Ua(e,t){return t?`${e}/`:e}function Wa(e,t=null){let n=Ba(e==null?void 0:[...e]);if(n===`0`)return null;if(t?.signature===n)return t;let r=new Map,i=new Set,a=new Set;for(let t of e??[]){let e=Va(t.path);if(e==null)continue;let n=Ua(e.path,e.isDirectory);r.set(n,t.status),t.status===`ignored`&&e.isDirectory?a.add(n):e.isDirectory&&a.delete(n);for(let t of Ha(e.path))i.add(t)}return{directoriesWithChanges:i,ignoredDirectoryPaths:a,signature:n,statusByPath:r}}var Ga=e=>e.trim().toLowerCase(),Ka=e=>e.split(`/`).at(-1)??e,qa=e=>{let t=e.toLowerCase().split(`.`),n=[];for(let e=1;e<t.length;e+=1)n.push(t.slice(e).join(`.`));return n};function Ja(e,t){return typeof e==`string`?{name:e,remappedFrom:t}:{...e,remappedFrom:t}}function Ya(e){let t=pt(e),n=t.remap,r=new Map;for(let[e,n]of Object.entries(t.byFileName??{}))r.set(e.toLowerCase(),n);let i=new Map;for(let[e,n]of Object.entries(t.byFileExtension??{}))i.set(Ga(e),n);let a=Object.entries(t.byFileNameContains??{}).map(([e,t])=>[e.toLowerCase(),t]);return{resolveIcon:(e,o)=>{if(e===`file-tree-icon-file`&&o!=null){let n=Ka(o),s=n.toLowerCase(),c=r.get(s);if(c!=null)return Ja(c,e);for(let[t,n]of a)if(s.includes(t))return Ja(n,e);let l=qa(n);for(let t of l){let n=i.get(t);if(n!=null)return Ja(n,e)}let u=dt(t.set,n,l);if(u!=null&&t.set!==`none`)return{name:I(u),remappedFrom:e,token:u}}let s=n?.[e];return s==null?{name:e}:Ja(s,e)}}}var q,Xa,Za,Qa,$a,eo,to,no,ro,io,ao={},oo=[],so=Array.isArray,co=oo.slice,lo=Object.assign;function uo(e){e&&e.parentNode&&e.remove()}function fo(e,t,n){var r,i,a,o={};for(a in t)a==`key`?r=t[a]:a==`ref`&&typeof e!=`function`?i=t[a]:o[a]=t[a];return arguments.length>2&&(o.children=arguments.length>3?co.call(arguments,2):n),po(e,o,r,i,null)}function po(e,t,n,r,i){var a={type:e,props:t,key:n,ref:r,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:i??++Xa,__i:-1,__u:0};return i==null&&q.vnode!=null&&q.vnode(a),a}function mo(e){return e.children}function ho(e,t){this.props=e,this.context=t,this.__g=0}function go(e,t){if(t==null)return e.__?go(e.__,e.__i+1):null;for(var n;t<e.__k.length;t++)if((n=e.__k[t])!=null&&n.__e!=null)return n.__e;return typeof e.type==`function`?go(e):null}function _o(e){var t,n;if((e=e.__)!=null&&e.__c!=null){for(e.__e=null,t=0;t<e.__k.length;t++)if((n=e.__k[t])!=null&&n.__e!=null){e.__e=n.__e;break}return _o(e)}}function vo(e){(8&e.__g||!(e.__g|=8)||!Za.push(e)||$a++)&&Qa==q.debounceRendering||((Qa=q.debounceRendering)||queueMicrotask)(yo)}function yo(){for(var e,t,n,r,i,a,o,s,c=1;Za.length;)Za.length>c&&Za.sort(eo),e=Za.shift(),c=Za.length,8&e.__g&&(n=void 0,i=(r=(t=e).__v).__e,a=[],o=[],(s=t.__P)&&((n=lo({},r)).__v=r.__v+1,q.vnode&&q.vnode(n),Do(s,n,r,t.__n,s.namespaceURI,32&r.__u?[i]:null,a,i??go(r),!!(32&r.__u),o,s.ownerDocument),n.__v=r.__v,n.__.__k[n.__i]=n,ko(a,n,o),n.__e!=i&&_o(n)));$a=0}function bo(e,t,n,r,i,a,o,s,c,l,u,d){var f,p,m,h,g,_,v,y=r&&r.__k||oo,b=t.length;for(c=xo(n,t,y,c,b),f=0;f<b;f++)(m=n.__k[f])!=null&&(p=m.__i==-1?ao:y[m.__i]||ao,m.__i=f,_=Do(e,m,p,i,a,o,s,c,l,u,d),h=m.__e,m.ref&&p.ref!=m.ref&&(p.ref&&Mo(p.ref,null,m),u.push(m.ref,m.__c||h,m)),g==null&&h!=null&&(g=h),(v=!!(4&m.__u))||p.__k===m.__k?c=So(m,c,e,v):typeof m.type==`function`&&_!==void 0?c=_:h&&(c=h.nextSibling),m.__u&=-7);return n.__e=g,c}function xo(e,t,n,r,i){var a,o,s,c,l,u=n.length,d=u,f=0;for(e.__k=Array(i),a=0;a<i;a++)(o=t[a])!=null&&typeof o!=`boolean`&&typeof o!=`function`?(c=a+f,(o=e.__k[a]=typeof o==`string`||typeof o==`number`||typeof o==`bigint`||o.constructor==String?po(null,o,null,null,null):so(o)?po(mo,{children:o},null,null,null):o.constructor==null&&o.__b>0?po(o.type,o.props,o.key,o.ref?o.ref:null,o.__v):o).__=e,o.__b=e.__b+1,s=null,(l=o.__i=Co(o,n,c,d))!=-1&&(d--,(s=n[l])&&(s.__u|=2)),s==null||s.__v==null?(l==-1&&(i>u?f--:i<u&&f++),typeof o.type!=`function`&&(o.__u|=4)):l!=c&&(l==c-1?f--:l==c+1?f++:(l>c?f--:f++,o.__u|=4))):e.__k[a]=null;if(d)for(a=0;a<u;a++)(s=n[a])!=null&&!(2&s.__u)&&(s.__e==r&&(r=go(s)),No(s,s));return r}function So(e,t,n,r){var i,a;if(typeof e.type==`function`){for(i=e.__k,a=0;i&&a<i.length;a++)i[a]&&(i[a].__=e,t=So(i[a],t,n,r));return t}e.__e!=t&&(r&&(t&&e.type&&!t.parentNode&&(t=go(e)),n.insertBefore(e.__e,t||null)),t=e.__e);do t&&=t.nextSibling;while(t!=null&&t.nodeType==8);return t}function Co(e,t,n,r){var i,a,o,s=e.key,c=e.type,l=t[n],u=l!=null&&(2&l.__u)==0;if(l===null&&e.key==null||u&&s==l.key&&c==l.type)return n;if(r>+!!u){for(i=n-1,a=n+1;i>=0||a<t.length;)if((l=t[o=i>=0?i--:a++])!=null&&!(2&l.__u)&&s==l.key&&c==l.type)return o}return-1}function wo(e,t,n){t[0]==`-`?e.setProperty(t,n??``):e[t]=n??``}function To(e,t,n,r,i){var a;n:if(t==`style`)if(typeof n==`string`)e.style.cssText=n;else{if(typeof r==`string`&&(e.style.cssText=r=``),r)for(t in r)n&&t in n||wo(e.style,t,``);if(n)for(t in n)r&&n[t]==r[t]||wo(e.style,t,n[t])}else if(t[0]==`o`&&t[1]==`n`)a=t!=(t=t.replace(to,`$1`)),(t=t.slice(2))[0].toLowerCase()!=t[0]&&(t=t.toLowerCase()),e.__l||={},e.__l[t+a]=n,n?r?n.l=r.l:(n.l=no,e.addEventListener(t,a?io:ro,a)):e.removeEventListener(t,a?io:ro,a);else{if(i==`http://www.w3.org/2000/svg`)t=t.replace(/xlink(H|:h)/,`h`).replace(/sName$/,`s`);else if(t!=`width`&&t!=`height`&&t!=`href`&&t!=`list`&&t!=`form`&&t!=`tabIndex`&&t!=`download`&&t!=`rowSpan`&&t!=`colSpan`&&t!=`role`&&t!=`popover`&&t in e)try{e[t]=n??``;break n}catch{}typeof n==`function`||(n==null||!1===n&&t[4]!=`-`?e.removeAttribute(t):e.setAttribute(t,t==`popover`&&n==1?``:n))}}function Eo(e){return function(t){if(this.__l){var n=this.__l[t.type+e];if(t.u==null)t.u=no++;else if(t.u<n.l)return;return n(q.event?q.event(t):t)}}}function Do(e,t,n,r,i,a,o,s,c,l,u){var d,f,p,m,h,g,_,v,y,b,x,S,C,w,T,E,D,ee,te,O,k,A=t.type;if(t.constructor!=null)return null;128&n.__u&&(c=!!(32&n.__u),n.__c.__z&&(s=t.__e=n.__e=(a=n.__c.__z)[0],n.__c.__z=null)),(d=q.__b)&&d(t);n:if(typeof A==`function`)try{if(v=t.props,y=`prototype`in A&&A.prototype.render,b=(d=A.contextType)&&r[d.__c],x=d?b?b.props.value:d.__:r,n.__c?2&(f=t.__c=n.__c).__g&&(f.__g|=1,_=!0):(y?t.__c=f=new A(v,x):(t.__c=f=new ho(v,x),f.constructor=A,f.render=Po),b&&b.sub(f),f.props=v,f.state||={},f.context=x,f.__n=r,p=!0,f.__g|=8,f.__h=[],f._sb=[]),y&&f.__s==null&&(f.__s=f.state),y&&A.getDerivedStateFromProps!=null&&(f.__s==f.state&&(f.__s=lo({},f.__s)),lo(f.__s,A.getDerivedStateFromProps(v,f.__s))),m=f.props,h=f.state,f.__v=t,p)y&&A.getDerivedStateFromProps==null&&f.componentWillMount!=null&&f.componentWillMount(),y&&f.componentDidMount!=null&&f.__h.push(f.componentDidMount);else{if(y&&A.getDerivedStateFromProps==null&&v!==m&&f.componentWillReceiveProps!=null&&f.componentWillReceiveProps(v,x),!(4&f.__g)&&f.shouldComponentUpdate!=null&&!1===f.shouldComponentUpdate(v,f.__s,x)||t.__v==n.__v){for(t.__v!=n.__v&&(f.props=v,f.state=f.__s,f.__g&=-9),t.__e=n.__e,t.__k=n.__k,t.__k.some(function(e){e&&(e.__=t)}),S=0;S<f._sb.length;S++)f.__h.push(f._sb[S]);f._sb=[],f.__h.length&&o.push(f);break n}f.componentWillUpdate!=null&&f.componentWillUpdate(v,f.__s,x),y&&f.componentDidUpdate!=null&&f.__h.push(function(){f.componentDidUpdate(m,h,g)})}if(f.context=x,f.props=v,f.__P=e,f.__g&=-5,C=q.__r,w=0,y){for(f.state=f.__s,f.__g&=-9,C&&C(t),d=f.render(f.props,f.state,f.context),T=0;T<f._sb.length;T++)f.__h.push(f._sb[T]);f._sb=[]}else do f.__g&=-9,C&&C(t),d=f.render(f.props,f.state,f.context),f.state=f.__s;while(8&f.__g&&++w<25);f.state=f.__s,f.getChildContext!=null&&(r=lo({},r,f.getChildContext())),y&&!p&&f.getSnapshotBeforeUpdate!=null&&(g=f.getSnapshotBeforeUpdate(m,h)),E=d,d!=null&&d.type===mo&&d.key==null&&(E=Ao(d.props.children)),s=bo(e,so(E)?E:[E],t,n,r,i,a,o,s,c,l,u),t.__u&=-161,f.__h.length&&o.push(f),_&&(f.__g&=-4)}catch(e){if(t.__v=null,c||a!=null)if(e.then){for(D=0,ee=!1,t.__u|=c?160:128,t.__c.__z=[],te=0;te<a.length;te++)(O=a[te])==null||ee||(O.nodeType==8&&O.data==`$s`?(D>0&&t.__c.__z.push(O),D++,a[te]=null):O.nodeType==8&&O.data==`/$s`?(--D>0&&t.__c.__z.push(O),ee=D===0,s=a[te],a[te]=null):D>0&&(t.__c.__z.push(O),a[te]=null));if(!ee){for(;s&&s.nodeType==8&&s.nextSibling;)s=s.nextSibling;a[a.indexOf(s)]=null,t.__c.__z=[s]}t.__e=s}else{for(k=a.length;k--;)uo(a[k]);Oo(t)}else t.__e=n.__e,t.__k=n.__k,e.then||Oo(t);q.__e(e,t,n)}else s=t.__e=jo(n.__e,t,n,r,i,a,o,c,l,u);return(d=q.diffed)&&d(t),128&t.__u?void 0:s}function Oo(e){e&&e.__c&&(e.__c.__g|=4),e&&e.__k&&e.__k.forEach(Oo)}function ko(e,t,n){for(var r=0;r<n.length;r++)Mo(n[r],n[++r],n[++r]);q.__c&&q.__c(t,e),e.some(function(t){try{e=t.__h,t.__h=[],e.some(function(e){e.call(t)})}catch(e){q.__e(e,t.__v)}})}function Ao(e){return typeof e!=`object`||!e||e.__b&&e.__b>0?e:so(e)?e.map(Ao):lo({},e)}function jo(e,t,n,r,i,a,o,s,c,l){var u,d,f,p,m,h,g,_,v=n.props,y=t.props,b=t.type;if(b==`svg`?i=`http://www.w3.org/2000/svg`:b==`math`?i=`http://www.w3.org/1998/Math/MathML`:i||=`http://www.w3.org/1999/xhtml`,a!=null){for(u=0;u<a.length;u++)if((m=a[u])&&`setAttribute`in m==!!b&&(b?m.localName==b:m.nodeType==3)){e=m,a[u]=null;break}}if(e==null){if(b==null)return l.createTextNode(y);e=l.createElementNS(i,b,y.is&&y),s&&=(q.__m&&q.__m(t,a),!1),a=null}if(b==null)v===y||s&&e.data==y||(e.data=y);else{if(a&&=co.call(e.childNodes),v=n.props||ao,!s&&a!=null)for(v={},u=0;u<e.attributes.length;u++)v[(m=e.attributes[u]).name]=m.value;for(u in v)if(m=v[u],u!=`children`){if(u==`dangerouslySetInnerHTML`)f=m;else if(!(u in y)){if(u==`value`&&`defaultValue`in y||u==`checked`&&`defaultChecked`in y)continue;To(e,u,null,m,i)}}for(u in _=1&n.__u,y)m=y[u],u==`children`?p=m:u==`dangerouslySetInnerHTML`?d=m:u==`value`?h=m:u==`checked`?g=m:s&&typeof m!=`function`||v[u]===m&&!_||To(e,u,m,v[u],i);if(d)s||f&&(d.__html==f.__html||d.__html==e.innerHTML)||(e.innerHTML=d.__html),t.__k=[];else if(f&&(e.innerHTML=``),bo(b==`template`?e.content:e,so(p)?p:[p],t,n,r,b==`foreignObject`?`http://www.w3.org/1999/xhtml`:i,a,o,a?a[0]:n.__k&&go(n,0),s,c,l),a!=null)for(u=a.length;u--;)uo(a[u]);s||(u=`value`,b==`progress`&&h==null?e.removeAttribute(`value`):h==null||h===e[u]&&(b!==`progress`||h)||To(e,u,h,v[u],i),u=`checked`,g!=null&&g!=e[u]&&To(e,u,g,v[u],i))}return e}function Mo(e,t,n){try{if(typeof e==`function`){var r=typeof e.__u==`function`;r&&e.__u(),r&&t==null||(e.__u=e(t))}else e.current=t}catch(e){q.__e(e,n)}}function No(e,t,n){var r,i;if(q.unmount&&q.unmount(e),(r=e.ref)&&(r.current&&r.current!=e.__e||Mo(r,null,t)),(r=e.__c)!=null){if(r.componentWillUnmount)try{r.componentWillUnmount()}catch(e){q.__e(e,t)}r.__P=null}if(r=e.__k)for(i=0;i<r.length;i++)r[i]&&No(r[i],t,n||typeof e.type!=`function`);n||uo(e.__e),e.__e&&e.__e.__l&&(e.__e.__l=null),e.__e=e.__c=e.__=null}function Po(e,t,n){return this.constructor(e,n)}function Fo(e,t){var n,r,i,a;t==document&&(t=document.documentElement),q.__&&q.__(e,t),r=(n=!!(e&&32&e.__u))?null:t.__k,e=t.__k=fo(mo,null,[e]),i=[],a=[],Do(t,e,r||ao,ao,t.namespaceURI,r?null:t.firstChild?co.call(t.childNodes):null,i,r?r.__e:t.firstChild,n,a,t.ownerDocument),ko(i,e,a)}function Io(e,t){e.__u|=32,Fo(e,t)}q={__e:function(e,t,n,r){for(var i,a,o;t=t.__;)if((i=t.__c)&&!(1&i.__g)){i.__g|=4;try{if((a=i.constructor)&&a.getDerivedStateFromError!=null&&(i.setState(a.getDerivedStateFromError(e)),o=8&i.__g),i.componentDidCatch!=null&&(i.componentDidCatch(e,r||{}),o=8&i.__g),o)return void(i.__g|=2)}catch(t){e=t}}throw $a=0,e}},Xa=0,ho.prototype.setState=function(e,t){var n=this.__s!=null&&this.__s!=this.state?this.__s:this.__s=lo({},this.state);typeof e==`function`&&(e=e(lo({},n),this.props)),e&&lo(n,e),e!=null&&this.__v&&(t&&this._sb.push(t),vo(this))},ho.prototype.forceUpdate=function(e){this.__v&&(this.__g|=4,e&&this.__h.push(e),vo(this))},ho.prototype.render=mo,Za=[],$a=0,eo=function(e,t){return e.__v.__b-t.__v.__b},to=/(PointerCapture)$|Capture$/i,no=0,ro=Eo(!1),io=Eo(!0);var Lo=0;Array.isArray;function J(e,t,n,r,i,a){t||={};var o,s,c=t;if(`ref`in c&&typeof e!=`function`)for(s in c={},t)s==`ref`?o=t[s]:c[s]=t[s];var l={type:e,props:c,key:n,ref:o,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--Lo,__i:-1,__u:0,__source:i,__self:a};return q.vnode&&q.vnode(l),l}var Ro=16,zo=16,Bo={};function Vo({name:e,remappedFrom:t,token:n,width:r,height:i,viewBox:a,label:o,alignCapitals:s=!1}){"use no memo";let c=`#${e.replace(/^#/,``)}`,{width:l,height:u,viewBox:d}=Bo[e]??{width:Ro,height:zo},f=r??l,p=i??u,m=a??d??`0 0 ${l} ${u}`;return J(`svg`,{"data-icon-name":t??e,"data-icon-token":n,"data-align-capitals":s,...o==null?{"aria-hidden":!0}:{"aria-label":o,role:`img`},viewBox:m,width:f,height:p,children:J(`use`,{href:c})})}var Ho=e=>{if(e.length<2)return[e,``];let t=Math.ceil(e.length/2);return[e.slice(0,t),e.slice(t)]},Uo=e=>{if(e.length<4)return[e,``];let t=e.lastIndexOf(`.`)+1,n=e.length-t>10,r=t>=1&&!n?t:Math.ceil(e.length/2);return[e.slice(0,r),e.slice(r)]},Wo=e=>{if(e.length<4)return[e,``];let t=e.lastIndexOf(`/`)+1,n=e.length-t>25,r=t>=1&&!n?t:Math.ceil(e.length/2);return[e.slice(0,r),e.slice(r)]},Go=(e,{splitIndex:t}={})=>{if(typeof t!=`number`){let t=Math.ceil(e.length/2);return[e.slice(0,t),e.slice(t)]}return[e.slice(0,t),e.slice(t)]},Ko=(e,{splitOffset:t}={})=>{if(typeof t!=`number`||t<=0||t>=e.length){let t=Math.ceil(e.length/2);return[e.slice(0,t),e.slice(t)]}let n=e.length-t;return[e.slice(0,n),e.slice(n)]},qo=(e,{splitOffset:t}={})=>{if(typeof t!=`number`||t<=0||t>=e.length){let t=Math.ceil(e.length/2);return[e.slice(0,t),e.slice(t)]}let n=t;return[e.slice(0,n),e.slice(n)]};function Jo({children:e,marker:t,variant:n=`default`}){"use no memo";return J(`div`,{"aria-hidden":!0,"data-truncate-marker-cell":!0,children:J(`div`,{"data-truncate-marker":!0,children:typeof t==`function`?t({children:e}):n===`fade`?J(`span`,{"data-truncate-fade":!0}):t})})}function Yo(e){"use no memo";let{mode:t,children:n}=e;return J(`div`,{children:[J(`div`,{"data-truncate-content":`visible`,children:t===`fruncate`?J(`span`,{children:n}):n}),J(`div`,{"data-truncate-content":`overflow`,"aria-hidden":!0,children:t===`fruncate`?J(`span`,{children:n}):n})]})}function Xo({children:e,mode:t=`truncate`,marker:n=`…`,variant:r=`default`,...i}){"use no memo";let a=J(Yo,{mode:t,children:e},`content`),o=J(Jo,{marker:n,mode:t,variant:r},`marker`),s=J(`div`,{"data-truncate-fill":!0},`fill`);return J(`div`,{"data-truncate-container":t,"data-truncate-variant":r,...i,children:J(`div`,{"data-truncate-grid":!0,children:t===`truncate`?[a,o]:[o,a,s]})})}function Zo({children:e,...t}){"use no memo";return J(Xo,{mode:`truncate`,...t,children:e})}function Qo({children:e,...t}){"use no memo";return J(Xo,{mode:`fruncate`,...t,children:e})}function $o({children:e,contents:t,priority:n=`end`,split:r=`center`,minimumLength:i=12,className:a,style:o,...s}){"use no memo";let c=null,l=null;if(Array.isArray(t)){if(t.length!==2)return console.error(`MiddleTruncate: contents must be an array of two items`),null;c=J(Zo,{...s,children:t[0]}),l=J(Qo,{...s,children:t[1]})}else{if(typeof e!=`string`)return console.error(`MiddleTruncate: children must be a string`),null;if(e.length===0)return J(`div`,{className:a,style:o});if(e.length<i)return J(n===`end`?Qo:Zo,{...s,className:a,style:o,children:e});let t=null,u=null,d=null;if(typeof r==`string`)r===`center`?t=Ho:r===`extension`?t=Uo:r===`leaf-path`&&(t=Wo);else if(typeof r==`number`)t=Go,u=r;else if(Array.isArray(r)){let[e,n]=r;d=n,e===`last`?t=Ko:e===`first`&&(t=qo)}else typeof r==`function`&&(t=r);t??=Ho;let[f,p]=t(e,{priority:n,variant:s.variant,splitIndex:typeof u==`number`?u:void 0,splitOffset:typeof d==`number`?d:void 0}),m=f.length>=p.length,h=n===`equal`&&!m,g=n===`equal`&&m,_={},v={};h&&(_.marker=``),g&&(v.marker=``),c=J(Zo,{...s,..._,children:f}),l=J(Qo,{...s,...v,children:p})}return J(`div`,{"data-truncate-group-container":`middle`,className:a,style:o,children:[J(`div`,{"data-truncate-segment-priority":n===`start`||n===`equal`?`1`:`2`,children:c}),J(`div`,{"data-truncate-segment-priority":n===`end`||n===`equal`?`1`:`2`,children:l})]})}var es={endIndex:-1,startIndex:-1};function ts(e,t,n){return Math.min(Math.max(e,t),n)}function ns(e,t){return e<0||t<e?es:{endIndex:t,startIndex:e}}function rs(e){return e.startIndex<0||e.endIndex<e.startIndex}function is(e,t){return rs(e)?0:(e.endIndex-e.startIndex+1)*t}function as(e,t,n){if(t<=0)return-1;let r=t*n;return e<=0?0:e>=r?t:Math.floor(e/n)}function os(e,t,n){return t<=0||e<=0?-1:e>=t*n?t-1:Math.ceil(e/n)-1}function ss(e){let t=new Map;return e.forEach((e,n)=>{if(e.kind!==`directory`||!e.isExpanded)return;let r=e.ancestorPaths.length,i=t.get(r);if(i==null){t.set(r,[n]);return}i.push(n)}),t}function cs(e,t){let n=0,r=e.length-1,i=-1;for(;n<=r;){let a=Math.floor((n+r)/2),o=e[a];if(o==null)break;if(o<=t){i=a,n=a+1;continue}r=a-1}return i}function ls(e){let t=new Map,n=[];for(let r=0;r<e.length;r+=1){let i=e[r];if(i==null)continue;let a=i.kind===`directory`&&i.isExpanded?[...i.ancestorPaths,i.path]:i.ancestorPaths,o=0;for(;o<n.length&&o<a.length&&n[o]===a[o];)o+=1;for(let e=n.length-1;e>=o;--e){let i=n[e];i!=null&&t.set(i,r-1)}n.length=o;for(let e=o;e<a.length;e+=1){let t=a[e];t!=null&&n.push(t)}}let r=e.length-1;for(let e of n)t.set(e,r);return t}function us(e,t,n){if(e.length===0||t<=0)return[];let r=ls(e),i=ss(e),a=[];for(let r=0;r<e.length;r+=1){let o=i.get(r);if(o==null||o.length===0)break;let s=t+r*n,c=cs(o,Math.min(e.length-1,Math.floor(s/n))),l=null;for(;c>=0;){let t=o[c],n=t==null?null:e[t]??null;if(n!=null&&(r===0||n.ancestorPaths[r-1]===a[r-1]?.path)){l=n;break}--c}if(l==null)break;a.push(l)}return a.map((i,a)=>{let o=a*n,s=(r.get(i.path)??e.length-1)+1;if(s>=e.length)return{row:i,top:o};let c=s*n-t;return{row:i,top:Math.min(o,c-n)}}).filter(e=>e.top+n>0)}function ds(e,t){let n=t.totalRowCount??e.length,r=n*t.itemHeight,i=Math.max(0,t.viewportHeight),a=Math.max(0,Math.floor(t.overscan)),o=Math.max(0,r-i),s=ts(t.scrollTop,0,o),c=t.stickyRows??us(e,s,t.itemHeight),l=c.reduce((e,n)=>Math.max(e,n.top+t.itemHeight),0),u=Math.min(r,s+l),d=Math.max(0,i-l),f=Math.max(0,r-u),p=as(s,n,t.itemHeight),m=as(u,n,t.itemHeight),h=l<=0||p<0||p>=n?-1:p,g=h===-1?-1:Math.min(n-1,m-1),_=h===-1||g<h?0:g-h+1,v=d<=0||m>=n?es:ns(m,os(u+d,n,t.itemHeight)),y=g+1,b=rs(v)?es:ns(Math.max(y,v.startIndex-a),Math.min(n-1,v.endIndex+a)),x=is(b,t.itemHeight);return{occlusion:{firstOccludedIndex:h,lastOccludedIndex:g,occludedCount:_},physical:{itemHeight:t.itemHeight,maxScrollTop:o,overscan:a,scrollTop:s,totalHeight:r,totalRowCount:n,viewportHeight:i},projected:{contentHeight:f,paneHeight:d,paneTop:u},sticky:{height:l,rows:c},visible:v,window:{endIndex:b.endIndex,height:x,offsetTop:rs(b)?0:b.startIndex*t.itemHeight,startIndex:b.startIndex}}}var fs={added:`A`,deleted:`D`,ignored:null,modified:`M`,renamed:`R`,untracked:`U`},ps={added:`Git status: added`,deleted:`Git status: deleted`,ignored:`Git status: ignored`,modified:`Git status: modified`,renamed:`Git status: renamed`,untracked:`Git status: untracked`},ms=`Contains git status items`;function hs(e){let{currentScrollTop:t,focusedIndex:n,itemHeight:r,topInset:i=0,viewportHeight:a}=e;if(n<0)return null;let o=Math.max(0,i),s=n*r,c=s+r;if(s<t+o){let e=Math.max(0,s-o);return e===t?null:e}if(c>t+a){let e=c-a;return e===t?null:e}return null}function gs(e){let{currentScrollTop:t,focusedIndex:n,itemHeight:r,offset:i,topInset:a=0,totalHeight:o,viewportHeight:s}=e;if(i===`nearest`)return hs({currentScrollTop:t,focusedIndex:n,itemHeight:r,topInset:a,viewportHeight:s});if(n<0)return null;let c=Math.max(0,a),l=n*r,u=Math.max(0,s-c),d=i===`center`?c+Math.max(0,(u-r)/2):c,f=Math.max(0,o-s),p=Math.max(0,Math.min(l-d,f));return p===t?null:p}function _s(e){let{currentScrollTop:t,focusedIndex:n,itemHeight:r,targetViewportOffset:i,totalHeight:a,viewportHeight:o}=e;if(n<0)return null;let s=Math.max(0,i),c=n*r,l=c+r,u=t+s,d=t+o;if(c>=u&&l<=d)return null;let f=Math.max(0,a-o),p=Math.max(0,Math.min(c-s,f));return p===t?null:p}function vs(e){if(e==null||!e.isConnected||e===document.body||e===document.documentElement)return!1;e.focus({preventScroll:!0});let t=e.getRootNode();return t instanceof ShadowRoot?t.activeElement===e:document.activeElement===e}function ys(e){let t=e.getRootNode();if(t instanceof ShadowRoot){let e=t.activeElement;return e instanceof HTMLElement?e:null}let n=document.activeElement;return n instanceof HTMLElement&&e.contains(n)?n:null}function bs(e,t){if(e==null)return t;let n=e.getBoundingClientRect().height;return n>0?n:e.clientHeight>0?e.clientHeight:t}function xs(e,t){return e!=null&&e>0?e:t}function Ss(e){let t=e.borderBoxSize,n=Array.isArray(t)?t[0]:t;return n!=null&&Number.isFinite(n.blockSize)&&n.blockSize>0?n.blockSize:e.contentRect.height>0?e.contentRect.height:null}function Cs(e,t,n,r,i=0){let a=hs({currentScrollTop:e.scrollTop,focusedIndex:t,itemHeight:n,topInset:i,viewportHeight:r});return a==null?!1:(e.scrollTop=a,!0)}function ws(e,t,n,r,i,a,o=0){let s=gs({currentScrollTop:e.scrollTop,focusedIndex:t,itemHeight:n,offset:a,topInset:o,totalHeight:i,viewportHeight:r});return s==null?!1:(e.scrollTop=s,!0)}function Ts(e,t,n,r,i,a){let o=_s({currentScrollTop:e.scrollTop,focusedIndex:t,itemHeight:n,targetViewportOffset:a,totalHeight:i,viewportHeight:r});return o==null?!1:(e.scrollTop=o,!0)}function Es(e,t,n,r){return n.end<n.start?null:e<n.start?-t:e>n.end?r:null}function Ds(e){let{renamingPath:t,previousRenamingPath:n,hasRenderedInput:r}=e;return t==null?`reset`:r?n===t?`ignore`:`focus-input`:`reveal-canonical`}function Os({ariaLabel:e,isFlattened:t=!1,ref:n,value:r,onBlur:i,onInput:a}){return J(`input`,{ref:n,"data-item-rename-input":!0,...t?{"data-item-flattened-rename-input":!0}:{},"aria-label":e,value:r,onBlur:i,onInput:a,onClick:e=>e.stopPropagation(),onMouseDown:e=>e.stopPropagation(),onPointerDown:e=>e.stopPropagation()})}function ks(e){let{row:t,mode:n,targetPath:r,ariaLabel:i,domId:a,isParked:o,itemHeight:s,features:c,state:l,extraStyle:u}=e,d=n===`sticky`,f=t.ancestorPaths.at(-1)??``,p={};return l.isFocusRinged&&(p[`data-item-focused`]=!0),t.isSelected&&(p[`data-item-selected`]=!0),l.isContextHovered&&(p[`data-item-context-hover`]=`true`),l.isDragTarget&&(p[`data-item-drag-target`]=!0),l.isDragging&&(p[`data-item-dragging`]=!0),l.effectiveGitStatus!=null&&(p[`data-item-git-status`]=l.effectiveGitStatus),l.containsGitChange&&(p[`data-item-contains-git-change`]=`true`),{"aria-expanded":!d&&t.kind===`directory`?t.isExpanded:void 0,"aria-haspopup":c.contextMenuEnabled?`menu`:void 0,"aria-label":i,"aria-level":d?void 0:t.level+1,"aria-posinset":d?void 0:t.posInSet+1,"aria-selected":d?void 0:t.isSelected?`true`:`false`,"aria-setsize":d?void 0:t.setSize,"data-file-tree-sticky-path":d?r:void 0,"data-file-tree-sticky-row":d?`true`:void 0,"data-item-context-menu-button-visibility":c.actionLaneEnabled?c.contextMenuButtonVisibility:void 0,"data-item-context-menu-trigger-mode":c.contextMenuEnabled?c.contextMenuTriggerMode:void 0,"data-item-has-context-menu-action-lane":c.actionLaneEnabled?`true`:void 0,"data-item-has-git-lane":c.gitLaneActive?`true`:void 0,"data-item-parent-path":f.length>0?f:void 0,"data-item-parked":o?`true`:void 0,"data-item-path":r,"data-item-type":t.kind===`directory`?`folder`:`file`,"data-type":`item`,id:d?void 0:a,role:d?void 0:`treeitem`,style:{minHeight:`${s}px`,...u},tabIndex:!d&&t.isFocused?0:-1,...p}}function As(e){let{event:t,mode:n,isSearchOpen:r,isDirectory:i}=e,a=t.ctrlKey||t.metaKey,o=t.shiftKey||a,s=t.shiftKey?{additive:a,kind:`range`}:a?{kind:`toggle`}:{kind:`single`};return{closeSearch:r,revealCanonical:n===`sticky`,selection:s,toggleDirectory:!o&&i}}var js,Ms,Ns,Ps,Fs=Object.is,Is=0,Ls=[],Rs=q,zs=Rs.__b,Bs=Rs.__r,Vs=Rs.diffed,Hs=Rs.__c,Us=Rs.unmount,Ws=Rs.__;function Gs(e,t){Rs.__h&&Rs.__h(Ms,e,Is||t),Is=0;var n=Ms.__H||={__:[],__h:[]};return e>=n.__.length&&n.__.push({}),n.__[e]}function Ks(e){return Is=1,qs(ic,e)}function qs(e,t,n){var r=Gs(js++,2);if(r.t=e,!r.__c&&(r.__=[n?n(t):ic(void 0,t),function(e){var t=r.__N?r.__N[0]:r.__[0],n=r.t(t,e);Fs(t,n)||(r.__N=[n,r.__[1]],r.__c.setState({}))}],r.__c=Ms,!Ms.__f)){var i=function(e,t,n){if(!r.__c.__H)return!0;var i=r.__c.__H.__.filter(function(e){return!!e.__c});if(i.every(function(e){return!e.__N}))return!a||a.call(this,e,t,n);var o=r.__c.props!==e;return i.forEach(function(e){if(e.__N){var t=e.__[0];e.__=e.__N,e.__N=void 0,Fs(t,e.__[0])||(o=!0)}}),a&&a.call(this,e,t,n)||o};Ms.__f=!0;var a=Ms.shouldComponentUpdate,o=Ms.componentWillUpdate;Ms.componentWillUpdate=function(e,t,n){if(4&this.__g){var r=a;a=void 0,i(e,t,n),a=r}o&&o.call(this,e,t,n)},Ms.shouldComponentUpdate=i}return r.__N||r.__}function Js(e,t){var n=Gs(js++,3);!Rs.__s&&rc(n.__H,t)&&(n.__=e,n.u=t,Ms.__H.__h.push(n))}function Ys(e,t){var n=Gs(js++,4);!Rs.__s&&rc(n.__H,t)&&(n.__=e,n.u=t,Ms.__h.push(n))}function Y(e){return Is=5,Xs(function(){return{current:e}},[])}function Xs(e,t){var n=Gs(js++,7);return rc(n.__H,t)&&(n.__=e(),n.__H=t,n.__h=e),n.__}function Zs(e,t){return Is=8,Xs(function(){return e},t)}function Qs(){for(var e;e=Ls.shift();)if(e.__P&&e.__H)try{e.__H.__h.forEach(tc),e.__H.__h.forEach(nc),e.__H.__h=[]}catch(t){e.__H.__h=[],Rs.__e(t,e.__v)}}Rs.__b=function(e){Ms=null,zs&&zs(e)},Rs.__=function(e,t){e&&t.__k&&t.__k.__m&&(e.__m=t.__k.__m),Ws&&Ws(e,t)},Rs.__r=function(e){Bs&&Bs(e),js=0;var t=(Ms=e.__c).__H;t&&(Ns===Ms?(t.__h=[],Ms.__h=[],t.__.forEach(function(e){e.__N&&(e.__=e.__N),e.u=e.__N=void 0})):(t.__h.forEach(tc),t.__h.forEach(nc),t.__h=[],js=0)),Ns=Ms},Rs.diffed=function(e){Vs&&Vs(e);var t=e.__c;t&&t.__H&&(t.__H.__h.length&&(Ls.push(t)!==1&&Ps===Rs.requestAnimationFrame||((Ps=Rs.requestAnimationFrame)||ec)(Qs)),t.__H.__.forEach(function(e){e.u&&(e.__H=e.u),e.u=void 0})),Ns=Ms=null},Rs.__c=function(e,t){t.some(function(e){try{e.__h.forEach(tc),e.__h=e.__h.filter(function(e){return!e.__||nc(e)})}catch(n){t.some(function(e){e.__h&&=[]}),t=[],Rs.__e(n,e.__v)}}),Hs&&Hs(e,t)},Rs.unmount=function(e){Us&&Us(e);var t,n=e.__c;n&&n.__H&&(n.__H.__.forEach(function(e){try{tc(e)}catch(e){t=e}}),n.__H=void 0,t&&Rs.__e(t,n.__v))};var $s=typeof requestAnimationFrame==`function`;function ec(e){var t,n=function(){clearTimeout(r),$s&&cancelAnimationFrame(t),setTimeout(e)},r=setTimeout(n,35);$s&&(t=requestAnimationFrame(n))}function tc(e){var t=Ms,n=e.__c;typeof n==`function`&&(e.__c=void 0,n()),Ms=t}function nc(e){var t=Ms;e.__c=e.__(),Ms=t}function rc(e,t){return!e||e.length!==t.length||t.some(function(t,n){return!Fs(t,e[n])})}function ic(e,t){return typeof t==`function`?t(e):t}function ac(e,t=null,n=null){"use no memo";let r=e.flattenedSegments;return r==null||r.length===0?t??e.name:J(`span`,{"data-item-flattened-subitems":!0,children:r.map((e,i)=>{let a=i===r.length-1;return J(mo,{children:[J(`span`,{"data-item-flattened-subitem":e.path,"data-item-flattened-subitem-drag-target":n===e.path?`true`:void 0,children:a&&t!=null?t:J(Zo,{children:e.name})}),i<r.length-1?` / `:``]},e.path)})})}function oc(e){return e.isFlattened?e.flattenedSegments?.findLast(e=>e.isTerminal)?.path??e.path:e.path}function sc(e){let t=e.flattenedSegments;return t==null||t.length===0?e.name:t.map(e=>e.name).join(` / `)}function cc(e,t,n,r){return e.map((e,i)=>{let a=i*n,o=e.subtreeEndIndex+1;if(o>=r)return{row:e.row,top:a};let s=o*n-t;return{row:e.row,top:Math.min(a,s-n)}}).filter(e=>e.top+n>0)}function lc({controller:e,itemHeight:t,overscan:n,scrollTop:r,stickyFolders:i,viewportHeight:a}){let o=e.getVisibleCount(),s=i&&o>0?e.getStickyRowCandidates(r,t):[],c=s==null&&i&&o>0?e.getVisibleRows(0,o-1):[],l=ds(c,{itemHeight:t,overscan:n,scrollTop:r,stickyRows:s==null?void 0:cc(s,r,t,o),totalRowCount:o,viewportHeight:a}),u=i&&r<=0&&o>0?e.getStickyRowCandidates(1,t):[],d=u!=null&&r<=0?cc(u,1,t,o):i&&r<=0&&c.length>0?us(c,1,t):l.sticky.rows;return{overlayHeight:d.reduce((e,n)=>Math.max(e,n.top+t),0),overlayRows:d,snapshot:l,visibleRows:c}}var uc=400,dc=10,fc=40,pc=18;function X(e,t,n){let r=e,i=document.elementFromPoint?.bind(document)??null,a=r.elementFromPoint?.(t,n)??i?.(t,n)??null;return e instanceof ShadowRoot&&(a==null||!e.contains(a))?mc(e,t,n):a instanceof HTMLElement?a:null}function mc(e,t,n){let r=Array.from(e.querySelectorAll(`[data-type="item"], [data-item-flattened-subitem]`));for(let e=r.length-1;e>=0;e--){let i=r[e],a=i.getBoundingClientRect();if(t>=a.left&&t<=a.right&&n>=a.top&&n<=a.bottom)return i}return null}function hc(e){let t=e?.closest?.(`[data-type="item"]`);if(!(t instanceof HTMLElement))return null;let n=t.dataset.itemPath??null;if(n==null)return null;let r=e?.closest?.(`[data-item-flattened-subitem]`),i=r instanceof HTMLElement?r.getAttribute(`data-item-flattened-subitem`)??null:null;if(i!=null&&i.endsWith(`/`))return{directoryPath:i,flattenedSegmentPath:i,hoveredPath:n,kind:`directory`};if(t.dataset.itemType===`folder`)return{directoryPath:n,flattenedSegmentPath:null,hoveredPath:n,kind:`directory`};let a=t.dataset.itemParentPath??null;return a==null||a.length===0?{directoryPath:null,flattenedSegmentPath:null,hoveredPath:n,kind:`root`}:{directoryPath:a,flattenedSegmentPath:null,hoveredPath:n,kind:`directory`}}function gc(e){let t=e.cloneNode(!0);return t.removeAttribute(`id`),t.dataset.fileTreeDragPreview=`true`,t.setAttribute(`aria-hidden`,`true`),t.tabIndex=-1,Object.assign(t.style,{boxShadow:`0 4px 12px rgba(0, 0, 0, 0.15)`,left:`0px`,margin:`0`,pointerEvents:`none`,position:`fixed`,top:`0px`,willChange:`transform`,zIndex:`10000`}),t}function _c(){return navigator.vendor!==`Apple Computer, Inc.`}function vc(e,t){let n=e-t.top;if(n<fc)return-Math.ceil((fc-Math.max(0,n))/fc*pc);let r=t.bottom-e;return r<fc?Math.ceil((fc-Math.max(0,r))/fc*pc):0}function yc(e,t){if(e!=null){let t=fs[e];return t==null?null:{text:t,title:ps[e]}}return t?{icon:{name:`file-tree-icon-dot`,width:6,height:6},title:ms}:null}function bc(e,t,n){if(t==null||t.size===0)return null;let r=[];for(let i=e.length-1;i>=0;--i){let a=e[i],o=n.get(a);if(o!=null){for(let e of r)n.set(e,o);return o?`ignored`:null}if(t.has(a)){n.set(a,!0);for(let e of r)n.set(e,!0);return`ignored`}r.push(a)}for(let e of r)n.set(e,!1);return null}function xc(e){return e!=null&&`toggle`in e}function Sc(e){return e.code===`Space`||e.key===` `||e.key===`Spacebar`}function Cc(e){return e.key.length===1&&/^[\p{L}\p{N}]$/u.test(e.key)&&!e.ctrlKey&&!e.metaKey&&!e.altKey}function wc(e){return e==null?``:`[data-item-section="spacing-item"][data-ancestor-path="${e.replaceAll(`\\`,`\\\\`).replaceAll(`"`,`\\"`)}"] { opacity: 1; }`}function Tc(e){return e.shiftKey&&e.key===`F10`||e.key===`ContextMenu`}function Ec(e,t){return t&&Tc(e)||(e.ctrlKey||e.metaKey)&&Sc(e)?!0:e.key===`ArrowDown`||e.key===`ArrowLeft`||e.key===`ArrowRight`||e.key===`ArrowUp`}var Dc=new Set([`ArrowDown`,`ArrowLeft`,`ArrowRight`,`ArrowUp`,`End`,`Home`,`PageDown`,`PageUp`]);function Oc(e){for(let t of e.composedPath())if(t instanceof HTMLElement&&(t.dataset.fileTreeContextMenuRoot===`true`||t.dataset.type===`context-menu-anchor`||t.dataset.type===`context-menu-trigger`||t.getAttribute(`slot`)===`context-menu`))return!0;return!1}function kc(e){return{bottom:e.bottom,height:e.height,left:e.left,right:e.right,top:e.top,width:e.width,x:e.x,y:e.y}}function Ac(e,t){return{bottom:t,height:0,left:e,right:e,top:t,width:0,x:e,y:t}}function jc(e,t){if(e==null)return t.offsetTop;let n=t.getBoundingClientRect(),r=e.getBoundingClientRect();return n.top-r.top}function Mc(e,t,n){if(n==null){e.delete(t);return}e.set(t,n)}function Nc(e,t,n){if(e==null)return null;let r=t.get(e)??null;if(r!=null)return r;let i=n.get(e)??null;return i?.dataset.itemParked===`true`?null:i}function Pc(e){if(e==null)return[];let t=[];for(let n of e.querySelectorAll(`button[data-file-tree-sticky-row="true"]`)){if(!(n instanceof HTMLElement))continue;let e=n.dataset.fileTreeStickyPath;e!=null&&t.push(e)}return t}function Fc(e,t){if(e==null||t==null)return null;for(let n of e.querySelectorAll(`button[data-item-focused="true"][data-item-parked="true"]`))if(n instanceof HTMLElement&&n.dataset.itemPath===t)return n;return null}function Ic(e,t,n,r,i,a,o){let s=Math.max(0,a-i),c=t?.getBoundingClientRect()??null,l=c==null||n==null?null:n.getBoundingClientRect().top-c.top,u=Fc(e,r),d=c==null||u==null?null:u.getBoundingClientRect().top-c.top;return Math.max(0,Math.min(d??Math.max(l??0,s),Math.max(0,o-i)))}function Lc(e,t){return{kind:e.kind,name:sc(e),path:t}}function Rc(e){return e==null?void 0:`${e}__tree`}function zc(e,t,n){if(e!=null)return`${e}__focused-item-${encodeURIComponent(t)}${n?`__parked`:``}`}function Bc(e){return e===`file-tree-icon-chevron`||e===`file-tree-icon-dot`||e===`file-tree-icon-file`||e===`file-tree-icon-lock`}function Vc(e,t){if(e==null)return null;if(`text`in e)return J(`span`,{title:e.title,children:e.text});let n=typeof e.icon==`string`?Bc(e.icon)?t(e.icon):{name:e.icon}:Bc(e.icon.name)?(()=>{let n=t(e.icon.name),{name:r,...i}=e.icon;return{...n,...i}})():e.icon;return J(`span`,{title:e.title,children:J(Vo,{...n})})}function Hc(e){e!=null&&vs(e.querySelector([`button:not([disabled])`,`[href]`,`input:not([disabled])`,`select:not([disabled])`,`textarea:not([disabled])`,`[tabindex]:not([tabindex="-1"])`].join(`, `))??e)}function Z(e,t,{actionLaneEnabled:n=!1,customDecoration:r=null,decorationLaneEnabled:i=!1,dragTargetFlattenedSegmentPath:a=null,gitDecoration:o=null,gitLaneActive:s=!1,renameInput:c=null,showDecorativeActionAffordance:l=!1}={}){let u=oc(e);return J(mo,{children:[e.depth>0?J(`div`,{"data-item-section":`spacing`,children:Array.from({length:e.depth}).map((t,n)=>J(`div`,{"data-item-section":`spacing-item`,"data-ancestor-path":e.ancestorPaths[n]},n))}):null,J(`div`,{"data-item-section":`icon`,children:e.kind===`directory`?J(Vo,{...t(`file-tree-icon-chevron`)}):J(Vo,{...t(`file-tree-icon-file`,u)})}),J(`div`,{"data-item-section":`content`,children:e.isFlattened?ac(e,c,a):c??J($o,{minimumLength:5,split:`extension`,children:e.name})}),i?J(`div`,{"data-item-section":`decoration`,children:r==null?null:Vc(r,t)}):null,s?J(`div`,{"data-item-section":`git`,children:Vc(o,t)}):null,n?J(`div`,{"data-item-section":`action`,children:l?J(`span`,{"aria-hidden":`true`,"data-item-action-affordance":`decorative`,children:J(Vo,{...t(`file-tree-icon-ellipsis`)})}):null}):null]})}function Uc(e,t,n,r={}){let{controller:i,renameView:a,visualFocusPath:o,contextHoverPath:s,draggedPathSet:c,dragTarget:l,dragAndDropEnabled:u,shouldSuppressContextMenu:d,handleRowDragStart:f,handleRowDragEnd:p,handleRowTouchStart:m,instanceId:h,itemHeight:g,gitStatusByPath:_,ignoredGitDirectories:v,ignoredInheritanceCache:y,directoriesWithGitChanges:b,gitLaneActive:x,contextMenuEnabled:S,contextMenuTriggerMode:C,contextMenuButtonTriggerEnabled:w,contextMenuButtonVisibility:T,contextMenuRightClickEnabled:E,registerRenameInput:D,registerButton:ee,resolveIcon:te,renderDecorationForRow:O,openContextMenuForRow:k,onRowClick:A,onKeyDown:j}=e,M=oc(t),{isParked:N=!1,mode:ne=`flow`,style:re}=r,ie=ne===`sticky`,P=_?.get(M)??null??bc(t.ancestorPaths,v,y),ae=t.kind===`directory`&&(b?.has(M)??!1),oe=O(t,M),se=yc(P,ae),ce=S&&w,le=oe!=null||x||ce,ue=ce&&T===`always`,de=a.getPath()===M,fe=de?a.getValue():``,pe=ie||!de?null:J(Os,{ref:D,ariaLabel:`Rename ${sc(t)}`,isFlattened:t.isFlattened,value:fe,onBlur:()=>{a.commit()},onInput:e=>{a.setValue(e.currentTarget.value)}}),me=Z(t,te,{actionLaneEnabled:ce,customDecoration:oe,decorationLaneEnabled:le,dragTargetFlattenedSegmentPath:l?.flattenedSegmentPath??null,gitDecoration:se,gitLaneActive:x,renameInput:pe,showDecorativeActionAffordance:ue}),he={...ks({ariaLabel:sc(t),domId:t.isFocused?zc(h,M,N):void 0,extraStyle:re,features:{actionLaneEnabled:ce,contextMenuButtonVisibility:ce?T:null,contextMenuEnabled:S,contextMenuTriggerMode:S?C:null,gitLaneActive:x},isParked:N,itemHeight:g,mode:ne,row:t,state:{containsGitChange:ae,effectiveGitStatus:P,isContextHovered:s===M,isDragTarget:l?.kind===`directory`&&l.directoryPath===M,isDragging:c?.has(M)===!0,isFocusRinged:t.isFocused&&o===M},targetPath:M}),key:n,onContextMenu:S||u?e=>{if(d()){e.preventDefault();return}S&&(e.preventDefault(),E&&(i.focusMountedPathFromInput(M),k(t,M,{anchorRect:Ac(e.clientX,e.clientY),source:`right-click`})))}:void 0,onFocus:ie?void 0:()=>{i.focusMountedPathFromInput(M)},onKeyDown:ie?void 0:j,ref:e=>{ee(M,e)}};return!ie&&de?J(`div`,{...he,children:me}):J(`button`,{...he,type:`button`,draggable:u&&!N,onDragEnd:u&&!N?p:void 0,onDragStart:u&&!N?e=>{f(e,t,M)}:void 0,onMouseDown:e=>{if(ie){e.preventDefault();return}i.isSearchOpen()&&e.preventDefault()},onTouchStart:u&&!N?e=>{m(e,t,M)}:void 0,onClick:e=>{A(e,t,M,ne)},children:me})}function Wc(e,t,n){return t.end<t.start?[]:e.controller.getVisibleRows(t.start,t.end).filter(e=>!n.has(oc(e))).map((n,r)=>Uc(e,n,t.start+r))}function Gc({composition:e,controller:t,gitStatusByPath:n,ignoredGitDirectories:r,directoriesWithGitChanges:i,icons:a,instanceId:o,itemHeight:s=gt,overscan:c=10,renamingEnabled:l=!1,renderRowDecoration:u,searchBlurBehavior:d=`close`,searchEnabled:f=!1,searchFakeFocus:p=!1,slotHost:m,stickyFolders:h=!1,initialViewportHeight:g=420}){"use no memo";let _=Y(null),v=Y(null),y=Y(!1),b=Y(null),x=Y(null),S=Y(null),C=Y(null),w=Y(null),T=Y(new Map),E=Y(new Map),D=Y(()=>{}),k=Y(null),A=Y(0),j=Y(!1),M=Y(null);M.current!==t&&(j.current=!1,M.current=t);let N=Y(!1),ne=Y(null),re=Y(null),ie=Y(!1),P=Y(null),ae=Y(null),oe=Y(null),se=Y(null),ce=Y(null),le=Y(null),ue=Y(null),de=Y(null),fe=Y(!1),pe=Y(null),me=Y(null),he=Y(null),ge=Y(null),_e=Xs(()=>new Map,[]),[,ve]=Ks(0),[ye,be]=Ks(null),[xe,Se]=Ks(null),[Ce,we]=Ks(null),[Te,Ee]=Ks(null),[De,Oe]=Ks(0),[F,ke]=Ks(null),Ae=Y(F);Ae.current=F;let je=Y(null),Me=Y(null),Ne=Y(null),Pe=Y(null),Fe=Y(null),Ie=Y(!1),Le=()=>{Me.current=null,Ne.current=null,Pe.current=null},Re=(e,t)=>{Me.current=e,Ne.current=null,Pe.current=t==null?null:{path:e,scrollTop:t}},ze=(e,t)=>{Me.current=null,Ne.current={path:e,viewportOffset:t},Pe.current=null},Be=Y(d===`retain`&&t.isSearchOpen()),[Ve,He]=Ks(p);Js(()=>{p||He(!1)},[p]);let Ue=Y(!1),We=Zs(()=>{Ue.current=!0,He(e=>e&&!1)},[]),[Ge,Ke]=Ks(()=>lc({controller:t,itemHeight:s,overscan:c,scrollTop:0,stickyFolders:h,viewportHeight:g})),[qe,Je]=Ks(!1);Js(()=>{Je(!0)},[]);let Ye=e?.contextMenu?.enabled===!0||e?.contextMenu?.render!=null||e?.contextMenu?.onOpen!=null||e?.contextMenu?.onClose!=null,Xe=e?.contextMenu?.triggerMode??(Ye?`right-click`:`both`),Ze=Xe===`both`||Xe===`button`,Qe=e?.contextMenu?.buttonVisibility??`when-needed`,$e=Xe===`both`||Xe===`right-click`;Ys(()=>{let e=S.current;if(e==null)return;let t=e=>{if(!(e instanceof CustomEvent))return;let t=e.detail?.path??null;Fe.current=t,Se(t),Ee(t==null?null:`pointer`)},n=e=>{e instanceof CustomEvent&&(Ie.current=e.detail?.disabled===!0)};return e.addEventListener(`file-tree-debug-set-context-menu-trigger`,t),e.addEventListener(`file-tree-debug-set-scroll-suppression`,n),()=>{e.removeEventListener(`file-tree-debug-set-context-menu-trigger`,t),e.removeEventListener(`file-tree-debug-set-scroll-suppression`,n)}},[]);let et=Zs((e,t)=>{Mc(T.current,e,t)},[]),tt=Zs((e,t)=>{Mc(E.current,e,t)},[]),nt=Zs(e=>{x.current=e},[]),rt=Zs(e=>Nc(e,E.current,T.current),[]),it=n!=null||r!=null||i!=null,{resolveIcon:at}=Xs(()=>Ya(a),[a]),ot=t[Na](),st=ot.getPath(),ct=st!=null,lt=t.isSearchOpen(),ut=t.getSearchValue(),I=t.getFocusedPath(),L=t.getFocusedIndex(),dt=t.getScrollRequest(),ft=t.isDragAndDropEnabled(),pt=t.getDragSession(),mt=Xs(()=>pt==null?null:new Set(pt.draggedPaths),[pt]),ht=pt?.target??null,_t=pt?.primaryPath??null,vt=Rc(o),{overlayHeight:yt,overlayRows:bt,snapshot:xt,visibleRows:St}=Ge,Ct=xt.physical.viewportHeight,wt=Xs(()=>({end:xt.window.endIndex,start:xt.window.startIndex}),[xt.window.endIndex,xt.window.startIndex]),Tt=bt,Et=xt.sticky.rows,Dt=xt.physical.totalHeight,Ot=xt.sticky.height,kt=Xs(()=>new Set(Et.map(e=>oc(e.row))),[Et]),At=L>=0&&L>=wt.start&&L<=wt.end,jt=Zs((e,t)=>u?.({item:Lc(e,t),row:e})??null,[u]),Mt=Zs(e=>vs(e==null?null:T.current.get(e)??null)?!0:vs(S.current),[]),Nt=Zs(e=>{Mt(t.focusNearestPath(e))},[t,Mt]),Pt=Y(Nt);Pt.current=Nt;let Ft=Y(!0),It=Y(()=>{}),Lt=Zs((t=!0)=>{let n=Ae.current;n!=null&&(Ft.current=Ft.current&&t,ke(null),e?.contextMenu?.onClose?.(),Ft.current&&Nt(n.path))},[e?.contextMenu,Nt]);It.current=Lt;let Rt=Zs(e=>{let t=e==null?null:jc(S.current,e);we(e=>e===t?e:t)},[]),zt=Zs((e,n,r)=>{let i=t.getItem(n);if(i==null)return;let a=rt(n);if(a?.dataset.fileTreeStickyRow===`true`){let e=C.current;Re(n,e?.scrollTop??null),N.current=!0,be(e=>e===n?e:n)}i.focus(),Rt(a),Ft.current=!0,ke({anchorRect:r?.anchorRect??null,item:Lc(e,n),path:n,source:r?.source??`keyboard`})},[t,rt,Rt]),Bt=Zs(e=>{if(l){if(t.isSearchOpen()){let e=C.current,t=bs(e,Ct);P.current=L<0||e==null?null:Math.max(0,Math.min(L*s-e.scrollTop,Math.max(0,t-s))),ie.current=!0}t.startRenaming(e)!==!1&&(Ee(`focus`),ve(e=>e+1))}},[t,L,s,l,Ct]),Vt=Zs((e,{restoreTreeFocus:n=!0,targetOffset:r=`live-overlay`}={})=>{let i=C.current;if(i==null)return!1;t.focusPath(e);let a=t.getFocusedIndex();if(a<0)return!1;let o=t.getVisibleRows(a,a)[0]??null;if(o==null)return!1;let l=bs(i,Ct),u=t.getVisibleCount()*s,d=r===`sticky-parents`?o.ancestorPaths.length*s:lc({controller:t,itemHeight:s,overscan:c,scrollTop:i.scrollTop,stickyFolders:h,viewportHeight:l}).snapshot.sticky.height;return N.current=!0,Ts(i,a,s,l,u,d),D.current(),je.current=n?e:null,!0},[t,s,c,Ct,h]),Ht=()=>y.current===!0||ge.current!=null||fe.current===!0,Ut=e=>typeof window.requestAnimationFrame==`function`?window.requestAnimationFrame(()=>{e()}):window.setTimeout(e,16),R=e=>{if(e!=null){if(typeof window.cancelAnimationFrame==`function`){window.cancelAnimationFrame(e);return}window.clearTimeout(e)}},Wt=()=>{se.current!=null&&(clearTimeout(se.current),se.current=null),oe.current=null},Gt=()=>{le.current?.remove(),le.current=null},Kt=()=>{R(ae.current),ae.current=null,ce.current=null},qt=e=>{let t=S.current?.getRootNode();if(t instanceof ShadowRoot){t.append(e);return}document.body.append(e)},Jt=()=>{de.current?.(),de.current=null,ge.current!=null&&(clearTimeout(ge.current),ge.current=null),fe.current=!1,pe.current=null,he.current=null,me.current!=null&&(me.current.setAttribute(`draggable`,`true`),me.current.style.removeProperty(`touch-action`),me.current=null),Gt(),Wt(),Kt(),ue.current=null},z=(e,n)=>{let r=S.current?.getRootNode(),i=hc(X(r instanceof ShadowRoot?r:document,e,n));return t.setDragTarget(i),t.getDragSession()?.target??null},Yt=e=>{let n=t.getDragAndDropConfig()?.openOnDropDelay??800;if(e==null||e.kind!==`directory`||e.directoryPath==null||n<=0){Wt();return}let r=t.getItem(e.directoryPath),i=xc(r)?r:null;if(i==null||i.isExpanded()){Wt();return}let a=`${e.directoryPath}::${e.flattenedSegmentPath??``}`;oe.current!==a&&(Wt(),oe.current=a,se.current=setTimeout(()=>{let n=t.getDragSession()?.target;n?.kind!==`directory`||n.directoryPath!==e.directoryPath||n.flattenedSegmentPath!==e.flattenedSegmentPath||i.expand()},n))},B=()=>{ae.current=null;let e=ce.current,n=C.current;if(e==null||n==null||t.getDragSession()==null)return;let r=n.getBoundingClientRect(),i=vc(e.clientY,r);if(i===0)return;let a=Math.max(0,n.scrollHeight-n.clientHeight),o=Math.max(0,Math.min(a,n.scrollTop+i));o!==n.scrollTop&&(n.scrollTop=o,D.current()),Yt(z(e.clientX,e.clientY)),ae.current=Ut(B)},Xt=(e,t)=>{ce.current={clientX:e,clientY:t},ae.current??=Ut(B)},Zt=(e,n,r)=>{let i=e.currentTarget;if(i!=null){if(Jt(),Gt(),Wt(),Kt(),t.startDrag(r)===!1){e.preventDefault();return}if(ue.current=n,e.dataTransfer!=null&&(e.dataTransfer.effectAllowed=`move`,e.dataTransfer.dropEffect=`move`,e.dataTransfer.setData(`text/plain`,r),_c())){let t=gc(i),n=i.getBoundingClientRect();Object.assign(t.style,{height:`${n.height}px`,opacity:`0.85`,transform:`translate3d(-9999px, 0px, 0)`,width:`${n.width}px`}),qt(t),le.current=t,e.dataTransfer.setDragImage(t,Math.max(0,e.clientX-n.left),Math.max(0,e.clientY-n.top))}}},Qt=()=>{Gt(),Wt(),Kt(),ue.current=null,t.cancelDrag()},$t=(e,n,r)=>{if(ge.current!=null||fe.current)return;let i=e.touches[0],a=e.currentTarget;if(i==null||a==null)return;he.current={clientX:i.clientX,clientY:i.clientY},me.current=a,a.setAttribute(`draggable`,`false`);let o=(e={})=>{let t=e.restoreNativeDraggable??!fe.current;ge.current!=null&&(clearTimeout(ge.current),ge.current=null),document.removeEventListener(`touchmove`,s),document.removeEventListener(`touchend`,c),document.removeEventListener(`touchcancel`,c),de.current===o&&(de.current=null),t&&(a.setAttribute(`draggable`,`true`),me.current===a&&(me.current=null),he.current=null)},s=e=>{let t=e.touches[0],n=he.current;if(t==null||n==null)return;let r=t.clientX-n.clientX,i=t.clientY-n.clientY;r*r+i*i<=dc*dc||o()},c=()=>{o()};document.addEventListener(`touchmove`,s,{passive:!0}),document.addEventListener(`touchend`,c),document.addEventListener(`touchcancel`,c),de.current=o,ge.current=setTimeout(()=>{if(o({restoreNativeDraggable:!1}),t.startDrag(r)===!1){a.setAttribute(`draggable`,`true`),me.current===a&&(me.current=null),he.current=null;return}fe.current=!0,me.current=a,a.setAttribute(`draggable`,`false`),a.style.setProperty(`touch-action`,`none`),ue.current=n;let e=a.getBoundingClientRect(),s=gc(a);Object.assign(s.style,{height:`${e.height}px`,opacity:`0.85`,transform:`translate3d(${e.left}px, ${e.top}px, 0)`,width:`${e.width}px`}),qt(s),le.current=s,pe.current={x:i.clientX-e.left,y:i.clientY-e.top};let c=e=>{let t=e.touches[0];if(t==null)return;e.preventDefault();let n=pe.current;n!=null&&le.current!=null&&(le.current.style.transform=`translate3d(${t.clientX-n.x}px, ${t.clientY-n.y}px, 0)`),Yt(z(t.clientX,t.clientY)),Xt(t.clientX,t.clientY)},l=e=>{let n=e.changedTouches[0];n!=null&&z(n.clientX,n.clientY),t.completeDrag(),Jt()},u=()=>{t.cancelDrag(),Jt()};de.current=()=>{document.removeEventListener(`touchmove`,c),document.removeEventListener(`touchend`,l),document.removeEventListener(`touchcancel`,u)},document.addEventListener(`touchmove`,c,{passive:!1}),document.addEventListener(`touchend`,l),document.addEventListener(`touchcancel`,u)},uc)},en=e=>{if(F!=null){if(e.key===`Escape`){Lt(),e.preventDefault(),e.stopPropagation();return}Dc.has(e.key)&&(e.preventDefault(),e.stopPropagation());return}if(ot.isActive()){if(e.key===`Escape`)ot.cancel();else if(e.key===`Enter`)ot.commit();else return;Ee(`focus`),ve(e=>e+1),e.preventDefault(),e.stopPropagation();return}if(l&&e.key===`F2`){Bt(I??void 0),e.preventDefault(),e.stopPropagation();return}if(lt){if(e.key===`Escape`)ie.current=!1,P.current=null,t.closeSearch();else if(e.key===`Enter`){let e=t.getFocusedPath();e!=null&&t.selectOnlyPath(e);let n=C.current,r=bs(n,Ct);P.current=L<0||n==null?null:Math.max(0,Math.min(L*s-n.scrollTop,Math.max(0,r-s))),ie.current=!0,t.closeSearch()}else if(e.key===`ArrowDown`)t.focusNextSearchMatch();else if(e.key===`ArrowUp`)t.focusPreviousSearchMatch();else return;Ee(`focus`),ve(e=>e+1),e.preventDefault(),e.stopPropagation();return}if(f&&Cc(e)){t.openSearch(e.key),ve(e=>e+1),e.preventDefault(),e.stopPropagation();return}let n=Ye&&Tc(e),r=Ec(e,Ye),i=r&&S.current!=null?ys(S.current):null,a=r?new Set(Pc(S.current)):new Set,o=i?.dataset.fileTreeStickyPath??null,c=i?.dataset.fileTreeStickyRow===`true`&&o!=null;if(c&&o!==I&&a.has(o)){let e=C.current;Re(o,e?.scrollTop??null),t.focusPath(o)}let u=t.getFocusedPath(),d=t.getFocusedIndex(),p=t.getFocusedItem();if(p==null)return;let m=xc(p)?p:null,h=u!=null&&(kt.has(u)||c&&o===u&&a.has(u)),g=e.key===`ArrowDown`||e.key===`ArrowUp`||e.key===`ArrowRight`&&m!=null&&m.isExpanded(),_=e.key===`ArrowLeft`&&h&&m!=null&&m.isExpanded(),v=C.current,y=!0;if(e.shiftKey&&e.key===`ArrowDown`)t.extendSelectionFromFocused(1);else if(e.shiftKey&&e.key===`ArrowUp`)t.extendSelectionFromFocused(-1);else if(n&&u!=null&&d>=0){let e=t.getVisibleRows(d,d)[0]??null,n=Nc(u,E.current,T.current);e==null||n==null?y=!1:zt(e,u)}else if((e.ctrlKey||e.metaKey)&&Sc(e))t.toggleFocusedSelection();else if((e.ctrlKey||e.metaKey)&&e.key.toLowerCase()===`a`)t.selectAllVisiblePaths();else switch(e.key){case`ArrowDown`:t.focusNextItem();break;case`ArrowUp`:t.focusPreviousItem();break;case`ArrowRight`:m==null||m.isExpanded()?t.focusNextItem():m.expand();break;case`ArrowLeft`:m!=null&&m.isExpanded()?m.collapse():t.focusParentItem();break;case`Home`:t.focusFirstItem();break;case`End`:t.focusLastItem();break;default:y=!1}if(!y)return;Ee(`focus`);let b=t.getFocusedPath(),x=b!=null&&(kt.has(b)||a.has(b)),w=g&&b!==u,D=n&&c&&o===u&&b===u;if((h||D)&&b!=null&&(w&&x||D))Re(b,v?.scrollTop??null),N.current=!0,be(e=>e===b?e:b);else{let t=e.key===`ArrowUp`&&h&&b!==u;b!=null&&(t||_&&b===u)?(ze(b,Ic(S.current,v,i,u,s,Ot,Ct)),N.current=!0,be(e=>e===b?e:b)):Le()}ve(e=>e+1),e.preventDefault(),e.stopPropagation()};Ys(()=>{if(!(!f||!lt)){if(Be.current){Be.current=!1;return}vs(w.current)}},[lt,f]),Ys(()=>{let e=x.current;switch(Ds({hasRenderedInput:e!=null,previousRenamingPath:re.current,renamingPath:st})){case`reset`:re.current=null;return;case`reveal-canonical`:st!=null&&Vt(st,{restoreTreeFocus:!1,targetOffset:`live-overlay`});return;case`ignore`:return;case`focus-input`:e!=null&&(je.current=null,re.current=st,vs(e),e.select());return}},[wt.end,wt.start,st,Vt,kt]),Ys(()=>{let e=S.current;if(e==null)return;let t=null,n=()=>{t!=null&&(clearTimeout(t),t=null)},r=()=>{let t=ys(e)?.dataset.itemPath??null;be(e=>e===t?e:t)},i=()=>{n(),N.current=!0,r()},a=i=>{let a=i.relatedTarget;if(a==null){n(),t=setTimeout(()=>{if(t=null,ys(e)!=null){r();return}N.current=!1,be(null)},0);return}if(!(a instanceof Node)||!e.contains(a)){n(),N.current=!1,be(null);return}let o=a instanceof HTMLElement?a.dataset.itemPath??null:null;be(e=>e===o?e:o)};return e.addEventListener(`focusin`,i),e.addEventListener(`focusout`,a),()=>{n(),e.removeEventListener(`focusin`,i),e.removeEventListener(`focusout`,a)}},[]),Ys(()=>{let e=S.current;e!=null&&(xt.physical.scrollTop<=0?e.dataset.scrollAtTop=`true`:delete e.dataset.scrollAtTop)},[xt.physical.scrollTop]),Ys(()=>{let e=null,n=C.current,r=b.current,i=S.current;if(n==null)return;k.current=bs(n,g);let a=()=>{let e=t.getVisibleCount(),r=xs(k.current,g),i=Math.max(0,e*s-r);n.scrollTop>i&&(n.scrollTop=i),Ke(lc({controller:t,itemHeight:s,overscan:c,scrollTop:Math.min(n.scrollTop,i),stickyFolders:h,viewportHeight:r}))};if(!j.current){j.current=!0;let e=t.getFocusedIndex();if(e>=0){let r=xs(k.current,g),i=t.getVisibleRows(e,e)[0]??null;Cs(n,e,s,r,h&&i!=null?Math.max(0,Math.min(i.ancestorPaths.length*s,Math.max(0,r-s))):0)}}D.current=a;let o=!1,l=t.subscribe(()=>{o?ve(e=>e+1):o=!0,a()}),u=()=>{Ie.current!==!0&&(r!=null&&(r.dataset.isScrolling??=``),i!=null&&(i.dataset.isScrolling??=``),y.current=!0,e!=null&&clearTimeout(e),e=setTimeout(()=>{r!=null&&delete r.dataset.isScrolling,i!=null&&delete i.dataset.isScrolling,y.current=!1,Oe(e=>e+1),e=null},50))},d=null,f=()=>{i!=null&&delete i.dataset.overlayReveal,d!=null&&(clearTimeout(d),d=null)},p=()=>{i==null||Ie.current===!0||n.scrollTop>0||(i.dataset.overlayReveal=`true`,d!=null&&clearTimeout(d),d=setTimeout(()=>{f()},200))},m=()=>{if(a(),n.scrollTop>0&&f(),Ae.current!=null&&y.current&&It.current(),Ie.current===!0){y.current=!1;return}Se(e=>e==null?e:null),u()},_=()=>{u(),p()},v=new Set([`ArrowUp`,`ArrowDown`,`ArrowLeft`,`ArrowRight`,`PageUp`,`PageDown`,`Home`,`End`,` `,`Spacebar`]),x=e=>{v.has(e.key)&&_()};n.addEventListener(`scroll`,m,{passive:!0}),n.addEventListener(`wheel`,_,{passive:!0}),n.addEventListener(`touchmove`,_,{passive:!0}),n.addEventListener(`keydown`,x);let w=typeof ResizeObserver<`u`?new ResizeObserver(e=>{k.current=(e[0]==null?null:Ss(e[0]))??bs(n,g),a()}):null;return w?.observe(n),()=>{D.current=()=>{},l(),n.removeEventListener(`scroll`,m),n.removeEventListener(`wheel`,_),n.removeEventListener(`touchmove`,_),n.removeEventListener(`keydown`,x),e!=null&&clearTimeout(e),d!=null&&clearTimeout(d),r!=null&&delete r.dataset.isScrolling,i!=null&&(delete i.dataset.isScrolling,delete i.dataset.overlayReveal),y.current=!1,k.current=null,w?.disconnect()}},[t,g,s,c,h]),Ys(()=>{Ye||F==null||Lt(!1)},[Lt,Ye,F]);let V=Xs(()=>F==null?null:`${F.path}::${F.source}`,[F]);Ys(()=>{if(V==null){m?.clearSlotContent(te);return}let t=Ae.current;if(t==null)return;let n=v.current??_.current;if(n==null)return;let r={anchorElement:n,anchorRect:t.anchorRect??kc(n.getBoundingClientRect()),close:e=>{It.current(e?.restoreFocus??!0)},restoreFocus:()=>{Ft.current&&Pt.current(Ae.current?.path??null)}},i=e?.contextMenu?.render?.(t.item,r)??null;return m?.setSlotContent(te,i),e?.contextMenu?.onOpen?.(t.item,r),Hc(i),queueMicrotask(()=>{i==null||!i.isConnected||document.activeElement===i&&Hc(i)}),()=>{m?.clearSlotContent(te)}},[V,e?.contextMenu,m]),Ys(()=>{F!=null&&t.getItem(F.path)==null&&Lt()},[Lt,F,t]),Ys(()=>{if(F==null)return;let e=S.current?.getRootNode(),t=e instanceof ShadowRoot?e.host:S.current,n=e=>{let n=e.target;n instanceof Node&&(Oc(e)||_.current?.contains(n)!==!0&&t?.contains(n)!==!0&&Lt())},r=e=>{e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),Lt())};return document.addEventListener(`mousedown`,n,!0),document.addEventListener(`keydown`,r,!0),()=>{document.removeEventListener(`mousedown`,n,!0),document.removeEventListener(`keydown`,r,!0)}},[Lt,F]),Ys(()=>{let e=C.current,n=S.current;if(e==null||n==null){ne.current=I;return}let r=I==null?null:T.current.get(I)??null,i=ys(n),a=i?.dataset.itemPath??null,o=ct&&x.current===i,c=f&&w.current===i,l=ie.current&&!lt,u=P.current??0,d=je.current,p=Me.current,m=Ne.current,g=Pe.current,_=i!=null,v=N.current||_,y=ne.current!==I,b=p!=null&&p===I&&I!=null,E=!1,ee=!1;if(dt!=null&&dt.id!==A.current){A.current=dt.id;let n=dt.visibleIndex,r=t.getVisibleRows(n,n)[0]??null;if(r!=null){let t=h?Math.max(0,Math.min(r.ancestorPaths.length*s,Math.max(0,Ct-s))):Ot;E=!0,ee=ws(e,n,s,Ct,Dt,dt.offset,t)}t.clearScrollRequest(dt.id)}let te=!E&&l&&Ts(e,L,s,Ct,Dt,u),O=!E&&d!=null&&d===I&&Ts(e,L,s,Ct,Dt,Ot),k=!E&&m!=null&&m.path===I&&Ts(e,L,s,Ct,Dt,m.viewportOffset),j=!E&&g!=null&&g.path===I&&e.scrollTop!==g.scrollTop;if(j&&(e.scrollTop=g.scrollTop),(j||ee||O||k||te||v&&y&&d!==I&&!b&&Cs(e,L,s,Ct,Ot))&&D.current(),E){ne.current=I;return}if(!v){ne.current=I;return}if(o){ne.current=I;return}if(c&&!l){ne.current=I;return}if(r==null){l&&L>=0&&(Ts(e,L,s,Ct,Dt,u),D.current()),ne.current=I;return}(y||l||d===I||p===I||m?.path===I||g?.path===I||a==null||a!==I)&&(vs(r),d===I&&(je.current=null),p===I&&(Me.current=null),m?.path===I&&(Ne.current=null),g?.path===I&&(Pe.current=null),ie.current=!1,P.current=null),ne.current=I},[t,L,I,At,s,ct,lt,wt,Ct,f,dt,h,Ot,Dt,St]);let tn=L>=0&&L>=xt.visible.startIndex&&L<=xt.visible.endIndex,nn=I!=null&&Tt.some(e=>oc(e.row)===I),rn=tn||nn,an=Ze&&N.current===!0&&rn?I:null,on=Te===`pointer`?xe:null,sn=F?.path??Fe.current??on??an??xe,cn=F?.source===`right-click`;Ys(()=>{y.current&&F==null||Rt(rt(sn))},[F,rt,wt,Ct,De,Tt,sn,Rt,St]);let ln=Zs(e=>{if(y.current||Oc(e))return;let t=e.target;if(!(t instanceof HTMLElement)||t.closest?.(`[data-type="context-menu-trigger"]`)!=null)return;let n=t.closest?.(`[data-file-tree-sticky-row="true"]`),r=t.closest?.(`[data-type="item"]`),i=n instanceof HTMLElement?n.dataset.fileTreeStickyPath??null:r instanceof HTMLElement?r.dataset.itemPath??null:null;i!=null&&Ee(e=>e===`pointer`?e:`pointer`),Se(e=>e===i?e:i)},[]),un=Zs(()=>{Se(null)},[]);Ys(()=>{if(!ft)return;let e=()=>{Jt(),t.cancelDrag()};return window.addEventListener(`dragend`,e),()=>{window.removeEventListener(`dragend`,e),Jt(),t.cancelDrag()}},[t,ft]);let dn=e=>{if(!ft||t.getDragSession()==null||fe.current)return;let n=hc(e.target instanceof HTMLElement?e.target:null);t.setDragTarget(n),Yt(t.getDragSession()?.target??null),Xt(e.clientX,e.clientY),e.dataTransfer!=null&&(e.dataTransfer.dropEffect=`move`),e.preventDefault()},fn=e=>{if(!ft||t.getDragSession()==null||fe.current)return;let n=e.relatedTarget;n instanceof Node&&S.current?.contains(n)===!0||(Wt(),Kt(),t.setDragTarget(null))},pn=e=>{!ft||t.getDragSession()==null||fe.current||(e.preventDefault(),z(e.clientX,e.clientY),t.completeDrag(),Gt(),Wt(),Kt(),ue.current=null)},mn=xt.window.height,hn=xt.window.offsetTop,gn=Math.min(0,Ct-mn),_n=Math.min(0,Ct-mn-Ot),vn=ye===I||ie.current,yn=I!=null&&vn&&!At&&L>=0?St[L]??t.getVisibleRows(L,L)[0]??null:null,bn=yn==null?null:Es(L,s,wt,mn),xn=ue.current,Sn=_t!=null&&xn!=null&&xn.path===_t&&xn.index>=wt.start&&xn.index<=wt.end,Cn=_t!=null&&xn!=null&&xn.path===_t&&!Sn&&xn.path!==yn?.path?xn:null,wn=Cn==null?null:Es(Cn.index,s,wt,mn),Tn=wc((L>=0?St[L]??t.getVisibleRows(L,L)[0]??null:null)?.ancestorPaths.at(-1)??null),En=lt&&I!=null?zc(o,I,!At):void 0,Dn=F?.path??(lt?I:ye),On=F?.path??xe,kn=rt(sn),An=Ye&&Ze&&!cn&&!ct&&kn!=null&&Ce!=null&&sn!=null,jn=Ye&&(An||F!=null),Mn=F?.anchorRect,Nn=Mn==null&&kn!=null&&Ce!=null&&(F!=null||An)?Ce:null,Pn=Mn==null?Nn==null?void 0:{top:`${Nn}px`}:{left:`${Mn.left}px`,position:`fixed`,right:`auto`,top:`${Mn.top}px`},Fn=cn?{opacity:`0`}:void 0,In=Zs((e,n,r,i)=>{let a=As({event:{ctrlKey:e.ctrlKey,metaKey:e.metaKey,shiftKey:e.shiftKey},isDirectory:n.kind===`directory`,isSearchOpen:lt,mode:i}),o=a.toggleDirectory&&n.kind===`directory`,s=o?t.resolveMountedDirectoryPathFromInput(r):null;if(o&&s==null)return;let c=s??r;switch(a.selection.kind){case`range`:t.selectPathRange(c,a.selection.additive);break;case`toggle`:t.togglePathSelectionFromInput(c);break;case`single`:t.selectOnlyMountedPathFromInput(c);break}let l=e.currentTarget instanceof HTMLElement?e.currentTarget:null,u=n.index>=xt.visible.startIndex&&n.index<=xt.visible.endIndex,d=i===`flow`&&u&&l!=null&&l.dataset.itemParked!==`true`;t.focusMountedPathFromInput(c),d&&(N.current=!0,be(e=>e===c?e:c),Ee(`focus`)),o&&t.toggleMountedDirectoryFromInput(c),a.closeSearch&&t.closeSearch(),a.revealCanonical&&Vt(c,{targetOffset:`sticky-parents`})},[t,lt,xt.visible.endIndex,xt.visible.startIndex,Vt]),Ln=()=>{if(y.current||!Ze||sn==null||kn==null)return;let e=t.getItem(sn);e!=null&&(Rt(kn),Ft.current=!0,ke({anchorRect:null,item:{kind:e.isDirectory()?`directory`:`file`,name:kn.getAttribute(`aria-label`)??sn,path:e.getPath()},path:e.getPath(),source:`button`}))},Rn={contextHoverPath:On,contextMenuButtonTriggerEnabled:Ze,contextMenuButtonVisibility:Qe,contextMenuEnabled:Ye,contextMenuRightClickEnabled:$e,contextMenuTriggerMode:Xe,controller:t,directoriesWithGitChanges:i,dragAndDropEnabled:ft,draggedPathSet:mt,dragTarget:ht,gitLaneActive:it,gitStatusByPath:n,handleRowDragEnd:Qt,handleRowDragStart:Zt,handleRowTouchStart:$t,ignoredGitDirectories:r,ignoredInheritanceCache:_e,instanceId:o,itemHeight:s,onKeyDown:en,onRowClick:In,openContextMenuForRow:zt,registerButton:et,registerRenameInput:nt,renameView:ot,renderDecorationForRow:jt,resolveIcon:at,shouldSuppressContextMenu:Ht,visualFocusPath:Dn},zn={...Rn,registerButton:tt};return J(`div`,{ref:S,id:vt,"data-file-tree-context-menu-button-visibility":Ye&&Ze?Qe:void 0,"data-file-tree-context-menu-trigger-mode":Ye?Xe:void 0,"data-file-tree-has-context-menu-action-lane":Ye&&Ze?`true`:void 0,"data-file-tree-has-git-lane":it?`true`:void 0,"data-file-tree-virtualized-root":`true`,onDragLeave:ft?fn:void 0,onDragOver:ft?dn:void 0,onDrop:ft?pn:void 0,onKeyDown:en,onPointerLeave:Ye?un:void 0,onPointerOver:Ye?ln:void 0,role:`tree`,tabIndex:-1,style:{outline:`none`,position:`relative`},children:[J(`style`,{"data-file-tree-guide-style":`true`,dangerouslySetInnerHTML:{__html:Tn}}),J(`slot`,{name:ee,"data-type":`header-slot`}),f?J(`div`,{"data-file-tree-search-container":!0,"data-open":lt?`true`:`false`,children:J(`input`,{ref:w,"aria-activedescendant":En,"aria-controls":vt,placeholder:`Search…`,"data-file-tree-search-input":!0,"data-file-tree-search-input-fake-focus":Ve?`true`:void 0,value:ut,onBlur:()=>{d===`retain`&&!Ue.current||t.closeSearch()},onFocus:We,onPointerDown:We,onInput:e=>{We();let n=e.currentTarget;t.setSearch(n.value)}})}):null,J(`div`,{ref:C,"data-file-tree-virtualized-scroll":`true`,children:[h&&qe&&Tt.length>0?J(`div`,{"aria-hidden":`true`,"data-file-tree-sticky-overlay":`true`,children:J(`div`,{"data-file-tree-sticky-overlay-content":`true`,style:{height:`${yt}px`},children:Tt.map((e,t)=>Uc(zn,e.row,`sticky:${oc(e.row)}`,{mode:`sticky`,style:{left:`0`,position:`absolute`,right:`0`,top:`${e.top}px`,zIndex:`${Tt.length-t}`}}))})}):null,J(`div`,{ref:b,"data-file-tree-virtualized-list":`true`,style:{height:`${Dt}px`},children:[J(`div`,{"data-file-tree-virtualized-sticky-offset":`true`,"aria-hidden":`true`,style:{height:`${hn}px`}}),J(`div`,{"data-file-tree-virtualized-sticky":`true`,style:{height:`${mn}px`,top:`${gn}px`,bottom:`${_n}px`},children:[Wc(Rn,wt,kt),yn!=null&&bn!=null?Uc(Rn,yn,`parked:${yn.path}`,{isParked:!0,style:{left:`0`,opacity:`0`,pointerEvents:_t===yn.path?`none`:void 0,position:`absolute`,right:`0`,top:`${bn}px`}}):null,Cn!=null&&wn!=null?Uc(Rn,Cn,`parked-drag:${Cn.path}`,{isParked:!0,style:{left:`0`,opacity:`0`,pointerEvents:`none`,position:`absolute`,right:`0`,top:`${wn}px`}}):null]})]})]}),Ye?J(`div`,{ref:_,"data-type":`context-menu-anchor`,"data-visible":jn?`true`:`false`,style:Pn,children:[J(`button`,{ref:v,type:`button`,"data-type":O,"aria-label":`Options`,"aria-haspopup":`menu`,"aria-expanded":F==null?`false`:`true`,"data-visible":An?`true`:`false`,onMouseDown:e=>{e.preventDefault()},onClick:e=>{if(e.preventDefault(),e.stopPropagation(),F!=null){Lt();return}Ln()},tabIndex:-1,style:Fn,children:J(Vo,{...at(`file-tree-icon-ellipsis`)})}),F==null?null:J(`slot`,{name:te})]}):null,F==null?null:J(`div`,{"data-type":`context-menu-wash`,"aria-hidden":`true`,onMouseDownCapture:e=>{e.preventDefault(),Lt()},onTouchStartCapture:e=>{e.preventDefault(),e.stopPropagation(),Lt()},onTouchMoveCapture:e=>{e.preventDefault(),e.stopPropagation()},onWheelCapture:e=>{e.preventDefault(),e.stopPropagation()}})]})}var Kc={hydrateRoot:(e,t)=>{Io(fo(Gc,t),e)},renderRoot:(e,t)=>{Fo(fo(Gc,t),e)},unmountRoot:e=>{Fo(null,e)}};function qc(e,t){Kc.renderRoot(e,t)}function Jc(e,t){Kc.hydrateRoot(e,t)}function Yc(e){Kc.unmountRoot(e)}var Xc=class{#e=new Map;#t=null;clearAll(){for(let e of this.#e.values())e.remove();this.#e.clear()}clearSlotContent(e){let t=this.#n(e);t!=null&&(t.remove(),this.#e.delete(e))}setHost(e){if(this.#t=e,e!=null){this.#i(e);for(let[e,t]of this.#e)this.#r(e,t)}}setSlotContent(e,t){let n=this.#n(e);if(n===t){t!=null&&(this.#e.set(e,t),this.#r(e,t));return}if(n?.remove(),t==null){this.#e.delete(e);return}this.#e.set(e,t),this.#r(e,t)}setSlotHtml(e,t){let n=t?.trim()??``;if(n.length===0){this.setSlotContent(e,null);return}let r=this.#n(e);if(r!=null&&r.innerHTML===n){this.#e.set(e,r),this.#r(e,r);return}let i=document.createElement(`div`);i.innerHTML=n,this.setSlotContent(e,i)}#n(e){let t=this.#e.get(e)??null;if(t!=null)return t;let n=this.#t;if(n==null)return null;for(let t of Array.from(n.children))if(t instanceof HTMLElement&&t.dataset.fileTreeManagedSlot===e)return t;return null}#r(e,t){t.slot=e,t.dataset.fileTreeManagedSlot=e,this.#t!=null&&t.parentNode!==this.#t&&this.#t.appendChild(t)}#i(e){for(let t of Array.from(e.children)){if(!(t instanceof HTMLElement))continue;let e=t.dataset.fileTreeManagedSlot;e==null||this.#e.has(e)||this.#e.set(e,t)}}},Zc,Q,Qc,$c,el,tl,nl,rl,il,al,ol,sl,cl,ll,ul={},dl=[],fl=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,pl=Array.isArray;function ml(e,t){for(var n in t)e[n]=t[n];return e}function hl(e){e&&e.parentNode&&e.parentNode.removeChild(e)}function gl(e,t,n,r,i){var a={type:e,props:t,key:n,ref:r,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:i??++Qc,__i:-1,__u:0};return i==null&&Q.vnode!=null&&Q.vnode(a),a}function _l(e){return e.children}function vl(e,t){this.props=e,this.context=t}function yl(e,t){if(t==null)return e.__?yl(e.__,e.__i+1):null;for(var n;t<e.__k.length;t++)if((n=e.__k[t])!=null&&n.__e!=null)return n.__e;return typeof e.type==`function`?yl(e):null}function bl(e){if(e.__P&&e.__d){var t=e.__v,n=t.__e,r=[],i=[],a=ml({},t);a.__v=t.__v+1,Q.vnode&&Q.vnode(a),jl(e.__P,a,t,e.__n,e.__P.namespaceURI,32&t.__u?[n]:null,r,n??yl(t),!!(32&t.__u),i),a.__v=t.__v,a.__.__k[a.__i]=a,Nl(r,a,i),t.__e=t.__=null,a.__e!=n&&xl(a)}}function xl(e){if((e=e.__)!=null&&e.__c!=null)return e.__e=e.__c.base=null,e.__k.some(function(t){if(t!=null&&t.__e!=null)return e.__e=e.__c.base=t.__e}),xl(e)}function Sl(e){(!e.__d&&(e.__d=!0)&&$c.push(e)&&!Cl.__r++||el!=Q.debounceRendering)&&((el=Q.debounceRendering)||tl)(Cl)}function Cl(){try{for(var e,t=1;$c.length;)$c.length>t&&$c.sort(nl),e=$c.shift(),t=$c.length,bl(e)}finally{$c.length=Cl.__r=0}}function wl(e,t,n,r,i,a,o,s,c,l,u){var d,f,p,m,h,g,_,v=r&&r.__k||dl,y=t.length;for(c=Tl(n,t,v,c,y),d=0;d<y;d++)(p=n.__k[d])!=null&&(f=p.__i!=-1&&v[p.__i]||ul,p.__i=d,g=jl(e,p,f,i,a,o,s,c,l,u),m=p.__e,p.ref&&f.ref!=p.ref&&(f.ref&&Il(f.ref,null,p),u.push(p.ref,p.__c||m,p)),h==null&&m!=null&&(h=m),(_=!!(4&p.__u))||f.__k===p.__k?(c=El(p,c,e,_),_&&f.__e&&(f.__e=null)):typeof p.type==`function`&&g!==void 0?c=g:m&&(c=m.nextSibling),p.__u&=-7);return n.__e=h,c}function Tl(e,t,n,r,i){var a,o,s,c,l,u=n.length,d=u,f=0;for(e.__k=Array(i),a=0;a<i;a++)(o=t[a])!=null&&typeof o!=`boolean`&&typeof o!=`function`?(typeof o==`string`||typeof o==`number`||typeof o==`bigint`||o.constructor==String?o=e.__k[a]=gl(null,o,null,null,null):pl(o)?o=e.__k[a]=gl(_l,{children:o},null,null,null):o.constructor===void 0&&o.__b>0?o=e.__k[a]=gl(o.type,o.props,o.key,o.ref?o.ref:null,o.__v):e.__k[a]=o,c=a+f,o.__=e,o.__b=e.__b+1,s=null,(l=o.__i=Dl(o,n,c,d))!=-1&&(d--,(s=n[l])&&(s.__u|=2)),s==null||s.__v==null?(l==-1&&(i>u?f--:i<u&&f++),typeof o.type!=`function`&&(o.__u|=4)):l!=c&&(l==c-1?f--:l==c+1?f++:(l>c?f--:f++,o.__u|=4))):e.__k[a]=null;if(d)for(a=0;a<u;a++)(s=n[a])!=null&&!(2&s.__u)&&(s.__e==r&&(r=yl(s)),Ll(s,s));return r}function El(e,t,n,r){var i,a;if(typeof e.type==`function`){for(i=e.__k,a=0;i&&a<i.length;a++)i[a]&&(i[a].__=e,t=El(i[a],t,n,r));return t}e.__e!=t&&(r&&(t&&e.type&&!t.parentNode&&(t=yl(e)),n.insertBefore(e.__e,t||null)),t=e.__e);do t&&=t.nextSibling;while(t!=null&&t.nodeType==8);return t}function Dl(e,t,n,r){var i,a,o,s=e.key,c=e.type,l=t[n],u=l!=null&&(2&l.__u)==0;if(l===null&&s==null||u&&s==l.key&&c==l.type)return n;if(r>+!!u){for(i=n-1,a=n+1;i>=0||a<t.length;)if((l=t[o=i>=0?i--:a++])!=null&&!(2&l.__u)&&s==l.key&&c==l.type)return o}return-1}function Ol(e,t,n){t[0]==`-`?e.setProperty(t,n??``):e[t]=n==null?``:typeof n!=`number`||fl.test(t)?n:n+`px`}function kl(e,t,n,r,i){var a,o;n:if(t==`style`)if(typeof n==`string`)e.style.cssText=n;else{if(typeof r==`string`&&(e.style.cssText=r=``),r)for(t in r)n&&t in n||Ol(e.style,t,``);if(n)for(t in n)r&&n[t]==r[t]||Ol(e.style,t,n[t])}else if(t[0]==`o`&&t[1]==`n`)a=t!=(t=t.replace(ol,`$1`)),o=t.toLowerCase(),t=o in e||t==`onFocusOut`||t==`onFocusIn`?o.slice(2):t.slice(2),e.l||={},e.l[t+a]=n,n?r?n[al]=r[al]:(n[al]=sl,e.addEventListener(t,a?ll:cl,a)):e.removeEventListener(t,a?ll:cl,a);else{if(i==`http://www.w3.org/2000/svg`)t=t.replace(/xlink(H|:h)/,`h`).replace(/sName$/,`s`);else if(t!=`width`&&t!=`height`&&t!=`href`&&t!=`list`&&t!=`form`&&t!=`tabIndex`&&t!=`download`&&t!=`rowSpan`&&t!=`colSpan`&&t!=`role`&&t!=`popover`&&t in e)try{e[t]=n??``;break n}catch{}typeof n==`function`||(n==null||!1===n&&t[4]!=`-`?e.removeAttribute(t):e.setAttribute(t,t==`popover`&&n==1?``:n))}}function Al(e){return function(t){if(this.l){var n=this.l[t.type+e];if(t[il]==null)t[il]=sl++;else if(t[il]<n[al])return;return n(Q.event?Q.event(t):t)}}}function jl(e,t,n,r,i,a,o,s,c,l){var u,d,f,p,m,h,g,_,v,y,b,x,S,C,w,T=t.type;if(t.constructor!==void 0)return null;128&n.__u&&(c=!!(32&n.__u),a=[s=t.__e=n.__e]),(u=Q.__b)&&u(t);n:if(typeof T==`function`)try{if(_=t.props,v=T.prototype&&T.prototype.render,y=(u=T.contextType)&&r[u.__c],b=u?y?y.props.value:u.__:r,n.__c?g=(d=t.__c=n.__c).__=d.__E:(v?t.__c=d=new T(_,b):(t.__c=d=new vl(_,b),d.constructor=T,d.render=Rl),y&&y.sub(d),d.state||={},d.__n=r,f=d.__d=!0,d.__h=[],d._sb=[]),v&&d.__s==null&&(d.__s=d.state),v&&T.getDerivedStateFromProps!=null&&(d.__s==d.state&&(d.__s=ml({},d.__s)),ml(d.__s,T.getDerivedStateFromProps(_,d.__s))),p=d.props,m=d.state,d.__v=t,f)v&&T.getDerivedStateFromProps==null&&d.componentWillMount!=null&&d.componentWillMount(),v&&d.componentDidMount!=null&&d.__h.push(d.componentDidMount);else{if(v&&T.getDerivedStateFromProps==null&&_!==p&&d.componentWillReceiveProps!=null&&d.componentWillReceiveProps(_,b),t.__v==n.__v||!d.__e&&d.shouldComponentUpdate!=null&&!1===d.shouldComponentUpdate(_,d.__s,b)){t.__v!=n.__v&&(d.props=_,d.state=d.__s,d.__d=!1),t.__e=n.__e,t.__k=n.__k,t.__k.some(function(e){e&&(e.__=t)}),dl.push.apply(d.__h,d._sb),d._sb=[],d.__h.length&&o.push(d);break n}d.componentWillUpdate!=null&&d.componentWillUpdate(_,d.__s,b),v&&d.componentDidUpdate!=null&&d.__h.push(function(){d.componentDidUpdate(p,m,h)})}if(d.context=b,d.props=_,d.__P=e,d.__e=!1,x=Q.__r,S=0,v)d.state=d.__s,d.__d=!1,x&&x(t),u=d.render(d.props,d.state,d.context),dl.push.apply(d.__h,d._sb),d._sb=[];else do d.__d=!1,x&&x(t),u=d.render(d.props,d.state,d.context),d.state=d.__s;while(d.__d&&++S<25);d.state=d.__s,d.getChildContext!=null&&(r=ml(ml({},r),d.getChildContext())),v&&!f&&d.getSnapshotBeforeUpdate!=null&&(h=d.getSnapshotBeforeUpdate(p,m)),C=u!=null&&u.type===_l&&u.key==null?Pl(u.props.children):u,s=wl(e,pl(C)?C:[C],t,n,r,i,a,o,s,c,l),d.base=t.__e,t.__u&=-161,d.__h.length&&o.push(d),g&&(d.__E=d.__=null)}catch(e){if(t.__v=null,c||a!=null)if(e.then){for(t.__u|=c?160:128;s&&s.nodeType==8&&s.nextSibling;)s=s.nextSibling;a[a.indexOf(s)]=null,t.__e=s}else{for(w=a.length;w--;)hl(a[w]);Ml(t)}else t.__e=n.__e,t.__k=n.__k,e.then||Ml(t);Q.__e(e,t,n)}else a==null&&t.__v==n.__v?(t.__k=n.__k,t.__e=n.__e):s=t.__e=Fl(n.__e,t,n,r,i,a,o,c,l);return(u=Q.diffed)&&u(t),128&t.__u?void 0:s}function Ml(e){e&&(e.__c&&(e.__c.__e=!0),e.__k&&e.__k.some(Ml))}function Nl(e,t,n){for(var r=0;r<n.length;r++)Il(n[r],n[++r],n[++r]);Q.__c&&Q.__c(t,e),e.some(function(t){try{e=t.__h,t.__h=[],e.some(function(e){e.call(t)})}catch(e){Q.__e(e,t.__v)}})}function Pl(e){return typeof e!=`object`||!e||e.__b>0?e:pl(e)?e.map(Pl):e.constructor===void 0?ml({},e):null}function Fl(e,t,n,r,i,a,o,s,c){var l,u,d,f,p,m,h,g=n.props||ul,_=t.props,v=t.type;if(v==`svg`?i=`http://www.w3.org/2000/svg`:v==`math`?i=`http://www.w3.org/1998/Math/MathML`:i||=`http://www.w3.org/1999/xhtml`,a!=null){for(l=0;l<a.length;l++)if((p=a[l])&&`setAttribute`in p==!!v&&(v?p.localName==v:p.nodeType==3)){e=p,a[l]=null;break}}if(e==null){if(v==null)return document.createTextNode(_);e=document.createElementNS(i,v,_.is&&_),s&&=(Q.__m&&Q.__m(t,a),!1),a=null}if(v==null)g===_||s&&e.data==_||(e.data=_);else{if(a=v==`textarea`&&_.defaultValue!=null?null:a&&Zc.call(e.childNodes),!s&&a!=null)for(g={},l=0;l<e.attributes.length;l++)g[(p=e.attributes[l]).name]=p.value;for(l in g)p=g[l],l==`dangerouslySetInnerHTML`?d=p:l==`children`||l in _||l==`value`&&`defaultValue`in _||l==`checked`&&`defaultChecked`in _||kl(e,l,null,p,i);for(l in _)p=_[l],l==`children`?f=p:l==`dangerouslySetInnerHTML`?u=p:l==`value`?m=p:l==`checked`?h=p:s&&typeof p!=`function`||g[l]===p||kl(e,l,p,g[l],i);if(u)s||d&&(u.__html==d.__html||u.__html==e.innerHTML)||(e.innerHTML=u.__html),t.__k=[];else if(d&&(e.innerHTML=``),wl(t.type==`template`?e.content:e,pl(f)?f:[f],t,n,r,v==`foreignObject`?`http://www.w3.org/1999/xhtml`:i,a,o,a?a[0]:n.__k&&yl(n,0),s,c),a!=null)for(l=a.length;l--;)hl(a[l]);s&&v!=`textarea`||(l=`value`,v==`progress`&&m==null?e.removeAttribute(`value`):m!=null&&(m!==e[l]||v==`progress`&&!m||v==`option`&&m!=g[l])&&kl(e,l,m,g[l],i),l=`checked`,h!=null&&h!=e[l]&&kl(e,l,h,g[l],i))}return e}function Il(e,t,n){try{if(typeof e==`function`){var r=typeof e.__u==`function`;r&&e.__u(),r&&t==null||(e.__u=e(t))}else e.current=t}catch(e){Q.__e(e,n)}}function Ll(e,t,n){var r,i;if(Q.unmount&&Q.unmount(e),(r=e.ref)&&(r.current&&r.current!=e.__e||Il(r,null,t)),(r=e.__c)!=null){if(r.componentWillUnmount)try{r.componentWillUnmount()}catch(e){Q.__e(e,t)}r.base=r.__P=null}if(r=e.__k)for(i=0;i<r.length;i++)r[i]&&Ll(r[i],t,n||typeof e.type!=`function`);n||hl(e.__e),e.__c=e.__=e.__e=void 0}function Rl(e,t,n){return this.constructor(e,n)}Zc=dl.slice,Q={__e:function(e,t,n,r){for(var i,a,o;t=t.__;)if((i=t.__c)&&!i.__)try{if((a=i.constructor)&&a.getDerivedStateFromError!=null&&(i.setState(a.getDerivedStateFromError(e)),o=i.__d),i.componentDidCatch!=null&&(i.componentDidCatch(e,r||{}),o=i.__d),o)return i.__E=i}catch(t){e=t}throw e}},Qc=0,vl.prototype.setState=function(e,t){var n=this.__s!=null&&this.__s!=this.state?this.__s:this.__s=ml({},this.state);typeof e==`function`&&(e=e(ml({},n),this.props)),e&&ml(n,e),e!=null&&this.__v&&(t&&this._sb.push(t),Sl(this))},vl.prototype.forceUpdate=function(e){this.__v&&(this.__e=!0,e&&this.__h.push(e),Sl(this))},vl.prototype.render=_l,$c=[],tl=typeof Promise==`function`?Promise.prototype.then.bind(Promise.resolve()):setTimeout,nl=function(e,t){return e.__v.__b-t.__v.__b},Cl.__r=0,rl=Math.random().toString(8),il=`__d`+rl,al=`__a`+rl,ol=/(PointerCapture)$|Capture$/i,sl=0,cl=Al(!1),ll=Al(!0);var $=`__c`,zl=`__k`,Bl=`__d`,Vl=`__s`,Hl=/[\s\n\\/='"\0<>]/,Ul=/^(xlink|xmlns|xml)([A-Z])/,Wl=/^(?:accessK|auto[A-Z]|cell|ch|col|cont|cross|dateT|encT|form[A-Z]|frame|hrefL|inputM|maxL|minL|noV|playsI|popoverT|readO|rowS|src[A-Z]|tabI|useM|item[A-Z])/,Gl=/^ac|^ali|arabic|basel|cap|clipPath$|clipRule$|color|dominant|enable|fill|flood|font|glyph[^R]|horiz|image|letter|lighting|marker[^WUH]|overline|panose|pointe|paint|rendering|shape|stop|strikethrough|stroke|text[^L]|transform|underline|unicode|units|^v[^i]|^w|^xH/,Kl=new Set([`draggable`,`spellcheck`]);function ql(e){e.__g===void 0?e[Bl]=!0:e.__g|=8}function Jl(e){e.__g===void 0?e[Bl]=!1:e.__g&=-9}function Yl(e){return e.__g===void 0?!0===e[Bl]:!!(8&e.__g)}var Xl=/["&<]/;function Zl(e){if(e.length===0||!1===Xl.test(e))return e;for(var t=0,n=0,r=``,i=``;n<e.length;n++){switch(e.charCodeAt(n)){case 34:i=`&quot;`;break;case 38:i=`&amp;`;break;case 60:i=`&lt;`;break;default:continue}n!==t&&(r+=e.slice(t,n)),r+=i,t=n+1}return n!==t&&(r+=e.slice(t,n)),r}var Ql={},$l=new Set(`animation-iteration-count.border-image-outset.border-image-slice.border-image-width.box-flex.box-flex-group.box-ordinal-group.column-count.fill-opacity.flex.flex-grow.flex-negative.flex-order.flex-positive.flex-shrink.flood-opacity.font-weight.grid-column.grid-row.line-clamp.line-height.opacity.order.orphans.stop-opacity.stroke-dasharray.stroke-dashoffset.stroke-miterlimit.stroke-opacity.stroke-width.tab-size.widows.z-index.zoom`.split(`.`)),eu=/[A-Z]/g;function tu(e){var t=``;for(var n in e){var r=e[n];if(r!=null&&r!==``){var i=n[0]==`-`?n:Ql[n]||(Ql[n]=n.replace(eu,`-$&`).toLowerCase()),a=`;`;typeof r!=`number`||i.startsWith(`--`)||$l.has(i)||(a=`px;`),t=t+i+`:`+r+a}}return t||void 0}function nu(){this.__d=!0}function ru(e,t){return{__v:e,context:t,props:e.props,setState:nu,forceUpdate:nu,__d:!0,__h:[]}}function iu(e,t,n){if(!e.s){if(n instanceof au){if(!n.s)return void(n.o=iu.bind(null,e,t));1&t&&(t=n.s),n=n.v}if(n&&n.then)return void n.then(iu.bind(null,e,t),iu.bind(null,e,2));e.s=t,e.v=n;let r=e.o;r&&r(e)}}var au=function(){function e(){}return e.prototype.then=function(t,n){var r=new e,i=this.s;if(i){var a=1&i?t:n;if(a){try{iu(r,1,a(this.v))}catch(e){iu(r,2,e)}return r}return this}return this.o=function(e){try{var i=e.v;1&e.s?iu(r,1,t?t(i):i):n?iu(r,1,n(i)):iu(r,2,i)}catch(e){iu(r,2,e)}},r},e}(),ou,su,cu,lu,uu={},du=Array.isArray,fu=Object.assign,pu=``,mu=`<!--$s-->`,hu=`<!--/$s-->`;function gu(e,t){var n,r=e.type,i=!0;return e[$]?(i=!1,(n=e[$]).state=n[Vl]):n=new r(e.props,t),e[$]=n,n.__v=e,n.props=e.props,n.context=t,ql(n),n.state??=uu,n[Vl]??(n[Vl]=n.state),r.getDerivedStateFromProps?n.state=fu({},n.state,r.getDerivedStateFromProps(n.props,n.state)):i&&n.componentWillMount?(n.componentWillMount(),n.state=n[Vl]===n.state?n.state:n[Vl]):!i&&n.componentWillUpdate&&n.componentWillUpdate(),cu&&cu(e),n.render(n.props,n.state,t)}function _u(e,t,n,r,i,a,o){if(e==null||!0===e||!1===e||e===pu)return pu;var s=typeof e;if(s!=`object`)return s==`function`?pu:s==`string`?Zl(e):e+pu;if(du(e)){var c,l=pu;i[zl]=e;for(var u=e.length,d=0;d<u;d++){var f=e[d];if(f!=null&&typeof f!=`boolean`){var p,m=_u(f,t,n,r,i,a,o);typeof m==`string`?l+=m:(c||=Array(u),l&&c.push(l),l=pu,du(m)?(p=c).push.apply(p,m):c.push(m))}}return c?(l&&c.push(l),c):l}if(e.constructor!==void 0)return pu;e.__=i,ou&&ou(e);var h=e.type,g=e.props;if(typeof h==`function`){var _,v,y,b=t;if(h===_l){if(`tpl`in g){for(var x=pu,S=0;S<g.tpl.length;S++)if(x+=g.tpl[S],g.exprs&&S<g.exprs.length){var C=g.exprs[S];if(C==null)continue;typeof C!=`object`||C.constructor!==void 0&&!du(C)?x+=C:x+=_u(C,t,n,r,e,a,o)}return x}if(`UNSTABLE_comment`in g)return`<!--`+Zl(g.UNSTABLE_comment)+`-->`;v=g.children}else{if((_=h.contextType)!=null){var w=t[_.__c];b=w?w.props.value:_.__}var T=h.prototype&&typeof h.prototype.render==`function`;if(T)v=gu(e,b),y=e[$];else{e[$]=y=ru(e,b);for(var E=0;Yl(y)&&E++<25;){Jl(y),cu&&cu(e);try{v=h.call(y,g,b)}catch(t){throw a&&t&&typeof t.then==`function`&&(e._suspended=!0),t}}ql(y)}if(y.getChildContext!=null&&(t=fu({},t,y.getChildContext())),T&&Q.errorBoundaries&&(h.getDerivedStateFromError||y.componentDidCatch)){v=v!=null&&v.type===_l&&v.key==null&&v.props.tpl==null?v.props.children:v;try{return _u(v,t,n,r,e,a,!1)}catch(i){return h.getDerivedStateFromError&&(y[Vl]=h.getDerivedStateFromError(i)),y.componentDidCatch&&y.componentDidCatch(i,uu),Yl(y)?(v=gu(e,t),(y=e[$]).getChildContext!=null&&(t=fu({},t,y.getChildContext())),_u(v=v!=null&&v.type===_l&&v.key==null&&v.props.tpl==null?v.props.children:v,t,n,r,e,a,o)):pu}finally{su&&su(e),lu&&lu(e)}}}v=v!=null&&v.type===_l&&v.key==null&&v.props.tpl==null?v.props.children:v;try{var D=_u(v,t,n,r,e,a,o);return su&&su(e),Q.unmount&&Q.unmount(e),e._suspended?typeof D==`string`?mu+D+hu:du(D)?(D.unshift(mu),D.push(hu),D):D.then(function(e){return mu+e+hu}):D}catch(i){if(!a&&o&&o.onError){var ee=function i(s){return o.onError(s,e,function(e,s){try{return _u(e,t,n,r,s,a,o)}catch(e){return i(e)}})}(i);if(ee!==void 0)return ee;var te=Q.__e;return te&&te(i,e),pu}if(!a||!i||typeof i.then!=`function`)throw i;return i.then(function i(){try{var s=_u(v,t,n,r,e,a,o);return e._suspended?mu+s+hu:s}catch(e){if(!e||typeof e.then!=`function`)throw e;return e.then(i)}})}}var O,k=`<`+h,A=pu;for(var j in g){var M=g[j];if(typeof(M=yu(M)?M.value:M)!=`function`||j===`class`||j===`className`){switch(j){case`children`:O=M;continue;case`key`:case`ref`:case`__self`:case`__source`:continue;case`htmlFor`:if(`for`in g)continue;j=`for`;break;case`className`:if(`class`in g)continue;j=`class`;break;case`defaultChecked`:j=`checked`;break;case`defaultSelected`:j=`selected`;break;case`defaultValue`:case`value`:switch(j=`value`,h){case`textarea`:O=M;continue;case`select`:r=M;continue;case`option`:r!=M||`selected`in g||(k+=` selected`)}break;case`dangerouslySetInnerHTML`:A=M&&M.__html;continue;case`style`:typeof M==`object`&&(M=tu(M));break;case`acceptCharset`:j=`accept-charset`;break;case`httpEquiv`:j=`http-equiv`;break;default:if(Ul.test(j))j=j.replace(Ul,`$1:$2`).toLowerCase();else{if(Hl.test(j))continue;j[4]!==`-`&&!Kl.has(j)||M==null?n?Gl.test(j)&&(j=j===`panose1`?`panose-1`:j.replace(/([A-Z])/g,`-$1`).toLowerCase()):Wl.test(j)&&(j=j.toLowerCase()):M+=pu}}M!=null&&!1!==M&&(k=!0===M||M===pu?k+` `+j:k+` `+j+`="`+(typeof M==`string`?Zl(M):M+pu)+`"`)}}if(Hl.test(h))throw Error(h+` is not a valid HTML tag name in `+k+`>`);if(A||(typeof O==`string`?A=Zl(O):O!=null&&!1!==O&&!0!==O&&(A=_u(O,t,h===`svg`||h!==`foreignObject`&&n,r,e,a,o))),su&&su(e),lu&&lu(e),!A&&vu.has(h))return k+`/>`;var N=`</`+h+`>`,ne=k+`>`;return du(A)?[ne].concat(A,[N]):typeof A==`string`?ne+A+N:[ne,A,N]}var vu=new Set([`area`,`base`,`br`,`col`,`command`,`embed`,`hr`,`img`,`input`,`keygen`,`link`,`meta`,`param`,`source`,`track`,`wbr`]);function yu(e){return typeof e==`object`&&!!e&&typeof e.peek==`function`&&`value`in e}var bu=0;function xu(e){return e!=null&&e.length>0?e:(bu+=1,`pst_ft_${bu}`)}function Su({initialVisibleRowCount:e,itemHeight:t}){return e==null?420:Math.max(0,e)*(t??gt)}function Cu(e){if(typeof document>`u`)return;let t=document.createElement(`div`);t.innerHTML=e;let n=t.querySelector(`svg`);return n instanceof SVGElement?n:void 0}function wu(e){return e.querySelector(`#file-tree-icon-chevron`)instanceof SVGElement&&e.querySelector(`#file-tree-icon-file`)instanceof SVGElement&&e.querySelector(`#file-tree-icon-dot`)instanceof SVGElement&&e.querySelector(`#file-tree-icon-lock`)instanceof SVGElement}function Tu(e){return Array.from(e.children).filter(e=>e instanceof SVGElement)}var Eu=class{static LoadedCustomComponent=!0;#e;#t;#n;#r;#i;#a;#o;#s;#c;#l=new Xc;#u;#d;#f;#p;#m;#h;#g;#_;#v;#y=null;#b;#x=!1;#S=!1;constructor(e){let{composition:t,density:n,fileTreeSearchMode:r,gitStatus:i,id:a,initialSearchQuery:o,icons:s,itemHeight:c,onSearchChange:l,onSelectionChange:u,overscan:d,renderRowDecoration:f,renaming:p,search:m,searchBlurBehavior:h,searchFakeFocus:g,stickyFolders:_,unsafeCSS:v,initialVisibleRowCount:y,...b}=e;this.#e=t,this.#n=xu(a),this.#p=Wa(i),this.#m=s,this.#h=v,this.#r=u,this.#i=f,this.#a=p!=null&&p!==!1,this.#o=h,this.#s=m===!0,this.#c=g===!0,this.#u=ht(n,c),this.#d={itemHeight:this.#u.itemHeight,overscan:d,stickyFolders:_,initialVisibleRowCount:y},this.#t=new za({...b,fileTreeSearchMode:r,initialSearchQuery:o,onSearchChange:l,renaming:p}),this.#v=this.#t.getSelectionVersion(),this.#y=this.#r==null?null:this.subscribe(()=>{this.#D()})}unmount(){this.#b!=null&&(Yc(this.#b),delete this.#b.dataset.fileTreeVirtualizedWrapper,this.#b=void 0),this.#l.clearAll(),this.#l.setHost(null),this.#f!=null&&(delete this.#f.dataset.fileTreeVirtualized,this.#I(this.#f),this.#f=void 0)}cleanUp(){this.unmount(),this.#y?.(),this.#y=null,this.#t.destroy()}getFileTreeContainer(){return this.#f}getItem(e){return this.#t.getItem(e)}getFocusedItem(){return this.#t.getFocusedItem()}getFocusedPath(){return this.#t.getFocusedPath()}getSelectedPaths(){return this.#t.getSelectedPaths()}getComposition(){return this.#e}getItemHeight(){return this.#u.itemHeight}getDensityFactor(){return this.#u.factor}subscribe(e){let t=!1;return this.#t.subscribe(()=>{if(!t){t=!0;return}e()})}focusPath(e){this.#t.focusPath(e)}scrollToPath(e,t){this.#t.scrollToPath(e,t)}focusNearestPath(e){return this.#t.focusNearestPath(e)}add(e){this.#t.add(e)}batch(e){this.#t.batch(e)}move(e,t,n){this.#t.move(e,t,n)}onMutation(e,t){return this.#t.onMutation(e,t)}setSearch(e){this.#t.setSearch(e)}openSearch(e){this.#t.openSearch(e)}closeSearch(){this.#t.closeSearch()}isSearchOpen(){return this.#t.isSearchOpen()}getSearchValue(){return this.#t.getSearchValue()}getSearchMatchingPaths(){return this.#t.getSearchMatchingPaths()}focusNextSearchMatch(){this.#t.focusNextSearchMatch()}focusPreviousSearchMatch(){this.#t.focusPreviousSearchMatch()}startRenaming(e,t){return this.#t.startRenaming(e,t)}remove(e,t){this.#t.remove(e,t)}resetPaths(e,t){this.#t.resetPaths(e,t)}setComposition(e){this.#e=e;let t=this.#T();t!=null&&(this.#O(),qc(t.wrapper,this.#w()))}setGitStatus(e){this.#p=Wa(e,this.#p);let t=this.#T();t!=null&&qc(t.wrapper,this.#w())}setIcons(e){this.#m=e;let t=this.#T();t!=null&&(this.#E(t.host,t.wrapper),qc(t.wrapper,this.#w()))}hydrate({fileTreeContainer:e}){let t=this.#P(e),n=this.#N(t);this.#O(),Jc(n,this.#w())}render({containerWrapper:e,fileTreeContainer:t}){let n=this.#P(t??this.#f,e),r=this.#N(n);this.#O(),qc(r,this.#w())}#C(){return{initialViewportHeight:Su({initialVisibleRowCount:this.#d.initialVisibleRowCount,itemHeight:this.#d.itemHeight}),itemHeight:this.#d.itemHeight,overscan:this.#d.overscan,stickyFolders:this.#d.stickyFolders}}#w(){return{composition:this.#e,controller:this.#t,gitStatusByPath:this.#p?.statusByPath,ignoredGitDirectories:this.#p?.ignoredDirectoryPaths,directoriesWithGitChanges:this.#p?.directoriesWithChanges,icons:this.#m,instanceId:this.#n,renamingEnabled:this.#a,renderRowDecoration:this.#i,searchBlurBehavior:this.#o,searchEnabled:this.#s,searchFakeFocus:this.#c,slotHost:this.#l,...this.#C()}}#T(){let e=this.#f,t=this.#b;return e==null||t==null?null:{host:e,wrapper:t}}#E(e,t){let n=e.shadowRoot;n!=null&&(this.#k(n),this.#A(n)),this.#j(t)}#D(){let e=this.#r;if(e==null)return;let t=this.#t.getSelectionVersion();t!==this.#v&&(this.#v=t,e(this.#t.getSelectedPaths()))}#O(){let e=this.#e?.header?.render;if(e!=null){this.#l.setSlotContent(ee,e());return}this.#l.setSlotHtml(ee,this.#e?.header?.html??null)}#k(e){let t=Tu(e).find(e=>wu(e)),n=Cu(ut(pt(this.#m).set));n!=null&&(t!=null&&t.outerHTML===n.outerHTML||(t==null?e.prepend(n):t.replaceWith(n)))}#A(e){let t=Tu(e),n=t.find(e=>wu(e)),r=t.filter(e=>e!==n),i=pt(this.#m).spriteSheet?.trim()??``;if(i.length===0){for(let e of r)e.remove();return}let a=Cu(i);if(a==null){for(let e of r)e.remove();return}if(!(r.length===1&&r[0].outerHTML===a.outerHTML)){for(let e of r)e.remove();e.appendChild(a)}}#j(e){let t=pt(this.#m);t.colored&&L(t.set)?e.dataset.fileTreeColoredIcons=`true`:delete e.dataset.fileTreeColoredIcons}#M(e){let t=e.querySelector(`style[${w}]`);if(this.#g==null&&t instanceof HTMLStyleElement&&(this.#g=t),this.#h==null||this.#h===``){this.#g?.remove(),this.#g=void 0,this.#_=void 0;return}this.#g?.parentNode===e&&this.#_===this.#h||(this.#g??=document.createElement(`style`),this.#g.setAttribute(w,``),this.#g.parentNode!==e&&e.appendChild(this.#g),this.#g.textContent=bt(this.#h),this.#_=this.#h)}#N(e){if(this.#b!=null)return this.#b;let t=e.shadowRoot;if(t==null)throw Error(`FileTree requires a shadow root`);let n=Array.from(t.children).filter(e=>e instanceof HTMLDivElement&&typeof e.dataset.fileTreeId==`string`&&e.dataset.fileTreeId.length>0),r=n.find(e=>e.dataset.fileTreeId===this.#n)??n[0];return r!=null&&(this.#n=r.dataset.fileTreeId??this.#n),this.#b=r??document.createElement(`div`),this.#b.dataset.fileTreeId=this.#n,this.#b.dataset.fileTreeVirtualizedWrapper=`true`,this.#E(e,this.#b),this.#b.parentNode!==t&&t.appendChild(this.#b),this.#b}#P(e,t){let n=e??this.#f??document.createElement(`file-tree-container`);t!=null&&n.parentNode!==t&&t.appendChild(n);let r=n.shadowRoot??n.attachShadow({mode:`open`});return Et(n,r),this.#M(r),n.dataset.fileTreeVirtualized=`true`,n.style.display=`flex`,this.#F(n),this.#l.setHost(n),this.#f=n,n}#F(e){e.style.getPropertyValue(`--trees-item-height`)===``&&(e.style.setProperty(`--trees-item-height`,`${String(this.#u.itemHeight)}px`),this.#x=!0),e.style.getPropertyValue(`--trees-density-override`)===``&&(e.style.setProperty(`--trees-density-override`,String(this.#u.factor)),this.#S=!0)}#I(e){this.#x&&=(e.style.removeProperty(`--trees-item-height`),!1),this.#S&&=(e.style.removeProperty(`--trees-density-override`),!1)}};function Du(e){let[t]=(0,y.useState)(()=>new Eu(e)),n=(0,y.useRef)({timeout:null,model:t});return(0,y.useEffect)(()=>{let{current:e}=n;return e.timeout!=null&&(clearTimeout(e.timeout),e.timeout=null),()=>{e.timeout=setTimeout(()=>e.model.cleanUp(),1)}},[]),{model:t}}function Ou(e){let t={boundPaths:new Set,expandedPaths:[],gitStatus:[],paths:[],selectedPaths:[]};return ku(e,``,t),t}function ku(e,t,n){let r=Au(t,e.name);n.paths.push(e.kind===`folder`?`${r}/`:r),e.kind===`folder`&&e.children?.length&&n.expandedPaths.push(r),(e.selected||e.active)&&n.selectedPaths.push(r),e.bound&&n.boundPaths.add(r),e.gitStatus&&n.gitStatus.push({path:r,status:e.gitStatus});for(let t of e.children??[])ku(t,r,n)}function Au(e,t){return e?`${e}/${t}`:t}function ju({root:e}){let t=(0,y.useMemo)(()=>Ou(e),[e]),{model:n}=Du({density:`compact`,flattenEmptyDirectories:!1,gitStatus:t.gitStatus,icons:{set:`minimal`,colored:!1},id:`march-project-tree`,initialExpandedPaths:t.expandedPaths,initialSelectedPaths:t.selectedPaths,paths:t.paths,renderRowDecoration:e=>t.boundPaths.has(e.item.path)?{text:`◆`,title:`Bound to session`}:null,search:!0});return(0,b.jsxs)(`aside`,{className:`panel left-panel`,"aria-label":`Projects`,children:[(0,b.jsxs)(`div`,{className:`projects-header`,children:[(0,b.jsx)(`h3`,{children:`Projects`}),(0,b.jsxs)(`button`,{className:`menu-button`,type:`button`,"aria-label":`Open project menu`,children:[(0,b.jsx)(`span`,{}),(0,b.jsx)(`span`,{}),(0,b.jsx)(`span`,{})]})]}),(0,b.jsx)(`div`,{className:`projects-body`,children:(0,b.jsx)(ne,{className:`project-tree-host`,model:n,"aria-label":`Project files`})})]})}function Mu(e){let{sessions:t,activity:n,fsEntries:r,fsPath:i,providerQuota:a,running:o}=e,{onOpenSession:s,onCreateSession:c,onBrowseRoots:l,onBrowsePath:u}=e,[d,f]=(0,y.useState)(``),p=d.trim().length>0&&!o;async function m(e=d){let t=e.trim();!t||o||(await c(t),f(``))}return(0,b.jsxs)(`aside`,{className:`panel right-panel`,"aria-label":`Sessions`,children:[(0,b.jsx)(`div`,{className:`right-header`,children:`会话`}),(0,b.jsxs)(`div`,{className:`right-body`,children:[(0,b.jsxs)(`div`,{className:`workspace-picker`,"aria-label":`Workspace picker`,children:[(0,b.jsx)(`label`,{htmlFor:`workspace-path`,children:`Workspace`}),(0,b.jsxs)(`div`,{className:`workspace-input-row`,children:[(0,b.jsx)(`input`,{id:`workspace-path`,value:d,onChange:e=>f(e.target.value),placeholder:`Paste or browse a folder path`}),(0,b.jsx)(`button`,{type:`button`,disabled:!p,onClick:()=>m(),children:`Open`})]}),(0,b.jsx)(`div`,{className:`workspace-path`,children:i??`Roots`}),(0,b.jsx)(`button`,{type:`button`,className:`fs-row`,onClick:l,children:`↖ Roots`}),r.map(e=>(0,b.jsxs)(`div`,{className:`fs-entry-row`,children:[(0,b.jsx)(`button`,{type:`button`,onClick:()=>u(e.path),children:e.name}),(0,b.jsx)(`button`,{type:`button`,onClick:()=>m(e.path),children:`Open`})]},e.path))]}),a?(0,b.jsx)(Nu,{quota:a}):null,(0,b.jsx)(`div`,{className:`right-divider`,children:`Sessions`}),t.map(e=>(0,b.jsxs)(`button`,{className:e.active?`session-row active`:`session-row`,type:`button`,onClick:()=>s(e.id),children:[(0,b.jsx)(`span`,{children:e.title}),(0,b.jsx)(`time`,{children:e.workspacePath??e.time})]},e.id)),(0,b.jsx)(`div`,{className:`right-divider`,children:`Activity`}),n.map(e=>(0,b.jsxs)(`button`,{className:`activity-row`,type:`button`,children:[(0,b.jsx)(`span`,{children:e.action}),(0,b.jsx)(`time`,{children:e.time})]},e.id))]})]})}function Nu({quota:e}){return(0,b.jsxs)(`div`,{className:`provider-quota`,"aria-label":`Provider quota`,children:[(0,b.jsxs)(`div`,{className:`provider-quota-header`,children:[(0,b.jsx)(`span`,{children:e.label}),(0,b.jsx)(`time`,{children:e.providerId})]}),e.limits.flatMap(e=>e.windows.map(t=>{let n=Math.round(t.remainingPercent);return(0,b.jsxs)(`div`,{className:`quota-row`,children:[(0,b.jsxs)(`div`,{className:`quota-row-main`,children:[(0,b.jsx)(`span`,{children:Pu(t.label)}),(0,b.jsxs)(`strong`,{children:[n,`% left`]})]}),(0,b.jsx)(`div`,{className:`quota-bar`,"aria-label":`${n}% quota left`,children:(0,b.jsx)(`span`,{style:{width:`${Math.max(0,Math.min(100,n))}%`}})}),(0,b.jsx)(`em`,{children:Fu(t.resetsAt)})]},`${e.id}:${t.id}`)}))]})}function Pu(e){return e===`weekly`?`Weekly limit:`:`${e} limit:`}function Fu(e){if(!e)return`reset unknown`;let t=new Date(e);if(Number.isNaN(t.getTime()))return`reset unknown`;let n=String(t.getHours()).padStart(2,`0`),r=String(t.getMinutes()).padStart(2,`0`),i=[`Jan`,`Feb`,`Mar`,`Apr`,`May`,`Jun`,`Jul`,`Aug`,`Sep`,`Oct`,`Nov`,`Dec`][t.getMonth()];return`resets ${n}:${r} on ${t.getDate()} ${i}`}function Iu(e){let t=[];for(let n of e){if(n.type===`tool_result`){let e=t.at(-1);if(e?.kind===`tool`&&e.tool===n.tool){e.summary=n.summary,e.status=n.status;continue}}t.push(Lu(n))}return t}function Lu(e){switch(e.type){case`user_message`:return{id:e.id,kind:`message`,actor:`user`,text:e.text,time:e.time};case`assistant_message`:return{id:e.id,kind:`message`,actor:`march`,text:e.text,time:e.time};case`assistant_thought`:return{id:e.id,kind:`thought`,title:e.title,text:e.text,status:e.status};case`tool_call`:return{id:e.id,kind:`tool`,tool:e.tool,target:e.target,status:e.status};case`tool_result`:return{id:e.id,kind:`tool`,tool:e.tool,target:`result`,status:e.status,summary:e.summary};case`file_diff`:return{id:e.id,kind:`diff`,path:e.path,lines:e.lines};case`terminal_output`:return{id:e.id,kind:`terminal`,command:e.command,output:e.output,status:e.status};case`error`:return{id:e.id,kind:`error`,message:e.message,detail:e.detail}}}function Ru({item:e}){return e.kind===`message`?(0,b.jsx)(zu,{item:e}):(0,b.jsxs)(`article`,{className:`message-row assistant-turn`,children:[(0,b.jsx)(`div`,{className:`agent-dot march`,children:`M`}),(0,b.jsx)(`div`,{className:`message-body`,children:(0,b.jsx)(Bu,{item:e})})]})}function zu({item:e}){return(0,b.jsxs)(`article`,{className:`message-row ${e.actor===`user`?`user-turn`:`assistant-turn`}`,children:[(0,b.jsx)(`div`,{className:e.actor===`user`?`agent-dot`:`agent-dot march`,children:e.actor===`user`?`U`:`M`}),(0,b.jsxs)(`div`,{className:`message-body`,children:[(0,b.jsx)(`p`,{children:e.text}),e.time?(0,b.jsx)(`time`,{children:e.time}):null]})]})}function Bu({item:e}){switch(e.kind){case`thought`:return(0,b.jsx)(Vu,{item:e});case`tool`:return(0,b.jsx)(Hu,{item:e});case`diff`:return(0,b.jsx)(Uu,{item:e});case`terminal`:return(0,b.jsx)(Wu,{item:e});case`error`:return(0,b.jsx)(Gu,{item:e})}}function Vu({item:e}){return(0,b.jsxs)(`details`,{className:`timeline-aux thought-block`,open:e.status===`open`,children:[(0,b.jsxs)(`summary`,{children:[(0,b.jsx)(`span`,{children:`thinking`}),(0,b.jsx)(`strong`,{children:e.title})]}),(0,b.jsx)(`p`,{children:e.text})]})}function Hu({item:e}){return(0,b.jsxs)(`details`,{className:`timeline-aux tool-block`,open:e.status!==`done`,children:[(0,b.jsxs)(`summary`,{children:[(0,b.jsx)(`span`,{children:e.tool}),(0,b.jsx)(`strong`,{children:e.target}),(0,b.jsx)(`em`,{children:e.status})]}),e.summary?(0,b.jsx)(`p`,{children:e.summary}):null]})}function Uu({item:e}){return(0,b.jsxs)(`div`,{className:`timeline-aux diff-block`,children:[(0,b.jsxs)(`div`,{className:`aux-title`,children:[(0,b.jsx)(`span`,{children:`diff`}),(0,b.jsx)(`strong`,{children:e.path})]}),(0,b.jsx)(`div`,{className:`diff-inline`,children:e.lines.map(e=>(0,b.jsx)(`div`,{className:`diff-line ${e.kind}`,children:e.text},`${e.kind}:${e.text}`))})]})}function Wu({item:e}){return(0,b.jsxs)(`details`,{className:`timeline-aux terminal-block`,open:e.status!==`done`,children:[(0,b.jsxs)(`summary`,{children:[(0,b.jsx)(`span`,{children:`terminal`}),(0,b.jsx)(`strong`,{children:e.command}),(0,b.jsx)(`em`,{children:e.status})]}),(0,b.jsx)(`pre`,{children:e.output})]})}function Gu({item:e}){return(0,b.jsxs)(`div`,{className:`timeline-aux error-block`,children:[(0,b.jsxs)(`div`,{className:`aux-title`,children:[(0,b.jsx)(`span`,{children:`error`}),(0,b.jsx)(`strong`,{children:e.message})]}),e.detail?(0,b.jsx)(`p`,{children:e.detail}):null]})}function Ku({items:e}){return(0,b.jsx)(`div`,{className:`timeline-list`,"aria-label":`Session events`,children:e.map(e=>(0,b.jsx)(Ru,{item:e},e.id))})}function qu({timeline:e,connected:t,error:n}){let r=Iu(e.events);return(0,b.jsxs)(`main`,{className:`timeline`,"aria-label":`Agent timeline`,children:[(0,b.jsxs)(`div`,{className:`main-header`,children:[(0,b.jsx)(`span`,{children:`Session`}),(0,b.jsx)(`span`,{className:t?`runtime-pill connected`:`runtime-pill`,children:t?`runner`:`mock`})]}),(0,b.jsxs)(`div`,{className:`timeline-scroll`,children:[(0,b.jsxs)(`div`,{className:`session-title`,children:[(0,b.jsx)(`h1`,{children:e.title}),(0,b.jsx)(`span`,{children:n??e.meta})]}),(0,b.jsx)(Ku,{items:r})]})]})}function Ju({runtime:e}){let[t,n]=(0,y.useState)(!1),[r,i]=(0,y.useState)(!1),{model:a}=e;return(0,b.jsxs)(`div`,{className:`app-shell`,"data-left-open":t,"data-right-open":r,children:[(0,b.jsx)(`div`,{className:`overlay`,onClick:()=>{n(!1),i(!1)}}),(0,b.jsx)(ju,{root:a.workspace}),(0,b.jsx)(qu,{timeline:a.timeline,connected:e.connected,error:e.error}),(0,b.jsx)(Mu,{sessions:a.sessions,activity:a.activity,fsEntries:e.fsEntries,fsPath:e.fsPath,providerQuota:a.providerQuota,running:e.running,onOpenSession:e.openSession,onCreateSession:e.createSession,onBrowseRoots:e.browseRoots,onBrowsePath:e.browsePath}),(0,b.jsx)(x,{composer:a.composer,running:e.running,disabled:!a.activeSessionId,onSubmit:e.submitPrompt,onOpenLeft:()=>n(!0),onOpenRight:()=>i(!0)})]})}var Yu={activeSessionId:`web-shell`,workspace:{id:`root`,name:`march-cli-standalone`,kind:`folder`,selected:!0,bound:!0,children:[{id:`src`,name:`src`,kind:`folder`,children:[{id:`web-ui`,name:`web-ui`,kind:`folder`,children:[{id:`app`,name:`App.tsx`,kind:`file`,active:!0,bound:!0,gitStatus:`modified`},{id:`model`,name:`model.ts`,kind:`file`},{id:`styles`,name:`styles.css`,kind:`file`}]}]},{id:`test`,name:`test`,kind:`folder`},{id:`agents`,name:`AGENTS.md`,kind:`file`},{id:`package`,name:`package.json`,kind:`file`,gitStatus:`modified`}]},timeline:{title:`Web shell`,meta:`mock adapter · fast`,events:[{id:`u1`,type:`user_message`,text:`参考 MindFS,做正式 Web UI。`,time:`09:41`},{id:`m1`,type:`assistant_message`,text:`先组件化,runtime 保持不变。`,time:`09:41`},{id:`th1`,type:`assistant_thought`,title:`Planning`,text:`把 runtime 事件先整理成 timeline item,再交给 UI 渲染。`,status:`closed`},{id:`t1`,type:`tool_call`,tool:`read`,target:`workspace`,status:`running`},{id:`tr1`,type:`tool_result`,tool:`read`,summary:`4 files inspected`,status:`done`},{id:`d1`,type:`file_diff`,path:`src/web-ui/src/model.ts`,lines:[{kind:`add`,text:`+ Timeline adapter model`},{kind:`keep`,text:` runtime adapter pending`}]},{id:`term1`,type:`terminal_output`,command:`npm run test:fast`,output:`PASS web-ui.smoke.mjs`,status:`done`}]},sessions:[{id:`web-shell`,title:`Web shell`,time:`now`,active:!0},{id:`memory`,title:`Memory`,time:`1d`}],activity:[{id:`read`,action:`read`,time:`now`},{id:`edit`,action:`edit`,time:`2m`},{id:`test`,action:`test`,time:`5m`}],composer:{mode:`Chat`,placeholder:`Message March…`}};function Xu(e,t){let n=[...e],r=`${t.type}:${n.length}:${Date.now()}`;switch(t.type){case`web_user_message`:return n.push({id:r,type:`user_message`,text:t.text,time:id()}),n;case`text_delta`:return Zu(n,t.delta,r);case`thinking_start`:return n.push({id:r,type:`assistant_thought`,title:`Thinking`,text:``,status:`open`}),n;case`thinking_delta`:return Qu(n,t.delta,r);case`thinking_end`:return $u(n);case`tool_start`:return n.push({id:r,type:`tool_call`,tool:t.name,target:nd(t.args),status:`running`}),n;case`tool_end`:return n.push({id:r,type:`tool_result`,tool:t.name,summary:rd(t.result),status:t.isError?`failed`:`done`}),n;case`edit_diff`:return n.push({id:r,type:`file_diff`,path:t.path,lines:ed(t.diffLines)}),n;case`status`:return n.push({id:r,type:`terminal_output`,command:`status`,output:t.text,status:`done`}),n;case`retry_start`:return n.push({id:r,type:`error`,message:`Retrying`,detail:t.errorMessage}),n;case`retry_end`:return!t.success&&t.finalError&&n.push({id:r,type:`error`,message:`Retry failed`,detail:t.finalError}),n;default:return n}}function Zu(e,t,n){let r=e.at(-1);return r?.type===`assistant_message`?r.text+=t:e.push({id:n,type:`assistant_message`,text:t,time:id()}),e}function Qu(e,t,n){let r=e.at(-1);return r?.type===`assistant_thought`&&r.status===`open`?r.text+=t:e.push({id:n,type:`assistant_thought`,title:`Thinking`,text:t,status:`open`}),e}function $u(e){let t=e.at(-1);return t?.type===`assistant_thought`&&(t.status=`closed`),e}function ed(e=[]){return e.map(e=>({kind:td(e.type),text:e.text??``}))}function td(e){return e===`add`?`add`:e===`del`?`remove`:`keep`}function nd(e){return e==null?`running`:JSON.stringify(e).slice(0,160)}function rd(e){return e==null?`done`:typeof e==`string`?e.slice(0,240):JSON.stringify(e).slice(0,240)}function id(){return new Intl.DateTimeFormat(void 0,{hour:`2-digit`,minute:`2-digit`}).format(new Date)}async function ad(e){let t=await fetch(fd(`/api/snapshot`,{sessionId:e}));if(!t.ok)throw Error(await t.text());return t.json()}async function od(e){let t=await fetch(`/api/sessions`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({workspacePath:e})});if(!t.ok)throw Error(await t.text());return t.json()}async function sd(){let e=await fetch(`/api/fs/roots`);if(!e.ok)throw Error(await e.text());return(await e.json()).roots}async function cd(e){let t=await fetch(fd(`/api/fs/list`,{path:e}));if(!t.ok)throw Error(await t.text());return(await t.json()).entries}async function ld(e){let t=await fetch(fd(`/api/provider-quota`,{sessionId:e}));if(!t.ok)throw Error(await t.text());return(await t.json()).snapshot??null}async function ud(e,t){let n=await fetch(`/api/turn`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({sessionId:e,prompt:t})});if(!n.ok)throw Error(await n.text());return n.json()}function dd(e,t,n){let r=new EventSource(fd(`/api/events`,{sessionId:e}));return r.addEventListener(`runtime`,e=>{t(JSON.parse(e.data))}),r.onerror=n,()=>r.close()}function fd(e,t){let n=new URLSearchParams;for(let[e,r]of Object.entries(t))r&&n.set(e,r);let r=n.toString();return r?`${e}?${r}`:e}function pd(){let[e,t]=(0,y.useState)(Yu),[n,r]=(0,y.useState)(!1),[i,a]=(0,y.useState)(!1),[o,s]=(0,y.useState)(null),[c,l]=(0,y.useState)([]),[u,d]=(0,y.useState)(null),f=e.activeSessionId??null,p=(0,y.useRef)(new Map);(0,y.useEffect)(()=>{let e=!0;return ad().then(n=>{e&&(t(n),r(!0))}).catch(()=>r(!1)),sd().then(t=>e&&l(t)).catch(()=>{}),()=>{e=!1}},[]),(0,y.useEffect)(()=>{if(!f)return;let e=dd(f,e=>{if(r(!0),e.type===`provider_quota_snapshot`){t(t=>t.activeSessionId===f?{...t,providerQuota:e.snapshot}:t);return}t(t=>{let n=gd(t,t=>Xu(t,e));return hd(n,p.current),n})},()=>r(!1));return g(f).catch(()=>void 0),e},[f]);async function m(e){s(null),t(md(await ad(e),p.current))}async function h(e){a(!0),s(null);try{let n=await od(e);t(n.snapshot),hd(n.snapshot,p.current)}catch(e){s(e instanceof Error?e.message:String(e))}finally{a(!1)}}async function g(e){let n=await ld(e);t(t=>t.activeSessionId===e?{...t,providerQuota:n}:t)}async function _(){d(null),l(await sd())}async function v(e){d(e),l(await cd(e))}async function b(e){if(!f){s(`Choose a workspace before sending a message`);return}a(!0),s(null);try{await ud(f,e)}catch(e){let n=e instanceof Error?e.message:String(e);s(n),t(e=>{let t=gd(e,e=>[...e,{id:`client-error:${Date.now()}`,type:`error`,message:n}]);return hd(t,p.current),t})}finally{a(!1)}}return{model:e,connected:n,running:i,error:o,fsEntries:c,fsPath:u,openSession:m,createSession:h,browseRoots:_,browsePath:v,submitPrompt:b}}function md(e,t){let n=e.activeSessionId,r=n?t.get(n):null;return r?{...e,timeline:{...e.timeline,events:r}}:e}function hd(e,t){e.activeSessionId&&t.set(e.activeSessionId,e.timeline.events)}function gd(e,t){return{...e,timeline:{...e.timeline,events:t(e.timeline.events)}}}function _d(){return(0,b.jsx)(Ju,{runtime:pd()})}(0,v.createRoot)(document.getElementById(`root`)).render((0,b.jsx)(y.StrictMode,{children:(0,b.jsx)(_d,{})}));
1845
+ }`}var xt=new WeakMap;function St(e){let t=xt.get(e);if(t!=null)return t;let n=document.createElement(`div`);n.setAttribute(T,`true`);let r=document.createElement(`div`);r.style.position=`relative`,r.style.height=`200%`,n.appendChild(r),e.appendChild(n);let i=Math.max(n.offsetWidth-n.clientWidth,0);return n.remove(),xt.set(e,i),i}function Ct(e,t){if(!e.isConnected)return;let n=St(t);if(n==null)return;let r=t.querySelector(`style[${E}]`),i=r instanceof HTMLStyleElement?r:document.createElement(`style`);r instanceof HTMLStyleElement||(i.setAttribute(E,``),t.appendChild(i)),i.textContent=`:host { ${D}: ${n}px; }`}var wt;function Tt(e){if(typeof CSSStyleSheet<`u`&&typeof CSSStyleSheet.prototype.replaceSync==`function`&&`adoptedStyleSheets`in e){wt??(wt=new CSSStyleSheet,wt.replaceSync(yt(_t)));let t=!1;try{e.adoptedStyleSheets=[wt],t=!0}catch{}if(t){e.querySelector(`style[${C}]`)?.remove();return}}if(e.querySelector(`style[data-file-tree-style]`)==null){let t=document.createElement(`style`);t.setAttribute(C,``),t.textContent=yt(_t),e.prepend(t)}}function Et(e,t){Dt(e,t),Tt(t),Ct(e,t)}function Dt(e,t){let n=e.querySelector(`template[shadowrootmode="open"], template[data-file-tree-shadowrootmode="open"]`);n instanceof HTMLTemplateElement&&(t.childNodes.length>0||(t.appendChild(n.content.cloneNode(!0)),n.hasAttribute(`shadowrootmode`)&&n.remove()))}if(typeof HTMLElement<`u`&&customElements.get(`file-tree-container`)==null){class e extends HTMLElement{constructor(){super()}connectedCallback(){let e=this.shadowRoot??this.attachShadow({mode:`open`});Et(this,e)}}if(customElements.define(S,e),typeof document<`u`)for(let e of Array.from(document.querySelectorAll(S)))e instanceof HTMLElement&&Et(e,e.shadowRoot??e.attachShadow({mode:`open`}))}var Ot=5,kt=1<<Ot,At=kt*4;function jt(){return{childIdByNameId:new Map,childIds:[],childPositionById:new Map,childVisibleChunkSums:null,totalChildSubtreeNodeCount:0,totalChildVisibleSubtreeCount:0}}function Mt(){return{childIdByNameId:null,childIds:[],childPositionById:null,childVisibleChunkSums:null,totalChildSubtreeNodeCount:0,totalChildVisibleSubtreeCount:0}}function Nt(e,t){if(t.childIdByNameId!=null)return t.childIdByNameId;let n=new Map;for(let r of t.childIds){let t=e[r];t!=null&&n.set(t.nameId,r)}return t.childIdByNameId=n,n}function Pt(e){if(e.childPositionById!=null)return e.childPositionById;let t=new Map;for(let n=0;n<e.childIds.length;n++){let r=e.childIds[n];r!=null&&t.set(r,n)}return e.childPositionById=t,t}function Ft(e,t){e.childPositionById!=null&&e.childPositionById.set(t,e.childIds.length),e.childIds.push(t)}function It(e,t){if(e.childPositionById!=null)for(let n=t;n<e.childIds.length;n++){let t=e.childIds[n];t!=null&&e.childPositionById.set(t,n)}}function Lt(e,t){let n=0,r=0;for(let i of t.childIds){let t=e[i];t!=null&&(n+=t.subtreeNodeCount,r+=t.visibleSubtreeCount)}t.totalChildSubtreeNodeCount=n,t.totalChildVisibleSubtreeCount=r,Vt(e,t)}function Rt(e,t,n,r){if(e.totalChildSubtreeNodeCount+=n,e.totalChildVisibleSubtreeCount+=r,e.childVisibleChunkSums==null||r===0)return;let i=Pt(e).get(t);if(i===void 0)return;let a=i>>Ot;e.childVisibleChunkSums[a]+=r}function zt(e,t,n){let r=t.childVisibleChunkSums;if(r!=null){let i=n,a=0;for(let o of r){if(i<o){let r=Ht(e,t,a,i);return{...r,childVisibleIndex:n-r.localVisibleIndex}}i-=o,a+=kt}throw Error(`Visible child index ${String(n)} is out of range`)}let i=n;for(let r=0;r<t.childIds.length;r++){let a=t.childIds[r];if(a==null)continue;let o=e[a];if(o!=null){if(i<o.visibleSubtreeCount)return{childIndex:r,childVisibleIndex:n-i,localVisibleIndex:i};i-=o.visibleSubtreeCount}}throw Error(`Visible child index ${String(n)} is out of range`)}function Bt(e,t,n){let r=0,i=t.childVisibleChunkSums,a=0;if(i!=null){let e=n>>Ot;for(let t=0;t<e;t+=1)r+=i[t]??0;a=e<<Ot}for(let i=a;i<n;i+=1){let n=t.childIds[i];if(n==null)continue;let a=e[n];a!=null&&(r+=a.visibleSubtreeCount)}return r}function Vt(e,t){if(t.childIds.length<At){t.childVisibleChunkSums=null;return}let n=Math.ceil(t.childIds.length/kt),r=new Int32Array(n);for(let n=0;n<t.childIds.length;n++){let i=t.childIds[n];if(i==null)continue;let a=e[i];a!=null&&(r[n>>Ot]+=a.visibleSubtreeCount)}t.childVisibleChunkSums=r}function Ht(e,t,n,r){let i=Math.min(t.childIds.length,n+kt),a=r;for(let r=n;r<i;r++){let n=t.childIds[r];if(n==null)continue;let i=e[n];if(i!=null){if(a<i.visibleSubtreeCount)return{childIndex:r,localVisibleIndex:a};a-=i.visibleSubtreeCount}}throw Error(`Visible child index ${String(r)} is out of range`)}var Ut=7,R=3,Wt=1<<R,Gt=4;function Kt(e,t,n=0){return e<<Gt|n<<R|t}function qt(e){return e.depthAndFlags>>>Gt}function Jt(e){return(e.depthAndFlags&Wt)>>R}function z(e){return(e.depthAndFlags&Wt)!==0}function Yt(e){return e.depthAndFlags&Ut}function B(e,t){return(Yt(e)&t)!==0}function Xt(e,t){e.depthAndFlags|=t}function Zt(e,t){e.depthAndFlags=Kt(t,Yt(e),Jt(e))}var Qt=Symbol(`benchmarkInstrumentation`);function $t(e,t){return t==null||Object.defineProperty(e,Qt,{configurable:!0,enumerable:!1,value:t,writable:!1}),e}function en(e){return e==null?null:e[Qt]??null}function V(e,t,n){return e==null?n():e.measurePhase(t,n)}function tn(e,t,n){!Number.isFinite(n)||e==null||e.setCounter(t,n)}function nn(e){return e>=48&&e<=57}function rn(e){let t=[],n=0,r=0;for(;r<e.length;){for(;r<e.length&&!nn(e.charCodeAt(r));)r+=1;if(r>=e.length)break;r>n&&t.push(e.slice(n,r));let i=0;for(;r<e.length&&nn(e.charCodeAt(r));)i=i*10+(e.charCodeAt(r)-48),r+=1;t.push(i),n=r}return(n<e.length||t.length===0)&&t.push(e.slice(n)),t}function an(e){let t=e.toLowerCase();return{lowerValue:t,tokens:rn(t)}}function on(e,t){let n=Math.min(e.length,t.length);for(let r=0;r<n;r++){let n=e[r],i=t[r];if(n===i)continue;if(typeof n==`number`&&typeof i==`number`)return n<i?-1:1;let a=String(n),o=String(i);if(a!==o)return a<o?-1:1}return e.length===t.length?0:e.length<t.length?-1:1}function sn(e,t){if(e.tokens.length===1&&t.tokens.length===1&&typeof e.tokens[0]==`string`&&typeof t.tokens[0]==`string`)return e.lowerValue===t.lowerValue?0:e.lowerValue<t.lowerValue?-1:1;let n=on(e.tokens,t.tokens);return n===0?e.lowerValue===t.lowerValue?0:e.lowerValue<t.lowerValue?-1:1:n}function cn(e,t,n){let r=sn(n(e),n(t));return r===0?e===t?0:e<t?-1:1:r}function ln(e,t){return cn(e,t,an)}function un(e,t){return t===e.segments.length-1?+!!e.isDirectory:1}function dn(e,t){let n=Math.min(e.segments.length,t.segments.length);for(let r=0;r<n;r++){let n=e.segments[r],i=t.segments[r];if(n===i)continue;let a=un(e,r);return a===un(t,r)?ln(n,i):a===1?-1:1}return e.segments.length===t.segments.length?e.isDirectory===t.isDirectory?0:e.isDirectory?-1:1:e.segments.length<t.segments.length?-1:1}function fn(e,t){return dn(e,t)}function pn(e,t,n){let r=e=>{let t=n.get(e);if(t!=null)return t;let r=an(e);return n.set(e,r),r},i=Math.min(e.segments.length,t.segments.length);for(let n=0;n<i;n++){let i=e.segments[n],a=t.segments[n];if(i===a)continue;let o=un(e,n);return o===un(t,n)?cn(i,a,r):o===1?-1:1}return e.segments.length===t.segments.length?e.isDirectory===t.isDirectory?0:e.isDirectory?-1:1:e.segments.length<t.segments.length?-1:1}function mn(e,t){let n=e.sortKeyById[t];if(n!==void 0)return n;let r=e.valueById[t],i=an(r);return e.sortKeyById[t]=i,i}function hn(e={}){return{flattenEmptyDirectories:e.flattenEmptyDirectories!==!1,sort:e.sort??`default`}}function gn(e){let t=e.length>0&&e.charCodeAt(e.length-1)===47,n=t?e.length-1:e.length,r=[],i=0;for(let t=0;t<n;t++)e.charCodeAt(t)===47&&(r.push(e.slice(i,t)),i=t+1);return r.push(e.slice(i,n)),{hasTrailingSlash:t,segments:r}}function _n(e){let{hasTrailingSlash:t,segments:n}=gn(e);return{basename:n[n.length-1]??``,isDirectory:t,path:e,segments:n}}function vn(e){if(e.length===0)return{requiresDirectory:!1,segments:[]};let{hasTrailingSlash:t,segments:n}=gn(e);return{requiresDirectory:t,segments:n}}var yn=``;function bn(){let e=new Map;return e.set(yn,0),{idByValue:e,valueById:[yn],sortKeyById:[an(yn)]}}function xn(e,t){let n=e.idByValue.get(t);if(n!==void 0)return n;let r=e.valueById.length;return e.idByValue.set(t,r),e.valueById.push(t),r}function Sn(e,t){let n=e.valueById[t];if(n===void 0)throw Error(`Unknown segment ID: ${String(t)}`);return n}var Cn=Symbol(`pathStorePreparedInputKind`);function wn(e,t){return e[Cn]=t,e}function Tn(e){return{basename:e.basename,depth:e.segments.length,isDirectory:e.isDirectory,path:e.path,segments:e.segments}}function En(e,t,n){return n===`default`?fn(e,t):n(Tn(e),Tn(t))}function Dn(){return{depthAndFlags:Kt(0,3,1),nameId:0,parentId:0,subtreeNodeCount:1,visibleSubtreeCount:1}}function On(e,t){let n=Math.min(e.length,t.length);for(let r=0;r<n;r++)if(e[r]!==t[r])return r;return n}function kn(e){return e.isDirectory?e.segments.length:e.segments.length-1}function An(e){return Array.isArray(e)&&e.every(e=>typeof e==`object`&&!!e&&typeof e.path==`string`&&Array.isArray(e.segments)&&typeof e.basename==`string`&&typeof e.isDirectory==`boolean`)}function jn(e){return Array.isArray(e)&&e.every(e=>typeof e==`string`)}function Mn(e,t={}){return Rn(e,t).map(e=>e.path)}function Nn(e,t={}){let n=Rn(e,t);return wn({paths:n.map(e=>e.path),preparedPaths:n},`prepared`)}function Pn(e){let t=e.length,n=!1;for(let r=0;r<t;r+=1){let t=e[r];if(t.length>0&&t.charCodeAt(t.length-1)===47){n=!0;break}}return wn({paths:e,presortedPaths:e,presortedPathsContainDirectories:n},`presorted`)}function Fn(e){let t=e,n=t.preparedPaths;if(t[Cn]===`prepared`&&n!=null)return n;if(!An(n))throw Error(`preparedInput must come from PathStore.prepareInput()`);return n}function In(e){let t=e;return t[Cn]===`presorted`&&t.presortedPaths!=null||jn(t.presortedPaths)?t.presortedPaths:null}function Ln(e){let t=e;return typeof t.presortedPathsContainDirectories==`boolean`?t.presortedPathsContainDirectories:null}function Rn(e,t={}){let n=hn(t),r=en(t);tn(r,`workload.inputFiles`,e.length);let i=V(r,`store.preparePathEntries.parse`,()=>e.map(e=>_n(e)));return V(r,`store.preparePathEntries.sort`,()=>i.sort((e,t)=>En(e,t,n.sort))),i}var zn=class{directories=new Map;directoryStack=[0];presortedDirectoryNodeIds=[];initialExpandedPathSet;createdDirectoriesAllExpanded=!1;createdDirectoryCount=0;lastPreparedPath=null;nodes=[Dn()];options;instrumentation;segmentSortKeyCache=new Map;segmentTable=bn();hasDeferredDirectoryIndexes=!1;constructor(e={}){this.instrumentation=en(e),this.options=hn(e);let t=e.initialExpandedPaths??null;if(t==null||t.length===0)this.initialExpandedPathSet=null;else{let e=new Set,n=t.length;for(let r=0;r<n;r+=1){let n=t[r],i=n.length;e.add(i>0&&n.charCodeAt(i-1)===47?n.slice(0,i-1):n)}this.initialExpandedPathSet=e,this.createdDirectoriesAllExpanded=!0}this.directories.set(0,jt())}appendPaths(e){return V(this.instrumentation,`store.builder.appendPaths.parse`,()=>this.appendPreparedPaths(e.map(e=>_n(e))))}appendPreparedPaths(e,t=!0){return this.createdDirectoriesAllExpanded=!1,V(this.instrumentation,`store.builder.appendPreparedPaths`,()=>{for(let n of e)this.appendPreparedPath(n,t)}),this}appendPresortedPaths(e,t=null){return V(this.instrumentation,`store.builder.appendPresortedPaths`,()=>{if(t===!1){this.appendPresortedFilePaths(e);return}this.createdDirectoriesAllExpanded=!1;let n=null,r=0,i=this.nodes,a=this.segmentTable,o=a.idByValue,s=a.valueById,c=this.directoryStack,l=0,u=``,d=0;for(let t of e){if(n===t)throw Error(`Duplicate path: "${t}"`);let e=t.length>0&&t.charCodeAt(t.length-1)===47,a=e?t.length-1:t.length,f=0,p=0;if(n!=null)if(u.length>0&&t.length>u.length&&t.startsWith(u))f=d,p=u.length;else{let r=Math.min(a,n.length),i=!0;for(let e=0;e<r;e++){let r=t.charCodeAt(e);if(r!==n.charCodeAt(e)){i=!1;break}r===47&&(f++,p=e+1)}i&&e&&r===a&&n.length>a&&n.charCodeAt(a)===47&&(f++,p=a+1)}l=f,r=f;let m=p,h=t.indexOf(`/`,m);for(;h>=0&&h<a;){let e=c[l];if(e===void 0)throw Error(`Directory stack underflow while building the path store`);r++;let n=t.slice(m,h),a=o.get(n);a===void 0&&(a=s.length,o.set(n,a),s.push(n));let u=i.length;i.push({depthAndFlags:Kt(r,0,1),nameId:a,parentId:e,subtreeNodeCount:1,visibleSubtreeCount:1}),this.recordCreatedDirectoryPath(t.slice(0,h)),l++,c[l]=u,m=h+1,h=t.indexOf(`/`,m)}if(e){if(m<a){let e=c[l];if(e===void 0)throw Error(`Unable to resolve directory parent for "${t}"`);r++;let n=t.slice(m,a),u=o.get(n);u===void 0&&(u=s.length,o.set(n,u),s.push(n));let d=i.length;i.push({depthAndFlags:Kt(r,0,1),nameId:u,parentId:e,subtreeNodeCount:1,visibleSubtreeCount:1}),l++,c[l]=d}let e=c[l];if(e===void 0)throw Error(`Unable to resolve directory node for "${t}"`);this.promoteDirectoryToExplicit(e,t)}else{let e=c[l];if(e===void 0)throw Error(`Unable to resolve file parent for "${t}"`);let n=t.slice(m),a=o.get(n);a===void 0&&(a=s.length,o.set(n,a),s.push(n)),i.push({depthAndFlags:Kt(r+1,0),nameId:a,parentId:e,subtreeNodeCount:1,visibleSubtreeCount:1})}m!==u.length&&(u=t.substring(0,m),d=r),n=t}c.length=l+1,n!=null&&(this.lastPreparedPath=_n(n)),this.hasDeferredDirectoryIndexes=!0}),this}appendPresortedFilePaths(e){let t=null,n=0,r=this.nodes,i=this.segmentTable,a=i.idByValue,o=i.valueById,s=this.directoryStack,c=0,l=``,u=0;for(let i of e){if(t===i)throw Error(`Duplicate path: "${i}"`);let e=i.length,d=0,f=0;if(t!=null)if(l.length>0&&i.length>l.length&&i.startsWith(l))d=u,f=l.length;else{let n=Math.min(e,t.length);for(let e=0;e<n;e++){let n=i.charCodeAt(e);if(n!==t.charCodeAt(e))break;n===47&&(d++,f=e+1)}}c=d,n=d;let p=f,m=i.indexOf(`/`,p);for(;m>=0;){let e=s[c];if(e===void 0)throw Error(`Directory stack underflow while building the path store`);n++;let t=i.slice(p,m),l=a.get(t);l===void 0&&(l=o.length,a.set(t,l),o.push(t));let u=r.length;r.push({depthAndFlags:Kt(n,0,1),nameId:l,parentId:e,subtreeNodeCount:1,visibleSubtreeCount:1}),this.recordCreatedDirectoryPath(i.slice(0,m)),this.presortedDirectoryNodeIds.push(u),c++,s[c]=u,p=m+1,m=i.indexOf(`/`,p)}let h=s[c];if(h===void 0)throw Error(`Unable to resolve file parent for "${i}"`);let g=i.slice(p),_=a.get(g);_===void 0&&(_=o.length,a.set(g,_),o.push(g)),r.push({depthAndFlags:Kt(n+1,0),nameId:_,parentId:h,subtreeNodeCount:1,visibleSubtreeCount:1}),p!==l.length&&(l=i.substring(0,p),u=n),t=i}s.length=c+1,t!=null&&(this.lastPreparedPath=_n(t)),this.hasDeferredDirectoryIndexes=!0}finish(e={}){let t=e.skipSubtreeCountPass===!0;return this.hasDeferredDirectoryIndexes?(V(this.instrumentation,`store.builder.buildDirectoryIndexes`,()=>this.buildPresortedFinish(t)),this.hasDeferredDirectoryIndexes=!1):t||V(this.instrumentation,`store.builder.computeSubtreeCounts`,()=>this.computeSubtreeCounts(0)),{directories:this.directories,nodes:this.nodes,options:this.options,rootId:0,segmentTable:this.segmentTable,presortedDirectoryNodeIds:this.presortedDirectoryNodeIds.length>0?this.presortedDirectoryNodeIds:null}}didMatchAllInitialExpandedPaths(){return this.createdDirectoriesAllExpanded&&this.initialExpandedPathSet!=null&&this.createdDirectoryCount===this.initialExpandedPathSet.size}appendPreparedPath(e,t){if(this.hasDeferredDirectoryIndexes&&=(this.buildDirectoryIndexes(),!1),this.lastPreparedPath!=null){if(e.path===this.lastPreparedPath.path)throw Error(`Duplicate path: "${e.path}"`);if(t&&(this.options.sort===`default`?pn(this.lastPreparedPath,e,this.segmentSortKeyCache):En(this.lastPreparedPath,e,this.options.sort))>0)throw Error(`Builder input must be sorted before appendPaths(): "${e.path}"`)}let n=this.lastPreparedPath,r=kn(e),i=n==null?0:kn(n),a=n==null?0:On(n.segments,e.segments),o=Math.min(a,r,i);this.directoryStack.length=o+1;for(let n=o;n<r;n++){let r=this.directoryStack[this.directoryStack.length-1];if(r===void 0)throw Error(`Directory stack underflow while building the path store`);let i=t?this.getOrCreateDirectoryChild(r,e.segments[n]):this.createDirectoryChild(r,e.segments[n]);this.directoryStack.push(i)}if(e.isDirectory){let t=this.directoryStack[this.directoryStack.length-1];if(t===void 0)throw Error(`Unable to resolve directory node for "${e.path}"`);this.promoteDirectoryToExplicit(t,e.path),this.lastPreparedPath=e;return}let s=this.directoryStack[this.directoryStack.length-1];if(s===void 0)throw Error(`Unable to resolve file parent for "${e.path}"`);t?this.createFileChild(s,e.basename,e.path):this.createFileChildUnchecked(s,e.basename),this.lastPreparedPath=e}recordCreatedDirectoryPath(e){!this.createdDirectoriesAllExpanded||this.initialExpandedPathSet==null||(this.createdDirectoryCount+=1,this.initialExpandedPathSet.has(e)||(this.createdDirectoriesAllExpanded=!1))}createFileChild(e,t,n){let r=xn(this.segmentTable,t),i=this.getDirectoryIndex(e),a=i.childIdByNameId;if(a!=null&&a.get(r)!==void 0)throw Error(`Path collides with an existing entry: "${n}"`);let o=this.nodes[e];if(o===void 0)throw Error(`Unknown parent node ID: ${String(e)}`);let s=this.nodes.length;return this.nodes.push({depthAndFlags:Kt(qt(o)+1,0),nameId:r,parentId:e,subtreeNodeCount:1,visibleSubtreeCount:1}),a?.set(r,s),Ft(i,s),s}createFileChildUnchecked(e,t){let n=xn(this.segmentTable,t),r=this.getDirectoryIndex(e),i=this.nodes[e];if(i===void 0)throw Error(`Unknown parent node ID: ${String(e)}`);let a=this.nodes.length;return this.nodes.push({depthAndFlags:Kt(qt(i)+1,0),nameId:n,parentId:e,subtreeNodeCount:1,visibleSubtreeCount:1}),r.childIdByNameId!=null&&r.childIdByNameId.set(n,a),Ft(r,a),a}getOrCreateDirectoryChild(e,t){let n=xn(this.segmentTable,t),r=this.getDirectoryIndex(e);if(r.childIdByNameId!=null){let e=r.childIdByNameId.get(n);if(e!==void 0){let n=this.nodes[e];if(n!=null&&!z(n))throw Error(`Path collides with an existing file while creating directory "${t}"`);return e}}let i=this.nodes[e];if(i===void 0)throw Error(`Unknown parent node ID: ${String(e)}`);let a=this.nodes.length;return this.nodes.push({depthAndFlags:Kt(qt(i)+1,0,1),nameId:n,parentId:e,subtreeNodeCount:1,visibleSubtreeCount:1}),r.childIdByNameId!=null&&r.childIdByNameId.set(n,a),Ft(r,a),this.directories.set(a,jt()),a}createDirectoryChild(e,t){let n=xn(this.segmentTable,t),r=this.getDirectoryIndex(e),i=this.nodes[e];if(i===void 0)throw Error(`Unknown parent node ID: ${String(e)}`);let a=this.nodes.length;return this.nodes.push({depthAndFlags:Kt(qt(i)+1,0,1),nameId:n,parentId:e,subtreeNodeCount:1,visibleSubtreeCount:1}),r.childIdByNameId!=null&&r.childIdByNameId.set(n,a),Ft(r,a),this.directories.set(a,jt()),a}promoteDirectoryToExplicit(e,t){let n=this.nodes[e];if(n===void 0)throw Error(`Unknown directory node ID: ${String(e)}`);if(!z(n))throw Error(`Path is not a directory: "${t}"`);if(B(n,1))throw Error(`Duplicate path: "${t}"`);Xt(n,1)}getDirectoryIndex(e){let t=this.directories.get(e);if(t!==void 0)return t;throw Error(`Unknown directory child index for node ${String(e)}`)}buildPresortedFinish(e){let t=this.nodes,n=this.directories;n.set(0,Mt());let r=-1,i=null;for(let e=1;e<t.length;e++){let a=t[e];if(a==null)continue;if(z(a)){let t=Mt();n.set(e,t),r=e,i=t}let o;a.parentId===r?o=i:(o=n.get(a.parentId),r=a.parentId,i=o??null),o?.childIds.push(e)}if(!e)for(let e=t.length-1;e>=1;e--){let n=t[e];if(n==null)continue;let r=t[n.parentId];r!=null&&(r.subtreeNodeCount+=n.subtreeNodeCount,r.visibleSubtreeCount+=n.visibleSubtreeCount)}}buildDirectoryIndexes(){let e=this.nodes;for(let t=1;t<e.length;t++){let n=e[t];if(n==null)continue;z(n)&&this.directories.set(t,jt());let r=this.directories.get(n.parentId);r!=null&&(r.childIdByNameId!=null&&r.childIdByNameId.set(n.nameId,t),Ft(r,t))}}computeSubtreeCounts(e){let t=this.nodes[e];if(t===void 0)throw Error(`Unknown node ID: ${String(e)}`);if(!z(t))return t.subtreeNodeCount=1,t.visibleSubtreeCount=1,1;let n=this.getDirectoryIndex(e),r=1;for(let e of n.childIds)r+=this.computeSubtreeCounts(e);return Lt(this.nodes,n),t.subtreeNodeCount=r,t.visibleSubtreeCount=r,r}};function Bn(e,t=`closed`,n=null){let r=Hn(t);return{activeNodeCount:e.nodes.length-1,collapsedDirectoryIds:new Set,collapseNewDirectoriesByDefault:!1,defaultExpansion:r,directoriesOpenByDefault:r===`open`,hasCollapsedDirectoryOverrides:!1,directoryLoadInfoById:new Map,expandedDirectoryIds:new Set,instrumentation:n,listeners:new Map,pathCacheByNodeId:new Map([[e.rootId,{path:``,version:0}]]),pathCacheVersion:0,snapshot:e,transactionStack:[]}}function Vn(){return{affectedAncestorIds:new Set,affectedNodeIds:new Set,events:[]}}function Hn(e){if(typeof e!=`number`)return e;if(!Number.isInteger(e)||e<0)throw Error(`initialExpansion must be "open", "closed", or a non-negative integer depth. Received: ${String(e)}`);return e}function Un(e,t){return B(t,2)||e.defaultExpansion===`open`?!0:e.defaultExpansion===`closed`?!1:qt(t)<=e.defaultExpansion}function Wn(e,t,n=e.snapshot.nodes[t]){return n==null||!z(n)?!1:e.directoriesOpenByDefault&&!e.hasCollapsedDirectoryOverrides?!0:e.collapsedDirectoryIds.has(t)?!1:e.expandedDirectoryIds.has(t)?!0:Un(e,n)}function Gn(e,t,n,r=e.snapshot.nodes[t]){if(r==null||!z(r))return;let i=Un(e,r);if(n){if(i){e.collapsedDirectoryIds.delete(t),e.hasCollapsedDirectoryOverrides=e.collapsedDirectoryIds.size>0;return}e.expandedDirectoryIds.add(t);return}if(i){e.collapsedDirectoryIds.add(t),e.hasCollapsedDirectoryOverrides=!0;return}e.expandedDirectoryIds.delete(t)}function Kn(e,t){let n=e.directoryLoadInfoById.get(t);if(n!=null)return n;let r={activeAttemptId:null,errorMessage:null,nextAttemptId:1,state:`loaded`};return e.directoryLoadInfoById.set(t,r),r}function qn(e,t){return e.directoryLoadInfoById.get(t)?.state??`loaded`}function Jn(e,t){let n=Kn(e,t);if(n.state===`loading`&&n.activeAttemptId!=null)return{attemptId:n.activeAttemptId,nodeId:t,reused:!0};let r=n.nextAttemptId;return n.activeAttemptId=r,n.errorMessage=null,n.nextAttemptId+=1,n.state=`loading`,{attemptId:r,nodeId:t,reused:!1}}function Yn(e,t){let n=Kn(e,t);n.activeAttemptId=null,n.errorMessage=null,n.state=`unloaded`}function Xn(e,t,n){let r=e.directoryLoadInfoById.get(t);return r==null||r.activeAttemptId!==n?!1:(r.activeAttemptId=null,r.errorMessage=null,r.state=`loaded`,!0)}function Zn(e,t,n){return e.directoryLoadInfoById.get(t)?.activeAttemptId===n}function Qn(e,t,n,r){let i=e.directoryLoadInfoById.get(t);return i==null||i.activeAttemptId!==n?!1:(i.activeAttemptId=null,i.errorMessage=r??null,i.state=`error`,!0)}function $n(e,t){e.directoryLoadInfoById.delete(t)}function er(e,t,n){let r=n,i=e.listeners.get(t);return i==null?e.listeners.set(t,new Set([r])):i.add(r),()=>{let n=e.listeners.get(t);n!=null&&(n.delete(r),n.size===0&&e.listeners.delete(t))}}function tr(e){return{affectedAncestorIds:e.affectedAncestorIds??[],affectedNodeIds:e.affectedNodeIds??[],canonicalChanged:!0,operation:`add`,path:e.path,projectionChanged:e.projectionChanged,visibleCountDelta:null}}function nr(e){return{affectedAncestorIds:e.affectedAncestorIds??[],affectedNodeIds:e.affectedNodeIds??[],canonicalChanged:!0,operation:`remove`,path:e.path,projectionChanged:e.projectionChanged,recursive:e.recursive,visibleCountDelta:null}}function rr(e){return{affectedAncestorIds:e.affectedAncestorIds??[],affectedNodeIds:e.affectedNodeIds??[],canonicalChanged:!0,from:e.from,operation:`move`,projectionChanged:e.projectionChanged,to:e.to,visibleCountDelta:null}}function ir(e){return{affectedAncestorIds:e.affectedAncestorIds??[],affectedNodeIds:e.affectedNodeIds??[],canonicalChanged:!1,operation:`expand`,path:e.path,projectionChanged:!0,visibleCountDelta:null}}function ar(e){return{affectedAncestorIds:e.affectedAncestorIds??[],affectedNodeIds:e.affectedNodeIds??[],canonicalChanged:!1,operation:`collapse`,path:e.path,projectionChanged:!0,visibleCountDelta:null}}function or(e){return{affectedAncestorIds:e.affectedAncestorIds??[],affectedNodeIds:e.affectedNodeIds??[],canonicalChanged:!1,operation:`mark-directory-unloaded`,path:e.path,projectionChanged:e.projectionChanged,visibleCountDelta:null}}function sr(e){return{affectedAncestorIds:e.affectedAncestorIds??[],affectedNodeIds:e.affectedNodeIds??[],attemptId:e.attemptId,canonicalChanged:!1,operation:`begin-child-load`,path:e.path,projectionChanged:e.projectionChanged,reused:e.reused,visibleCountDelta:null}}function cr(e){return{affectedAncestorIds:e.affectedAncestorIds??[],affectedNodeIds:e.affectedNodeIds??[],attemptId:e.attemptId,canonicalChanged:e.childEvents.some(e=>e.canonicalChanged),childEvents:e.childEvents,operation:`apply-child-patch`,path:e.path,projectionChanged:e.projectionChanged,visibleCountDelta:null}}function lr(e){return{affectedAncestorIds:e.affectedAncestorIds??[],affectedNodeIds:e.affectedNodeIds??[],attemptId:e.attemptId,canonicalChanged:!1,operation:`complete-child-load`,path:e.path,projectionChanged:e.projectionChanged,stale:e.stale,visibleCountDelta:null}}function ur(e){return{affectedAncestorIds:e.affectedAncestorIds??[],affectedNodeIds:e.affectedNodeIds??[],attemptId:e.attemptId,canonicalChanged:!1,errorMessage:e.errorMessage,operation:`fail-child-load`,path:e.path,projectionChanged:e.projectionChanged,stale:e.stale,visibleCountDelta:null}}function dr(e){return{activeNodeCountAfter:e.activeNodeCountAfter,activeNodeCountBefore:e.activeNodeCountBefore,affectedAncestorIds:e.affectedAncestorIds??[],affectedNodeIds:e.affectedNodeIds??[],cachedPathEntryCountAfter:e.cachedPathEntryCountAfter,cachedPathEntryCountBefore:e.cachedPathEntryCountBefore,canonicalChanged:!1,idsPreserved:e.idsPreserved,loadInfoEntryCountAfter:e.loadInfoEntryCountAfter,loadInfoEntryCountBefore:e.loadInfoEntryCountBefore,mode:e.mode,operation:`cleanup`,projectionChanged:e.projectionChanged,reclaimedCachedPathEntryCount:e.reclaimedCachedPathEntryCount,reclaimedLoadInfoEntryCount:e.reclaimedLoadInfoEntryCount,reclaimedNodeSlotCount:e.reclaimedNodeSlotCount,reclaimedSegmentCount:e.reclaimedSegmentCount,segmentCountAfter:e.segmentCountAfter,segmentCountBefore:e.segmentCountBefore,totalNodeSlotCountAfter:e.totalNodeSlotCountAfter,totalNodeSlotCountBefore:e.totalNodeSlotCountBefore,visibleCountDelta:null}}function fr(e,t,n){return{...n,visibleCountDelta:Cr(e)-t}}function pr(e,t){let n=Cr(e),r=Vn();e.transactionStack.push(r);try{t()}catch(t){throw gr(e,r,!1),t}gr(e,r,!0,Cr(e)-n)}function mr(e,t){let n=e.instrumentation;if(n==null){hr(e,t);return}V(n,`store.events.record`,()=>hr(e,t))}function hr(e,t){let n=e.transactionStack[e.transactionStack.length-1]??null;if(n==null){xr(e,t);return}n.events.push(t),br(n,t)}function gr(e,t,n,r=null){if(e.transactionStack.pop()!==t)throw Error(`Transaction stack underflow`);if(!n)return;let i=e.transactionStack[e.transactionStack.length-1]??null;if(i!=null){let n=e.instrumentation;n==null?yr(i,t):V(n,`store.events.batch.merge`,()=>yr(i,t));return}let a=_r(t,r),o=e.instrumentation;if(o==null){xr(e,a);return}V(o,`store.events.batch.commit`,()=>xr(e,a))}function _r(e,t){return{affectedAncestorIds:[...e.affectedAncestorIds],affectedNodeIds:[...e.affectedNodeIds],canonicalChanged:e.events.some(e=>e.canonicalChanged),events:[...e.events],operation:`batch`,projectionChanged:e.events.some(e=>e.projectionChanged),visibleCountDelta:t}}function vr(e,t){for(let n of t.affectedAncestorIds)e.affectedAncestorIds.add(n);for(let n of t.affectedNodeIds)e.affectedNodeIds.add(n)}function yr(e,t){for(let n of t.events)e.events.push(n);vr(e,t)}function br(e,t){for(let n of t.affectedNodeIds)e.affectedNodeIds.add(n);for(let n of t.affectedAncestorIds)e.affectedAncestorIds.add(n)}function xr(e,t){let n=e.instrumentation;if(n==null){Sr(e,t);return}V(n,`store.events.emit`,()=>Sr(e,t))}function Sr(e,t){e.listeners.get(t.operation)?.forEach(e=>e(t)),e.listeners.get(`*`)?.forEach(e=>e(t))}function Cr(e){return e.snapshot.nodes[e.snapshot.rootId]?.visibleSubtreeCount??0}function wr(e,t){if(e.snapshot.options.flattenEmptyDirectories!==!0)return null;let n=e.snapshot.nodes[t];if(n==null||!z(n)||B(n,2))return null;let r=e.snapshot.directories.get(t);if(r==null||r.childIds.length!==1)return null;let i=r.childIds[0];if(i==null)return null;let a=e.snapshot.nodes[i];return a==null||!z(a)?null:i}function Tr(e,t){let n=t;for(;;){let t=wr(e,n);if(t==null)return n;n=t}}function Er(e,t){let n=[t],r=t;for(;;){let t=wr(e,r);if(t==null)return n;n.push(t),r=t}}function Dr(e,t){let n=t==null?e.snapshot.rootId:Ir(e,t);return n==null?[]:Rr(e,n)}function Or(e,t){let n=_n(t),r=n.isDirectory?n.segments:n.segments.slice(0,-1),i=$r(e,Qr(e,r)),{createdNodeIds:a,directoryId:o}=zr(e,r),s=new Set(a),c=o;if(n.isDirectory){let n=W(e,o);if(B(n,1))throw Error(`Path already exists: "${t}"`);Xt(n,1),e.pathCacheByNodeId.set(o,{path:t,version:e.pathCacheVersion}),s.add(o)}else c=Vr(e,o,n.basename),s.add(c);Nr(e,o);let l=$r(e,o);return tr({affectedAncestorIds:Fr(e,c),affectedNodeIds:[...s],path:t,projectionChanged:ei(i,l)})}function kr(e,t,n){let r=Ir(e,t);if(r==null)throw Error(`Path does not exist: "${t}"`);let i=W(e,r);if(B(i,2))throw Error(`The root node cannot be removed`);if(z(i)&&U(e,r).childIds.length>0&&n.recursive!==!0)throw Error(`Cannot remove a non-empty directory without recursive: "${t}"`);let a=i.parentId,o=$r(e,a),s=Xr(e,r);Wr(e,a,r,i.nameId),Zr(e,a),Nr(e,a);let c=$r(e,a);return nr({affectedAncestorIds:Fr(e,a),affectedNodeIds:s,path:t,projectionChanged:ei(o,c),recursive:n.recursive===!0})}function Ar(e,t,n,r){let i=Ir(e,t);if(i==null)throw Error(`Source path does not exist: "${t}"`);let a=W(e,i);if(B(a,2))throw Error(`The root node cannot be moved`);let o=r.collision??`error`,s=Jr(e,i,n),c=$r(e,a.parentId),l=$r(e,s.parentId),u=Sn(e.snapshot.segmentTable,a.nameId),d=xn(e.snapshot.segmentTable,s.basename);if(s.parentId===a.parentId&&u===s.basename)return null;if(z(a)&&ii(e,i,s.parentId))throw Error(`Cannot move a directory into one of its descendants`);let f=Nt(e.snapshot.nodes,U(e,s.parentId)).get(d),p=s.existingNodeId??f??null;if(p!=null&&p!==i&&Yr(e,p,o,Jt(a))===`skip`)return null;let m=a.parentId;Wr(e,m,i,a.nameId),a.parentId=s.parentId,a.nameId=d,e.pathCacheByNodeId.delete(i),ri(e,i),Ur(e,s.parentId,i),Zr(e,m),e.pathCacheVersion++,Nr(e,m),s.parentId!==m&&Nr(e,s.parentId);let h=$r(e,m),g=$r(e,s.parentId);return rr({affectedAncestorIds:[...new Set([...Fr(e,m),...Fr(e,s.parentId)])],affectedNodeIds:[i],from:t,projectionChanged:ti([c,l],[h,g]),to:H(e,i)})}function jr(e,t){let n=e.pathCacheByNodeId.get(t);return n!=null&&n.version===e.pathCacheVersion?n.path:null}function Mr(e,t,n){return e.pathCacheByNodeId.set(t,{path:n,version:e.pathCacheVersion}),n}function H(e,t){let n=W(e,t),r=jr(e,t);if(r!=null)return r;if(B(n,2))return Mr(e,t,``);let i=H(e,n.parentId),a=Sn(e.snapshot.segmentTable,n.nameId),o=i.length===0?a:`${i}${a}`;return Mr(e,t,z(n)?`${o}/`:o)}function Nr(e,t){let n=e.instrumentation;if(n==null){oi(e,t);return}V(n,`store.recomputeCountsUpwardFrom`,()=>oi(e,t))}function Pr(e,t){let n=[[t,0]],{nodes:r,directories:i}=e.snapshot;for(;n.length>0;){let t=n[n.length-1],a=t[0],o=r[a];if(o==null||!z(o)){ai(e,a,o,!0),n.pop();continue}let s=i.get(a);if(s==null||t[1]>=s.childIds.length){ai(e,a,o,!0),n.pop();continue}let c=s.childIds[t[1]++];n.push([c,0])}}function Fr(e,t){let n=[],r=t;for(;r!=null;){let t=W(e,r);if(n.push(r),r===e.snapshot.rootId)break;r=t.parentId}return n}function Ir(e,t){if(t.length===0)return e.snapshot.rootId;let n=vn(t);return Lr(e,n.segments,n.requiresDirectory)}function Lr(e,t,n){let r=e.snapshot.rootId;for(let n of t){let t=e.snapshot.segmentTable.idByValue.get(n);if(t===void 0)return null;let i=U(e,r),a=Nt(e.snapshot.nodes,i).get(t);if(a===void 0)return null;r=a}let i=W(e,r);return n&&!z(i)?null:r}function U(e,t){let n=e.snapshot.directories.get(t);if(n===void 0)throw Error(`Unknown directory child index for node ${String(t)}`);return n}function W(e,t){let n=e.snapshot.nodes[t];if(n===void 0||B(n,4))throw Error(`Unknown node ID: ${String(t)}`);return n}function Rr(e,t){let n=e.snapshot.nodes[t];if(n===void 0||B(n,4))return[];if(!z(n))return[H(e,t)];if(U(e,t).childIds.length===0)return B(n,1)&&!B(n,2)?[H(e,t)]:[];let r=[],i=[{childIndex:0,nodeId:t}];for(;i.length>0;){let t=i[i.length-1];if(t==null)break;let n=e.snapshot.nodes[t.nodeId];if(n===void 0||B(n,4)){i.pop();continue}if(!z(n)){r.push(H(e,t.nodeId)),i.pop();continue}let a=U(e,t.nodeId);if(a.childIds.length===0){B(n,1)&&!B(n,2)&&r.push(H(e,t.nodeId)),i.pop();continue}let o=a.childIds[t.childIndex];if(o==null){i.pop();continue}t.childIndex++,i.push({childIndex:0,nodeId:o})}return r}function zr(e,t){let n=[],r=e.snapshot.rootId;for(let i of t){let t=xn(e.snapshot.segmentTable,i),a=U(e,r),o=Nt(e.snapshot.nodes,a).get(t);if(o!==void 0){if(!z(W(e,o)))throw Error(`Cannot create a directory that collides with an existing file: "${i}"`);r=o;continue}r=Br(e,r,t),n.push(r)}return{createdNodeIds:n,directoryId:r}}function Br(e,t,n){let r=W(e,t),i=e.snapshot.nodes.length;return e.snapshot.nodes.push({depthAndFlags:Kt(qt(r)+1,0,1),nameId:n,parentId:t,subtreeNodeCount:1,visibleSubtreeCount:1}),e.snapshot.directories.set(i,jt()),Ur(e,t,i),e.collapseNewDirectoriesByDefault&&(e.collapsedDirectoryIds.add(i),e.hasCollapsedDirectoryOverrides=!0),e.activeNodeCount++,i}function Vr(e,t,n){let r=xn(e.snapshot.segmentTable,n),i=U(e,t);if(Nt(e.snapshot.nodes,i).has(r))throw Error(`Path already exists: "${ci(e,t,n)}"`);let a=W(e,t),o=e.snapshot.nodes.length;return e.snapshot.nodes.push({depthAndFlags:Kt(qt(a)+1,0),nameId:r,parentId:t,subtreeNodeCount:1,visibleSubtreeCount:1}),Ur(e,t,o),e.activeNodeCount++,o}function Hr(e,t,n){let r=0,i=t.childIds.length;for(;r<i;){let a=r+i>>>1,o=t.childIds[a];if(o==null){i=a;continue}Gr(e,n,o)<0?i=a:r=a+1}return r}function Ur(e,t,n){let r=U(e,t),i=W(e,n);Nt(e.snapshot.nodes,r).set(i.nameId,n),Rt(r,n,i.subtreeNodeCount,i.visibleSubtreeCount);let a=Hr(e,r,n);r.childIds.splice(a,0,n),It(r,a),Vt(e.snapshot.nodes,r)}function Wr(e,t,n,r){let i=U(e,t),a=Pt(i),o=a.get(n)??-1;Nt(e.snapshot.nodes,i).delete(r),a.delete(n);let s=e.snapshot.nodes[n];s!=null&&Rt(i,n,-s.subtreeNodeCount,-s.visibleSubtreeCount),o>=0&&(i.childIds.splice(o,1),It(i,o),Vt(e.snapshot.nodes,i))}function Gr(e,t,n){let r=e.snapshot.options.sort;return r===`default`?Kr(e,t,n):r(qr(e,t),qr(e,n))}function Kr(e,t,n){let r=W(e,t),i=W(e,n),a=z(r);if(a!==z(i))return a?-1:1;let o=sn(mn(e.snapshot.segmentTable,r.nameId),mn(e.snapshot.segmentTable,i.nameId));if(o!==0)return o;let s=Sn(e.snapshot.segmentTable,r.nameId),c=Sn(e.snapshot.segmentTable,i.nameId);return s===c?t<n?-1:1:s<c?-1:1}function qr(e,t){let n=W(e,t),r=H(e,t),i=z(n),a=i?r.slice(0,-1):r;return{basename:Sn(e.snapshot.segmentTable,n.nameId),depth:qt(n),isDirectory:i,path:r,segments:a.length===0?[]:a.split(`/`)}}function Jr(e,t,n){let r=W(e,t),i=Ir(e,n);if(i!=null){let t=W(e,i);if(z(t))return{basename:Sn(e.snapshot.segmentTable,r.nameId),existingNodeId:null,parentId:i};let a=vn(n).segments;return{basename:a[a.length-1]??``,existingNodeId:i,parentId:t.parentId}}let a=vn(n),o=a.segments[a.segments.length-1]??``,s=a.segments.slice(0,-1),c=s.length===0?e.snapshot.rootId:Lr(e,s,!0);if(c==null)throw Error(`Destination parent does not exist: "${n}"`);return{basename:o,existingNodeId:null,parentId:c}}function Yr(e,t,n,r){if(n===`skip`)return`skip`;if(n===`error`)throw Error(`Destination already exists: "${H(e,t)}"`);let i=W(e,t);if(Jt(i)!==r)throw Error(`replace collision requires the same source and destination kinds`);if(z(i)&&U(e,t).childIds.length>0)throw Error(`replace collision does not support non-empty directories`);let a=i.parentId,o=i.nameId;return Xr(e,t),Wr(e,a,t,o),Zr(e,a),Nr(e,a),`handled`}function Xr(e,t){let n=[],r=[{nodeId:t,visitedChildren:!1}];for(;r.length>0;){let t=r.pop();if(t==null)break;let i=W(e,t.nodeId);if(t.visitedChildren||!z(i)){z(i)&&e.snapshot.directories.delete(t.nodeId),Xt(i,4),e.pathCacheByNodeId.delete(t.nodeId),e.collapsedDirectoryIds.delete(t.nodeId)&&(e.hasCollapsedDirectoryOverrides=e.collapsedDirectoryIds.size>0),e.expandedDirectoryIds.delete(t.nodeId),$n(e,t.nodeId),e.activeNodeCount--,n.push(t.nodeId);continue}r.push({nodeId:t.nodeId,visitedChildren:!0});let a=U(e,t.nodeId);for(let e=a.childIds.length-1;e>=0;e--){let t=a.childIds[e];t!=null&&r.push({nodeId:t,visitedChildren:!1})}}return n}function Zr(e,t){let n=t;for(;n!=null;){let t=W(e,n);if(!z(t)||B(t,2)||U(e,n).childIds.length>0)return;Xt(t,1),n=t.parentId===n?null:t.parentId}}function Qr(e,t){let n=e.snapshot.rootId;for(let r of t){let t=e.snapshot.segmentTable.idByValue.get(r);if(t==null)break;let i=Nt(e.snapshot.nodes,U(e,n)).get(t);if(i==null||!z(W(e,i)))break;n=i}return n}function $r(e,t){let n=ni(e,t);if(n==null)return null;let r=Tr(e,n),i=W(e,r),a=n===r?null:Er(e,n).map(t=>H(e,t));return JSON.stringify({flattenedSegmentPaths:a,hasChildren:U(e,r).childIds.length>0,path:H(e,r),terminalKind:Jt(i)})}function ei(e,t){return ti([e],[t])}function ti(e,t){for(let n=0;n<e.length;n+=1){let r=e[n],i=t[n];if(r==null||i==null||r!==i)return!0}return!1}function ni(e,t){let n=t;for(;n!=null;){let t=W(e,n);if(!z(t)||B(t,2))return null;if(!Wn(e,n,t))return n;n=t.parentId}return null}function ri(e,t){let n=W(e,t);if(Zt(n,(t===e.snapshot.rootId?-1:qt(W(e,n.parentId)))+1),!z(n))return;let r=U(e,t);for(let t of r.childIds)ri(e,t)}function ii(e,t,n){let r=n;for(;r!=null;){if(r===t)return!0;let n=W(e,r);if(r===e.snapshot.rootId)return!1;r=n.parentId}return!1}function ai(e,t,n=W(e,t),r=!1){let i=e.instrumentation;if(i==null){si(e,t,n,r);return}V(i,`store.recomputeNodeCounts`,()=>si(e,t,n,r))}function oi(e,t){let n=t;for(;n!=null;){let t=W(e,n),r=t.subtreeNodeCount,i=t.visibleSubtreeCount;if(ai(e,n,t),n===e.snapshot.rootId)return;let a=t.subtreeNodeCount-r,o=t.visibleSubtreeCount-i,s=t.parentId;(a!==0||o!==0)&&Rt(U(e,s),n,a,o),n=s}}function si(e,t,n,r){if(!z(n)){n.subtreeNodeCount=1,n.visibleSubtreeCount=1;return}let i=U(e,t);if(r){let t=e.instrumentation;t==null?Lt(e.snapshot.nodes,i):V(t,`store.recomputeNodeCounts.rebuildChildAggregates`,()=>Lt(e.snapshot.nodes,i))}let a=1+i.totalChildSubtreeNodeCount,o=i.totalChildVisibleSubtreeCount;if(n.subtreeNodeCount=a,B(n,2)){n.visibleSubtreeCount=o;return}n.visibleSubtreeCount=wr(e,t)==null?Wn(e,t,n)?1+o:1:o}function ci(e,t,n){let r=H(e,t);return r.length===0?n:`${r}${n}`}function li(e){return e!=null&&!B(e,4)}function ui(e,t){let n=e.snapshot.nodes[t];return!li(n)||!z(n)||B(n,2)?null:n}function di(e){let t=0;for(let[n,r]of e.pathCacheByNodeId)r.version===e.pathCacheVersion&&li(e.snapshot.nodes[n])&&(t+=1);return t}function fi(e){return Math.max(0,e.valueById.length-1)}function pi(e){return{activeNodeCount:e.activeNodeCount,cachedPathEntryCount:di(e),loadInfoEntryCount:e.directoryLoadInfoById.size,segmentCount:fi(e.snapshot.segmentTable),totalNodeSlotCount:Math.max(0,e.snapshot.nodes.length-1)}}function mi(e,t,n,r){return{activeNodeCountAfter:r.activeNodeCount,activeNodeCountBefore:n.activeNodeCount,cachedPathEntryCountAfter:r.cachedPathEntryCount,cachedPathEntryCountBefore:n.cachedPathEntryCount,idsPreserved:t,loadInfoEntryCountAfter:r.loadInfoEntryCount,loadInfoEntryCountBefore:n.loadInfoEntryCount,mode:e,reclaimedCachedPathEntryCount:n.cachedPathEntryCount-r.cachedPathEntryCount,reclaimedLoadInfoEntryCount:n.loadInfoEntryCount-r.loadInfoEntryCount,reclaimedNodeSlotCount:n.totalNodeSlotCount-r.totalNodeSlotCount,reclaimedSegmentCount:n.segmentCount-r.segmentCount,segmentCountAfter:r.segmentCount,segmentCountBefore:n.segmentCount,totalNodeSlotCountAfter:r.totalNodeSlotCount,totalNodeSlotCountBefore:n.totalNodeSlotCount}}function hi(e){let t=[],n=[];for(let n of e.collapsedDirectoryIds)ui(e,n)!=null&&t.push(H(e,n));for(let t of e.expandedDirectoryIds)ui(e,t)!=null&&n.push(H(e,t));return{collapsedPaths:t,expandedPaths:n}}function gi(e){let t=[];for(let[n,r]of e.directoryLoadInfoById)ui(e,n)==null||qn(e,n)===`loaded`||t.push({info:{activeAttemptId:null,errorMessage:r.errorMessage,nextAttemptId:r.nextAttemptId,state:r.state},path:H(e,n)});return t}function _i(e,t){e.collapsedDirectoryIds.clear(),e.hasCollapsedDirectoryOverrides=!1,e.expandedDirectoryIds.clear();for(let n of t.expandedPaths){let t=Ir(e,n);t!=null&&Gn(e,t,!0,W(e,t))}for(let n of t.collapsedPaths){let t=Ir(e,n);t!=null&&Gn(e,t,!1,W(e,t))}}function vi(e,t){e.directoryLoadInfoById.clear();for(let n of t){let t=Ir(e,n.path);t!=null&&ui(e,t)!=null&&e.directoryLoadInfoById.set(t,{activeAttemptId:null,errorMessage:n.info.errorMessage,nextAttemptId:n.info.nextAttemptId,state:n.info.state})}}function yi(e){e.pathCacheVersion+=1,e.pathCacheByNodeId.clear(),e.pathCacheByNodeId.set(e.snapshot.rootId,{path:``,version:e.pathCacheVersion})}function bi(e){let t=e.snapshot.segmentTable,n=bn();for(let r of e.snapshot.nodes)if(li(r)){if(B(r,2)){r.nameId=0;continue}r.nameId=xn(n,Sn(t,r.nameId))}e.snapshot.segmentTable=n}function xi(e){for(let[t,n]of e.snapshot.directories){let r=e.snapshot.nodes[t];if(!li(r)||!z(r)){e.snapshot.directories.delete(t);continue}let i=n.childIds.filter(n=>{let r=e.snapshot.nodes[n];return li(r)&&r.parentId===t});n.childIds=i,n.childIdByNameId=new Map(i.map(t=>[W(e,t).nameId,t])),n.childPositionById=new Map(i.map((e,t)=>[e,t])),Lt(e.snapshot.nodes,n)}}function Si(e){let t=e.snapshot.nodes.length-1;for(;t>e.snapshot.rootId;){let n=e.snapshot.nodes[t];if(li(n))break;--t}e.snapshot.nodes.length=t+1}function Ci(e){let t=hi(e),n=gi(e);V(e.instrumentation,`store.cleanup.stable.clearPathCaches`,()=>yi(e)),V(e.instrumentation,`store.cleanup.stable.rebuildSegmentTable`,()=>bi(e)),V(e.instrumentation,`store.cleanup.stable.rebuildDirectoryIndexes`,()=>xi(e)),V(e.instrumentation,`store.cleanup.stable.trimTrailingRemovedNodeSlots`,()=>Si(e)),V(e.instrumentation,`store.cleanup.stable.restoreExpansionOverrides`,()=>_i(e,t)),V(e.instrumentation,`store.cleanup.stable.restoreDirectoryLoadInfos`,()=>vi(e,n)),V(e.instrumentation,`store.cleanup.stable.recomputeCounts`,()=>Pr(e,e.snapshot.rootId))}function wi(e){let t=hi(e),n=gi(e),r=V(e.instrumentation,`store.cleanup.aggressive.listPaths`,()=>Dr(e)),i=$t({...e.snapshot.options},e.instrumentation),a=V(e.instrumentation,`store.cleanup.aggressive.rebuildSnapshot`,()=>{let e=new zn(i);return e.appendPaths(r),e.finish()});e.snapshot=a,e.activeNodeCount=a.nodes.length-1,e.pathCacheByNodeId=new Map([[a.rootId,{path:``,version:0}]]),e.pathCacheVersion=0,V(e.instrumentation,`store.cleanup.aggressive.restoreExpansionOverrides`,()=>_i(e,t)),V(e.instrumentation,`store.cleanup.aggressive.restoreDirectoryLoadInfos`,()=>vi(e,n)),V(e.instrumentation,`store.cleanup.aggressive.recomputeCounts`,()=>Pr(e,e.snapshot.rootId))}function Ti(e){for(let t of e.directoryLoadInfoById.values())if(t.state===`loading`&&t.activeAttemptId!=null)return!0;return!1}function Ei(e,t){let n=pi(e);t===`stable`?V(e.instrumentation,`store.cleanup.stable`,()=>Ci(e)):V(e.instrumentation,`store.cleanup.aggressive`,()=>wi(e));let r=pi(e);return mi(t,t===`stable`,n,r)}var Di=64;function Oi(e,t){let n=t+2;if(n<=e.length)return e;let r=e.length;for(;r<n;)r*=2;let i=new Int32Array(r);return i.fill(-1),i.set(e),i}function ki(e){return W(e,e.snapshot.rootId).visibleSubtreeCount}function Ai(e,t,n,r){let i=W(e,t.terminalNodeId),a=Math.max(1,i.visibleSubtreeCount);return Math.min(r-1,n+a-1)}function ji(e,t,n,r){return{ancestorPaths:r,index:t.index,posInSet:t.posInSet,row:Ji(e,t.cursor),setSize:t.setSize,subtreeEndIndex:Ai(e,t.cursor,t.index,n)}}function Mi(e,t,n,r,i,a){let o=U(e,t),{childIndex:s,childVisibleIndex:c,localVisibleIndex:l}=zt(e.snapshot.nodes,o,n),u=o.childIds[s];if(u==null)throw Error(`Visible index ${String(n)} is out of range`);return Ni(e,u,l,r+c,i+1,s,o.childIds.length,a)}function Ni(e,t,n,r,i,a,o,s){if(!z(W(e,t))){if(n===0)return{ancestors:s,cursor:{headNodeId:t,terminalNodeId:t,visibleDepth:i},index:r,posInSet:a,setSize:o};throw Error(`Visible index ${String(n)} is out of range for file`)}let c=G(e,t,i);if(n===0)return{ancestors:s,cursor:c,index:r,posInSet:a,setSize:o};let l=W(e,c.terminalNodeId);if(!z(l)||!Wn(e,c.terminalNodeId,l))throw Error(`Visible index ${String(n)} is out of range for collapsed directory`);return Mi(e,c.terminalNodeId,n-1,r+1,c.visibleDepth,[...s,{cursor:c,index:r,posInSet:a,setSize:o}])}function Pi(e,t){let n=ki(e);if(t<0||t>=n)return null;let r=Mi(e,e.snapshot.rootId,t,0,-1,[]),i=r.ancestors.map(t=>H(e,t.cursor.terminalNodeId)),a=null;return{ancestorPaths:i,get ancestorRows(){if(a!=null)return a;let t=[],i=[];for(let a of r.ancestors){let r=ji(e,a,n,[...i]);t.push(r),i.push(r.row.path)}return a=t,a},index:r.index,posInSet:r.posInSet,row:Ji(e,r.cursor),setSize:r.setSize,subtreeEndIndex:Ai(e,r.cursor,r.index,n)}}function Fi(e,t,n){let r=e.instrumentation,i=ki(e);if(i<=0||n<t)return[];let a=Math.max(0,Math.min(t,i-1)),o=Math.max(a,Math.min(n,i-1));if(r==null){if(a===0)return qi(e,o+1);let t=[],n=Vi(e,a);for(let r=a;r<=o&&n!=null;r++){let r=Ji(e,n);t.push(r),n=Wi(e,n)}return t}let s=[],c=0,l=0,u=V(r,`store.getVisibleSlice.selectFirstRow`,()=>Vi(e,a));for(let t=a;t<=o&&u!=null;t++){let t=V(r,`store.getVisibleSlice.materializeRow`,()=>Ji(e,u));s.push(t),t.isFlattened&&(c++,l+=t.flattenedSegments?.length??0),u=V(r,`store.getVisibleSlice.advanceCursor`,()=>Wi(e,u))}return tn(r,`workload.visibleRowsRead`,s.length),tn(r,`workload.flattenedRowsRead`,c),tn(r,`workload.flattenedSegmentsRead`,l),s}function Ii(e,t=ki(e)){let n=e.instrumentation;return n==null?Ki(e,t):V(n,`store.getVisibleTreeProjection`,()=>Ki(e,t))}function Li(e){return Gi(Ii(e))}function Ri(e,t){let n=Ir(e,t);if(n==null||n===e.snapshot.rootId||z(W(e,n))&&Tr(e,n)!==n)return null;let r=0,i=n,{nodes:a,rootId:o}=e.snapshot;for(;i!==o;){let t=W(e,i).parentId,n=U(e,t),s=Pt(n).get(i);if(s==null)throw Error(`Child ${String(i)} was not found in its parent index`);if(r+=Bt(a,n,s),t!==o){let n=W(e,t),a=wr(e,t);if(!Wn(e,t,n)&&a!==i)return null;Tr(e,t)===t&&(r+=1)}i=t}return r}function zi(e,t){let n=Ir(e,t);if(n==null)throw Error(`Path does not exist: "${t}"`);let r=W(e,n);if(!z(r))throw Error(`Path is not a directory: "${t}"`);return Wn(e,n,r)?null:(Gn(e,n,!0,r),Nr(e,n),ir({affectedAncestorIds:Fr(e,n),affectedNodeIds:[n],path:t,projectionChanged:!0}))}function Bi(e,t){let n=Ir(e,t);if(n==null)throw Error(`Path does not exist: "${t}"`);let r=W(e,n);if(!z(r))throw Error(`Path is not a directory: "${t}"`);return Wn(e,n,r)?(Gn(e,n,!1,r),Nr(e,n),ar({affectedAncestorIds:Fr(e,n),affectedNodeIds:[n],path:t,projectionChanged:!0})):null}function Vi(e,t){return t<0||t>=ki(e)?null:Hi(e,e.snapshot.rootId,t,-1)}function Hi(e,t,n,r){let i=U(e,t),a=e.instrumentation,{childIndex:o,localVisibleIndex:s}=a==null?zt(e.snapshot.nodes,i,n):V(a,`store.getVisibleSlice.selectChildIndex`,()=>zt(e.snapshot.nodes,i,n)),c=i.childIds[o];if(c!=null)return Ui(e,c,s,r+1);throw Error(`Visible index ${String(n)} is out of range`)}function Ui(e,t,n,r){if(!z(W(e,t))){if(n===0)return{headNodeId:t,terminalNodeId:t,visibleDepth:r};throw Error(`Visible index ${String(n)} is out of range for file`)}let i=G(e,t,r);if(n===0)return i;let a=W(e,i.terminalNodeId);if(!z(a)||!Wn(e,i.terminalNodeId,a))throw Error(`Visible index ${String(n)} is out of range for collapsed directory`);return Hi(e,i.terminalNodeId,n-1,i.visibleDepth)}function G(e,t,n){return z(W(e,t))?e.instrumentation==null?{headNodeId:t,terminalNodeId:Tr(e,t),visibleDepth:n}:{headNodeId:t,terminalNodeId:V(e.instrumentation,`store.getVisibleSlice.flatten.resolveTerminalDirectory`,()=>Tr(e,t)),visibleDepth:n}:{headNodeId:t,terminalNodeId:t,visibleDepth:n}}function K(e,t){let n=W(e,t);if(!z(n))return!0;let r=n.parentId;return r===e.snapshot.rootId?!0:wr(e,r)!==t}function Wi(e,t){let n=W(e,t.terminalNodeId);if(z(n)){let r=U(e,t.terminalNodeId);if(Wn(e,t.terminalNodeId,n)&&r.childIds.length>0){let n=r.childIds[0];return n==null?null:Ui(e,n,0,t.visibleDepth+1)}}let r=t.terminalNodeId,i=t.visibleDepth;for(;;){let t=W(e,r);if(r===e.snapshot.rootId)return null;let n=t.parentId,a=U(e,n),o=Pt(a).get(r)??-1;if(o<0)throw Error(`Child ${String(r)} was not found in its parent index`);let s=a.childIds[o+1]??null;if(s!=null)return Ui(e,s,0,i);K(e,r)&&i--,r=n}}function Gi(e){let t=e.paths.length,n=Array(t);for(let r=0;r<t;r+=1){let t=e.getParentIndex(r);n[r]={index:r,parentPath:t>=0?e.paths[t]??null:null,path:e.paths[r]??``,posInSet:e.posInSetByIndex[r]??0,setSize:e.setSizeByIndex[r]??0}}return{getParentIndex:e.getParentIndex,rows:n,get visibleIndexByPath(){return e.visibleIndexByPath}}}function Ki(e,t){let n=Array(t),r=new Int32Array(t),i=new Int32Array(t),a=new Int32Array(t),o=new Int32Array(Di);o.fill(-1);let s=0,{nodes:c,directories:l,segmentTable:u}=e.snapshot,d=[[l.get(e.snapshot.rootId),0,-1,``]],f=e.snapshot.options.flattenEmptyDirectories,p=e.pathCacheByNodeId,m=e.pathCacheVersion,h=u.valueById;for(;d.length>0&&s<t;){let t=d[d.length-1],u=t[0];if(t[1]>=u.childIds.length){d.pop();continue}let g=t[1],_=u.childIds[t[1]++],v=c[_],y=t[2]+1,b=t[3];o=Oi(o,y);let x,S=_;if(z(v))S=f?Tr(e,_):_,x=S===_?`${b}${h[v.nameId]}/`:H(e,S);else{let e=p.get(_);x=e!=null&&e.version===m?e.path:`${b}${h[v.nameId]}`}r[s]=o[y],n[s]=x,i[s]=g,a[s]=u.childIds.length,o[y+1]=s,s+=1;let C=c[S];C!=null&&z(C)&&Wn(e,S,C)&&d.push([l.get(S),0,y,x])}s<t&&(n.length=s);let g=r.subarray(0,s),_=i.subarray(0,s),v=a.subarray(0,s),y=null;return{getParentIndex(e){return e<0||e>=s?-1:g[e]??-1},paths:n,posInSetByIndex:_,setSizeByIndex:v,get visibleIndexByPath(){if(y==null){y=new Map;for(let e=0;e<s;e+=1)y.set(n[e]??``,e)}return y}}}function qi(e,t){let n=Array(t),r=0,{nodes:i,directories:a,segmentTable:o}=e.snapshot,s=[[a.get(e.snapshot.rootId),0,-1]],c=o.valueById,l=e.snapshot.options.flattenEmptyDirectories,u=e.pathCacheByNodeId,d=e.pathCacheVersion;for(;s.length>0&&r<t;){let t=s[s.length-1],o=t[0];if(t[1]>=o.childIds.length){s.pop();continue}let f=o.childIds[t[1]++],p=i[f],m=t[2]+1;if(!z(p)){let t=u.get(f);n[r++]={depth:m,flattenedSegments:void 0,hasChildren:!1,id:f,isExpanded:!1,isFlattened:!1,isLoading:!1,kind:`file`,loadState:void 0,name:c[p.nameId],path:t!=null&&t.version===d?t.path:H(e,f)};continue}let h=l?Tr(e,f):f,g={headNodeId:f,terminalNodeId:h,visibleDepth:m};n[r++]=Ji(e,g);let _=i[h];_!=null&&z(_)&&Wn(e,h,_)&&s.push([a.get(h),0,m])}return r<t&&(n.length=r),n}function Ji(e,t){let n=W(e,t.terminalNodeId),r=z(n)?Yi(e,t):null,i=H(e,t.terminalNodeId),a=Sn(e.snapshot.segmentTable,n.nameId),o=z(n)&&U(e,t.terminalNodeId).childIds.length>0,s=t.headNodeId!==t.terminalNodeId,c=e.instrumentation,l=s?c==null?Er(e,t.headNodeId).map(n=>{let r=W(e,n);return{isTerminal:n===t.terminalNodeId,name:Sn(e.snapshot.segmentTable,r.nameId),nodeId:n,path:H(e,n)}}):V(c,`store.getVisibleSlice.flatten.collectSegments`,()=>Er(e,t.headNodeId).map(n=>{let r=W(e,n);return{isTerminal:n===t.terminalNodeId,name:Sn(e.snapshot.segmentTable,r.nameId),nodeId:n,path:H(e,n)}})):void 0;return{depth:t.visibleDepth,flattenedSegments:l,hasChildren:o,id:t.terminalNodeId,isExpanded:z(n)&&Wn(e,t.terminalNodeId,n),isFlattened:s,isLoading:r===`loading`,kind:z(n)?`directory`:`file`,loadState:r==null||r===`loaded`?void 0:r,name:a,path:i}}function Yi(e,t){if(t.headNodeId===t.terminalNodeId)return qn(e,t.terminalNodeId);let n=Er(e,t.headNodeId),r=!1,i=!1;for(let t of n){let n=qn(e,t);if(n===`loading`)return`loading`;if(n===`error`){i=!0;continue}n===`unloaded`&&(r=!0)}return i?`error`:r?`unloaded`:`loaded`}function Xi(e){let{directories:t,nodes:n,options:r,rootId:i,presortedDirectoryNodeIds:a}=e.snapshot,o=r.flattenEmptyDirectories===!0,s=e=>{let r=n[e];if(r==null||!z(r))return;let i=t.get(e);if(i==null)throw Error(`Unknown directory child index for node ${String(e)}`);let a=i.childIds,s=a.length,c=0,l=0;for(let e=0;e<s;e++){let t=a[e];if(t==null)continue;let r=n[t];c+=r.subtreeNodeCount,l+=r.visibleSubtreeCount}i.totalChildSubtreeNodeCount=c,i.totalChildVisibleSubtreeCount=l,s>=128&&Vt(n,i),r.subtreeNodeCount=1+c;let u;if(o&&s===1){let e=n[a[0]];u=e!=null&&z(e)?l:1+l}else u=1+l;r.visibleSubtreeCount=u};if(a!=null)for(let e=a.length-1;e>=0;e--)s(a[e]);else for(let e=n.length-1;e>=1;e--)s(e);let c=n[i],l=t.get(i);if(c==null||l==null)return;let u=l.childIds,d=0,f=0;for(let e=0;e<u.length;e++){let t=u[e];if(t==null)continue;let r=n[t];d+=r.subtreeNodeCount,f+=r.visibleSubtreeCount}l.totalChildSubtreeNodeCount=d,l.totalChildVisibleSubtreeCount=f,Vt(n,l),c.subtreeNodeCount=1+d,c.visibleSubtreeCount=f}function Zi(e){return e.initialExpansion===`open`&&(e.initialExpandedPaths==null||e.initialExpandedPaths.length===0)}var Qi=class e{#e;constructor(e={}){let t=en(e),n=V(t,`store.builder.create`,()=>new zn(e));if(e.preparedInput!=null){let t=In(e.preparedInput);t==null?n.appendPreparedPaths(Fn(e.preparedInput),!1):n.appendPresortedPaths(t,Ln(e.preparedInput))}else{let r=e.paths??[];e.presorted===!0?n.appendPaths(r):n.appendPreparedPaths(V(t,`store.preparePathEntries`,()=>Rn(r,e)))}let r=V(t,`store.builder.finish`,()=>n.finish({skipSubtreeCountPass:!0})),i=V(t,`store.state.detectAllDirectoriesExpanded`,()=>(e.initialExpansion??`closed`)===`closed`&&n.didMatchAllInitialExpandedPaths());this.#e=V(t,`store.state.create`,()=>Bn(r,i?`open`:e.initialExpansion??`closed`,t)),i&&(this.#e.collapseNewDirectoriesByDefault=!0);let a=i?this.#e.snapshot.directories.size-1:V(t,`store.state.initializeExpandedPaths`,()=>this.initializeExpandedPaths(e.initialExpandedPaths));i||Zi(e)||(e.initialExpansion??`closed`)===`closed`&&a===this.#e.snapshot.directories.size-1||(e.initialExpandedPaths?.length??0)>0&&V(t,`store.state.checkAllDirectoriesExpanded`,()=>this.hasAllDirectoriesExpanded())?V(t,`store.state.initializeOpenVisibleCounts`,()=>Xi(this.#e)):V(t,`store.state.recomputeCounts`,()=>Pr(this.#e,this.#e.snapshot.rootId))}static preparePaths(e,t={}){return Mn(e,t)}static prepareInput(e,t={}){return Nn(e,t)}static preparePresortedInput(e){return Pn(e)}list(e){return V(this.#e.instrumentation,`store.list`,()=>Dr(this.#e,e))}add(e){V(this.#e.instrumentation,`store.add`,()=>{let t=ki(this.#e);mr(this.#e,fr(this.#e,t,Or(this.#e,e)))})}remove(e,t={}){V(this.#e.instrumentation,`store.remove`,()=>{let n=ki(this.#e);mr(this.#e,fr(this.#e,n,kr(this.#e,e,t)))})}move(e,t,n={}){V(this.#e.instrumentation,`store.move`,()=>{let r=ki(this.#e),i=Ar(this.#e,e,t,n);i!=null&&mr(this.#e,fr(this.#e,r,i))})}batch(e){pr(this.#e,()=>{if(typeof e==`function`){e(this);return}for(let t of e)switch(t.type){case`add`:this.add(t.path);break;case`remove`:this.remove(t.path,{recursive:t.recursive});break;case`move`:this.move(t.from,t.to,{collision:t.collision});break}})}getVisibleCount(){return V(this.#e.instrumentation,`store.getVisibleCount`,()=>ki(this.#e))}getVisibleSlice(e,t){return V(this.#e.instrumentation,`store.getVisibleSlice`,()=>Fi(this.#e,e,t))}getVisibleRowContext(e){return V(this.#e.instrumentation,`store.getVisibleRowContext`,()=>Pi(this.#e,e))}getVisibleTreeProjection(){return Li(this.#e)}getVisibleTreeProjectionData(e){return Ii(this.#e,e)}getVisibleIndex(e){return V(this.#e.instrumentation,`store.getVisibleIndex`,()=>Ri(this.#e,e))}getPathInfo(e){return V(this.#e.instrumentation,`store.getPathInfo`,()=>{let t=Ir(this.#e,e);if(t==null)return null;let n=W(this.#e,t);return{depth:qt(n),kind:z(n)?`directory`:`file`,path:H(this.#e,t)}})}isExpanded(e){return V(this.#e.instrumentation,`store.isExpanded`,()=>{let t=this.requireDirectoryNodeId(e),n=W(this.#e,t);return Wn(this.#e,t,n)})}expand(e){V(this.#e.instrumentation,`store.expand`,()=>{let t=ki(this.#e),n=zi(this.#e,e);n!=null&&mr(this.#e,fr(this.#e,t,n))})}collapse(e){V(this.#e.instrumentation,`store.collapse`,()=>{let t=ki(this.#e),n=Bi(this.#e,e);n!=null&&mr(this.#e,fr(this.#e,t,n))})}on(e,t){return er(this.#e,e,t)}getDirectoryLoadState(e){let t=this.requireDirectoryNodeId(e);return qn(this.#e,t)}markDirectoryUnloaded(e){V(this.#e.instrumentation,`store.markDirectoryUnloaded`,()=>{let t=this.requireDirectoryNodeId(e);if(U(this.#e,t).childIds.length>0)throw Error(`Cannot mark a directory with known children as unloaded: "${e}"`);let n=ki(this.#e);Yn(this.#e,t),mr(this.#e,fr(this.#e,n,or({affectedAncestorIds:Fr(this.#e,t),affectedNodeIds:[t],path:e,projectionChanged:this.isDirectoryProjectionVisible(t)})))})}beginChildLoad(e){return V(this.#e.instrumentation,`store.beginChildLoad`,()=>{let t=this.requireDirectoryNodeId(e),n=ki(this.#e),r=Jn(this.#e,t);return mr(this.#e,fr(this.#e,n,sr({affectedAncestorIds:Fr(this.#e,t),affectedNodeIds:[t],attemptId:r.attemptId,path:e,projectionChanged:this.isDirectoryProjectionVisible(t),reused:r.reused}))),r})}applyChildPatch(e,t){return V(this.#e.instrumentation,`store.applyChildPatch`,()=>{let n=this.resolveActiveDirectoryNodeId(e.nodeId);if(n==null||qn(this.#e,n)!==`loading`||!Zn(this.#e,n,e.attemptId))return!1;let r=H(this.#e,n);this.validateChildPatch(r,t);let i=ki(this.#e),a=[];for(let e of t.operations){$i(r,e);let t=ki(this.#e);switch(e.type){case`add`:a.push(fr(this.#e,t,Or(this.#e,e.path)));break;case`remove`:a.push(fr(this.#e,t,kr(this.#e,e.path,{recursive:e.recursive})));break;case`move`:{let n=Ar(this.#e,e.from,e.to,{collision:e.collision});n!=null&&a.push(fr(this.#e,t,n));break}}}let o=a.some(e=>e.projectionChanged)||this.isDirectoryProjectionVisible(n);return mr(this.#e,fr(this.#e,i,cr({affectedAncestorIds:Fr(this.#e,n),affectedNodeIds:[n],attemptId:e.attemptId,childEvents:a,path:H(this.#e,n),projectionChanged:o}))),!0})}completeChildLoad(e){return V(this.#e.instrumentation,`store.completeChildLoad`,()=>{let t=this.resolveActiveDirectoryNodeId(e.nodeId);if(t==null)return!1;let n=ki(this.#e),r=Xn(this.#e,t,e.attemptId);return mr(this.#e,fr(this.#e,n,lr({affectedAncestorIds:Fr(this.#e,t),affectedNodeIds:[t],attemptId:e.attemptId,path:H(this.#e,t),projectionChanged:this.isDirectoryProjectionVisible(t),stale:!r}))),r})}failChildLoad(e,t){return V(this.#e.instrumentation,`store.failChildLoad`,()=>{let n=this.resolveActiveDirectoryNodeId(e.nodeId);if(n==null)return!1;let r=ki(this.#e),i=Qn(this.#e,n,e.attemptId,t);return mr(this.#e,fr(this.#e,r,ur({affectedAncestorIds:Fr(this.#e,n),affectedNodeIds:[n],attemptId:e.attemptId,errorMessage:t,path:H(this.#e,n),projectionChanged:this.isDirectoryProjectionVisible(n),stale:!i}))),i})}cleanup(e={}){return V(this.#e.instrumentation,`store.cleanup`,()=>{if(this.#e.transactionStack.length>0)throw Error(`Cleanup cannot run during an open batch or transaction.`);if(Ti(this.#e))throw Error(`Cleanup cannot run while directory loads are active.`);let t=ki(this.#e),n=Ei(this.#e,e.mode??`stable`);return mr(this.#e,fr(this.#e,t,dr({...n,affectedAncestorIds:[],affectedNodeIds:[],projectionChanged:n.idsPreserved===!1}))),n})}getNodeCount(){return this.#e.activeNodeCount}initializeExpandedPaths(e){if(e==null||e.length===0)return 0;let t=0,n=[],r=[],i=0,a=null,o=this.#e.snapshot.segmentTable,s=o.valueById,c=this.#e.snapshot.nodes,l=new Map;for(let u of e){a!=null&&u<a&&(a=null,i=0,n.length=0,r.length=0);let e=u.length>0&&u.charCodeAt(u.length-1)===47?u.length-1:u.length;if(e===0){a=u,i=e,n.length=0,r.length=0;continue}let d=0,f=0;if(a!=null){let t=Math.min(e,i),n=!0;for(let e=0;e<t;e+=1){let t=u.charCodeAt(e);if(t!==a.charCodeAt(e)){n=!1;break}t===47&&(d+=1,f=e+1)}n&&(t===i&&e>t&&u.charCodeAt(t)===47?(d+=1,f=t+1):t===e&&i>t&&a.charCodeAt(t)===47&&(d+=1,f=e+1)),d=Math.min(d,r.length)}let p=d===0?this.#e.snapshot.rootId:r[d-1]??this.#e.snapshot.rootId,m=d,h=!0,g=f;for(;g<=e;){let t=u.indexOf(`/`,g),i=t===-1||t>e?e:t,a=u.slice(g,i),f=U(this.#e,p).childIds,_=m===d?n[m]??0:0,v=_,y,b=l.get(a)??an(a);l.set(a,b);let x=(e,t)=>{for(v=e;v<t;v+=1){let e=f[v],t=c[e],n=s[t.nameId];if(n===a)return y=e,!0;let r=sn(mn(o,t.nameId),b);if(r>0||r===0&&n>a)return!1}return!1};if(!x(_,f.length)&&_>0&&x(0,_),y===void 0){h=!1;break}if(!z(W(this.#e,y))){h=!1;break}if(n[m]=v,r[m]=y,p=y,m+=1,i===e)break;g=i+1}if(a=u,i=e,n.length=m,r.length=m,!h){a=null,i=0,n.length=0,r.length=0;continue}for(let e=d;e<m;e+=1){let n=r[e];if(n==null)continue;let i=W(this.#e,n);Wn(this.#e,n,i)||(Gn(this.#e,n,!0,i),t+=1)}}return t}hasAllDirectoriesExpanded(){for(let e of this.#e.snapshot.directories.keys()){if(e===this.#e.snapshot.rootId)continue;let t=W(this.#e,e);if(!Wn(this.#e,e,t))return!1}return!0}requireDirectoryNodeId(e){let t=Ir(this.#e,e);if(t==null)throw Error(`Path does not exist: "${e}"`);if(!z(W(this.#e,t)))throw Error(`Path is not a directory: "${e}"`);return t}resolveActiveDirectoryNodeId(e){try{if(!z(W(this.#e,e)))throw Error(`Node is not a directory: ${String(e)}`);return e}catch{return null}}isDirectoryProjectionVisible(e){let t=e;for(;t!==this.#e.snapshot.rootId;){let e=W(this.#e,t).parentId;if(e!==this.#e.snapshot.rootId){let n=W(this.#e,e),r=wr(this.#e,e);if(!Wn(this.#e,e,n)&&r!==t)return!1}t=e}return!0}validateChildPatch(t,n){new e({paths:this.list(t),presorted:!0,sort:this.#e.snapshot.options.sort}).batch(n.operations)}};function $i(e,t){switch(t.type){case`add`:case`remove`:if(!t.path.startsWith(e)||t.path===e)throw Error(`Child patch operation must stay within ${e}: "${t.path}"`);break;case`move`:if(!t.from.startsWith(e)||!t.to.startsWith(e)||t.from===e||t.to===e)throw Error(`Child patch move must stay within ${e}: "${t.from}" -> "${t.to}"`);break}}var ea=e=>e.startsWith(`f::`)?e.slice(3):e;function ta(e){let t=e.lastIndexOf(`/`);return t<0?{parentPath:``,baseName:e}:{parentPath:e.slice(0,t),baseName:e.slice(t+1)}}function na(e,t){return e===``?t:`${e}/${t}`}function ra({files:e,path:t,isFolder:n,nextBasename:r}){let i=ea(t),a=r.trim();if(a.length===0)return{error:`Name cannot be empty.`};if(a.includes(`/`))return{error:`Name cannot include "/".`};let{parentPath:o,baseName:s}=ta(i);if(a===s)return{nextFiles:e,sourcePath:i,destinationPath:i,isFolder:n};let c=na(o,a),l=Array(e.length),u=new Set;if(!n){let t=`${c}/`,r=!1;for(let n=0;n<e.length;n++){let a=e[n];if(a!==i&&a.startsWith(t))return{error:`"${c}" already exists.`};let o=a===i?c:a;if(u.has(o))return{error:`"${c}" already exists.`};u.add(o),l[n]=o,a===i&&(r=!0)}return r?{nextFiles:l,sourcePath:i,destinationPath:c,isFolder:n}:{error:`Could not find the selected file to rename.`}}let d=`${i}/`,f=`${c}/`,p=0;for(let t=0;t<e.length;t++){let n=e[t],r=n===i||n.startsWith(d);if(!r&&(n===c||n.startsWith(f)))return{error:`"${c}" already exists.`};let a=r?`${c}${n.slice(i.length)}`:n;if(u.has(a))return{error:`"${c}" already exists.`};u.add(a),l[t]=a,r&&p++}return p===0?{error:`Could not find the selected folder to rename.`}:{nextFiles:l,sourcePath:i,destinationPath:c,isFolder:n}}function ia(e){return e.endsWith(`/`)}function aa(e){let t=e.endsWith(`/`)?e.slice(0,-1):e,n=t.lastIndexOf(`/`),r=n<0?t:t.slice(n+1);return e.endsWith(`/`)?`${r}/`:r}function oa(e){let t=[],n=new Set;for(let r of e)n.has(r)||(n.add(r),t.push(r));let r=new Set;for(let e of t.toSorted((e,t)=>e.length===t.length?e.localeCompare(t):e.length-t.length)){let t=(e.endsWith(`/`)?e.slice(0,-1):e).split(`/`),n=!1;for(let e=0;e<t.length-1;e+=1){let i=`${t.slice(0,e+1).join(`/`)}/`;if(r.has(i)){n=!0;break}}n||r.add(e)}return t.filter(e=>r.has(e))}function sa(e,t){return t.includes(e)?oa(t):[e]}function ca(e,t){return e===t?!0:e==null||t==null?!1:e.kind===t.kind&&e.directoryPath===t.directoryPath&&e.flattenedSegmentPath===t.flattenedSegmentPath&&e.hoveredPath===t.hoveredPath}function la(e,t){return{draggedPaths:e,target:t}}function ua(e,t){if(t.kind!==`directory`||t.directoryPath==null)return!1;for(let n of e)if(ia(n)&&(t.directoryPath===n||t.directoryPath.startsWith(n)))return!0;return!1}function da(e,t){return t.kind===`root`||t.directoryPath==null?aa(e):t.directoryPath}function fa(e,t){let n=e.map(e=>{let n=da(e,t);return n===e?null:{from:e,to:n,type:`move`}}).filter(e=>e!=null);return n.length===0?null:{operations:n,result:{draggedPaths:e,operation:n.length===1?`move`:`batch`,target:t}}}function pa(e,t){if(e===t)return!0;if(e.length!==t.length)return!1;for(let n=0;n<e.length;n+=1)if(e[n]!==t[n])return!1;return!0}function ma(e,t,n){let{paths:r,preparedInput:i}=e;if(i==null){if(r==null)throw Error(`FileTree requires paths or preparedInput`);return{paths:r,preparedInput:void 0}}let a=i.paths;if(r==null)return{paths:a,preparedInput:i};if(!pa(Qi.preparePaths(r,n==null?{}:{sort:n}),a))throw Error(`FileTree ${t} received paths and preparedInput for different path lists`);return{paths:a,preparedInput:i}}function ha(e){return e.operation===`add`||e.operation===`remove`||e.operation===`move`||e.operation===`batch`}function ga(e,t,n){if(e===t)return n;let r=t.endsWith(`/`)?t:`${t}/`;return e.startsWith(r)?`${n.endsWith(`/`)?n:`${n}/`}${e.slice(r.length)}`:e}function _a(e,t){if(e===t)return!0;let n=t.endsWith(`/`)?t:`${t}/`;return e.startsWith(n)}function va(e,t,n=!1){if(e==null)return null;switch(t.operation){case`add`:case`expand`:case`collapse`:case`mark-directory-unloaded`:case`begin-child-load`:case`apply-child-patch`:case`complete-child-load`:case`fail-child-load`:case`cleanup`:return e;case`remove`:return _a(e,t.path)?n?e:null:e;case`move`:return ga(e,t.from,t.to);case`batch`:{let r=e;for(let e of t.events)if(r=va(r,e,n),r==null)return null;return r}}}function ya(e){return{canonicalChanged:e.canonicalChanged,projectionChanged:e.projectionChanged,visibleCountDelta:e.visibleCountDelta}}function ba(e){switch(e.operation){case`add`:return{...ya(e),operation:`add`,path:e.path};case`remove`:return{...ya(e),operation:`remove`,path:e.path,recursive:e.recursive};case`move`:return{...ya(e),from:e.from,operation:`move`,to:e.to}}}function xa(e){return{...ya(e),events:e.events.filter(e=>e.operation===`add`||e.operation===`remove`||e.operation===`move`).map(e=>ba(e)),operation:`batch`}}function Sa(e){switch(e.operation){case`add`:case`remove`:case`move`:return ba(e);case`batch`:return xa(e);default:return null}}function Ca(e,t){if(e.size!==t.length)return!1;for(let n of t)if(!e.has(n))return!1;return!0}function wa(e){let t=e.endsWith(`/`)?e.slice(0,-1):e;if(t.length===0)return[];let n=t.split(`/`);return n.slice(0,-1).map((e,t)=>`${n.slice(0,t+1).join(`/`)}/`)}function Ta(e){return wa(e).at(-1)??null}function Ea(e,t){return t==null?e:e.startsWith(t)?e.slice(t.length):e}function Da(e){return e.endsWith(`/`)}var Oa=e=>e.toLowerCase();function ka(e){let t=e.endsWith(`/`)?e.slice(0,-1):e,n=t.lastIndexOf(`/`);return n<0?t:t.slice(n+1)}function Aa(e){return e.endsWith(`/`)?e.slice(0,-1):e}function ja(e,t){return t&&!e.endsWith(`/`)?`${e}/`:e}var Ma=e=>{let t=e.trim();return t.length===0?``:(t.includes(`\\`)?t.replaceAll(`\\`,`/`):t).toLowerCase()},Na=Symbol(`FILE_TREE_RENAME_VIEW`),Pa=512,Fa=512;function Ia(e){return e===`top`||e===`center`?e:`nearest`}function La(e,t,n){if(e===0)return-1;if(n!=null){let e=t(n);if(e!=null)return e;let r=wa(n);for(let e=r.length-1;e>=0;--e){let n=r[e];if(n==null)continue;let i=t(n);if(i!=null)return i}}return 0}function Ra(e,t,n){if(e.paths.length===0)return{focusedIndex:-1,getParentIndex:e.getParentIndex,paths:e.paths,posInSetByIndex:e.posInSetByIndex,setSizeByIndex:e.setSizeByIndex};if(t==null)return{focusedIndex:0,getParentIndex:e.getParentIndex,paths:e.paths,posInSetByIndex:e.posInSetByIndex,setSizeByIndex:e.setSizeByIndex};let r=n??(t=>e.visibleIndexByPath.get(t)??null);return{focusedIndex:La(e.paths.length,r,t),getParentIndex:e.getParentIndex,paths:e.paths,posInSetByIndex:e.posInSetByIndex,setSizeByIndex:e.setSizeByIndex}}var za=class{#e;#t=new Set;#n=new Map;#r=null;#i=null;#a=new Map;#o=new Map;#s=-1;#c=null;#l=!1;#u=e=>-1;#d=new Map;#f=null;#p=null;#m=null;#h=null;#g=null;#_;#v;#y;#b=[];#x=new Int32Array;#S=new Int32Array;#C=void 0;#w=!1;#T=null;#E=``;#D=!1;#O=new Set;#k=[];#A;#j=null;#M=null;#N=null;#P=null;#F=null;#I=null;#L=null;#R=0;#z=null;#B=new Set;#V=0;#H;#U=0;#W=!1;#G=0;#K;constructor(e){let{dragAndDrop:t,fileTreeSearchMode:n,initialSearchQuery:r,initialSelectedPaths:i,renaming:a,onSearchChange:o,paths:s,preparedInput:c,...l}=e,u=ma({paths:s,preparedInput:c},`constructor`,l.sort);this.#e=l,t!=null&&t!==!1&&(this.#r=t===!0?{}:t),this.#w=a!=null&&a!==!1,a!=null&&a!==!1&&a!==!0&&(this.#C=a.canRename,this.#v=a.onError,this.#_=a.onRename),this.#y=o,this.#A=n??`hide-non-matches`,this.#H=this.#le(u.paths,u.preparedInput);let d=i?.map(e=>this.#Ne(e)).filter(e=>e!=null)??[],f=d.at(-1)??null;d.length>0&&(this.#B=new Set(d),this.#z=f,this.#V=1),this.#je(f,!1),r!=null&&this.#Te(r,!1),this.#K=this.#Re()}destroy(){this.#K?.(),this.#K=null,this.#n.clear(),this.#t.clear(),this.#d.clear(),this.#i=null,this.#he()}focusFirstItem(){this.#be().length>0&&this.#Fe(0)}focusLastItem(){this.#G<=0||(this.#Ie(),this.#Fe(this.#G-1))}focusNextItem(){this.#Ae(1)}focusParentItem(){if(this.#c==null)return;let e=Ta(this.#c);if(e==null)return;let t=this.#Z(e);t>=0&&this.#Fe(t)}focusPath(e){let t=this.#H.getPathInfo(e)?.path??null;if(t==null)return;this.#Ie();let n=this.#Z(t);n>=0&&this.#Fe(n)}scrollToPath(e,t){let n=this.#H.getPathInfo(e)?.path??null;if(n==null)return;this.#Ie();let r=this.#xe(n);r<0||this.#Me(r)!=null&&(t?.focus!==!1&&this.#Fe(r,!1),this.#L={id:this.#R+=1,offset:Ia(t?.offset),visibleIndex:r},this.#De())}focusMountedPathFromInput(e){let t=this.#H.getPathInfo(e)?.path??null;if(t==null)return;let n=this.#Z(t);n>=0&&this.#Fe(n)}focusNearestPath(e){let t=this.resolveNearestVisiblePath(e);if(t==null)return null;let n=this.#Z(t);return n>=0?(this.#Fe(n),this.#be()[n]??t):null}focusPreviousItem(){this.#Ae(-1)}getFocusedIndex(){return this.#s}getFocusedItem(){return this.#c==null?null:this.#Q(this.#c)}getFocusedPath(){return this.#c}getScrollRequest(){return this.#L}clearScrollRequest(e){this.#L?.id===e&&(this.#L=null)}resolveNearestVisiblePath(e){let t=this.#be();if(this.#G===0)return null;if(e==null)return this.#c??t[0]??null;let n=this.#H.getPathInfo(e)?.path??e,r=this.#Z(n);return r>=0?t[r]??n:this.#X(n)??this.#c??t[0]??null}getSelectedPaths(){return[...this.#B]}getSelectionVersion(){return this.#V}getVisibleCount(){return this.#G}getVisibleRows(e,t){if(t<e||this.#G===0)return[];let n=Math.max(0,e),r=Math.min(this.#G-1,t);if(r<n)return[];let i=r-n+1;if(this.#F==null&&!this.#l&&r>=this.#b.length&&i<=Fa){let e=[];for(let t=n;t<=r;t+=1){let n=this.#H.getVisibleRowContext(t);if(n==null)break;e.push(this.#ee(n))}return e}if(!this.#l&&r>=this.#b.length&&this.#Ie(),this.#F!=null){let e=Array.from({length:r-n+1},(e,t)=>this.#Se(n+t)),t=new Map,i=e[0]??-1,a=i;for(let n=1;n<=e.length;n+=1){let r=e[n];if(r!=null&&r===a+1){a=r;continue}if(i>=0&&this.#H.getVisibleSlice(i,a).forEach((e,n)=>{t.set(i+n,e)}),r==null){i=-1,a=-1;continue}i=r,a=r}return Array.from({length:r-n+1},(e,r)=>{let i=n+r,a=this.#Se(i),o=t.get(a),s=this.#b[a];if(o==null||s==null)throw Error(`Missing projection row for filtered visible index ${String(i)}`);return this.#$(o,i,a,{ancestorPaths:this.#re(a),path:s})})}return this.#H.getVisibleSlice(n,r).map((e,t)=>{let r=n+t,i=this.#b[r];if(i==null)throw Error(`Missing projection path for visible index ${String(r)}`);return this.#$(e,r,r,{ancestorPaths:this.#re(r),path:i})})}getStickyRowCandidates(e,t){if(this.#F!=null)return null;if(this.#G===0||e<=0||t<=0)return[];let n=[];for(let r=0;r<this.#G;r+=1){let i=e+r*t,a=Math.min(this.#G-1,Math.floor(i/t)),o=this.#te(a,r)??(a>0?this.#te(a-1,r):void 0);if(o==null)break;n.push({row:this.#ee(o),subtreeEndIndex:o.subtreeEndIndex})}return n}getItem(e){let t=this.#H.getPathInfo(e);return t==null?null:this.#Q(t.path,t)}resolveMountedDirectoryPathFromInput(e){let t=this.#H.getPathInfo(e);return t?.kind===`directory`?t.path:null}toggleMountedDirectoryFromInput(e){let t=this.resolveMountedDirectoryPathFromInput(e);t!=null&&this.#ze(t)}selectAllVisiblePaths(){this.#Ie();let e=[...this.#be()];this.#ae(e,this.#c??this.#z)}selectOnlyPath(e){let t=this.#Ne(e);t!=null&&this.#ae([t],t)}selectOnlyMountedPathFromInput(e){this.#ae([e],e)}selectPath(e){let t=this.#Ne(e);t==null||this.#B.has(t)||this.#ae([...this.#B,t])}deselectPath(e){let t=this.#Ne(e);t==null||!this.#B.has(t)||this.#ae([...this.#B].filter(e=>e!==t))}toggleFocusedSelection(){this.#c!=null&&this.togglePathSelectionFromInput(this.#c)}togglePathSelection(e){let t=this.#Ne(e);if(t!=null){if(this.#B.has(t)){this.deselectPath(t);return}this.selectPath(t)}}togglePathSelectionFromInput(e){let t=this.#Ne(e);if(t!=null){if(this.#B.has(t)){this.#ae([...this.#B].filter(e=>e!==t),t);return}this.#ae([...this.#B,t],t)}}selectPathRange(e,t){let n=this.#Ne(e);if(n==null)return;this.#Ie();let r=this.#z,i=r==null?-1:this.#Ce(r),a=this.#Ce(n);if(i===-1||a===-1){let e=t?[...this.#B,n]:[n];this.#ae(e,n);return}let[o,s]=i<=a?[i,a]:[a,i],c=this.#be().slice(o,s+1),l=t?[...this.#B,...c]:c;this.#ae(l,r)}extendSelectionFromFocused(e){if(this.#c==null)return;let t=this.#s;if(t===-1)return;let n=Math.min(this.#G-1,Math.max(0,t+e));if(n===t)return;!this.#l&&n>=this.#b.length&&this.#Ie();let r=this.#be(),i=r[t]??null,a=r[n]??null;if(i==null||a==null)return;let o=new Set(this.#B);o.has(i)&&o.has(a)?o.delete(i):o.add(a),this.#ae([...o],this.#z??i,!1),this.#Fe(n)}getDragAndDropConfig(){return this.#r}isDragAndDropEnabled(){return this.#r!=null}getDragSession(){return this.#i==null?null:{draggedPaths:[...this.#i.draggedPaths],primaryPath:this.#i.primaryPath,target:this.#i.target==null?null:{...this.#i.target}}}startDrag(e){if(this.#r==null)return!1;let t=this.#Ne(e);if(t==null||this.#M!=null&&this.#M.length>0)return!1;let n=this.getSelectedPaths(),r=sa(t,n);return this.#r.canDrag?.(r)===!1?!1:(n.includes(t)||this.#ae([t],t,!1),this.#Pe(t),this.#i={draggedPaths:r,primaryPath:t,target:null},this.#De(),!0)}setDragTarget(e){let t=this.#i;if(t==null)return;let n=e;if(n!=null){let e=la(t.draggedPaths,n);(ua(t.draggedPaths,n)||this.#r?.canDrop?.(e)===!1)&&(n=null)}ca(t.target,n)||(this.#i={...t,target:n},this.#De())}cancelDrag(){this.#i!=null&&(this.#i=null,this.#De())}completeDrag(){let e=this.#i;if(e==null)return!1;this.#i=null;let t=e.target==null?null:{...e.target};if(t==null)return this.#De(),!1;let n=la(e.draggedPaths,t);if(ua(e.draggedPaths,t)||this.#r?.canDrop?.(n)===!1)return this.#De(),!1;let r=fa(e.draggedPaths,t);if(r==null)return this.#De(),!1;try{if(r.operations.length===1){let e=r.operations[0];if(e==null||e.type!==`move`)throw Error(`Expected a single move operation for one-item drops`);this.#H.move(e.from,e.to,{collision:e.collision})}else this.#ce(r.operations),this.#H.batch(r.operations)}catch(e){return this.#De(),this.#r?.onDropError?.(e instanceof Error?e.message:String(e),n),!1}return this.#r?.onDropComplete?.(r.result),!0}subscribe(e){return this.#t.add(e),e(),()=>{this.#t.delete(e)}}add(e){this.#H.add(e)}remove(e,t={}){this.#H.remove(e,t)}move(e,t,n={}){this.#H.move(e,t,n)}batch(e){this.#H.batch(e)}onMutation(e,t){let n=e,r=t,i=this.#n.get(n);return i??(i=new Set,this.#n.set(n,i)),i.add(r),()=>{let e=this.#n.get(n);e?.delete(r),e?.size===0&&this.#n.delete(n)}}setSearch(e){this.#Te(e,!0)}openSearch(e=``){this.#Te(e,!0)}closeSearch(){this.#Te(null,!0)}isSearchOpen(){return this.#M!==null}getSearchValue(){return this.#M??``}getSearchMatchingPaths(){return this.#k}focusNextSearchMatch(){this.#we(1)}focusPreviousSearchMatch(){this.#we(-1)}startRenaming(e=this.#c??``,t={}){if(!this.#w)return!1;let n=this.#H.getPathInfo(e);if(n==null)return!1;let r=n.path,i=Da(r),a=Aa(r);if(this.#C?.({isFolder:i,path:a})===!1)return!1;for(let e of wa(r))this.#H.isExpanded(e)||this.#H.expand(e);return this.#ae([r],r,!1),this.#M!=null&&(this.#Te(null,!1),this.#y?.(this.#M)),this.#Pe(r),this.#T=r,this.#E=ka(r),this.#D=t.removeIfCanceled??!1,this.#De(),!0}[Na](){return{cancel:()=>{this.#q()},commit:()=>{this.#J()},getPath:()=>this.#T,getValue:()=>this.#E,isActive:()=>this.#T!=null,setValue:e=>{this.#Y(e)}}}#q(){if(this.#T==null)return;let e=this.#T,t=this.#D;if(this.#T=null,this.#E=``,this.#D=!1,t){this.remove(e,Da(e)?{recursive:!0}:void 0);return}this.#Pe(e),this.#De()}#J(){let e=this.#T;if(e==null)return;if(this.#D&&this.#E.trim().length===0){this.#T=null,this.#E=``,this.#D=!1,this.remove(e,Da(e)?{recursive:!0}:void 0);return}let t=Da(e),n=ra({files:this.#H.list(),isFolder:t,nextBasename:this.#E,path:Aa(e)});if(this.#T=null,this.#E=``,this.#D=!1,`error`in n){this.#Pe(e),this.#v?.(n.error),this.#De();return}if(n.sourcePath===n.destinationPath){this.#Pe(e),this.#De();return}this.#_?.({destinationPath:n.destinationPath,isFolder:n.isFolder,sourcePath:n.sourcePath}),this.move(ja(n.sourcePath,t),ja(n.destinationPath,t))}#Y(e){this.#T==null||this.#E===e||(this.#E=e,this.#De())}resetPaths(e,t={}){let n=this.#H.list().length,r=this.#G,i=ma({paths:e,preparedInput:t.preparedInput},`resetPaths`,this.#e.sort),a=this.#le(i.paths,i.preparedInput,t.initialExpandedPaths),o=this.#c,s=this.#T,c=this.getSelectedPaths(),l=this.#z;this.#K?.(),this.#H=a,this.#d.clear(),this.#he();let u=c.map(e=>a.getPathInfo(e)?.path??null).filter(e=>e!=null),d=!Ca(this.#B,u);this.#B=new Set(u),d&&(this.#V+=1),this.#z=l==null?null:a.getPathInfo(l)?.path??null,this.#T=s==null?null:a.getPathInfo(s)?.path??null,this.#T??(this.#E=``,this.#D=!1),this.#je(o,o!=null||u.length>0||this.#z!=null),this.#K=this.#Re(),this.#De(),this.#Oe({canonicalChanged:!0,operation:`reset`,pathCountAfter:i.paths.length,pathCountBefore:n,projectionChanged:!0,usedPreparedInput:t.preparedInput!=null,visibleCountDelta:this.#G-r})}#X(e){this.#Ie();let t=Ta(e),n=Ea(e,t),r=null,i=null;for(let e of this.#be()){if(Ta(e)!==t)continue;let a=Ea(e,t);if(a<n){r=e;continue}if(a>n){i=e;break}}return r??i}#Z(e){let t=this.#Ce(e);if(t!==-1)return t;let n=wa(e);for(let e=n.length-1;e>=0;--e){let t=n[e];if(t==null)continue;let r=this.#Ce(t);if(r!==-1)return r}return this.#be().length>0?0:-1}#Q(e,t){let n=this.#d.get(e);if(n!=null)return n;let r=t??this.#H.getPathInfo(e);if(r==null)return null;let i=r.kind===`directory`?this.#oe(r.path):this.#se(r.path);return this.#d.set(r.path,i),i}#$(e,t,n,r){return{ancestorPaths:r.ancestorPaths,depth:e.depth,flattenedSegments:e.flattenedSegments?.map(e=>({isTerminal:e.isTerminal,name:e.name,path:e.path})),hasChildren:e.hasChildren,index:t,isExpanded:e.isExpanded,isFlattened:e.isFlattened,isFocused:r.path===this.#c,isSelected:this.#B.has(r.path),kind:e.kind,level:e.depth,name:e.name,path:r.path,posInSet:r.posInSet??this.#x[n]??0,setSize:r.setSize??this.#S[n]??0}}#ee(e){return this.#$(e.row,e.index,e.index,{ancestorPaths:e.ancestorPaths,path:e.row.path,posInSet:e.posInSet,setSize:e.setSize})}#te(e,t){let n=this.#H.getVisibleRowContext(e);return n==null?void 0:n.ancestorRows[t]??(t===n.ancestorRows.length&&n.row.kind===`directory`&&n.row.isExpanded?n:void 0)}#ne(e){let t=this.#a.get(e);if(t!=null)return t;let n=this.#u(e),r=n<0?[]:[...this.#ne(n),n];return this.#a.set(e,r),r}#re(e){let t=this.#o.get(e);if(t!=null)return t;let n=this.#ne(e).map(e=>this.#b[e]??``).filter(e=>e!==``);return this.#o.set(e,n),n}#ie(e){this.#H.collapse(e)}#ae(e,t=this.#z,n=!0){let r=[...new Set(e)],i=!Ca(this.#B,r),a=this.#z!==t;!i&&!a||(this.#B=new Set(r),this.#z=t,i&&(this.#V+=1),n&&this.#De())}#oe(e){return{collapse:()=>{this.#ie(e)},deselect:()=>{this.deselectPath(e)},expand:()=>{this.#ke(e)},focus:()=>{this.focusPath(e)},getPath:()=>e,isDirectory:()=>!0,isExpanded:()=>this.#H.isExpanded(e),isFocused:()=>this.#c===e,isSelected:()=>this.#B.has(e),select:()=>{this.selectPath(e)},toggleSelect:()=>{this.togglePathSelection(e)},toggle:()=>{this.#ze(e)}}}#se(e){return{deselect:()=>{this.deselectPath(e)},focus:()=>{this.focusPath(e)},getPath:()=>e,isDirectory:()=>!1,isFocused:()=>this.#c===e,isSelected:()=>this.#B.has(e),select:()=>{this.selectPath(e)},toggleSelect:()=>{this.togglePathSelection(e)}}}#ce(e){let t=this.#H.list();this.#le(t).batch(e)}#le(e,t,n){return new Qi({...this.#e,paths:e,preparedInput:t??void 0,...n===void 0?{}:{initialExpandedPaths:n}})}#ue(){return this.#h??=this.#H.list(),this.#h}#de(){if(this.#m!=null)return this.#m;let e=new Set;for(let t of this.#ue()){e.add(t);for(let n of wa(t))e.add(n)}return this.#m=[...e].sort(),this.#m}#fe(){return this.#g??=this.#ue().map(Oa),this.#g}#pe(){return this.#f??=this.#de().filter(e=>e.endsWith(`/`)),this.#f}#me(){return this.#p??=this.#pe().map(Oa),this.#p}#he(){this.#f=null,this.#p=null,this.#m=null,this.#h=null,this.#g=null}#ge(){return this.#pe().filter(e=>this.#H.isExpanded(e))}#_e(e){let t=new Set(this.#j??[]);if(e)for(let e of this.#B)for(let n of wa(e))t.add(n);this.#ve(t)}#ve(e){this.#W=!0;try{for(let t of this.#pe()){let n=e.has(t),r=this.#H.isExpanded(t);n&&!r?this.#H.expand(t):!n&&r&&this.#H.collapse(t)}}finally{this.#W=!1}}#ye(){if(this.#M==null||this.#M.length===0){this.#k=[],this.#F=null,this.#I=null,this.#P=null,this.#G=this.#U;return}let e=this.#b;if(this.#k=e.filter(e=>this.#O.has(e)),this.#A!==`hide-non-matches`||this.#O.size===0){this.#F=null,this.#I=null,this.#P=null,this.#G=this.#U;return}let t=[],n=[],r=new Map;for(let[i,a]of e.entries())this.#N?.has(a)===!0&&(r.set(a,n.length),t.push(i),n.push(a));this.#F=t,this.#I=n,this.#P=r,this.#G=n.length}#be(){return this.#I??this.#b}#xe(e){return this.#I==null?this.#H.getVisibleIndex(e)??-1:this.#P?.get(e)??-1}#Se(e){return this.#F?.[e]??e}#Ce(e){return this.#P?.get(e)??this.#H.getVisibleIndex(e)??-1}#we(e){let t=this.#k;if(t.length===0)return;let n=this.#c,r=n==null?-1:t.indexOf(n),i=t[r<0?e>0?0:t.length-1:Math.min(t.length-1,Math.max(0,r+e))];i!=null&&this.focusPath(i)}#Te(e,t){let n=e==null?null:Ma(e),r=this.#M;if(r!==n){if(r==null&&n!=null&&(this.#j=this.#ge()),this.#M=n,n==null)this.#_e(!0),this.#j=null,this.#O.clear(),this.#N=null,this.#je(this.#c,!0);else if(n.length===0)this.#_e(!1),this.#O.clear(),this.#N=null,this.#je(this.#c,!0);else{let e=this.#Ee();this.#je(e,!0)}t&&(this.#y?.(this.#M),this.#De())}}#Ee(){if(this.#M==null||this.#M.length===0)return this.#O.clear(),this.#c;let e=this.#M,t=this.#ue(),n=this.#fe(),r=[],i=new Set,a=null;for(let o=0;o<t.length;o+=1){if(!n[o].includes(e))continue;let s=t[o];r.push(s),i.add(s),a??=s}let o=this.#pe(),s=this.#me();for(let t=0;t<o.length;t+=1){if(!s[t].includes(e))continue;let n=o[t];i.has(n)||(r.push(n),i.add(n),a??=n)}this.#O=i;let c=this.#A===`hide-non-matches`&&r.length>0?new Set:null;this.#N=c;let l=this.#A===`expand-matches`?new Set(this.#j??[]):new Set;for(let e of r){c?.add(e),e.endsWith(`/`)&&l.add(e);for(let t of wa(e))l.add(t),c?.add(t)}return this.#ve(l),a??this.#c}#De(){for(let e of this.#t)e()}#Oe(e){this.#n.get(e.operation)?.forEach(t=>{t(e)}),this.#n.get(`*`)?.forEach(t=>{t(e)})}#ke(e){for(let t of wa(e))this.#H.isExpanded(t)||this.#H.expand(t);this.#H.isExpanded(e)||this.#H.expand(e)}#Ae(e){let t=this.#G;if(t===0)return;let n=this.#s===-1?0:this.#s,r=Math.min(t-1,Math.max(0,n+e));(r!==n||this.#s===-1)&&(!this.#l&&this.#F==null&&r>=this.#b.length&&this.#Ie(),this.#Fe(r))}#je(e,t=!0){let n=this.#H.getVisibleCount();this.#U=n;let r=Ra(this.#H.getVisibleTreeProjectionData(t?void 0:Math.min(n,Pa)),e,t?e=>this.#H.getVisibleIndex(e):void 0);this.#a.clear(),this.#o.clear(),this.#l=r.paths.length>=n,this.#u=r.getParentIndex,this.#b=r.paths,this.#x=r.posInSetByIndex,this.#S=r.setSizeByIndex,this.#ye(),this.#s=e==null?this.#be().length>0?0:-1:this.#Z(e),this.#c=this.#s<0?null:this.#Me(this.#s)}#Me(e){return this.#be()[e]??(this.#F==null?this.#H.getVisibleRowContext(e)?.row.path??null:null)}#Ne(e){return this.#H.getPathInfo(e)?.path??null}#Pe(e){if(e==null)return;let t=this.#Z(e);t>=0&&this.#Fe(t,!1)}#Fe(e,t=!0){let n=this.#Me(e);n!=null&&(this.#s===e&&this.#c===n||(this.#s=e,this.#c=n,t&&this.#De()))}#Ie(){this.#l||this.#je(this.#c,!0)}#Le(e){let t=va(this.#T,e);t==null&&this.#T!=null&&(this.#E=``),this.#T=t;let n=va(this.#c,e,!0),r=[...this.#B].map(t=>va(t,e)).filter(e=>e!=null).map(e=>this.#H.getPathInfo(e)?.path??null).filter(e=>e!=null),i=va(this.#z,e),a=i==null?null:this.#H.getPathInfo(i)?.path??null,o=[...new Set(r)];return Ca(this.#B,o)||(this.#B=new Set(o),this.#V+=1),this.#z=a,n}#Re(){return this.#H.on(`*`,e=>{if(this.#W)return;e.canonicalChanged&&(this.#d.clear(),this.#he()),this.#i!=null&&ha(e)&&(this.#i=null);let t=ha(e)?this.#Le(e):this.#c,n=this.#M!=null&&this.#M.length>0?this.#Ee():this.#M===``?this.#c:t,r=this.#M!=null||e.operation!==`expand`&&e.operation!==`collapse`;this.#je(n,r),this.#De();let i=Sa(e);i!=null&&this.#Oe(i)})}#ze(e){if(this.#H.isExpanded(e)){this.#ie(e);return}this.#ke(e)}},Ba=e=>{if(e==null||e.length===0)return`0`;let t=`${e.length}`;for(let n of e)t+=`\0${n.path}\0${n.status}`;return t};function Va(e){let t=e.endsWith(`/`),n=``,r=-1;for(let t=0;t<=e.length;t+=1){if(!(e[t]===`/`||t===e.length)){r===-1&&(r=t);continue}r!==-1&&(n!==``&&(n+=`/`),n+=e.slice(r,t),r=-1)}return n===``?null:{isDirectory:t,path:n}}function Ha(e){let t=e.endsWith(`/`)?e.slice(0,-1):e;if(t.length===0)return[];let n=t.split(`/`);return n.slice(0,-1).map((e,t)=>`${n.slice(0,t+1).join(`/`)}/`)}function Ua(e,t){return t?`${e}/`:e}function Wa(e,t=null){let n=Ba(e==null?void 0:[...e]);if(n===`0`)return null;if(t?.signature===n)return t;let r=new Map,i=new Set,a=new Set;for(let t of e??[]){let e=Va(t.path);if(e==null)continue;let n=Ua(e.path,e.isDirectory);r.set(n,t.status),t.status===`ignored`&&e.isDirectory?a.add(n):e.isDirectory&&a.delete(n);for(let t of Ha(e.path))i.add(t)}return{directoriesWithChanges:i,ignoredDirectoryPaths:a,signature:n,statusByPath:r}}var Ga=e=>e.trim().toLowerCase(),Ka=e=>e.split(`/`).at(-1)??e,qa=e=>{let t=e.toLowerCase().split(`.`),n=[];for(let e=1;e<t.length;e+=1)n.push(t.slice(e).join(`.`));return n};function Ja(e,t){return typeof e==`string`?{name:e,remappedFrom:t}:{...e,remappedFrom:t}}function Ya(e){let t=pt(e),n=t.remap,r=new Map;for(let[e,n]of Object.entries(t.byFileName??{}))r.set(e.toLowerCase(),n);let i=new Map;for(let[e,n]of Object.entries(t.byFileExtension??{}))i.set(Ga(e),n);let a=Object.entries(t.byFileNameContains??{}).map(([e,t])=>[e.toLowerCase(),t]);return{resolveIcon:(e,o)=>{if(e===`file-tree-icon-file`&&o!=null){let n=Ka(o),s=n.toLowerCase(),c=r.get(s);if(c!=null)return Ja(c,e);for(let[t,n]of a)if(s.includes(t))return Ja(n,e);let l=qa(n);for(let t of l){let n=i.get(t);if(n!=null)return Ja(n,e)}let u=dt(t.set,n,l);if(u!=null&&t.set!==`none`)return{name:I(u),remappedFrom:e,token:u}}let s=n?.[e];return s==null?{name:e}:Ja(s,e)}}}var q,Xa,Za,Qa,$a,eo,to,no,ro,io,ao={},oo=[],so=Array.isArray,co=oo.slice,lo=Object.assign;function uo(e){e&&e.parentNode&&e.remove()}function fo(e,t,n){var r,i,a,o={};for(a in t)a==`key`?r=t[a]:a==`ref`&&typeof e!=`function`?i=t[a]:o[a]=t[a];return arguments.length>2&&(o.children=arguments.length>3?co.call(arguments,2):n),po(e,o,r,i,null)}function po(e,t,n,r,i){var a={type:e,props:t,key:n,ref:r,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:i??++Xa,__i:-1,__u:0};return i==null&&q.vnode!=null&&q.vnode(a),a}function mo(e){return e.children}function ho(e,t){this.props=e,this.context=t,this.__g=0}function go(e,t){if(t==null)return e.__?go(e.__,e.__i+1):null;for(var n;t<e.__k.length;t++)if((n=e.__k[t])!=null&&n.__e!=null)return n.__e;return typeof e.type==`function`?go(e):null}function _o(e){var t,n;if((e=e.__)!=null&&e.__c!=null){for(e.__e=null,t=0;t<e.__k.length;t++)if((n=e.__k[t])!=null&&n.__e!=null){e.__e=n.__e;break}return _o(e)}}function vo(e){(8&e.__g||!(e.__g|=8)||!Za.push(e)||$a++)&&Qa==q.debounceRendering||((Qa=q.debounceRendering)||queueMicrotask)(yo)}function yo(){for(var e,t,n,r,i,a,o,s,c=1;Za.length;)Za.length>c&&Za.sort(eo),e=Za.shift(),c=Za.length,8&e.__g&&(n=void 0,i=(r=(t=e).__v).__e,a=[],o=[],(s=t.__P)&&((n=lo({},r)).__v=r.__v+1,q.vnode&&q.vnode(n),Do(s,n,r,t.__n,s.namespaceURI,32&r.__u?[i]:null,a,i??go(r),!!(32&r.__u),o,s.ownerDocument),n.__v=r.__v,n.__.__k[n.__i]=n,ko(a,n,o),n.__e!=i&&_o(n)));$a=0}function bo(e,t,n,r,i,a,o,s,c,l,u,d){var f,p,m,h,g,_,v,y=r&&r.__k||oo,b=t.length;for(c=xo(n,t,y,c,b),f=0;f<b;f++)(m=n.__k[f])!=null&&(p=m.__i==-1?ao:y[m.__i]||ao,m.__i=f,_=Do(e,m,p,i,a,o,s,c,l,u,d),h=m.__e,m.ref&&p.ref!=m.ref&&(p.ref&&Mo(p.ref,null,m),u.push(m.ref,m.__c||h,m)),g==null&&h!=null&&(g=h),(v=!!(4&m.__u))||p.__k===m.__k?c=So(m,c,e,v):typeof m.type==`function`&&_!==void 0?c=_:h&&(c=h.nextSibling),m.__u&=-7);return n.__e=g,c}function xo(e,t,n,r,i){var a,o,s,c,l,u=n.length,d=u,f=0;for(e.__k=Array(i),a=0;a<i;a++)(o=t[a])!=null&&typeof o!=`boolean`&&typeof o!=`function`?(c=a+f,(o=e.__k[a]=typeof o==`string`||typeof o==`number`||typeof o==`bigint`||o.constructor==String?po(null,o,null,null,null):so(o)?po(mo,{children:o},null,null,null):o.constructor==null&&o.__b>0?po(o.type,o.props,o.key,o.ref?o.ref:null,o.__v):o).__=e,o.__b=e.__b+1,s=null,(l=o.__i=Co(o,n,c,d))!=-1&&(d--,(s=n[l])&&(s.__u|=2)),s==null||s.__v==null?(l==-1&&(i>u?f--:i<u&&f++),typeof o.type!=`function`&&(o.__u|=4)):l!=c&&(l==c-1?f--:l==c+1?f++:(l>c?f--:f++,o.__u|=4))):e.__k[a]=null;if(d)for(a=0;a<u;a++)(s=n[a])!=null&&!(2&s.__u)&&(s.__e==r&&(r=go(s)),No(s,s));return r}function So(e,t,n,r){var i,a;if(typeof e.type==`function`){for(i=e.__k,a=0;i&&a<i.length;a++)i[a]&&(i[a].__=e,t=So(i[a],t,n,r));return t}e.__e!=t&&(r&&(t&&e.type&&!t.parentNode&&(t=go(e)),n.insertBefore(e.__e,t||null)),t=e.__e);do t&&=t.nextSibling;while(t!=null&&t.nodeType==8);return t}function Co(e,t,n,r){var i,a,o,s=e.key,c=e.type,l=t[n],u=l!=null&&(2&l.__u)==0;if(l===null&&e.key==null||u&&s==l.key&&c==l.type)return n;if(r>+!!u){for(i=n-1,a=n+1;i>=0||a<t.length;)if((l=t[o=i>=0?i--:a++])!=null&&!(2&l.__u)&&s==l.key&&c==l.type)return o}return-1}function wo(e,t,n){t[0]==`-`?e.setProperty(t,n??``):e[t]=n??``}function To(e,t,n,r,i){var a;n:if(t==`style`)if(typeof n==`string`)e.style.cssText=n;else{if(typeof r==`string`&&(e.style.cssText=r=``),r)for(t in r)n&&t in n||wo(e.style,t,``);if(n)for(t in n)r&&n[t]==r[t]||wo(e.style,t,n[t])}else if(t[0]==`o`&&t[1]==`n`)a=t!=(t=t.replace(to,`$1`)),(t=t.slice(2))[0].toLowerCase()!=t[0]&&(t=t.toLowerCase()),e.__l||={},e.__l[t+a]=n,n?r?n.l=r.l:(n.l=no,e.addEventListener(t,a?io:ro,a)):e.removeEventListener(t,a?io:ro,a);else{if(i==`http://www.w3.org/2000/svg`)t=t.replace(/xlink(H|:h)/,`h`).replace(/sName$/,`s`);else if(t!=`width`&&t!=`height`&&t!=`href`&&t!=`list`&&t!=`form`&&t!=`tabIndex`&&t!=`download`&&t!=`rowSpan`&&t!=`colSpan`&&t!=`role`&&t!=`popover`&&t in e)try{e[t]=n??``;break n}catch{}typeof n==`function`||(n==null||!1===n&&t[4]!=`-`?e.removeAttribute(t):e.setAttribute(t,t==`popover`&&n==1?``:n))}}function Eo(e){return function(t){if(this.__l){var n=this.__l[t.type+e];if(t.u==null)t.u=no++;else if(t.u<n.l)return;return n(q.event?q.event(t):t)}}}function Do(e,t,n,r,i,a,o,s,c,l,u){var d,f,p,m,h,g,_,v,y,b,x,S,C,w,T,E,D,ee,te,O,k,A=t.type;if(t.constructor!=null)return null;128&n.__u&&(c=!!(32&n.__u),n.__c.__z&&(s=t.__e=n.__e=(a=n.__c.__z)[0],n.__c.__z=null)),(d=q.__b)&&d(t);n:if(typeof A==`function`)try{if(v=t.props,y=`prototype`in A&&A.prototype.render,b=(d=A.contextType)&&r[d.__c],x=d?b?b.props.value:d.__:r,n.__c?2&(f=t.__c=n.__c).__g&&(f.__g|=1,_=!0):(y?t.__c=f=new A(v,x):(t.__c=f=new ho(v,x),f.constructor=A,f.render=Po),b&&b.sub(f),f.props=v,f.state||={},f.context=x,f.__n=r,p=!0,f.__g|=8,f.__h=[],f._sb=[]),y&&f.__s==null&&(f.__s=f.state),y&&A.getDerivedStateFromProps!=null&&(f.__s==f.state&&(f.__s=lo({},f.__s)),lo(f.__s,A.getDerivedStateFromProps(v,f.__s))),m=f.props,h=f.state,f.__v=t,p)y&&A.getDerivedStateFromProps==null&&f.componentWillMount!=null&&f.componentWillMount(),y&&f.componentDidMount!=null&&f.__h.push(f.componentDidMount);else{if(y&&A.getDerivedStateFromProps==null&&v!==m&&f.componentWillReceiveProps!=null&&f.componentWillReceiveProps(v,x),!(4&f.__g)&&f.shouldComponentUpdate!=null&&!1===f.shouldComponentUpdate(v,f.__s,x)||t.__v==n.__v){for(t.__v!=n.__v&&(f.props=v,f.state=f.__s,f.__g&=-9),t.__e=n.__e,t.__k=n.__k,t.__k.some(function(e){e&&(e.__=t)}),S=0;S<f._sb.length;S++)f.__h.push(f._sb[S]);f._sb=[],f.__h.length&&o.push(f);break n}f.componentWillUpdate!=null&&f.componentWillUpdate(v,f.__s,x),y&&f.componentDidUpdate!=null&&f.__h.push(function(){f.componentDidUpdate(m,h,g)})}if(f.context=x,f.props=v,f.__P=e,f.__g&=-5,C=q.__r,w=0,y){for(f.state=f.__s,f.__g&=-9,C&&C(t),d=f.render(f.props,f.state,f.context),T=0;T<f._sb.length;T++)f.__h.push(f._sb[T]);f._sb=[]}else do f.__g&=-9,C&&C(t),d=f.render(f.props,f.state,f.context),f.state=f.__s;while(8&f.__g&&++w<25);f.state=f.__s,f.getChildContext!=null&&(r=lo({},r,f.getChildContext())),y&&!p&&f.getSnapshotBeforeUpdate!=null&&(g=f.getSnapshotBeforeUpdate(m,h)),E=d,d!=null&&d.type===mo&&d.key==null&&(E=Ao(d.props.children)),s=bo(e,so(E)?E:[E],t,n,r,i,a,o,s,c,l,u),t.__u&=-161,f.__h.length&&o.push(f),_&&(f.__g&=-4)}catch(e){if(t.__v=null,c||a!=null)if(e.then){for(D=0,ee=!1,t.__u|=c?160:128,t.__c.__z=[],te=0;te<a.length;te++)(O=a[te])==null||ee||(O.nodeType==8&&O.data==`$s`?(D>0&&t.__c.__z.push(O),D++,a[te]=null):O.nodeType==8&&O.data==`/$s`?(--D>0&&t.__c.__z.push(O),ee=D===0,s=a[te],a[te]=null):D>0&&(t.__c.__z.push(O),a[te]=null));if(!ee){for(;s&&s.nodeType==8&&s.nextSibling;)s=s.nextSibling;a[a.indexOf(s)]=null,t.__c.__z=[s]}t.__e=s}else{for(k=a.length;k--;)uo(a[k]);Oo(t)}else t.__e=n.__e,t.__k=n.__k,e.then||Oo(t);q.__e(e,t,n)}else s=t.__e=jo(n.__e,t,n,r,i,a,o,c,l,u);return(d=q.diffed)&&d(t),128&t.__u?void 0:s}function Oo(e){e&&e.__c&&(e.__c.__g|=4),e&&e.__k&&e.__k.forEach(Oo)}function ko(e,t,n){for(var r=0;r<n.length;r++)Mo(n[r],n[++r],n[++r]);q.__c&&q.__c(t,e),e.some(function(t){try{e=t.__h,t.__h=[],e.some(function(e){e.call(t)})}catch(e){q.__e(e,t.__v)}})}function Ao(e){return typeof e!=`object`||!e||e.__b&&e.__b>0?e:so(e)?e.map(Ao):lo({},e)}function jo(e,t,n,r,i,a,o,s,c,l){var u,d,f,p,m,h,g,_,v=n.props,y=t.props,b=t.type;if(b==`svg`?i=`http://www.w3.org/2000/svg`:b==`math`?i=`http://www.w3.org/1998/Math/MathML`:i||=`http://www.w3.org/1999/xhtml`,a!=null){for(u=0;u<a.length;u++)if((m=a[u])&&`setAttribute`in m==!!b&&(b?m.localName==b:m.nodeType==3)){e=m,a[u]=null;break}}if(e==null){if(b==null)return l.createTextNode(y);e=l.createElementNS(i,b,y.is&&y),s&&=(q.__m&&q.__m(t,a),!1),a=null}if(b==null)v===y||s&&e.data==y||(e.data=y);else{if(a&&=co.call(e.childNodes),v=n.props||ao,!s&&a!=null)for(v={},u=0;u<e.attributes.length;u++)v[(m=e.attributes[u]).name]=m.value;for(u in v)if(m=v[u],u!=`children`){if(u==`dangerouslySetInnerHTML`)f=m;else if(!(u in y)){if(u==`value`&&`defaultValue`in y||u==`checked`&&`defaultChecked`in y)continue;To(e,u,null,m,i)}}for(u in _=1&n.__u,y)m=y[u],u==`children`?p=m:u==`dangerouslySetInnerHTML`?d=m:u==`value`?h=m:u==`checked`?g=m:s&&typeof m!=`function`||v[u]===m&&!_||To(e,u,m,v[u],i);if(d)s||f&&(d.__html==f.__html||d.__html==e.innerHTML)||(e.innerHTML=d.__html),t.__k=[];else if(f&&(e.innerHTML=``),bo(b==`template`?e.content:e,so(p)?p:[p],t,n,r,b==`foreignObject`?`http://www.w3.org/1999/xhtml`:i,a,o,a?a[0]:n.__k&&go(n,0),s,c,l),a!=null)for(u=a.length;u--;)uo(a[u]);s||(u=`value`,b==`progress`&&h==null?e.removeAttribute(`value`):h==null||h===e[u]&&(b!==`progress`||h)||To(e,u,h,v[u],i),u=`checked`,g!=null&&g!=e[u]&&To(e,u,g,v[u],i))}return e}function Mo(e,t,n){try{if(typeof e==`function`){var r=typeof e.__u==`function`;r&&e.__u(),r&&t==null||(e.__u=e(t))}else e.current=t}catch(e){q.__e(e,n)}}function No(e,t,n){var r,i;if(q.unmount&&q.unmount(e),(r=e.ref)&&(r.current&&r.current!=e.__e||Mo(r,null,t)),(r=e.__c)!=null){if(r.componentWillUnmount)try{r.componentWillUnmount()}catch(e){q.__e(e,t)}r.__P=null}if(r=e.__k)for(i=0;i<r.length;i++)r[i]&&No(r[i],t,n||typeof e.type!=`function`);n||uo(e.__e),e.__e&&e.__e.__l&&(e.__e.__l=null),e.__e=e.__c=e.__=null}function Po(e,t,n){return this.constructor(e,n)}function Fo(e,t){var n,r,i,a;t==document&&(t=document.documentElement),q.__&&q.__(e,t),r=(n=!!(e&&32&e.__u))?null:t.__k,e=t.__k=fo(mo,null,[e]),i=[],a=[],Do(t,e,r||ao,ao,t.namespaceURI,r?null:t.firstChild?co.call(t.childNodes):null,i,r?r.__e:t.firstChild,n,a,t.ownerDocument),ko(i,e,a)}function Io(e,t){e.__u|=32,Fo(e,t)}q={__e:function(e,t,n,r){for(var i,a,o;t=t.__;)if((i=t.__c)&&!(1&i.__g)){i.__g|=4;try{if((a=i.constructor)&&a.getDerivedStateFromError!=null&&(i.setState(a.getDerivedStateFromError(e)),o=8&i.__g),i.componentDidCatch!=null&&(i.componentDidCatch(e,r||{}),o=8&i.__g),o)return void(i.__g|=2)}catch(t){e=t}}throw $a=0,e}},Xa=0,ho.prototype.setState=function(e,t){var n=this.__s!=null&&this.__s!=this.state?this.__s:this.__s=lo({},this.state);typeof e==`function`&&(e=e(lo({},n),this.props)),e&&lo(n,e),e!=null&&this.__v&&(t&&this._sb.push(t),vo(this))},ho.prototype.forceUpdate=function(e){this.__v&&(this.__g|=4,e&&this.__h.push(e),vo(this))},ho.prototype.render=mo,Za=[],$a=0,eo=function(e,t){return e.__v.__b-t.__v.__b},to=/(PointerCapture)$|Capture$/i,no=0,ro=Eo(!1),io=Eo(!0);var Lo=0;Array.isArray;function J(e,t,n,r,i,a){t||={};var o,s,c=t;if(`ref`in c&&typeof e!=`function`)for(s in c={},t)s==`ref`?o=t[s]:c[s]=t[s];var l={type:e,props:c,key:n,ref:o,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--Lo,__i:-1,__u:0,__source:i,__self:a};return q.vnode&&q.vnode(l),l}var Ro=16,zo=16,Bo={};function Vo({name:e,remappedFrom:t,token:n,width:r,height:i,viewBox:a,label:o,alignCapitals:s=!1}){"use no memo";let c=`#${e.replace(/^#/,``)}`,{width:l,height:u,viewBox:d}=Bo[e]??{width:Ro,height:zo},f=r??l,p=i??u,m=a??d??`0 0 ${l} ${u}`;return J(`svg`,{"data-icon-name":t??e,"data-icon-token":n,"data-align-capitals":s,...o==null?{"aria-hidden":!0}:{"aria-label":o,role:`img`},viewBox:m,width:f,height:p,children:J(`use`,{href:c})})}var Ho=e=>{if(e.length<2)return[e,``];let t=Math.ceil(e.length/2);return[e.slice(0,t),e.slice(t)]},Uo=e=>{if(e.length<4)return[e,``];let t=e.lastIndexOf(`.`)+1,n=e.length-t>10,r=t>=1&&!n?t:Math.ceil(e.length/2);return[e.slice(0,r),e.slice(r)]},Wo=e=>{if(e.length<4)return[e,``];let t=e.lastIndexOf(`/`)+1,n=e.length-t>25,r=t>=1&&!n?t:Math.ceil(e.length/2);return[e.slice(0,r),e.slice(r)]},Go=(e,{splitIndex:t}={})=>{if(typeof t!=`number`){let t=Math.ceil(e.length/2);return[e.slice(0,t),e.slice(t)]}return[e.slice(0,t),e.slice(t)]},Ko=(e,{splitOffset:t}={})=>{if(typeof t!=`number`||t<=0||t>=e.length){let t=Math.ceil(e.length/2);return[e.slice(0,t),e.slice(t)]}let n=e.length-t;return[e.slice(0,n),e.slice(n)]},qo=(e,{splitOffset:t}={})=>{if(typeof t!=`number`||t<=0||t>=e.length){let t=Math.ceil(e.length/2);return[e.slice(0,t),e.slice(t)]}let n=t;return[e.slice(0,n),e.slice(n)]};function Jo({children:e,marker:t,variant:n=`default`}){"use no memo";return J(`div`,{"aria-hidden":!0,"data-truncate-marker-cell":!0,children:J(`div`,{"data-truncate-marker":!0,children:typeof t==`function`?t({children:e}):n===`fade`?J(`span`,{"data-truncate-fade":!0}):t})})}function Yo(e){"use no memo";let{mode:t,children:n}=e;return J(`div`,{children:[J(`div`,{"data-truncate-content":`visible`,children:t===`fruncate`?J(`span`,{children:n}):n}),J(`div`,{"data-truncate-content":`overflow`,"aria-hidden":!0,children:t===`fruncate`?J(`span`,{children:n}):n})]})}function Xo({children:e,mode:t=`truncate`,marker:n=`…`,variant:r=`default`,...i}){"use no memo";let a=J(Yo,{mode:t,children:e},`content`),o=J(Jo,{marker:n,mode:t,variant:r},`marker`),s=J(`div`,{"data-truncate-fill":!0},`fill`);return J(`div`,{"data-truncate-container":t,"data-truncate-variant":r,...i,children:J(`div`,{"data-truncate-grid":!0,children:t===`truncate`?[a,o]:[o,a,s]})})}function Zo({children:e,...t}){"use no memo";return J(Xo,{mode:`truncate`,...t,children:e})}function Qo({children:e,...t}){"use no memo";return J(Xo,{mode:`fruncate`,...t,children:e})}function $o({children:e,contents:t,priority:n=`end`,split:r=`center`,minimumLength:i=12,className:a,style:o,...s}){"use no memo";let c=null,l=null;if(Array.isArray(t)){if(t.length!==2)return console.error(`MiddleTruncate: contents must be an array of two items`),null;c=J(Zo,{...s,children:t[0]}),l=J(Qo,{...s,children:t[1]})}else{if(typeof e!=`string`)return console.error(`MiddleTruncate: children must be a string`),null;if(e.length===0)return J(`div`,{className:a,style:o});if(e.length<i)return J(n===`end`?Qo:Zo,{...s,className:a,style:o,children:e});let t=null,u=null,d=null;if(typeof r==`string`)r===`center`?t=Ho:r===`extension`?t=Uo:r===`leaf-path`&&(t=Wo);else if(typeof r==`number`)t=Go,u=r;else if(Array.isArray(r)){let[e,n]=r;d=n,e===`last`?t=Ko:e===`first`&&(t=qo)}else typeof r==`function`&&(t=r);t??=Ho;let[f,p]=t(e,{priority:n,variant:s.variant,splitIndex:typeof u==`number`?u:void 0,splitOffset:typeof d==`number`?d:void 0}),m=f.length>=p.length,h=n===`equal`&&!m,g=n===`equal`&&m,_={},v={};h&&(_.marker=``),g&&(v.marker=``),c=J(Zo,{...s,..._,children:f}),l=J(Qo,{...s,...v,children:p})}return J(`div`,{"data-truncate-group-container":`middle`,className:a,style:o,children:[J(`div`,{"data-truncate-segment-priority":n===`start`||n===`equal`?`1`:`2`,children:c}),J(`div`,{"data-truncate-segment-priority":n===`end`||n===`equal`?`1`:`2`,children:l})]})}var es={endIndex:-1,startIndex:-1};function ts(e,t,n){return Math.min(Math.max(e,t),n)}function ns(e,t){return e<0||t<e?es:{endIndex:t,startIndex:e}}function rs(e){return e.startIndex<0||e.endIndex<e.startIndex}function is(e,t){return rs(e)?0:(e.endIndex-e.startIndex+1)*t}function as(e,t,n){if(t<=0)return-1;let r=t*n;return e<=0?0:e>=r?t:Math.floor(e/n)}function os(e,t,n){return t<=0||e<=0?-1:e>=t*n?t-1:Math.ceil(e/n)-1}function ss(e){let t=new Map;return e.forEach((e,n)=>{if(e.kind!==`directory`||!e.isExpanded)return;let r=e.ancestorPaths.length,i=t.get(r);if(i==null){t.set(r,[n]);return}i.push(n)}),t}function cs(e,t){let n=0,r=e.length-1,i=-1;for(;n<=r;){let a=Math.floor((n+r)/2),o=e[a];if(o==null)break;if(o<=t){i=a,n=a+1;continue}r=a-1}return i}function ls(e){let t=new Map,n=[];for(let r=0;r<e.length;r+=1){let i=e[r];if(i==null)continue;let a=i.kind===`directory`&&i.isExpanded?[...i.ancestorPaths,i.path]:i.ancestorPaths,o=0;for(;o<n.length&&o<a.length&&n[o]===a[o];)o+=1;for(let e=n.length-1;e>=o;--e){let i=n[e];i!=null&&t.set(i,r-1)}n.length=o;for(let e=o;e<a.length;e+=1){let t=a[e];t!=null&&n.push(t)}}let r=e.length-1;for(let e of n)t.set(e,r);return t}function us(e,t,n){if(e.length===0||t<=0)return[];let r=ls(e),i=ss(e),a=[];for(let r=0;r<e.length;r+=1){let o=i.get(r);if(o==null||o.length===0)break;let s=t+r*n,c=cs(o,Math.min(e.length-1,Math.floor(s/n))),l=null;for(;c>=0;){let t=o[c],n=t==null?null:e[t]??null;if(n!=null&&(r===0||n.ancestorPaths[r-1]===a[r-1]?.path)){l=n;break}--c}if(l==null)break;a.push(l)}return a.map((i,a)=>{let o=a*n,s=(r.get(i.path)??e.length-1)+1;if(s>=e.length)return{row:i,top:o};let c=s*n-t;return{row:i,top:Math.min(o,c-n)}}).filter(e=>e.top+n>0)}function ds(e,t){let n=t.totalRowCount??e.length,r=n*t.itemHeight,i=Math.max(0,t.viewportHeight),a=Math.max(0,Math.floor(t.overscan)),o=Math.max(0,r-i),s=ts(t.scrollTop,0,o),c=t.stickyRows??us(e,s,t.itemHeight),l=c.reduce((e,n)=>Math.max(e,n.top+t.itemHeight),0),u=Math.min(r,s+l),d=Math.max(0,i-l),f=Math.max(0,r-u),p=as(s,n,t.itemHeight),m=as(u,n,t.itemHeight),h=l<=0||p<0||p>=n?-1:p,g=h===-1?-1:Math.min(n-1,m-1),_=h===-1||g<h?0:g-h+1,v=d<=0||m>=n?es:ns(m,os(u+d,n,t.itemHeight)),y=g+1,b=rs(v)?es:ns(Math.max(y,v.startIndex-a),Math.min(n-1,v.endIndex+a)),x=is(b,t.itemHeight);return{occlusion:{firstOccludedIndex:h,lastOccludedIndex:g,occludedCount:_},physical:{itemHeight:t.itemHeight,maxScrollTop:o,overscan:a,scrollTop:s,totalHeight:r,totalRowCount:n,viewportHeight:i},projected:{contentHeight:f,paneHeight:d,paneTop:u},sticky:{height:l,rows:c},visible:v,window:{endIndex:b.endIndex,height:x,offsetTop:rs(b)?0:b.startIndex*t.itemHeight,startIndex:b.startIndex}}}var fs={added:`A`,deleted:`D`,ignored:null,modified:`M`,renamed:`R`,untracked:`U`},ps={added:`Git status: added`,deleted:`Git status: deleted`,ignored:`Git status: ignored`,modified:`Git status: modified`,renamed:`Git status: renamed`,untracked:`Git status: untracked`},ms=`Contains git status items`;function hs(e){let{currentScrollTop:t,focusedIndex:n,itemHeight:r,topInset:i=0,viewportHeight:a}=e;if(n<0)return null;let o=Math.max(0,i),s=n*r,c=s+r;if(s<t+o){let e=Math.max(0,s-o);return e===t?null:e}if(c>t+a){let e=c-a;return e===t?null:e}return null}function gs(e){let{currentScrollTop:t,focusedIndex:n,itemHeight:r,offset:i,topInset:a=0,totalHeight:o,viewportHeight:s}=e;if(i===`nearest`)return hs({currentScrollTop:t,focusedIndex:n,itemHeight:r,topInset:a,viewportHeight:s});if(n<0)return null;let c=Math.max(0,a),l=n*r,u=Math.max(0,s-c),d=i===`center`?c+Math.max(0,(u-r)/2):c,f=Math.max(0,o-s),p=Math.max(0,Math.min(l-d,f));return p===t?null:p}function _s(e){let{currentScrollTop:t,focusedIndex:n,itemHeight:r,targetViewportOffset:i,totalHeight:a,viewportHeight:o}=e;if(n<0)return null;let s=Math.max(0,i),c=n*r,l=c+r,u=t+s,d=t+o;if(c>=u&&l<=d)return null;let f=Math.max(0,a-o),p=Math.max(0,Math.min(c-s,f));return p===t?null:p}function vs(e){if(e==null||!e.isConnected||e===document.body||e===document.documentElement)return!1;e.focus({preventScroll:!0});let t=e.getRootNode();return t instanceof ShadowRoot?t.activeElement===e:document.activeElement===e}function ys(e){let t=e.getRootNode();if(t instanceof ShadowRoot){let e=t.activeElement;return e instanceof HTMLElement?e:null}let n=document.activeElement;return n instanceof HTMLElement&&e.contains(n)?n:null}function bs(e,t){if(e==null)return t;let n=e.getBoundingClientRect().height;return n>0?n:e.clientHeight>0?e.clientHeight:t}function xs(e,t){return e!=null&&e>0?e:t}function Ss(e){let t=e.borderBoxSize,n=Array.isArray(t)?t[0]:t;return n!=null&&Number.isFinite(n.blockSize)&&n.blockSize>0?n.blockSize:e.contentRect.height>0?e.contentRect.height:null}function Cs(e,t,n,r,i=0){let a=hs({currentScrollTop:e.scrollTop,focusedIndex:t,itemHeight:n,topInset:i,viewportHeight:r});return a==null?!1:(e.scrollTop=a,!0)}function ws(e,t,n,r,i,a,o=0){let s=gs({currentScrollTop:e.scrollTop,focusedIndex:t,itemHeight:n,offset:a,topInset:o,totalHeight:i,viewportHeight:r});return s==null?!1:(e.scrollTop=s,!0)}function Ts(e,t,n,r,i,a){let o=_s({currentScrollTop:e.scrollTop,focusedIndex:t,itemHeight:n,targetViewportOffset:a,totalHeight:i,viewportHeight:r});return o==null?!1:(e.scrollTop=o,!0)}function Es(e,t,n,r){return n.end<n.start?null:e<n.start?-t:e>n.end?r:null}function Ds(e){let{renamingPath:t,previousRenamingPath:n,hasRenderedInput:r}=e;return t==null?`reset`:r?n===t?`ignore`:`focus-input`:`reveal-canonical`}function Os({ariaLabel:e,isFlattened:t=!1,ref:n,value:r,onBlur:i,onInput:a}){return J(`input`,{ref:n,"data-item-rename-input":!0,...t?{"data-item-flattened-rename-input":!0}:{},"aria-label":e,value:r,onBlur:i,onInput:a,onClick:e=>e.stopPropagation(),onMouseDown:e=>e.stopPropagation(),onPointerDown:e=>e.stopPropagation()})}function ks(e){let{row:t,mode:n,targetPath:r,ariaLabel:i,domId:a,isParked:o,itemHeight:s,features:c,state:l,extraStyle:u}=e,d=n===`sticky`,f=t.ancestorPaths.at(-1)??``,p={};return l.isFocusRinged&&(p[`data-item-focused`]=!0),t.isSelected&&(p[`data-item-selected`]=!0),l.isContextHovered&&(p[`data-item-context-hover`]=`true`),l.isDragTarget&&(p[`data-item-drag-target`]=!0),l.isDragging&&(p[`data-item-dragging`]=!0),l.effectiveGitStatus!=null&&(p[`data-item-git-status`]=l.effectiveGitStatus),l.containsGitChange&&(p[`data-item-contains-git-change`]=`true`),{"aria-expanded":!d&&t.kind===`directory`?t.isExpanded:void 0,"aria-haspopup":c.contextMenuEnabled?`menu`:void 0,"aria-label":i,"aria-level":d?void 0:t.level+1,"aria-posinset":d?void 0:t.posInSet+1,"aria-selected":d?void 0:t.isSelected?`true`:`false`,"aria-setsize":d?void 0:t.setSize,"data-file-tree-sticky-path":d?r:void 0,"data-file-tree-sticky-row":d?`true`:void 0,"data-item-context-menu-button-visibility":c.actionLaneEnabled?c.contextMenuButtonVisibility:void 0,"data-item-context-menu-trigger-mode":c.contextMenuEnabled?c.contextMenuTriggerMode:void 0,"data-item-has-context-menu-action-lane":c.actionLaneEnabled?`true`:void 0,"data-item-has-git-lane":c.gitLaneActive?`true`:void 0,"data-item-parent-path":f.length>0?f:void 0,"data-item-parked":o?`true`:void 0,"data-item-path":r,"data-item-type":t.kind===`directory`?`folder`:`file`,"data-type":`item`,id:d?void 0:a,role:d?void 0:`treeitem`,style:{minHeight:`${s}px`,...u},tabIndex:!d&&t.isFocused?0:-1,...p}}function As(e){let{event:t,mode:n,isSearchOpen:r,isDirectory:i}=e,a=t.ctrlKey||t.metaKey,o=t.shiftKey||a,s=t.shiftKey?{additive:a,kind:`range`}:a?{kind:`toggle`}:{kind:`single`};return{closeSearch:r,revealCanonical:n===`sticky`,selection:s,toggleDirectory:!o&&i}}var js,Ms,Ns,Ps,Fs=Object.is,Is=0,Ls=[],Rs=q,zs=Rs.__b,Bs=Rs.__r,Vs=Rs.diffed,Hs=Rs.__c,Us=Rs.unmount,Ws=Rs.__;function Gs(e,t){Rs.__h&&Rs.__h(Ms,e,Is||t),Is=0;var n=Ms.__H||={__:[],__h:[]};return e>=n.__.length&&n.__.push({}),n.__[e]}function Ks(e){return Is=1,qs(ic,e)}function qs(e,t,n){var r=Gs(js++,2);if(r.t=e,!r.__c&&(r.__=[n?n(t):ic(void 0,t),function(e){var t=r.__N?r.__N[0]:r.__[0],n=r.t(t,e);Fs(t,n)||(r.__N=[n,r.__[1]],r.__c.setState({}))}],r.__c=Ms,!Ms.__f)){var i=function(e,t,n){if(!r.__c.__H)return!0;var i=r.__c.__H.__.filter(function(e){return!!e.__c});if(i.every(function(e){return!e.__N}))return!a||a.call(this,e,t,n);var o=r.__c.props!==e;return i.forEach(function(e){if(e.__N){var t=e.__[0];e.__=e.__N,e.__N=void 0,Fs(t,e.__[0])||(o=!0)}}),a&&a.call(this,e,t,n)||o};Ms.__f=!0;var a=Ms.shouldComponentUpdate,o=Ms.componentWillUpdate;Ms.componentWillUpdate=function(e,t,n){if(4&this.__g){var r=a;a=void 0,i(e,t,n),a=r}o&&o.call(this,e,t,n)},Ms.shouldComponentUpdate=i}return r.__N||r.__}function Js(e,t){var n=Gs(js++,3);!Rs.__s&&rc(n.__H,t)&&(n.__=e,n.u=t,Ms.__H.__h.push(n))}function Ys(e,t){var n=Gs(js++,4);!Rs.__s&&rc(n.__H,t)&&(n.__=e,n.u=t,Ms.__h.push(n))}function Y(e){return Is=5,Xs(function(){return{current:e}},[])}function Xs(e,t){var n=Gs(js++,7);return rc(n.__H,t)&&(n.__=e(),n.__H=t,n.__h=e),n.__}function Zs(e,t){return Is=8,Xs(function(){return e},t)}function Qs(){for(var e;e=Ls.shift();)if(e.__P&&e.__H)try{e.__H.__h.forEach(tc),e.__H.__h.forEach(nc),e.__H.__h=[]}catch(t){e.__H.__h=[],Rs.__e(t,e.__v)}}Rs.__b=function(e){Ms=null,zs&&zs(e)},Rs.__=function(e,t){e&&t.__k&&t.__k.__m&&(e.__m=t.__k.__m),Ws&&Ws(e,t)},Rs.__r=function(e){Bs&&Bs(e),js=0;var t=(Ms=e.__c).__H;t&&(Ns===Ms?(t.__h=[],Ms.__h=[],t.__.forEach(function(e){e.__N&&(e.__=e.__N),e.u=e.__N=void 0})):(t.__h.forEach(tc),t.__h.forEach(nc),t.__h=[],js=0)),Ns=Ms},Rs.diffed=function(e){Vs&&Vs(e);var t=e.__c;t&&t.__H&&(t.__H.__h.length&&(Ls.push(t)!==1&&Ps===Rs.requestAnimationFrame||((Ps=Rs.requestAnimationFrame)||ec)(Qs)),t.__H.__.forEach(function(e){e.u&&(e.__H=e.u),e.u=void 0})),Ns=Ms=null},Rs.__c=function(e,t){t.some(function(e){try{e.__h.forEach(tc),e.__h=e.__h.filter(function(e){return!e.__||nc(e)})}catch(n){t.some(function(e){e.__h&&=[]}),t=[],Rs.__e(n,e.__v)}}),Hs&&Hs(e,t)},Rs.unmount=function(e){Us&&Us(e);var t,n=e.__c;n&&n.__H&&(n.__H.__.forEach(function(e){try{tc(e)}catch(e){t=e}}),n.__H=void 0,t&&Rs.__e(t,n.__v))};var $s=typeof requestAnimationFrame==`function`;function ec(e){var t,n=function(){clearTimeout(r),$s&&cancelAnimationFrame(t),setTimeout(e)},r=setTimeout(n,35);$s&&(t=requestAnimationFrame(n))}function tc(e){var t=Ms,n=e.__c;typeof n==`function`&&(e.__c=void 0,n()),Ms=t}function nc(e){var t=Ms;e.__c=e.__(),Ms=t}function rc(e,t){return!e||e.length!==t.length||t.some(function(t,n){return!Fs(t,e[n])})}function ic(e,t){return typeof t==`function`?t(e):t}function ac(e,t=null,n=null){"use no memo";let r=e.flattenedSegments;return r==null||r.length===0?t??e.name:J(`span`,{"data-item-flattened-subitems":!0,children:r.map((e,i)=>{let a=i===r.length-1;return J(mo,{children:[J(`span`,{"data-item-flattened-subitem":e.path,"data-item-flattened-subitem-drag-target":n===e.path?`true`:void 0,children:a&&t!=null?t:J(Zo,{children:e.name})}),i<r.length-1?` / `:``]},e.path)})})}function oc(e){return e.isFlattened?e.flattenedSegments?.findLast(e=>e.isTerminal)?.path??e.path:e.path}function sc(e){let t=e.flattenedSegments;return t==null||t.length===0?e.name:t.map(e=>e.name).join(` / `)}function cc(e,t,n,r){return e.map((e,i)=>{let a=i*n,o=e.subtreeEndIndex+1;if(o>=r)return{row:e.row,top:a};let s=o*n-t;return{row:e.row,top:Math.min(a,s-n)}}).filter(e=>e.top+n>0)}function lc({controller:e,itemHeight:t,overscan:n,scrollTop:r,stickyFolders:i,viewportHeight:a}){let o=e.getVisibleCount(),s=i&&o>0?e.getStickyRowCandidates(r,t):[],c=s==null&&i&&o>0?e.getVisibleRows(0,o-1):[],l=ds(c,{itemHeight:t,overscan:n,scrollTop:r,stickyRows:s==null?void 0:cc(s,r,t,o),totalRowCount:o,viewportHeight:a}),u=i&&r<=0&&o>0?e.getStickyRowCandidates(1,t):[],d=u!=null&&r<=0?cc(u,1,t,o):i&&r<=0&&c.length>0?us(c,1,t):l.sticky.rows;return{overlayHeight:d.reduce((e,n)=>Math.max(e,n.top+t),0),overlayRows:d,snapshot:l,visibleRows:c}}var uc=400,dc=10,fc=40,pc=18;function X(e,t,n){let r=e,i=document.elementFromPoint?.bind(document)??null,a=r.elementFromPoint?.(t,n)??i?.(t,n)??null;return e instanceof ShadowRoot&&(a==null||!e.contains(a))?mc(e,t,n):a instanceof HTMLElement?a:null}function mc(e,t,n){let r=Array.from(e.querySelectorAll(`[data-type="item"], [data-item-flattened-subitem]`));for(let e=r.length-1;e>=0;e--){let i=r[e],a=i.getBoundingClientRect();if(t>=a.left&&t<=a.right&&n>=a.top&&n<=a.bottom)return i}return null}function hc(e){let t=e?.closest?.(`[data-type="item"]`);if(!(t instanceof HTMLElement))return null;let n=t.dataset.itemPath??null;if(n==null)return null;let r=e?.closest?.(`[data-item-flattened-subitem]`),i=r instanceof HTMLElement?r.getAttribute(`data-item-flattened-subitem`)??null:null;if(i!=null&&i.endsWith(`/`))return{directoryPath:i,flattenedSegmentPath:i,hoveredPath:n,kind:`directory`};if(t.dataset.itemType===`folder`)return{directoryPath:n,flattenedSegmentPath:null,hoveredPath:n,kind:`directory`};let a=t.dataset.itemParentPath??null;return a==null||a.length===0?{directoryPath:null,flattenedSegmentPath:null,hoveredPath:n,kind:`root`}:{directoryPath:a,flattenedSegmentPath:null,hoveredPath:n,kind:`directory`}}function gc(e){let t=e.cloneNode(!0);return t.removeAttribute(`id`),t.dataset.fileTreeDragPreview=`true`,t.setAttribute(`aria-hidden`,`true`),t.tabIndex=-1,Object.assign(t.style,{boxShadow:`0 4px 12px rgba(0, 0, 0, 0.15)`,left:`0px`,margin:`0`,pointerEvents:`none`,position:`fixed`,top:`0px`,willChange:`transform`,zIndex:`10000`}),t}function _c(){return navigator.vendor!==`Apple Computer, Inc.`}function vc(e,t){let n=e-t.top;if(n<fc)return-Math.ceil((fc-Math.max(0,n))/fc*pc);let r=t.bottom-e;return r<fc?Math.ceil((fc-Math.max(0,r))/fc*pc):0}function yc(e,t){if(e!=null){let t=fs[e];return t==null?null:{text:t,title:ps[e]}}return t?{icon:{name:`file-tree-icon-dot`,width:6,height:6},title:ms}:null}function bc(e,t,n){if(t==null||t.size===0)return null;let r=[];for(let i=e.length-1;i>=0;--i){let a=e[i],o=n.get(a);if(o!=null){for(let e of r)n.set(e,o);return o?`ignored`:null}if(t.has(a)){n.set(a,!0);for(let e of r)n.set(e,!0);return`ignored`}r.push(a)}for(let e of r)n.set(e,!1);return null}function xc(e){return e!=null&&`toggle`in e}function Sc(e){return e.code===`Space`||e.key===` `||e.key===`Spacebar`}function Cc(e){return e.key.length===1&&/^[\p{L}\p{N}]$/u.test(e.key)&&!e.ctrlKey&&!e.metaKey&&!e.altKey}function wc(e){return e==null?``:`[data-item-section="spacing-item"][data-ancestor-path="${e.replaceAll(`\\`,`\\\\`).replaceAll(`"`,`\\"`)}"] { opacity: 1; }`}function Tc(e){return e.shiftKey&&e.key===`F10`||e.key===`ContextMenu`}function Ec(e,t){return t&&Tc(e)||(e.ctrlKey||e.metaKey)&&Sc(e)?!0:e.key===`ArrowDown`||e.key===`ArrowLeft`||e.key===`ArrowRight`||e.key===`ArrowUp`}var Dc=new Set([`ArrowDown`,`ArrowLeft`,`ArrowRight`,`ArrowUp`,`End`,`Home`,`PageDown`,`PageUp`]);function Oc(e){for(let t of e.composedPath())if(t instanceof HTMLElement&&(t.dataset.fileTreeContextMenuRoot===`true`||t.dataset.type===`context-menu-anchor`||t.dataset.type===`context-menu-trigger`||t.getAttribute(`slot`)===`context-menu`))return!0;return!1}function kc(e){return{bottom:e.bottom,height:e.height,left:e.left,right:e.right,top:e.top,width:e.width,x:e.x,y:e.y}}function Ac(e,t){return{bottom:t,height:0,left:e,right:e,top:t,width:0,x:e,y:t}}function jc(e,t){if(e==null)return t.offsetTop;let n=t.getBoundingClientRect(),r=e.getBoundingClientRect();return n.top-r.top}function Mc(e,t,n){if(n==null){e.delete(t);return}e.set(t,n)}function Nc(e,t,n){if(e==null)return null;let r=t.get(e)??null;if(r!=null)return r;let i=n.get(e)??null;return i?.dataset.itemParked===`true`?null:i}function Pc(e){if(e==null)return[];let t=[];for(let n of e.querySelectorAll(`button[data-file-tree-sticky-row="true"]`)){if(!(n instanceof HTMLElement))continue;let e=n.dataset.fileTreeStickyPath;e!=null&&t.push(e)}return t}function Fc(e,t){if(e==null||t==null)return null;for(let n of e.querySelectorAll(`button[data-item-focused="true"][data-item-parked="true"]`))if(n instanceof HTMLElement&&n.dataset.itemPath===t)return n;return null}function Ic(e,t,n,r,i,a,o){let s=Math.max(0,a-i),c=t?.getBoundingClientRect()??null,l=c==null||n==null?null:n.getBoundingClientRect().top-c.top,u=Fc(e,r),d=c==null||u==null?null:u.getBoundingClientRect().top-c.top;return Math.max(0,Math.min(d??Math.max(l??0,s),Math.max(0,o-i)))}function Lc(e,t){return{kind:e.kind,name:sc(e),path:t}}function Rc(e){return e==null?void 0:`${e}__tree`}function zc(e,t,n){if(e!=null)return`${e}__focused-item-${encodeURIComponent(t)}${n?`__parked`:``}`}function Bc(e){return e===`file-tree-icon-chevron`||e===`file-tree-icon-dot`||e===`file-tree-icon-file`||e===`file-tree-icon-lock`}function Vc(e,t){if(e==null)return null;if(`text`in e)return J(`span`,{title:e.title,children:e.text});let n=typeof e.icon==`string`?Bc(e.icon)?t(e.icon):{name:e.icon}:Bc(e.icon.name)?(()=>{let n=t(e.icon.name),{name:r,...i}=e.icon;return{...n,...i}})():e.icon;return J(`span`,{title:e.title,children:J(Vo,{...n})})}function Hc(e){e!=null&&vs(e.querySelector([`button:not([disabled])`,`[href]`,`input:not([disabled])`,`select:not([disabled])`,`textarea:not([disabled])`,`[tabindex]:not([tabindex="-1"])`].join(`, `))??e)}function Z(e,t,{actionLaneEnabled:n=!1,customDecoration:r=null,decorationLaneEnabled:i=!1,dragTargetFlattenedSegmentPath:a=null,gitDecoration:o=null,gitLaneActive:s=!1,renameInput:c=null,showDecorativeActionAffordance:l=!1}={}){let u=oc(e);return J(mo,{children:[e.depth>0?J(`div`,{"data-item-section":`spacing`,children:Array.from({length:e.depth}).map((t,n)=>J(`div`,{"data-item-section":`spacing-item`,"data-ancestor-path":e.ancestorPaths[n]},n))}):null,J(`div`,{"data-item-section":`icon`,children:e.kind===`directory`?J(Vo,{...t(`file-tree-icon-chevron`)}):J(Vo,{...t(`file-tree-icon-file`,u)})}),J(`div`,{"data-item-section":`content`,children:e.isFlattened?ac(e,c,a):c??J($o,{minimumLength:5,split:`extension`,children:e.name})}),i?J(`div`,{"data-item-section":`decoration`,children:r==null?null:Vc(r,t)}):null,s?J(`div`,{"data-item-section":`git`,children:Vc(o,t)}):null,n?J(`div`,{"data-item-section":`action`,children:l?J(`span`,{"aria-hidden":`true`,"data-item-action-affordance":`decorative`,children:J(Vo,{...t(`file-tree-icon-ellipsis`)})}):null}):null]})}function Uc(e,t,n,r={}){let{controller:i,renameView:a,visualFocusPath:o,contextHoverPath:s,draggedPathSet:c,dragTarget:l,dragAndDropEnabled:u,shouldSuppressContextMenu:d,handleRowDragStart:f,handleRowDragEnd:p,handleRowTouchStart:m,instanceId:h,itemHeight:g,gitStatusByPath:_,ignoredGitDirectories:v,ignoredInheritanceCache:y,directoriesWithGitChanges:b,gitLaneActive:x,contextMenuEnabled:S,contextMenuTriggerMode:C,contextMenuButtonTriggerEnabled:w,contextMenuButtonVisibility:T,contextMenuRightClickEnabled:E,registerRenameInput:D,registerButton:ee,resolveIcon:te,renderDecorationForRow:O,openContextMenuForRow:k,onRowClick:A,onKeyDown:j}=e,M=oc(t),{isParked:N=!1,mode:ne=`flow`,style:re}=r,ie=ne===`sticky`,P=_?.get(M)??null??bc(t.ancestorPaths,v,y),ae=t.kind===`directory`&&(b?.has(M)??!1),oe=O(t,M),se=yc(P,ae),ce=S&&w,le=oe!=null||x||ce,ue=ce&&T===`always`,de=a.getPath()===M,fe=de?a.getValue():``,pe=ie||!de?null:J(Os,{ref:D,ariaLabel:`Rename ${sc(t)}`,isFlattened:t.isFlattened,value:fe,onBlur:()=>{a.commit()},onInput:e=>{a.setValue(e.currentTarget.value)}}),me=Z(t,te,{actionLaneEnabled:ce,customDecoration:oe,decorationLaneEnabled:le,dragTargetFlattenedSegmentPath:l?.flattenedSegmentPath??null,gitDecoration:se,gitLaneActive:x,renameInput:pe,showDecorativeActionAffordance:ue}),he={...ks({ariaLabel:sc(t),domId:t.isFocused?zc(h,M,N):void 0,extraStyle:re,features:{actionLaneEnabled:ce,contextMenuButtonVisibility:ce?T:null,contextMenuEnabled:S,contextMenuTriggerMode:S?C:null,gitLaneActive:x},isParked:N,itemHeight:g,mode:ne,row:t,state:{containsGitChange:ae,effectiveGitStatus:P,isContextHovered:s===M,isDragTarget:l?.kind===`directory`&&l.directoryPath===M,isDragging:c?.has(M)===!0,isFocusRinged:t.isFocused&&o===M},targetPath:M}),key:n,onContextMenu:S||u?e=>{if(d()){e.preventDefault();return}S&&(e.preventDefault(),E&&(i.focusMountedPathFromInput(M),k(t,M,{anchorRect:Ac(e.clientX,e.clientY),source:`right-click`})))}:void 0,onFocus:ie?void 0:()=>{i.focusMountedPathFromInput(M)},onKeyDown:ie?void 0:j,ref:e=>{ee(M,e)}};return!ie&&de?J(`div`,{...he,children:me}):J(`button`,{...he,type:`button`,draggable:u&&!N,onDragEnd:u&&!N?p:void 0,onDragStart:u&&!N?e=>{f(e,t,M)}:void 0,onMouseDown:e=>{if(ie){e.preventDefault();return}i.isSearchOpen()&&e.preventDefault()},onTouchStart:u&&!N?e=>{m(e,t,M)}:void 0,onClick:e=>{A(e,t,M,ne)},children:me})}function Wc(e,t,n){return t.end<t.start?[]:e.controller.getVisibleRows(t.start,t.end).filter(e=>!n.has(oc(e))).map((n,r)=>Uc(e,n,t.start+r))}function Gc({composition:e,controller:t,gitStatusByPath:n,ignoredGitDirectories:r,directoriesWithGitChanges:i,icons:a,instanceId:o,itemHeight:s=gt,overscan:c=10,renamingEnabled:l=!1,renderRowDecoration:u,searchBlurBehavior:d=`close`,searchEnabled:f=!1,searchFakeFocus:p=!1,slotHost:m,stickyFolders:h=!1,initialViewportHeight:g=420}){"use no memo";let _=Y(null),v=Y(null),y=Y(!1),b=Y(null),x=Y(null),S=Y(null),C=Y(null),w=Y(null),T=Y(new Map),E=Y(new Map),D=Y(()=>{}),k=Y(null),A=Y(0),j=Y(!1),M=Y(null);M.current!==t&&(j.current=!1,M.current=t);let N=Y(!1),ne=Y(null),re=Y(null),ie=Y(!1),P=Y(null),ae=Y(null),oe=Y(null),se=Y(null),ce=Y(null),le=Y(null),ue=Y(null),de=Y(null),fe=Y(!1),pe=Y(null),me=Y(null),he=Y(null),ge=Y(null),_e=Xs(()=>new Map,[]),[,ve]=Ks(0),[ye,be]=Ks(null),[xe,Se]=Ks(null),[Ce,we]=Ks(null),[Te,Ee]=Ks(null),[De,Oe]=Ks(0),[F,ke]=Ks(null),Ae=Y(F);Ae.current=F;let je=Y(null),Me=Y(null),Ne=Y(null),Pe=Y(null),Fe=Y(null),Ie=Y(!1),Le=()=>{Me.current=null,Ne.current=null,Pe.current=null},Re=(e,t)=>{Me.current=e,Ne.current=null,Pe.current=t==null?null:{path:e,scrollTop:t}},ze=(e,t)=>{Me.current=null,Ne.current={path:e,viewportOffset:t},Pe.current=null},Be=Y(d===`retain`&&t.isSearchOpen()),[Ve,He]=Ks(p);Js(()=>{p||He(!1)},[p]);let Ue=Y(!1),We=Zs(()=>{Ue.current=!0,He(e=>e&&!1)},[]),[Ge,Ke]=Ks(()=>lc({controller:t,itemHeight:s,overscan:c,scrollTop:0,stickyFolders:h,viewportHeight:g})),[qe,Je]=Ks(!1);Js(()=>{Je(!0)},[]);let Ye=e?.contextMenu?.enabled===!0||e?.contextMenu?.render!=null||e?.contextMenu?.onOpen!=null||e?.contextMenu?.onClose!=null,Xe=e?.contextMenu?.triggerMode??(Ye?`right-click`:`both`),Ze=Xe===`both`||Xe===`button`,Qe=e?.contextMenu?.buttonVisibility??`when-needed`,$e=Xe===`both`||Xe===`right-click`;Ys(()=>{let e=S.current;if(e==null)return;let t=e=>{if(!(e instanceof CustomEvent))return;let t=e.detail?.path??null;Fe.current=t,Se(t),Ee(t==null?null:`pointer`)},n=e=>{e instanceof CustomEvent&&(Ie.current=e.detail?.disabled===!0)};return e.addEventListener(`file-tree-debug-set-context-menu-trigger`,t),e.addEventListener(`file-tree-debug-set-scroll-suppression`,n),()=>{e.removeEventListener(`file-tree-debug-set-context-menu-trigger`,t),e.removeEventListener(`file-tree-debug-set-scroll-suppression`,n)}},[]);let et=Zs((e,t)=>{Mc(T.current,e,t)},[]),tt=Zs((e,t)=>{Mc(E.current,e,t)},[]),nt=Zs(e=>{x.current=e},[]),rt=Zs(e=>Nc(e,E.current,T.current),[]),it=n!=null||r!=null||i!=null,{resolveIcon:at}=Xs(()=>Ya(a),[a]),ot=t[Na](),st=ot.getPath(),ct=st!=null,lt=t.isSearchOpen(),ut=t.getSearchValue(),I=t.getFocusedPath(),L=t.getFocusedIndex(),dt=t.getScrollRequest(),ft=t.isDragAndDropEnabled(),pt=t.getDragSession(),mt=Xs(()=>pt==null?null:new Set(pt.draggedPaths),[pt]),ht=pt?.target??null,_t=pt?.primaryPath??null,vt=Rc(o),{overlayHeight:yt,overlayRows:bt,snapshot:xt,visibleRows:St}=Ge,Ct=xt.physical.viewportHeight,wt=Xs(()=>({end:xt.window.endIndex,start:xt.window.startIndex}),[xt.window.endIndex,xt.window.startIndex]),Tt=bt,Et=xt.sticky.rows,Dt=xt.physical.totalHeight,Ot=xt.sticky.height,kt=Xs(()=>new Set(Et.map(e=>oc(e.row))),[Et]),At=L>=0&&L>=wt.start&&L<=wt.end,jt=Zs((e,t)=>u?.({item:Lc(e,t),row:e})??null,[u]),Mt=Zs(e=>vs(e==null?null:T.current.get(e)??null)?!0:vs(S.current),[]),Nt=Zs(e=>{Mt(t.focusNearestPath(e))},[t,Mt]),Pt=Y(Nt);Pt.current=Nt;let Ft=Y(!0),It=Y(()=>{}),Lt=Zs((t=!0)=>{let n=Ae.current;n!=null&&(Ft.current=Ft.current&&t,ke(null),e?.contextMenu?.onClose?.(),Ft.current&&Nt(n.path))},[e?.contextMenu,Nt]);It.current=Lt;let Rt=Zs(e=>{let t=e==null?null:jc(S.current,e);we(e=>e===t?e:t)},[]),zt=Zs((e,n,r)=>{let i=t.getItem(n);if(i==null)return;let a=rt(n);if(a?.dataset.fileTreeStickyRow===`true`){let e=C.current;Re(n,e?.scrollTop??null),N.current=!0,be(e=>e===n?e:n)}i.focus(),Rt(a),Ft.current=!0,ke({anchorRect:r?.anchorRect??null,item:Lc(e,n),path:n,source:r?.source??`keyboard`})},[t,rt,Rt]),Bt=Zs(e=>{if(l){if(t.isSearchOpen()){let e=C.current,t=bs(e,Ct);P.current=L<0||e==null?null:Math.max(0,Math.min(L*s-e.scrollTop,Math.max(0,t-s))),ie.current=!0}t.startRenaming(e)!==!1&&(Ee(`focus`),ve(e=>e+1))}},[t,L,s,l,Ct]),Vt=Zs((e,{restoreTreeFocus:n=!0,targetOffset:r=`live-overlay`}={})=>{let i=C.current;if(i==null)return!1;t.focusPath(e);let a=t.getFocusedIndex();if(a<0)return!1;let o=t.getVisibleRows(a,a)[0]??null;if(o==null)return!1;let l=bs(i,Ct),u=t.getVisibleCount()*s,d=r===`sticky-parents`?o.ancestorPaths.length*s:lc({controller:t,itemHeight:s,overscan:c,scrollTop:i.scrollTop,stickyFolders:h,viewportHeight:l}).snapshot.sticky.height;return N.current=!0,Ts(i,a,s,l,u,d),D.current(),je.current=n?e:null,!0},[t,s,c,Ct,h]),Ht=()=>y.current===!0||ge.current!=null||fe.current===!0,Ut=e=>typeof window.requestAnimationFrame==`function`?window.requestAnimationFrame(()=>{e()}):window.setTimeout(e,16),R=e=>{if(e!=null){if(typeof window.cancelAnimationFrame==`function`){window.cancelAnimationFrame(e);return}window.clearTimeout(e)}},Wt=()=>{se.current!=null&&(clearTimeout(se.current),se.current=null),oe.current=null},Gt=()=>{le.current?.remove(),le.current=null},Kt=()=>{R(ae.current),ae.current=null,ce.current=null},qt=e=>{let t=S.current?.getRootNode();if(t instanceof ShadowRoot){t.append(e);return}document.body.append(e)},Jt=()=>{de.current?.(),de.current=null,ge.current!=null&&(clearTimeout(ge.current),ge.current=null),fe.current=!1,pe.current=null,he.current=null,me.current!=null&&(me.current.setAttribute(`draggable`,`true`),me.current.style.removeProperty(`touch-action`),me.current=null),Gt(),Wt(),Kt(),ue.current=null},z=(e,n)=>{let r=S.current?.getRootNode(),i=hc(X(r instanceof ShadowRoot?r:document,e,n));return t.setDragTarget(i),t.getDragSession()?.target??null},Yt=e=>{let n=t.getDragAndDropConfig()?.openOnDropDelay??800;if(e==null||e.kind!==`directory`||e.directoryPath==null||n<=0){Wt();return}let r=t.getItem(e.directoryPath),i=xc(r)?r:null;if(i==null||i.isExpanded()){Wt();return}let a=`${e.directoryPath}::${e.flattenedSegmentPath??``}`;oe.current!==a&&(Wt(),oe.current=a,se.current=setTimeout(()=>{let n=t.getDragSession()?.target;n?.kind!==`directory`||n.directoryPath!==e.directoryPath||n.flattenedSegmentPath!==e.flattenedSegmentPath||i.expand()},n))},B=()=>{ae.current=null;let e=ce.current,n=C.current;if(e==null||n==null||t.getDragSession()==null)return;let r=n.getBoundingClientRect(),i=vc(e.clientY,r);if(i===0)return;let a=Math.max(0,n.scrollHeight-n.clientHeight),o=Math.max(0,Math.min(a,n.scrollTop+i));o!==n.scrollTop&&(n.scrollTop=o,D.current()),Yt(z(e.clientX,e.clientY)),ae.current=Ut(B)},Xt=(e,t)=>{ce.current={clientX:e,clientY:t},ae.current??=Ut(B)},Zt=(e,n,r)=>{let i=e.currentTarget;if(i!=null){if(Jt(),Gt(),Wt(),Kt(),t.startDrag(r)===!1){e.preventDefault();return}if(ue.current=n,e.dataTransfer!=null&&(e.dataTransfer.effectAllowed=`move`,e.dataTransfer.dropEffect=`move`,e.dataTransfer.setData(`text/plain`,r),_c())){let t=gc(i),n=i.getBoundingClientRect();Object.assign(t.style,{height:`${n.height}px`,opacity:`0.85`,transform:`translate3d(-9999px, 0px, 0)`,width:`${n.width}px`}),qt(t),le.current=t,e.dataTransfer.setDragImage(t,Math.max(0,e.clientX-n.left),Math.max(0,e.clientY-n.top))}}},Qt=()=>{Gt(),Wt(),Kt(),ue.current=null,t.cancelDrag()},$t=(e,n,r)=>{if(ge.current!=null||fe.current)return;let i=e.touches[0],a=e.currentTarget;if(i==null||a==null)return;he.current={clientX:i.clientX,clientY:i.clientY},me.current=a,a.setAttribute(`draggable`,`false`);let o=(e={})=>{let t=e.restoreNativeDraggable??!fe.current;ge.current!=null&&(clearTimeout(ge.current),ge.current=null),document.removeEventListener(`touchmove`,s),document.removeEventListener(`touchend`,c),document.removeEventListener(`touchcancel`,c),de.current===o&&(de.current=null),t&&(a.setAttribute(`draggable`,`true`),me.current===a&&(me.current=null),he.current=null)},s=e=>{let t=e.touches[0],n=he.current;if(t==null||n==null)return;let r=t.clientX-n.clientX,i=t.clientY-n.clientY;r*r+i*i<=dc*dc||o()},c=()=>{o()};document.addEventListener(`touchmove`,s,{passive:!0}),document.addEventListener(`touchend`,c),document.addEventListener(`touchcancel`,c),de.current=o,ge.current=setTimeout(()=>{if(o({restoreNativeDraggable:!1}),t.startDrag(r)===!1){a.setAttribute(`draggable`,`true`),me.current===a&&(me.current=null),he.current=null;return}fe.current=!0,me.current=a,a.setAttribute(`draggable`,`false`),a.style.setProperty(`touch-action`,`none`),ue.current=n;let e=a.getBoundingClientRect(),s=gc(a);Object.assign(s.style,{height:`${e.height}px`,opacity:`0.85`,transform:`translate3d(${e.left}px, ${e.top}px, 0)`,width:`${e.width}px`}),qt(s),le.current=s,pe.current={x:i.clientX-e.left,y:i.clientY-e.top};let c=e=>{let t=e.touches[0];if(t==null)return;e.preventDefault();let n=pe.current;n!=null&&le.current!=null&&(le.current.style.transform=`translate3d(${t.clientX-n.x}px, ${t.clientY-n.y}px, 0)`),Yt(z(t.clientX,t.clientY)),Xt(t.clientX,t.clientY)},l=e=>{let n=e.changedTouches[0];n!=null&&z(n.clientX,n.clientY),t.completeDrag(),Jt()},u=()=>{t.cancelDrag(),Jt()};de.current=()=>{document.removeEventListener(`touchmove`,c),document.removeEventListener(`touchend`,l),document.removeEventListener(`touchcancel`,u)},document.addEventListener(`touchmove`,c,{passive:!1}),document.addEventListener(`touchend`,l),document.addEventListener(`touchcancel`,u)},uc)},en=e=>{if(F!=null){if(e.key===`Escape`){Lt(),e.preventDefault(),e.stopPropagation();return}Dc.has(e.key)&&(e.preventDefault(),e.stopPropagation());return}if(ot.isActive()){if(e.key===`Escape`)ot.cancel();else if(e.key===`Enter`)ot.commit();else return;Ee(`focus`),ve(e=>e+1),e.preventDefault(),e.stopPropagation();return}if(l&&e.key===`F2`){Bt(I??void 0),e.preventDefault(),e.stopPropagation();return}if(lt){if(e.key===`Escape`)ie.current=!1,P.current=null,t.closeSearch();else if(e.key===`Enter`){let e=t.getFocusedPath();e!=null&&t.selectOnlyPath(e);let n=C.current,r=bs(n,Ct);P.current=L<0||n==null?null:Math.max(0,Math.min(L*s-n.scrollTop,Math.max(0,r-s))),ie.current=!0,t.closeSearch()}else if(e.key===`ArrowDown`)t.focusNextSearchMatch();else if(e.key===`ArrowUp`)t.focusPreviousSearchMatch();else return;Ee(`focus`),ve(e=>e+1),e.preventDefault(),e.stopPropagation();return}if(f&&Cc(e)){t.openSearch(e.key),ve(e=>e+1),e.preventDefault(),e.stopPropagation();return}let n=Ye&&Tc(e),r=Ec(e,Ye),i=r&&S.current!=null?ys(S.current):null,a=r?new Set(Pc(S.current)):new Set,o=i?.dataset.fileTreeStickyPath??null,c=i?.dataset.fileTreeStickyRow===`true`&&o!=null;if(c&&o!==I&&a.has(o)){let e=C.current;Re(o,e?.scrollTop??null),t.focusPath(o)}let u=t.getFocusedPath(),d=t.getFocusedIndex(),p=t.getFocusedItem();if(p==null)return;let m=xc(p)?p:null,h=u!=null&&(kt.has(u)||c&&o===u&&a.has(u)),g=e.key===`ArrowDown`||e.key===`ArrowUp`||e.key===`ArrowRight`&&m!=null&&m.isExpanded(),_=e.key===`ArrowLeft`&&h&&m!=null&&m.isExpanded(),v=C.current,y=!0;if(e.shiftKey&&e.key===`ArrowDown`)t.extendSelectionFromFocused(1);else if(e.shiftKey&&e.key===`ArrowUp`)t.extendSelectionFromFocused(-1);else if(n&&u!=null&&d>=0){let e=t.getVisibleRows(d,d)[0]??null,n=Nc(u,E.current,T.current);e==null||n==null?y=!1:zt(e,u)}else if((e.ctrlKey||e.metaKey)&&Sc(e))t.toggleFocusedSelection();else if((e.ctrlKey||e.metaKey)&&e.key.toLowerCase()===`a`)t.selectAllVisiblePaths();else switch(e.key){case`ArrowDown`:t.focusNextItem();break;case`ArrowUp`:t.focusPreviousItem();break;case`ArrowRight`:m==null||m.isExpanded()?t.focusNextItem():m.expand();break;case`ArrowLeft`:m!=null&&m.isExpanded()?m.collapse():t.focusParentItem();break;case`Home`:t.focusFirstItem();break;case`End`:t.focusLastItem();break;default:y=!1}if(!y)return;Ee(`focus`);let b=t.getFocusedPath(),x=b!=null&&(kt.has(b)||a.has(b)),w=g&&b!==u,D=n&&c&&o===u&&b===u;if((h||D)&&b!=null&&(w&&x||D))Re(b,v?.scrollTop??null),N.current=!0,be(e=>e===b?e:b);else{let t=e.key===`ArrowUp`&&h&&b!==u;b!=null&&(t||_&&b===u)?(ze(b,Ic(S.current,v,i,u,s,Ot,Ct)),N.current=!0,be(e=>e===b?e:b)):Le()}ve(e=>e+1),e.preventDefault(),e.stopPropagation()};Ys(()=>{if(!(!f||!lt)){if(Be.current){Be.current=!1;return}vs(w.current)}},[lt,f]),Ys(()=>{let e=x.current;switch(Ds({hasRenderedInput:e!=null,previousRenamingPath:re.current,renamingPath:st})){case`reset`:re.current=null;return;case`reveal-canonical`:st!=null&&Vt(st,{restoreTreeFocus:!1,targetOffset:`live-overlay`});return;case`ignore`:return;case`focus-input`:e!=null&&(je.current=null,re.current=st,vs(e),e.select());return}},[wt.end,wt.start,st,Vt,kt]),Ys(()=>{let e=S.current;if(e==null)return;let t=null,n=()=>{t!=null&&(clearTimeout(t),t=null)},r=()=>{let t=ys(e)?.dataset.itemPath??null;be(e=>e===t?e:t)},i=()=>{n(),N.current=!0,r()},a=i=>{let a=i.relatedTarget;if(a==null){n(),t=setTimeout(()=>{if(t=null,ys(e)!=null){r();return}N.current=!1,be(null)},0);return}if(!(a instanceof Node)||!e.contains(a)){n(),N.current=!1,be(null);return}let o=a instanceof HTMLElement?a.dataset.itemPath??null:null;be(e=>e===o?e:o)};return e.addEventListener(`focusin`,i),e.addEventListener(`focusout`,a),()=>{n(),e.removeEventListener(`focusin`,i),e.removeEventListener(`focusout`,a)}},[]),Ys(()=>{let e=S.current;e!=null&&(xt.physical.scrollTop<=0?e.dataset.scrollAtTop=`true`:delete e.dataset.scrollAtTop)},[xt.physical.scrollTop]),Ys(()=>{let e=null,n=C.current,r=b.current,i=S.current;if(n==null)return;k.current=bs(n,g);let a=()=>{let e=t.getVisibleCount(),r=xs(k.current,g),i=Math.max(0,e*s-r);n.scrollTop>i&&(n.scrollTop=i),Ke(lc({controller:t,itemHeight:s,overscan:c,scrollTop:Math.min(n.scrollTop,i),stickyFolders:h,viewportHeight:r}))};if(!j.current){j.current=!0;let e=t.getFocusedIndex();if(e>=0){let r=xs(k.current,g),i=t.getVisibleRows(e,e)[0]??null;Cs(n,e,s,r,h&&i!=null?Math.max(0,Math.min(i.ancestorPaths.length*s,Math.max(0,r-s))):0)}}D.current=a;let o=!1,l=t.subscribe(()=>{o?ve(e=>e+1):o=!0,a()}),u=()=>{Ie.current!==!0&&(r!=null&&(r.dataset.isScrolling??=``),i!=null&&(i.dataset.isScrolling??=``),y.current=!0,e!=null&&clearTimeout(e),e=setTimeout(()=>{r!=null&&delete r.dataset.isScrolling,i!=null&&delete i.dataset.isScrolling,y.current=!1,Oe(e=>e+1),e=null},50))},d=null,f=()=>{i!=null&&delete i.dataset.overlayReveal,d!=null&&(clearTimeout(d),d=null)},p=()=>{i==null||Ie.current===!0||n.scrollTop>0||(i.dataset.overlayReveal=`true`,d!=null&&clearTimeout(d),d=setTimeout(()=>{f()},200))},m=()=>{if(a(),n.scrollTop>0&&f(),Ae.current!=null&&y.current&&It.current(),Ie.current===!0){y.current=!1;return}Se(e=>e==null?e:null),u()},_=()=>{u(),p()},v=new Set([`ArrowUp`,`ArrowDown`,`ArrowLeft`,`ArrowRight`,`PageUp`,`PageDown`,`Home`,`End`,` `,`Spacebar`]),x=e=>{v.has(e.key)&&_()};n.addEventListener(`scroll`,m,{passive:!0}),n.addEventListener(`wheel`,_,{passive:!0}),n.addEventListener(`touchmove`,_,{passive:!0}),n.addEventListener(`keydown`,x);let w=typeof ResizeObserver<`u`?new ResizeObserver(e=>{k.current=(e[0]==null?null:Ss(e[0]))??bs(n,g),a()}):null;return w?.observe(n),()=>{D.current=()=>{},l(),n.removeEventListener(`scroll`,m),n.removeEventListener(`wheel`,_),n.removeEventListener(`touchmove`,_),n.removeEventListener(`keydown`,x),e!=null&&clearTimeout(e),d!=null&&clearTimeout(d),r!=null&&delete r.dataset.isScrolling,i!=null&&(delete i.dataset.isScrolling,delete i.dataset.overlayReveal),y.current=!1,k.current=null,w?.disconnect()}},[t,g,s,c,h]),Ys(()=>{Ye||F==null||Lt(!1)},[Lt,Ye,F]);let V=Xs(()=>F==null?null:`${F.path}::${F.source}`,[F]);Ys(()=>{if(V==null){m?.clearSlotContent(te);return}let t=Ae.current;if(t==null)return;let n=v.current??_.current;if(n==null)return;let r={anchorElement:n,anchorRect:t.anchorRect??kc(n.getBoundingClientRect()),close:e=>{It.current(e?.restoreFocus??!0)},restoreFocus:()=>{Ft.current&&Pt.current(Ae.current?.path??null)}},i=e?.contextMenu?.render?.(t.item,r)??null;return m?.setSlotContent(te,i),e?.contextMenu?.onOpen?.(t.item,r),Hc(i),queueMicrotask(()=>{i==null||!i.isConnected||document.activeElement===i&&Hc(i)}),()=>{m?.clearSlotContent(te)}},[V,e?.contextMenu,m]),Ys(()=>{F!=null&&t.getItem(F.path)==null&&Lt()},[Lt,F,t]),Ys(()=>{if(F==null)return;let e=S.current?.getRootNode(),t=e instanceof ShadowRoot?e.host:S.current,n=e=>{let n=e.target;n instanceof Node&&(Oc(e)||_.current?.contains(n)!==!0&&t?.contains(n)!==!0&&Lt())},r=e=>{e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),Lt())};return document.addEventListener(`mousedown`,n,!0),document.addEventListener(`keydown`,r,!0),()=>{document.removeEventListener(`mousedown`,n,!0),document.removeEventListener(`keydown`,r,!0)}},[Lt,F]),Ys(()=>{let e=C.current,n=S.current;if(e==null||n==null){ne.current=I;return}let r=I==null?null:T.current.get(I)??null,i=ys(n),a=i?.dataset.itemPath??null,o=ct&&x.current===i,c=f&&w.current===i,l=ie.current&&!lt,u=P.current??0,d=je.current,p=Me.current,m=Ne.current,g=Pe.current,_=i!=null,v=N.current||_,y=ne.current!==I,b=p!=null&&p===I&&I!=null,E=!1,ee=!1;if(dt!=null&&dt.id!==A.current){A.current=dt.id;let n=dt.visibleIndex,r=t.getVisibleRows(n,n)[0]??null;if(r!=null){let t=h?Math.max(0,Math.min(r.ancestorPaths.length*s,Math.max(0,Ct-s))):Ot;E=!0,ee=ws(e,n,s,Ct,Dt,dt.offset,t)}t.clearScrollRequest(dt.id)}let te=!E&&l&&Ts(e,L,s,Ct,Dt,u),O=!E&&d!=null&&d===I&&Ts(e,L,s,Ct,Dt,Ot),k=!E&&m!=null&&m.path===I&&Ts(e,L,s,Ct,Dt,m.viewportOffset),j=!E&&g!=null&&g.path===I&&e.scrollTop!==g.scrollTop;if(j&&(e.scrollTop=g.scrollTop),(j||ee||O||k||te||v&&y&&d!==I&&!b&&Cs(e,L,s,Ct,Ot))&&D.current(),E){ne.current=I;return}if(!v){ne.current=I;return}if(o){ne.current=I;return}if(c&&!l){ne.current=I;return}if(r==null){l&&L>=0&&(Ts(e,L,s,Ct,Dt,u),D.current()),ne.current=I;return}(y||l||d===I||p===I||m?.path===I||g?.path===I||a==null||a!==I)&&(vs(r),d===I&&(je.current=null),p===I&&(Me.current=null),m?.path===I&&(Ne.current=null),g?.path===I&&(Pe.current=null),ie.current=!1,P.current=null),ne.current=I},[t,L,I,At,s,ct,lt,wt,Ct,f,dt,h,Ot,Dt,St]);let tn=L>=0&&L>=xt.visible.startIndex&&L<=xt.visible.endIndex,nn=I!=null&&Tt.some(e=>oc(e.row)===I),rn=tn||nn,an=Ze&&N.current===!0&&rn?I:null,on=Te===`pointer`?xe:null,sn=F?.path??Fe.current??on??an??xe,cn=F?.source===`right-click`;Ys(()=>{y.current&&F==null||Rt(rt(sn))},[F,rt,wt,Ct,De,Tt,sn,Rt,St]);let ln=Zs(e=>{if(y.current||Oc(e))return;let t=e.target;if(!(t instanceof HTMLElement)||t.closest?.(`[data-type="context-menu-trigger"]`)!=null)return;let n=t.closest?.(`[data-file-tree-sticky-row="true"]`),r=t.closest?.(`[data-type="item"]`),i=n instanceof HTMLElement?n.dataset.fileTreeStickyPath??null:r instanceof HTMLElement?r.dataset.itemPath??null:null;i!=null&&Ee(e=>e===`pointer`?e:`pointer`),Se(e=>e===i?e:i)},[]),un=Zs(()=>{Se(null)},[]);Ys(()=>{if(!ft)return;let e=()=>{Jt(),t.cancelDrag()};return window.addEventListener(`dragend`,e),()=>{window.removeEventListener(`dragend`,e),Jt(),t.cancelDrag()}},[t,ft]);let dn=e=>{if(!ft||t.getDragSession()==null||fe.current)return;let n=hc(e.target instanceof HTMLElement?e.target:null);t.setDragTarget(n),Yt(t.getDragSession()?.target??null),Xt(e.clientX,e.clientY),e.dataTransfer!=null&&(e.dataTransfer.dropEffect=`move`),e.preventDefault()},fn=e=>{if(!ft||t.getDragSession()==null||fe.current)return;let n=e.relatedTarget;n instanceof Node&&S.current?.contains(n)===!0||(Wt(),Kt(),t.setDragTarget(null))},pn=e=>{!ft||t.getDragSession()==null||fe.current||(e.preventDefault(),z(e.clientX,e.clientY),t.completeDrag(),Gt(),Wt(),Kt(),ue.current=null)},mn=xt.window.height,hn=xt.window.offsetTop,gn=Math.min(0,Ct-mn),_n=Math.min(0,Ct-mn-Ot),vn=ye===I||ie.current,yn=I!=null&&vn&&!At&&L>=0?St[L]??t.getVisibleRows(L,L)[0]??null:null,bn=yn==null?null:Es(L,s,wt,mn),xn=ue.current,Sn=_t!=null&&xn!=null&&xn.path===_t&&xn.index>=wt.start&&xn.index<=wt.end,Cn=_t!=null&&xn!=null&&xn.path===_t&&!Sn&&xn.path!==yn?.path?xn:null,wn=Cn==null?null:Es(Cn.index,s,wt,mn),Tn=wc((L>=0?St[L]??t.getVisibleRows(L,L)[0]??null:null)?.ancestorPaths.at(-1)??null),En=lt&&I!=null?zc(o,I,!At):void 0,Dn=F?.path??(lt?I:ye),On=F?.path??xe,kn=rt(sn),An=Ye&&Ze&&!cn&&!ct&&kn!=null&&Ce!=null&&sn!=null,jn=Ye&&(An||F!=null),Mn=F?.anchorRect,Nn=Mn==null&&kn!=null&&Ce!=null&&(F!=null||An)?Ce:null,Pn=Mn==null?Nn==null?void 0:{top:`${Nn}px`}:{left:`${Mn.left}px`,position:`fixed`,right:`auto`,top:`${Mn.top}px`},Fn=cn?{opacity:`0`}:void 0,In=Zs((e,n,r,i)=>{let a=As({event:{ctrlKey:e.ctrlKey,metaKey:e.metaKey,shiftKey:e.shiftKey},isDirectory:n.kind===`directory`,isSearchOpen:lt,mode:i}),o=a.toggleDirectory&&n.kind===`directory`,s=o?t.resolveMountedDirectoryPathFromInput(r):null;if(o&&s==null)return;let c=s??r;switch(a.selection.kind){case`range`:t.selectPathRange(c,a.selection.additive);break;case`toggle`:t.togglePathSelectionFromInput(c);break;case`single`:t.selectOnlyMountedPathFromInput(c);break}let l=e.currentTarget instanceof HTMLElement?e.currentTarget:null,u=n.index>=xt.visible.startIndex&&n.index<=xt.visible.endIndex,d=i===`flow`&&u&&l!=null&&l.dataset.itemParked!==`true`;t.focusMountedPathFromInput(c),d&&(N.current=!0,be(e=>e===c?e:c),Ee(`focus`)),o&&t.toggleMountedDirectoryFromInput(c),a.closeSearch&&t.closeSearch(),a.revealCanonical&&Vt(c,{targetOffset:`sticky-parents`})},[t,lt,xt.visible.endIndex,xt.visible.startIndex,Vt]),Ln=()=>{if(y.current||!Ze||sn==null||kn==null)return;let e=t.getItem(sn);e!=null&&(Rt(kn),Ft.current=!0,ke({anchorRect:null,item:{kind:e.isDirectory()?`directory`:`file`,name:kn.getAttribute(`aria-label`)??sn,path:e.getPath()},path:e.getPath(),source:`button`}))},Rn={contextHoverPath:On,contextMenuButtonTriggerEnabled:Ze,contextMenuButtonVisibility:Qe,contextMenuEnabled:Ye,contextMenuRightClickEnabled:$e,contextMenuTriggerMode:Xe,controller:t,directoriesWithGitChanges:i,dragAndDropEnabled:ft,draggedPathSet:mt,dragTarget:ht,gitLaneActive:it,gitStatusByPath:n,handleRowDragEnd:Qt,handleRowDragStart:Zt,handleRowTouchStart:$t,ignoredGitDirectories:r,ignoredInheritanceCache:_e,instanceId:o,itemHeight:s,onKeyDown:en,onRowClick:In,openContextMenuForRow:zt,registerButton:et,registerRenameInput:nt,renameView:ot,renderDecorationForRow:jt,resolveIcon:at,shouldSuppressContextMenu:Ht,visualFocusPath:Dn},zn={...Rn,registerButton:tt};return J(`div`,{ref:S,id:vt,"data-file-tree-context-menu-button-visibility":Ye&&Ze?Qe:void 0,"data-file-tree-context-menu-trigger-mode":Ye?Xe:void 0,"data-file-tree-has-context-menu-action-lane":Ye&&Ze?`true`:void 0,"data-file-tree-has-git-lane":it?`true`:void 0,"data-file-tree-virtualized-root":`true`,onDragLeave:ft?fn:void 0,onDragOver:ft?dn:void 0,onDrop:ft?pn:void 0,onKeyDown:en,onPointerLeave:Ye?un:void 0,onPointerOver:Ye?ln:void 0,role:`tree`,tabIndex:-1,style:{outline:`none`,position:`relative`},children:[J(`style`,{"data-file-tree-guide-style":`true`,dangerouslySetInnerHTML:{__html:Tn}}),J(`slot`,{name:ee,"data-type":`header-slot`}),f?J(`div`,{"data-file-tree-search-container":!0,"data-open":lt?`true`:`false`,children:J(`input`,{ref:w,"aria-activedescendant":En,"aria-controls":vt,placeholder:`Search…`,"data-file-tree-search-input":!0,"data-file-tree-search-input-fake-focus":Ve?`true`:void 0,value:ut,onBlur:()=>{d===`retain`&&!Ue.current||t.closeSearch()},onFocus:We,onPointerDown:We,onInput:e=>{We();let n=e.currentTarget;t.setSearch(n.value)}})}):null,J(`div`,{ref:C,"data-file-tree-virtualized-scroll":`true`,children:[h&&qe&&Tt.length>0?J(`div`,{"aria-hidden":`true`,"data-file-tree-sticky-overlay":`true`,children:J(`div`,{"data-file-tree-sticky-overlay-content":`true`,style:{height:`${yt}px`},children:Tt.map((e,t)=>Uc(zn,e.row,`sticky:${oc(e.row)}`,{mode:`sticky`,style:{left:`0`,position:`absolute`,right:`0`,top:`${e.top}px`,zIndex:`${Tt.length-t}`}}))})}):null,J(`div`,{ref:b,"data-file-tree-virtualized-list":`true`,style:{height:`${Dt}px`},children:[J(`div`,{"data-file-tree-virtualized-sticky-offset":`true`,"aria-hidden":`true`,style:{height:`${hn}px`}}),J(`div`,{"data-file-tree-virtualized-sticky":`true`,style:{height:`${mn}px`,top:`${gn}px`,bottom:`${_n}px`},children:[Wc(Rn,wt,kt),yn!=null&&bn!=null?Uc(Rn,yn,`parked:${yn.path}`,{isParked:!0,style:{left:`0`,opacity:`0`,pointerEvents:_t===yn.path?`none`:void 0,position:`absolute`,right:`0`,top:`${bn}px`}}):null,Cn!=null&&wn!=null?Uc(Rn,Cn,`parked-drag:${Cn.path}`,{isParked:!0,style:{left:`0`,opacity:`0`,pointerEvents:`none`,position:`absolute`,right:`0`,top:`${wn}px`}}):null]})]})]}),Ye?J(`div`,{ref:_,"data-type":`context-menu-anchor`,"data-visible":jn?`true`:`false`,style:Pn,children:[J(`button`,{ref:v,type:`button`,"data-type":O,"aria-label":`Options`,"aria-haspopup":`menu`,"aria-expanded":F==null?`false`:`true`,"data-visible":An?`true`:`false`,onMouseDown:e=>{e.preventDefault()},onClick:e=>{if(e.preventDefault(),e.stopPropagation(),F!=null){Lt();return}Ln()},tabIndex:-1,style:Fn,children:J(Vo,{...at(`file-tree-icon-ellipsis`)})}),F==null?null:J(`slot`,{name:te})]}):null,F==null?null:J(`div`,{"data-type":`context-menu-wash`,"aria-hidden":`true`,onMouseDownCapture:e=>{e.preventDefault(),Lt()},onTouchStartCapture:e=>{e.preventDefault(),e.stopPropagation(),Lt()},onTouchMoveCapture:e=>{e.preventDefault(),e.stopPropagation()},onWheelCapture:e=>{e.preventDefault(),e.stopPropagation()}})]})}var Kc={hydrateRoot:(e,t)=>{Io(fo(Gc,t),e)},renderRoot:(e,t)=>{Fo(fo(Gc,t),e)},unmountRoot:e=>{Fo(null,e)}};function qc(e,t){Kc.renderRoot(e,t)}function Jc(e,t){Kc.hydrateRoot(e,t)}function Yc(e){Kc.unmountRoot(e)}var Xc=class{#e=new Map;#t=null;clearAll(){for(let e of this.#e.values())e.remove();this.#e.clear()}clearSlotContent(e){let t=this.#n(e);t!=null&&(t.remove(),this.#e.delete(e))}setHost(e){if(this.#t=e,e!=null){this.#i(e);for(let[e,t]of this.#e)this.#r(e,t)}}setSlotContent(e,t){let n=this.#n(e);if(n===t){t!=null&&(this.#e.set(e,t),this.#r(e,t));return}if(n?.remove(),t==null){this.#e.delete(e);return}this.#e.set(e,t),this.#r(e,t)}setSlotHtml(e,t){let n=t?.trim()??``;if(n.length===0){this.setSlotContent(e,null);return}let r=this.#n(e);if(r!=null&&r.innerHTML===n){this.#e.set(e,r),this.#r(e,r);return}let i=document.createElement(`div`);i.innerHTML=n,this.setSlotContent(e,i)}#n(e){let t=this.#e.get(e)??null;if(t!=null)return t;let n=this.#t;if(n==null)return null;for(let t of Array.from(n.children))if(t instanceof HTMLElement&&t.dataset.fileTreeManagedSlot===e)return t;return null}#r(e,t){t.slot=e,t.dataset.fileTreeManagedSlot=e,this.#t!=null&&t.parentNode!==this.#t&&this.#t.appendChild(t)}#i(e){for(let t of Array.from(e.children)){if(!(t instanceof HTMLElement))continue;let e=t.dataset.fileTreeManagedSlot;e==null||this.#e.has(e)||this.#e.set(e,t)}}},Zc,Q,Qc,$c,el,tl,nl,rl,il,al,ol,sl,cl,ll,ul={},dl=[],fl=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,pl=Array.isArray;function ml(e,t){for(var n in t)e[n]=t[n];return e}function hl(e){e&&e.parentNode&&e.parentNode.removeChild(e)}function gl(e,t,n,r,i){var a={type:e,props:t,key:n,ref:r,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:i??++Qc,__i:-1,__u:0};return i==null&&Q.vnode!=null&&Q.vnode(a),a}function _l(e){return e.children}function vl(e,t){this.props=e,this.context=t}function yl(e,t){if(t==null)return e.__?yl(e.__,e.__i+1):null;for(var n;t<e.__k.length;t++)if((n=e.__k[t])!=null&&n.__e!=null)return n.__e;return typeof e.type==`function`?yl(e):null}function bl(e){if(e.__P&&e.__d){var t=e.__v,n=t.__e,r=[],i=[],a=ml({},t);a.__v=t.__v+1,Q.vnode&&Q.vnode(a),jl(e.__P,a,t,e.__n,e.__P.namespaceURI,32&t.__u?[n]:null,r,n??yl(t),!!(32&t.__u),i),a.__v=t.__v,a.__.__k[a.__i]=a,Nl(r,a,i),t.__e=t.__=null,a.__e!=n&&xl(a)}}function xl(e){if((e=e.__)!=null&&e.__c!=null)return e.__e=e.__c.base=null,e.__k.some(function(t){if(t!=null&&t.__e!=null)return e.__e=e.__c.base=t.__e}),xl(e)}function Sl(e){(!e.__d&&(e.__d=!0)&&$c.push(e)&&!Cl.__r++||el!=Q.debounceRendering)&&((el=Q.debounceRendering)||tl)(Cl)}function Cl(){try{for(var e,t=1;$c.length;)$c.length>t&&$c.sort(nl),e=$c.shift(),t=$c.length,bl(e)}finally{$c.length=Cl.__r=0}}function wl(e,t,n,r,i,a,o,s,c,l,u){var d,f,p,m,h,g,_,v=r&&r.__k||dl,y=t.length;for(c=Tl(n,t,v,c,y),d=0;d<y;d++)(p=n.__k[d])!=null&&(f=p.__i!=-1&&v[p.__i]||ul,p.__i=d,g=jl(e,p,f,i,a,o,s,c,l,u),m=p.__e,p.ref&&f.ref!=p.ref&&(f.ref&&Il(f.ref,null,p),u.push(p.ref,p.__c||m,p)),h==null&&m!=null&&(h=m),(_=!!(4&p.__u))||f.__k===p.__k?(c=El(p,c,e,_),_&&f.__e&&(f.__e=null)):typeof p.type==`function`&&g!==void 0?c=g:m&&(c=m.nextSibling),p.__u&=-7);return n.__e=h,c}function Tl(e,t,n,r,i){var a,o,s,c,l,u=n.length,d=u,f=0;for(e.__k=Array(i),a=0;a<i;a++)(o=t[a])!=null&&typeof o!=`boolean`&&typeof o!=`function`?(typeof o==`string`||typeof o==`number`||typeof o==`bigint`||o.constructor==String?o=e.__k[a]=gl(null,o,null,null,null):pl(o)?o=e.__k[a]=gl(_l,{children:o},null,null,null):o.constructor===void 0&&o.__b>0?o=e.__k[a]=gl(o.type,o.props,o.key,o.ref?o.ref:null,o.__v):e.__k[a]=o,c=a+f,o.__=e,o.__b=e.__b+1,s=null,(l=o.__i=Dl(o,n,c,d))!=-1&&(d--,(s=n[l])&&(s.__u|=2)),s==null||s.__v==null?(l==-1&&(i>u?f--:i<u&&f++),typeof o.type!=`function`&&(o.__u|=4)):l!=c&&(l==c-1?f--:l==c+1?f++:(l>c?f--:f++,o.__u|=4))):e.__k[a]=null;if(d)for(a=0;a<u;a++)(s=n[a])!=null&&!(2&s.__u)&&(s.__e==r&&(r=yl(s)),Ll(s,s));return r}function El(e,t,n,r){var i,a;if(typeof e.type==`function`){for(i=e.__k,a=0;i&&a<i.length;a++)i[a]&&(i[a].__=e,t=El(i[a],t,n,r));return t}e.__e!=t&&(r&&(t&&e.type&&!t.parentNode&&(t=yl(e)),n.insertBefore(e.__e,t||null)),t=e.__e);do t&&=t.nextSibling;while(t!=null&&t.nodeType==8);return t}function Dl(e,t,n,r){var i,a,o,s=e.key,c=e.type,l=t[n],u=l!=null&&(2&l.__u)==0;if(l===null&&s==null||u&&s==l.key&&c==l.type)return n;if(r>+!!u){for(i=n-1,a=n+1;i>=0||a<t.length;)if((l=t[o=i>=0?i--:a++])!=null&&!(2&l.__u)&&s==l.key&&c==l.type)return o}return-1}function Ol(e,t,n){t[0]==`-`?e.setProperty(t,n??``):e[t]=n==null?``:typeof n!=`number`||fl.test(t)?n:n+`px`}function kl(e,t,n,r,i){var a,o;n:if(t==`style`)if(typeof n==`string`)e.style.cssText=n;else{if(typeof r==`string`&&(e.style.cssText=r=``),r)for(t in r)n&&t in n||Ol(e.style,t,``);if(n)for(t in n)r&&n[t]==r[t]||Ol(e.style,t,n[t])}else if(t[0]==`o`&&t[1]==`n`)a=t!=(t=t.replace(ol,`$1`)),o=t.toLowerCase(),t=o in e||t==`onFocusOut`||t==`onFocusIn`?o.slice(2):t.slice(2),e.l||={},e.l[t+a]=n,n?r?n[al]=r[al]:(n[al]=sl,e.addEventListener(t,a?ll:cl,a)):e.removeEventListener(t,a?ll:cl,a);else{if(i==`http://www.w3.org/2000/svg`)t=t.replace(/xlink(H|:h)/,`h`).replace(/sName$/,`s`);else if(t!=`width`&&t!=`height`&&t!=`href`&&t!=`list`&&t!=`form`&&t!=`tabIndex`&&t!=`download`&&t!=`rowSpan`&&t!=`colSpan`&&t!=`role`&&t!=`popover`&&t in e)try{e[t]=n??``;break n}catch{}typeof n==`function`||(n==null||!1===n&&t[4]!=`-`?e.removeAttribute(t):e.setAttribute(t,t==`popover`&&n==1?``:n))}}function Al(e){return function(t){if(this.l){var n=this.l[t.type+e];if(t[il]==null)t[il]=sl++;else if(t[il]<n[al])return;return n(Q.event?Q.event(t):t)}}}function jl(e,t,n,r,i,a,o,s,c,l){var u,d,f,p,m,h,g,_,v,y,b,x,S,C,w,T=t.type;if(t.constructor!==void 0)return null;128&n.__u&&(c=!!(32&n.__u),a=[s=t.__e=n.__e]),(u=Q.__b)&&u(t);n:if(typeof T==`function`)try{if(_=t.props,v=T.prototype&&T.prototype.render,y=(u=T.contextType)&&r[u.__c],b=u?y?y.props.value:u.__:r,n.__c?g=(d=t.__c=n.__c).__=d.__E:(v?t.__c=d=new T(_,b):(t.__c=d=new vl(_,b),d.constructor=T,d.render=Rl),y&&y.sub(d),d.state||={},d.__n=r,f=d.__d=!0,d.__h=[],d._sb=[]),v&&d.__s==null&&(d.__s=d.state),v&&T.getDerivedStateFromProps!=null&&(d.__s==d.state&&(d.__s=ml({},d.__s)),ml(d.__s,T.getDerivedStateFromProps(_,d.__s))),p=d.props,m=d.state,d.__v=t,f)v&&T.getDerivedStateFromProps==null&&d.componentWillMount!=null&&d.componentWillMount(),v&&d.componentDidMount!=null&&d.__h.push(d.componentDidMount);else{if(v&&T.getDerivedStateFromProps==null&&_!==p&&d.componentWillReceiveProps!=null&&d.componentWillReceiveProps(_,b),t.__v==n.__v||!d.__e&&d.shouldComponentUpdate!=null&&!1===d.shouldComponentUpdate(_,d.__s,b)){t.__v!=n.__v&&(d.props=_,d.state=d.__s,d.__d=!1),t.__e=n.__e,t.__k=n.__k,t.__k.some(function(e){e&&(e.__=t)}),dl.push.apply(d.__h,d._sb),d._sb=[],d.__h.length&&o.push(d);break n}d.componentWillUpdate!=null&&d.componentWillUpdate(_,d.__s,b),v&&d.componentDidUpdate!=null&&d.__h.push(function(){d.componentDidUpdate(p,m,h)})}if(d.context=b,d.props=_,d.__P=e,d.__e=!1,x=Q.__r,S=0,v)d.state=d.__s,d.__d=!1,x&&x(t),u=d.render(d.props,d.state,d.context),dl.push.apply(d.__h,d._sb),d._sb=[];else do d.__d=!1,x&&x(t),u=d.render(d.props,d.state,d.context),d.state=d.__s;while(d.__d&&++S<25);d.state=d.__s,d.getChildContext!=null&&(r=ml(ml({},r),d.getChildContext())),v&&!f&&d.getSnapshotBeforeUpdate!=null&&(h=d.getSnapshotBeforeUpdate(p,m)),C=u!=null&&u.type===_l&&u.key==null?Pl(u.props.children):u,s=wl(e,pl(C)?C:[C],t,n,r,i,a,o,s,c,l),d.base=t.__e,t.__u&=-161,d.__h.length&&o.push(d),g&&(d.__E=d.__=null)}catch(e){if(t.__v=null,c||a!=null)if(e.then){for(t.__u|=c?160:128;s&&s.nodeType==8&&s.nextSibling;)s=s.nextSibling;a[a.indexOf(s)]=null,t.__e=s}else{for(w=a.length;w--;)hl(a[w]);Ml(t)}else t.__e=n.__e,t.__k=n.__k,e.then||Ml(t);Q.__e(e,t,n)}else a==null&&t.__v==n.__v?(t.__k=n.__k,t.__e=n.__e):s=t.__e=Fl(n.__e,t,n,r,i,a,o,c,l);return(u=Q.diffed)&&u(t),128&t.__u?void 0:s}function Ml(e){e&&(e.__c&&(e.__c.__e=!0),e.__k&&e.__k.some(Ml))}function Nl(e,t,n){for(var r=0;r<n.length;r++)Il(n[r],n[++r],n[++r]);Q.__c&&Q.__c(t,e),e.some(function(t){try{e=t.__h,t.__h=[],e.some(function(e){e.call(t)})}catch(e){Q.__e(e,t.__v)}})}function Pl(e){return typeof e!=`object`||!e||e.__b>0?e:pl(e)?e.map(Pl):e.constructor===void 0?ml({},e):null}function Fl(e,t,n,r,i,a,o,s,c){var l,u,d,f,p,m,h,g=n.props||ul,_=t.props,v=t.type;if(v==`svg`?i=`http://www.w3.org/2000/svg`:v==`math`?i=`http://www.w3.org/1998/Math/MathML`:i||=`http://www.w3.org/1999/xhtml`,a!=null){for(l=0;l<a.length;l++)if((p=a[l])&&`setAttribute`in p==!!v&&(v?p.localName==v:p.nodeType==3)){e=p,a[l]=null;break}}if(e==null){if(v==null)return document.createTextNode(_);e=document.createElementNS(i,v,_.is&&_),s&&=(Q.__m&&Q.__m(t,a),!1),a=null}if(v==null)g===_||s&&e.data==_||(e.data=_);else{if(a=v==`textarea`&&_.defaultValue!=null?null:a&&Zc.call(e.childNodes),!s&&a!=null)for(g={},l=0;l<e.attributes.length;l++)g[(p=e.attributes[l]).name]=p.value;for(l in g)p=g[l],l==`dangerouslySetInnerHTML`?d=p:l==`children`||l in _||l==`value`&&`defaultValue`in _||l==`checked`&&`defaultChecked`in _||kl(e,l,null,p,i);for(l in _)p=_[l],l==`children`?f=p:l==`dangerouslySetInnerHTML`?u=p:l==`value`?m=p:l==`checked`?h=p:s&&typeof p!=`function`||g[l]===p||kl(e,l,p,g[l],i);if(u)s||d&&(u.__html==d.__html||u.__html==e.innerHTML)||(e.innerHTML=u.__html),t.__k=[];else if(d&&(e.innerHTML=``),wl(t.type==`template`?e.content:e,pl(f)?f:[f],t,n,r,v==`foreignObject`?`http://www.w3.org/1999/xhtml`:i,a,o,a?a[0]:n.__k&&yl(n,0),s,c),a!=null)for(l=a.length;l--;)hl(a[l]);s&&v!=`textarea`||(l=`value`,v==`progress`&&m==null?e.removeAttribute(`value`):m!=null&&(m!==e[l]||v==`progress`&&!m||v==`option`&&m!=g[l])&&kl(e,l,m,g[l],i),l=`checked`,h!=null&&h!=e[l]&&kl(e,l,h,g[l],i))}return e}function Il(e,t,n){try{if(typeof e==`function`){var r=typeof e.__u==`function`;r&&e.__u(),r&&t==null||(e.__u=e(t))}else e.current=t}catch(e){Q.__e(e,n)}}function Ll(e,t,n){var r,i;if(Q.unmount&&Q.unmount(e),(r=e.ref)&&(r.current&&r.current!=e.__e||Il(r,null,t)),(r=e.__c)!=null){if(r.componentWillUnmount)try{r.componentWillUnmount()}catch(e){Q.__e(e,t)}r.base=r.__P=null}if(r=e.__k)for(i=0;i<r.length;i++)r[i]&&Ll(r[i],t,n||typeof e.type!=`function`);n||hl(e.__e),e.__c=e.__=e.__e=void 0}function Rl(e,t,n){return this.constructor(e,n)}Zc=dl.slice,Q={__e:function(e,t,n,r){for(var i,a,o;t=t.__;)if((i=t.__c)&&!i.__)try{if((a=i.constructor)&&a.getDerivedStateFromError!=null&&(i.setState(a.getDerivedStateFromError(e)),o=i.__d),i.componentDidCatch!=null&&(i.componentDidCatch(e,r||{}),o=i.__d),o)return i.__E=i}catch(t){e=t}throw e}},Qc=0,vl.prototype.setState=function(e,t){var n=this.__s!=null&&this.__s!=this.state?this.__s:this.__s=ml({},this.state);typeof e==`function`&&(e=e(ml({},n),this.props)),e&&ml(n,e),e!=null&&this.__v&&(t&&this._sb.push(t),Sl(this))},vl.prototype.forceUpdate=function(e){this.__v&&(this.__e=!0,e&&this.__h.push(e),Sl(this))},vl.prototype.render=_l,$c=[],tl=typeof Promise==`function`?Promise.prototype.then.bind(Promise.resolve()):setTimeout,nl=function(e,t){return e.__v.__b-t.__v.__b},Cl.__r=0,rl=Math.random().toString(8),il=`__d`+rl,al=`__a`+rl,ol=/(PointerCapture)$|Capture$/i,sl=0,cl=Al(!1),ll=Al(!0);var $=`__c`,zl=`__k`,Bl=`__d`,Vl=`__s`,Hl=/[\s\n\\/='"\0<>]/,Ul=/^(xlink|xmlns|xml)([A-Z])/,Wl=/^(?:accessK|auto[A-Z]|cell|ch|col|cont|cross|dateT|encT|form[A-Z]|frame|hrefL|inputM|maxL|minL|noV|playsI|popoverT|readO|rowS|src[A-Z]|tabI|useM|item[A-Z])/,Gl=/^ac|^ali|arabic|basel|cap|clipPath$|clipRule$|color|dominant|enable|fill|flood|font|glyph[^R]|horiz|image|letter|lighting|marker[^WUH]|overline|panose|pointe|paint|rendering|shape|stop|strikethrough|stroke|text[^L]|transform|underline|unicode|units|^v[^i]|^w|^xH/,Kl=new Set([`draggable`,`spellcheck`]);function ql(e){e.__g===void 0?e[Bl]=!0:e.__g|=8}function Jl(e){e.__g===void 0?e[Bl]=!1:e.__g&=-9}function Yl(e){return e.__g===void 0?!0===e[Bl]:!!(8&e.__g)}var Xl=/["&<]/;function Zl(e){if(e.length===0||!1===Xl.test(e))return e;for(var t=0,n=0,r=``,i=``;n<e.length;n++){switch(e.charCodeAt(n)){case 34:i=`&quot;`;break;case 38:i=`&amp;`;break;case 60:i=`&lt;`;break;default:continue}n!==t&&(r+=e.slice(t,n)),r+=i,t=n+1}return n!==t&&(r+=e.slice(t,n)),r}var Ql={},$l=new Set(`animation-iteration-count.border-image-outset.border-image-slice.border-image-width.box-flex.box-flex-group.box-ordinal-group.column-count.fill-opacity.flex.flex-grow.flex-negative.flex-order.flex-positive.flex-shrink.flood-opacity.font-weight.grid-column.grid-row.line-clamp.line-height.opacity.order.orphans.stop-opacity.stroke-dasharray.stroke-dashoffset.stroke-miterlimit.stroke-opacity.stroke-width.tab-size.widows.z-index.zoom`.split(`.`)),eu=/[A-Z]/g;function tu(e){var t=``;for(var n in e){var r=e[n];if(r!=null&&r!==``){var i=n[0]==`-`?n:Ql[n]||(Ql[n]=n.replace(eu,`-$&`).toLowerCase()),a=`;`;typeof r!=`number`||i.startsWith(`--`)||$l.has(i)||(a=`px;`),t=t+i+`:`+r+a}}return t||void 0}function nu(){this.__d=!0}function ru(e,t){return{__v:e,context:t,props:e.props,setState:nu,forceUpdate:nu,__d:!0,__h:[]}}function iu(e,t,n){if(!e.s){if(n instanceof au){if(!n.s)return void(n.o=iu.bind(null,e,t));1&t&&(t=n.s),n=n.v}if(n&&n.then)return void n.then(iu.bind(null,e,t),iu.bind(null,e,2));e.s=t,e.v=n;let r=e.o;r&&r(e)}}var au=function(){function e(){}return e.prototype.then=function(t,n){var r=new e,i=this.s;if(i){var a=1&i?t:n;if(a){try{iu(r,1,a(this.v))}catch(e){iu(r,2,e)}return r}return this}return this.o=function(e){try{var i=e.v;1&e.s?iu(r,1,t?t(i):i):n?iu(r,1,n(i)):iu(r,2,i)}catch(e){iu(r,2,e)}},r},e}(),ou,su,cu,lu,uu={},du=Array.isArray,fu=Object.assign,pu=``,mu=`<!--$s-->`,hu=`<!--/$s-->`;function gu(e,t){var n,r=e.type,i=!0;return e[$]?(i=!1,(n=e[$]).state=n[Vl]):n=new r(e.props,t),e[$]=n,n.__v=e,n.props=e.props,n.context=t,ql(n),n.state??=uu,n[Vl]??(n[Vl]=n.state),r.getDerivedStateFromProps?n.state=fu({},n.state,r.getDerivedStateFromProps(n.props,n.state)):i&&n.componentWillMount?(n.componentWillMount(),n.state=n[Vl]===n.state?n.state:n[Vl]):!i&&n.componentWillUpdate&&n.componentWillUpdate(),cu&&cu(e),n.render(n.props,n.state,t)}function _u(e,t,n,r,i,a,o){if(e==null||!0===e||!1===e||e===pu)return pu;var s=typeof e;if(s!=`object`)return s==`function`?pu:s==`string`?Zl(e):e+pu;if(du(e)){var c,l=pu;i[zl]=e;for(var u=e.length,d=0;d<u;d++){var f=e[d];if(f!=null&&typeof f!=`boolean`){var p,m=_u(f,t,n,r,i,a,o);typeof m==`string`?l+=m:(c||=Array(u),l&&c.push(l),l=pu,du(m)?(p=c).push.apply(p,m):c.push(m))}}return c?(l&&c.push(l),c):l}if(e.constructor!==void 0)return pu;e.__=i,ou&&ou(e);var h=e.type,g=e.props;if(typeof h==`function`){var _,v,y,b=t;if(h===_l){if(`tpl`in g){for(var x=pu,S=0;S<g.tpl.length;S++)if(x+=g.tpl[S],g.exprs&&S<g.exprs.length){var C=g.exprs[S];if(C==null)continue;typeof C!=`object`||C.constructor!==void 0&&!du(C)?x+=C:x+=_u(C,t,n,r,e,a,o)}return x}if(`UNSTABLE_comment`in g)return`<!--`+Zl(g.UNSTABLE_comment)+`-->`;v=g.children}else{if((_=h.contextType)!=null){var w=t[_.__c];b=w?w.props.value:_.__}var T=h.prototype&&typeof h.prototype.render==`function`;if(T)v=gu(e,b),y=e[$];else{e[$]=y=ru(e,b);for(var E=0;Yl(y)&&E++<25;){Jl(y),cu&&cu(e);try{v=h.call(y,g,b)}catch(t){throw a&&t&&typeof t.then==`function`&&(e._suspended=!0),t}}ql(y)}if(y.getChildContext!=null&&(t=fu({},t,y.getChildContext())),T&&Q.errorBoundaries&&(h.getDerivedStateFromError||y.componentDidCatch)){v=v!=null&&v.type===_l&&v.key==null&&v.props.tpl==null?v.props.children:v;try{return _u(v,t,n,r,e,a,!1)}catch(i){return h.getDerivedStateFromError&&(y[Vl]=h.getDerivedStateFromError(i)),y.componentDidCatch&&y.componentDidCatch(i,uu),Yl(y)?(v=gu(e,t),(y=e[$]).getChildContext!=null&&(t=fu({},t,y.getChildContext())),_u(v=v!=null&&v.type===_l&&v.key==null&&v.props.tpl==null?v.props.children:v,t,n,r,e,a,o)):pu}finally{su&&su(e),lu&&lu(e)}}}v=v!=null&&v.type===_l&&v.key==null&&v.props.tpl==null?v.props.children:v;try{var D=_u(v,t,n,r,e,a,o);return su&&su(e),Q.unmount&&Q.unmount(e),e._suspended?typeof D==`string`?mu+D+hu:du(D)?(D.unshift(mu),D.push(hu),D):D.then(function(e){return mu+e+hu}):D}catch(i){if(!a&&o&&o.onError){var ee=function i(s){return o.onError(s,e,function(e,s){try{return _u(e,t,n,r,s,a,o)}catch(e){return i(e)}})}(i);if(ee!==void 0)return ee;var te=Q.__e;return te&&te(i,e),pu}if(!a||!i||typeof i.then!=`function`)throw i;return i.then(function i(){try{var s=_u(v,t,n,r,e,a,o);return e._suspended?mu+s+hu:s}catch(e){if(!e||typeof e.then!=`function`)throw e;return e.then(i)}})}}var O,k=`<`+h,A=pu;for(var j in g){var M=g[j];if(typeof(M=yu(M)?M.value:M)!=`function`||j===`class`||j===`className`){switch(j){case`children`:O=M;continue;case`key`:case`ref`:case`__self`:case`__source`:continue;case`htmlFor`:if(`for`in g)continue;j=`for`;break;case`className`:if(`class`in g)continue;j=`class`;break;case`defaultChecked`:j=`checked`;break;case`defaultSelected`:j=`selected`;break;case`defaultValue`:case`value`:switch(j=`value`,h){case`textarea`:O=M;continue;case`select`:r=M;continue;case`option`:r!=M||`selected`in g||(k+=` selected`)}break;case`dangerouslySetInnerHTML`:A=M&&M.__html;continue;case`style`:typeof M==`object`&&(M=tu(M));break;case`acceptCharset`:j=`accept-charset`;break;case`httpEquiv`:j=`http-equiv`;break;default:if(Ul.test(j))j=j.replace(Ul,`$1:$2`).toLowerCase();else{if(Hl.test(j))continue;j[4]!==`-`&&!Kl.has(j)||M==null?n?Gl.test(j)&&(j=j===`panose1`?`panose-1`:j.replace(/([A-Z])/g,`-$1`).toLowerCase()):Wl.test(j)&&(j=j.toLowerCase()):M+=pu}}M!=null&&!1!==M&&(k=!0===M||M===pu?k+` `+j:k+` `+j+`="`+(typeof M==`string`?Zl(M):M+pu)+`"`)}}if(Hl.test(h))throw Error(h+` is not a valid HTML tag name in `+k+`>`);if(A||(typeof O==`string`?A=Zl(O):O!=null&&!1!==O&&!0!==O&&(A=_u(O,t,h===`svg`||h!==`foreignObject`&&n,r,e,a,o))),su&&su(e),lu&&lu(e),!A&&vu.has(h))return k+`/>`;var N=`</`+h+`>`,ne=k+`>`;return du(A)?[ne].concat(A,[N]):typeof A==`string`?ne+A+N:[ne,A,N]}var vu=new Set([`area`,`base`,`br`,`col`,`command`,`embed`,`hr`,`img`,`input`,`keygen`,`link`,`meta`,`param`,`source`,`track`,`wbr`]);function yu(e){return typeof e==`object`&&!!e&&typeof e.peek==`function`&&`value`in e}var bu=0;function xu(e){return e!=null&&e.length>0?e:(bu+=1,`pst_ft_${bu}`)}function Su({initialVisibleRowCount:e,itemHeight:t}){return e==null?420:Math.max(0,e)*(t??gt)}function Cu(e){if(typeof document>`u`)return;let t=document.createElement(`div`);t.innerHTML=e;let n=t.querySelector(`svg`);return n instanceof SVGElement?n:void 0}function wu(e){return e.querySelector(`#file-tree-icon-chevron`)instanceof SVGElement&&e.querySelector(`#file-tree-icon-file`)instanceof SVGElement&&e.querySelector(`#file-tree-icon-dot`)instanceof SVGElement&&e.querySelector(`#file-tree-icon-lock`)instanceof SVGElement}function Tu(e){return Array.from(e.children).filter(e=>e instanceof SVGElement)}var Eu=class{static LoadedCustomComponent=!0;#e;#t;#n;#r;#i;#a;#o;#s;#c;#l=new Xc;#u;#d;#f;#p;#m;#h;#g;#_;#v;#y=null;#b;#x=!1;#S=!1;constructor(e){let{composition:t,density:n,fileTreeSearchMode:r,gitStatus:i,id:a,initialSearchQuery:o,icons:s,itemHeight:c,onSearchChange:l,onSelectionChange:u,overscan:d,renderRowDecoration:f,renaming:p,search:m,searchBlurBehavior:h,searchFakeFocus:g,stickyFolders:_,unsafeCSS:v,initialVisibleRowCount:y,...b}=e;this.#e=t,this.#n=xu(a),this.#p=Wa(i),this.#m=s,this.#h=v,this.#r=u,this.#i=f,this.#a=p!=null&&p!==!1,this.#o=h,this.#s=m===!0,this.#c=g===!0,this.#u=ht(n,c),this.#d={itemHeight:this.#u.itemHeight,overscan:d,stickyFolders:_,initialVisibleRowCount:y},this.#t=new za({...b,fileTreeSearchMode:r,initialSearchQuery:o,onSearchChange:l,renaming:p}),this.#v=this.#t.getSelectionVersion(),this.#y=this.#r==null?null:this.subscribe(()=>{this.#D()})}unmount(){this.#b!=null&&(Yc(this.#b),delete this.#b.dataset.fileTreeVirtualizedWrapper,this.#b=void 0),this.#l.clearAll(),this.#l.setHost(null),this.#f!=null&&(delete this.#f.dataset.fileTreeVirtualized,this.#I(this.#f),this.#f=void 0)}cleanUp(){this.unmount(),this.#y?.(),this.#y=null,this.#t.destroy()}getFileTreeContainer(){return this.#f}getItem(e){return this.#t.getItem(e)}getFocusedItem(){return this.#t.getFocusedItem()}getFocusedPath(){return this.#t.getFocusedPath()}getSelectedPaths(){return this.#t.getSelectedPaths()}getComposition(){return this.#e}getItemHeight(){return this.#u.itemHeight}getDensityFactor(){return this.#u.factor}subscribe(e){let t=!1;return this.#t.subscribe(()=>{if(!t){t=!0;return}e()})}focusPath(e){this.#t.focusPath(e)}scrollToPath(e,t){this.#t.scrollToPath(e,t)}focusNearestPath(e){return this.#t.focusNearestPath(e)}add(e){this.#t.add(e)}batch(e){this.#t.batch(e)}move(e,t,n){this.#t.move(e,t,n)}onMutation(e,t){return this.#t.onMutation(e,t)}setSearch(e){this.#t.setSearch(e)}openSearch(e){this.#t.openSearch(e)}closeSearch(){this.#t.closeSearch()}isSearchOpen(){return this.#t.isSearchOpen()}getSearchValue(){return this.#t.getSearchValue()}getSearchMatchingPaths(){return this.#t.getSearchMatchingPaths()}focusNextSearchMatch(){this.#t.focusNextSearchMatch()}focusPreviousSearchMatch(){this.#t.focusPreviousSearchMatch()}startRenaming(e,t){return this.#t.startRenaming(e,t)}remove(e,t){this.#t.remove(e,t)}resetPaths(e,t){this.#t.resetPaths(e,t)}setComposition(e){this.#e=e;let t=this.#T();t!=null&&(this.#O(),qc(t.wrapper,this.#w()))}setGitStatus(e){this.#p=Wa(e,this.#p);let t=this.#T();t!=null&&qc(t.wrapper,this.#w())}setIcons(e){this.#m=e;let t=this.#T();t!=null&&(this.#E(t.host,t.wrapper),qc(t.wrapper,this.#w()))}hydrate({fileTreeContainer:e}){let t=this.#P(e),n=this.#N(t);this.#O(),Jc(n,this.#w())}render({containerWrapper:e,fileTreeContainer:t}){let n=this.#P(t??this.#f,e),r=this.#N(n);this.#O(),qc(r,this.#w())}#C(){return{initialViewportHeight:Su({initialVisibleRowCount:this.#d.initialVisibleRowCount,itemHeight:this.#d.itemHeight}),itemHeight:this.#d.itemHeight,overscan:this.#d.overscan,stickyFolders:this.#d.stickyFolders}}#w(){return{composition:this.#e,controller:this.#t,gitStatusByPath:this.#p?.statusByPath,ignoredGitDirectories:this.#p?.ignoredDirectoryPaths,directoriesWithGitChanges:this.#p?.directoriesWithChanges,icons:this.#m,instanceId:this.#n,renamingEnabled:this.#a,renderRowDecoration:this.#i,searchBlurBehavior:this.#o,searchEnabled:this.#s,searchFakeFocus:this.#c,slotHost:this.#l,...this.#C()}}#T(){let e=this.#f,t=this.#b;return e==null||t==null?null:{host:e,wrapper:t}}#E(e,t){let n=e.shadowRoot;n!=null&&(this.#k(n),this.#A(n)),this.#j(t)}#D(){let e=this.#r;if(e==null)return;let t=this.#t.getSelectionVersion();t!==this.#v&&(this.#v=t,e(this.#t.getSelectedPaths()))}#O(){let e=this.#e?.header?.render;if(e!=null){this.#l.setSlotContent(ee,e());return}this.#l.setSlotHtml(ee,this.#e?.header?.html??null)}#k(e){let t=Tu(e).find(e=>wu(e)),n=Cu(ut(pt(this.#m).set));n!=null&&(t!=null&&t.outerHTML===n.outerHTML||(t==null?e.prepend(n):t.replaceWith(n)))}#A(e){let t=Tu(e),n=t.find(e=>wu(e)),r=t.filter(e=>e!==n),i=pt(this.#m).spriteSheet?.trim()??``;if(i.length===0){for(let e of r)e.remove();return}let a=Cu(i);if(a==null){for(let e of r)e.remove();return}if(!(r.length===1&&r[0].outerHTML===a.outerHTML)){for(let e of r)e.remove();e.appendChild(a)}}#j(e){let t=pt(this.#m);t.colored&&L(t.set)?e.dataset.fileTreeColoredIcons=`true`:delete e.dataset.fileTreeColoredIcons}#M(e){let t=e.querySelector(`style[${w}]`);if(this.#g==null&&t instanceof HTMLStyleElement&&(this.#g=t),this.#h==null||this.#h===``){this.#g?.remove(),this.#g=void 0,this.#_=void 0;return}this.#g?.parentNode===e&&this.#_===this.#h||(this.#g??=document.createElement(`style`),this.#g.setAttribute(w,``),this.#g.parentNode!==e&&e.appendChild(this.#g),this.#g.textContent=bt(this.#h),this.#_=this.#h)}#N(e){if(this.#b!=null)return this.#b;let t=e.shadowRoot;if(t==null)throw Error(`FileTree requires a shadow root`);let n=Array.from(t.children).filter(e=>e instanceof HTMLDivElement&&typeof e.dataset.fileTreeId==`string`&&e.dataset.fileTreeId.length>0),r=n.find(e=>e.dataset.fileTreeId===this.#n)??n[0];return r!=null&&(this.#n=r.dataset.fileTreeId??this.#n),this.#b=r??document.createElement(`div`),this.#b.dataset.fileTreeId=this.#n,this.#b.dataset.fileTreeVirtualizedWrapper=`true`,this.#E(e,this.#b),this.#b.parentNode!==t&&t.appendChild(this.#b),this.#b}#P(e,t){let n=e??this.#f??document.createElement(`file-tree-container`);t!=null&&n.parentNode!==t&&t.appendChild(n);let r=n.shadowRoot??n.attachShadow({mode:`open`});return Et(n,r),this.#M(r),n.dataset.fileTreeVirtualized=`true`,n.style.display=`flex`,this.#F(n),this.#l.setHost(n),this.#f=n,n}#F(e){e.style.getPropertyValue(`--trees-item-height`)===``&&(e.style.setProperty(`--trees-item-height`,`${String(this.#u.itemHeight)}px`),this.#x=!0),e.style.getPropertyValue(`--trees-density-override`)===``&&(e.style.setProperty(`--trees-density-override`,String(this.#u.factor)),this.#S=!0)}#I(e){this.#x&&=(e.style.removeProperty(`--trees-item-height`),!1),this.#S&&=(e.style.removeProperty(`--trees-density-override`),!1)}};function Du(e){let[t]=(0,y.useState)(()=>new Eu(e)),n=(0,y.useRef)({timeout:null,model:t});return(0,y.useEffect)(()=>{let{current:e}=n;return e.timeout!=null&&(clearTimeout(e.timeout),e.timeout=null),()=>{e.timeout=setTimeout(()=>e.model.cleanUp(),1)}},[]),{model:t}}function Ou(e){let t={boundPaths:new Set,expandedPaths:[],gitStatus:[],paths:[],selectedPaths:[]};return ku(e,``,t),t}function ku(e,t,n){let r=Au(t,e.name);n.paths.push(e.kind===`folder`?`${r}/`:r),e.kind===`folder`&&e.children?.length&&n.expandedPaths.push(r),(e.selected||e.active)&&n.selectedPaths.push(r),e.bound&&n.boundPaths.add(r),e.gitStatus&&n.gitStatus.push({path:r,status:e.gitStatus});for(let t of e.children??[])ku(t,r,n)}function Au(e,t){return e?`${e}/${t}`:t}function ju({root:e}){let t=(0,y.useMemo)(()=>Ou(e),[e]),{model:n}=Du({density:`compact`,flattenEmptyDirectories:!1,gitStatus:t.gitStatus,icons:{set:`minimal`,colored:!1},id:`march-project-tree`,initialExpandedPaths:t.expandedPaths,initialSelectedPaths:t.selectedPaths,paths:t.paths,renderRowDecoration:e=>t.boundPaths.has(e.item.path)?{text:`◆`,title:`Bound to session`}:null,search:!0});return(0,b.jsxs)(`aside`,{className:`panel left-panel`,"aria-label":`Projects`,children:[(0,b.jsxs)(`div`,{className:`projects-header`,children:[(0,b.jsx)(`h3`,{children:`Projects`}),(0,b.jsxs)(`button`,{className:`menu-button`,type:`button`,"aria-label":`Open project menu`,children:[(0,b.jsx)(`span`,{}),(0,b.jsx)(`span`,{}),(0,b.jsx)(`span`,{})]})]}),(0,b.jsx)(`div`,{className:`projects-body`,children:(0,b.jsx)(ne,{className:`project-tree-host`,model:n,"aria-label":`Project files`})})]})}function Mu(e){let{sessions:t,activity:n,fsEntries:r,fsPath:i,providerQuota:a,running:o}=e,{onOpenSession:s,onCreateSession:c,onBrowseRoots:l,onBrowsePath:u}=e,[d,f]=(0,y.useState)(``),p=d.trim().length>0&&!o;async function m(e=d){let t=e.trim();!t||o||(await c(t),f(``))}return(0,b.jsxs)(`aside`,{className:`panel right-panel`,"aria-label":`Sessions`,children:[(0,b.jsx)(`div`,{className:`right-header`,children:`会话`}),(0,b.jsxs)(`div`,{className:`right-body`,children:[(0,b.jsxs)(`div`,{className:`workspace-picker`,"aria-label":`Workspace picker`,children:[(0,b.jsx)(`label`,{htmlFor:`workspace-path`,children:`Workspace`}),(0,b.jsxs)(`div`,{className:`workspace-input-row`,children:[(0,b.jsx)(`input`,{id:`workspace-path`,value:d,onChange:e=>f(e.target.value),placeholder:`Paste or browse a folder path`}),(0,b.jsx)(`button`,{type:`button`,disabled:!p,onClick:()=>m(),children:`Open`})]}),(0,b.jsx)(`div`,{className:`workspace-path`,children:i??`Roots`}),(0,b.jsx)(`button`,{type:`button`,className:`fs-row`,onClick:l,children:`↖ Roots`}),r.map(e=>(0,b.jsxs)(`div`,{className:`fs-entry-row`,children:[(0,b.jsx)(`button`,{type:`button`,onClick:()=>u(e.path),children:e.name}),(0,b.jsx)(`button`,{type:`button`,onClick:()=>m(e.path),children:`Open`})]},e.path))]}),a?(0,b.jsx)(Nu,{quota:a}):null,(0,b.jsx)(`div`,{className:`right-divider`,children:`Sessions`}),t.map(e=>(0,b.jsxs)(`button`,{className:e.active?`session-row active`:`session-row`,type:`button`,onClick:()=>s(e.id),children:[(0,b.jsx)(`span`,{children:e.title}),(0,b.jsx)(`time`,{children:e.workspacePath??e.time})]},e.id)),(0,b.jsx)(`div`,{className:`right-divider`,children:`Activity`}),n.map(e=>(0,b.jsxs)(`button`,{className:`activity-row`,type:`button`,children:[(0,b.jsx)(`span`,{children:e.action}),(0,b.jsx)(`time`,{children:e.time})]},e.id))]})]})}function Nu({quota:e}){return(0,b.jsxs)(`div`,{className:`provider-quota`,"aria-label":`Provider quota`,children:[(0,b.jsxs)(`div`,{className:`provider-quota-header`,children:[(0,b.jsx)(`span`,{children:e.label}),(0,b.jsx)(`time`,{children:e.providerId})]}),e.limits.flatMap(e=>e.windows.map(t=>{let n=Math.round(t.remainingPercent);return(0,b.jsxs)(`div`,{className:`quota-row`,children:[(0,b.jsxs)(`div`,{className:`quota-row-main`,children:[(0,b.jsx)(`span`,{children:Pu(t.label)}),(0,b.jsxs)(`strong`,{children:[n,`% left`]})]}),(0,b.jsx)(`div`,{className:`quota-bar`,"aria-label":`${n}% quota left`,children:(0,b.jsx)(`span`,{style:{width:`${Math.max(0,Math.min(100,n))}%`}})}),(0,b.jsx)(`em`,{children:Fu(t.resetsAt)})]},`${e.id}:${t.id}`)}))]})}function Pu(e){return e===`weekly`?`Weekly limit:`:`${e} limit:`}function Fu(e){if(!e)return`reset unknown`;let t=new Date(e);if(Number.isNaN(t.getTime()))return`reset unknown`;let n=String(t.getHours()).padStart(2,`0`),r=String(t.getMinutes()).padStart(2,`0`),i=[`Jan`,`Feb`,`Mar`,`Apr`,`May`,`Jun`,`Jul`,`Aug`,`Sep`,`Oct`,`Nov`,`Dec`][t.getMonth()];return`resets ${n}:${r} on ${t.getDate()} ${i}`}function Iu(e){let t=[];for(let n of e){if(n.type===`tool_result`){let e=t.at(-1);if(e?.kind===`tool`&&e.tool===n.tool){e.summary=n.summary,e.status=n.status;continue}}t.push(Lu(n))}return t}function Lu(e){switch(e.type){case`user_message`:return{id:e.id,kind:`message`,actor:`user`,text:e.text,time:e.time};case`assistant_message`:return{id:e.id,kind:`message`,actor:`march`,text:e.text,time:e.time};case`assistant_thought`:return{id:e.id,kind:`thought`,title:e.title,text:e.text,status:e.status};case`tool_call`:return{id:e.id,kind:`tool`,tool:e.tool,target:e.target,status:e.status};case`tool_result`:return{id:e.id,kind:`tool`,tool:e.tool,target:`result`,status:e.status,summary:e.summary};case`file_diff`:return{id:e.id,kind:`diff`,path:e.path,lines:e.lines};case`terminal_output`:return{id:e.id,kind:`terminal`,command:e.command,output:e.output,status:e.status};case`memory_recall`:return{id:e.id,kind:`memoryRecall`,hints:e.hints,report:e.report,variant:e.variant};case`error`:return{id:e.id,kind:`error`,message:e.message,detail:e.detail}}}function Ru({item:e}){return e.kind===`message`?(0,b.jsx)(zu,{item:e}):(0,b.jsxs)(`article`,{className:`message-row assistant-turn`,children:[(0,b.jsx)(`div`,{className:`agent-dot march`,children:`M`}),(0,b.jsx)(`div`,{className:`message-body`,children:(0,b.jsx)(Bu,{item:e})})]})}function zu({item:e}){return(0,b.jsxs)(`article`,{className:`message-row ${e.actor===`user`?`user-turn`:`assistant-turn`}`,children:[(0,b.jsx)(`div`,{className:e.actor===`user`?`agent-dot`:`agent-dot march`,children:e.actor===`user`?`U`:`M`}),(0,b.jsxs)(`div`,{className:`message-body`,children:[(0,b.jsx)(`p`,{children:e.text}),e.time?(0,b.jsx)(`time`,{children:e.time}):null]})]})}function Bu({item:e}){switch(e.kind){case`thought`:return(0,b.jsx)(Vu,{item:e});case`tool`:return(0,b.jsx)(Hu,{item:e});case`diff`:return(0,b.jsx)(Uu,{item:e});case`terminal`:return(0,b.jsx)(Wu,{item:e});case`memoryRecall`:return(0,b.jsx)(Gu,{item:e});case`error`:return(0,b.jsx)(qu,{item:e})}}function Vu({item:e}){return(0,b.jsxs)(`details`,{className:`timeline-aux thought-block`,open:e.status===`open`,children:[(0,b.jsxs)(`summary`,{children:[(0,b.jsx)(`span`,{children:`thinking`}),(0,b.jsx)(`strong`,{children:e.title})]}),(0,b.jsx)(`p`,{children:e.text})]})}function Hu({item:e}){return(0,b.jsxs)(`details`,{className:`timeline-aux tool-block`,open:e.status!==`done`,children:[(0,b.jsxs)(`summary`,{children:[(0,b.jsx)(`span`,{children:e.tool}),(0,b.jsx)(`strong`,{children:e.target}),(0,b.jsx)(`em`,{children:e.status})]}),e.summary?(0,b.jsx)(`p`,{children:e.summary}):null]})}function Uu({item:e}){return(0,b.jsxs)(`div`,{className:`timeline-aux diff-block`,children:[(0,b.jsxs)(`div`,{className:`aux-title`,children:[(0,b.jsx)(`span`,{children:`diff`}),(0,b.jsx)(`strong`,{children:e.path})]}),(0,b.jsx)(`div`,{className:`diff-inline`,children:e.lines.map(e=>(0,b.jsx)(`div`,{className:`diff-line ${e.kind}`,children:e.text},`${e.kind}:${e.text}`))})]})}function Wu({item:e}){return(0,b.jsxs)(`details`,{className:`timeline-aux terminal-block`,open:e.status!==`done`,children:[(0,b.jsxs)(`summary`,{children:[(0,b.jsx)(`span`,{children:`terminal`}),(0,b.jsx)(`strong`,{children:e.command}),(0,b.jsx)(`em`,{children:e.status})]}),(0,b.jsx)(`pre`,{children:e.output})]})}function Gu({item:e}){let t=e.variant===`assistant`,n=e.report?.candidates??[],r=(n.length?n:e.hints.map(e=>({...e,recalled:!0}))).slice(0,t?3:void 0),i=`${e.hints.length} recalled · ${n.length||r.length} ${(n.length||r.length)===1?`candidate`:`candidates`}`,a=typeof e.report?.threshold==`number`?` · threshold ${e.report.threshold.toFixed(2)}`:``,o=e.report?.vectorizerStatus===`fallback`?` · fallback`:``;return(0,b.jsxs)(`div`,{className:`timeline-aux memory-recall-block${t?` compact`:``}`,children:[(0,b.jsxs)(`div`,{className:`aux-title`,children:[(0,b.jsx)(`span`,{children:`memory`}),(0,b.jsxs)(`strong`,{children:[`recall · `,i,a,o]})]}),e.report?.warning?(0,b.jsxs)(`p`,{className:`memory-recall-warning`,children:[`! `,e.report.warning]}):null,(0,b.jsx)(`ul`,{children:r.length?r.map(e=>(0,b.jsxs)(`li`,{className:e.recalled===!1?`skipped`:`recalled`,children:[(0,b.jsx)(`span`,{children:e.recalled===!1?`×`:`✓`}),(0,b.jsxs)(`strong`,{children:[Ku(e.score),` `,e.name??e.id]})]},e.id)):(0,b.jsxs)(`li`,{className:`skipped`,children:[(0,b.jsx)(`span`,{children:`·`}),(0,b.jsx)(`strong`,{children:`no candidates`})]})})]})}function Ku(e){return typeof e==`number`&&Number.isFinite(e)?e.toFixed(2):`--`}function qu({item:e}){return(0,b.jsxs)(`div`,{className:`timeline-aux error-block`,children:[(0,b.jsxs)(`div`,{className:`aux-title`,children:[(0,b.jsx)(`span`,{children:`error`}),(0,b.jsx)(`strong`,{children:e.message})]}),e.detail?(0,b.jsx)(`p`,{children:e.detail}):null]})}function Ju({items:e}){return(0,b.jsx)(`div`,{className:`timeline-list`,"aria-label":`Session events`,children:e.map(e=>(0,b.jsx)(Ru,{item:e},e.id))})}function Yu({timeline:e,connected:t,error:n}){let r=Iu(e.events);return(0,b.jsxs)(`main`,{className:`timeline`,"aria-label":`Agent timeline`,children:[(0,b.jsxs)(`div`,{className:`main-header`,children:[(0,b.jsx)(`span`,{children:`Session`}),(0,b.jsx)(`span`,{className:t?`runtime-pill connected`:`runtime-pill`,children:t?`runner`:`mock`})]}),(0,b.jsxs)(`div`,{className:`timeline-scroll`,children:[(0,b.jsxs)(`div`,{className:`session-title`,children:[(0,b.jsx)(`h1`,{children:e.title}),(0,b.jsx)(`span`,{children:n??e.meta})]}),(0,b.jsx)(Ju,{items:r})]})]})}function Xu({runtime:e}){let[t,n]=(0,y.useState)(!1),[r,i]=(0,y.useState)(!1),{model:a}=e;return(0,b.jsxs)(`div`,{className:`app-shell`,"data-left-open":t,"data-right-open":r,children:[(0,b.jsx)(`div`,{className:`overlay`,onClick:()=>{n(!1),i(!1)}}),(0,b.jsx)(ju,{root:a.workspace}),(0,b.jsx)(Yu,{timeline:a.timeline,connected:e.connected,error:e.error}),(0,b.jsx)(Mu,{sessions:a.sessions,activity:a.activity,fsEntries:e.fsEntries,fsPath:e.fsPath,providerQuota:a.providerQuota,running:e.running,onOpenSession:e.openSession,onCreateSession:e.createSession,onBrowseRoots:e.browseRoots,onBrowsePath:e.browsePath}),(0,b.jsx)(x,{composer:a.composer,running:e.running,disabled:!a.activeSessionId,onSubmit:e.submitPrompt,onOpenLeft:()=>n(!0),onOpenRight:()=>i(!0)})]})}var Zu={activeSessionId:`web-shell`,workspace:{id:`root`,name:`march-cli-standalone`,kind:`folder`,selected:!0,bound:!0,children:[{id:`src`,name:`src`,kind:`folder`,children:[{id:`web-ui`,name:`web-ui`,kind:`folder`,children:[{id:`app`,name:`App.tsx`,kind:`file`,active:!0,bound:!0,gitStatus:`modified`},{id:`model`,name:`model.ts`,kind:`file`},{id:`styles`,name:`styles.css`,kind:`file`}]}]},{id:`test`,name:`test`,kind:`folder`},{id:`agents`,name:`AGENTS.md`,kind:`file`},{id:`package`,name:`package.json`,kind:`file`,gitStatus:`modified`}]},timeline:{title:`Web shell`,meta:`mock adapter · fast`,events:[{id:`u1`,type:`user_message`,text:`参考 MindFS,做正式 Web UI。`,time:`09:41`},{id:`m1`,type:`assistant_message`,text:`先组件化,runtime 保持不变。`,time:`09:41`},{id:`th1`,type:`assistant_thought`,title:`Planning`,text:`把 runtime 事件先整理成 timeline item,再交给 UI 渲染。`,status:`closed`},{id:`t1`,type:`tool_call`,tool:`read`,target:`workspace`,status:`running`},{id:`tr1`,type:`tool_result`,tool:`read`,summary:`4 files inspected`,status:`done`},{id:`d1`,type:`file_diff`,path:`src/web-ui/src/model.ts`,lines:[{kind:`add`,text:`+ Timeline adapter model`},{kind:`keep`,text:` runtime adapter pending`}]},{id:`term1`,type:`terminal_output`,command:`npm run test:fast`,output:`PASS web-ui.smoke.mjs`,status:`done`}]},sessions:[{id:`web-shell`,title:`Web shell`,time:`now`,active:!0},{id:`memory`,title:`Memory`,time:`1d`}],activity:[{id:`read`,action:`read`,time:`now`},{id:`edit`,action:`edit`,time:`2m`},{id:`test`,action:`test`,time:`5m`}],composer:{mode:`Chat`,placeholder:`Message March…`}};function Qu(e,t){let n=[...e],r=`${t.type}:${n.length}:${Date.now()}`;switch(t.type){case`web_user_message`:return n.push({id:r,type:`user_message`,text:t.text,time:od()}),n;case`text_delta`:return $u(n,t.delta,r);case`thinking_start`:return n.push({id:r,type:`assistant_thought`,title:`Thinking`,text:``,status:`open`}),n;case`thinking_delta`:return ed(n,t.delta,r);case`thinking_end`:return td(n);case`tool_start`:return n.push({id:r,type:`tool_call`,tool:t.name,target:id(t.args),status:`running`}),n;case`tool_end`:return n.push({id:r,type:`tool_result`,tool:t.name,summary:ad(t.result),status:t.isError?`failed`:`done`}),n;case`edit_diff`:return n.push({id:r,type:`file_diff`,path:t.path,lines:nd(t.diffLines)}),n;case`recall`:return((t.hints?.length??0)||t.report)&&n.push({id:r,type:`memory_recall`,hints:t.hints??[],report:t.report??null,variant:t.variant}),n;case`status`:return n.push({id:r,type:`terminal_output`,command:`status`,output:t.text,status:`done`}),n;case`retry_start`:return n.push({id:r,type:`error`,message:`Retrying`,detail:t.errorMessage}),n;case`retry_end`:return!t.success&&t.finalError&&n.push({id:r,type:`error`,message:`Retry failed`,detail:t.finalError}),n;default:return n}}function $u(e,t,n){let r=e.at(-1);return r?.type===`assistant_message`?r.text+=t:e.push({id:n,type:`assistant_message`,text:t,time:od()}),e}function ed(e,t,n){let r=e.at(-1);return r?.type===`assistant_thought`&&r.status===`open`?r.text+=t:e.push({id:n,type:`assistant_thought`,title:`Thinking`,text:t,status:`open`}),e}function td(e){let t=e.at(-1);return t?.type===`assistant_thought`&&(t.status=`closed`),e}function nd(e=[]){return e.map(e=>({kind:rd(e.type),text:e.text??``}))}function rd(e){return e===`add`?`add`:e===`del`?`remove`:`keep`}function id(e){return e==null?`running`:JSON.stringify(e).slice(0,160)}function ad(e){return e==null?`done`:typeof e==`string`?e.slice(0,240):JSON.stringify(e).slice(0,240)}function od(){return new Intl.DateTimeFormat(void 0,{hour:`2-digit`,minute:`2-digit`}).format(new Date)}async function sd(e){let t=await fetch(md(`/api/snapshot`,{sessionId:e}));if(!t.ok)throw Error(await t.text());return t.json()}async function cd(e){let t=await fetch(`/api/sessions`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({workspacePath:e})});if(!t.ok)throw Error(await t.text());return t.json()}async function ld(){let e=await fetch(`/api/fs/roots`);if(!e.ok)throw Error(await e.text());return(await e.json()).roots}async function ud(e){let t=await fetch(md(`/api/fs/list`,{path:e}));if(!t.ok)throw Error(await t.text());return(await t.json()).entries}async function dd(e){let t=await fetch(md(`/api/provider-quota`,{sessionId:e}));if(!t.ok)throw Error(await t.text());return(await t.json()).snapshot??null}async function fd(e,t){let n=await fetch(`/api/turn`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({sessionId:e,prompt:t})});if(!n.ok)throw Error(await n.text());return n.json()}function pd(e,t,n){let r=new EventSource(md(`/api/events`,{sessionId:e}));return r.addEventListener(`runtime`,e=>{t(JSON.parse(e.data))}),r.onerror=n,()=>r.close()}function md(e,t){let n=new URLSearchParams;for(let[e,r]of Object.entries(t))r&&n.set(e,r);let r=n.toString();return r?`${e}?${r}`:e}function hd(){let[e,t]=(0,y.useState)(Zu),[n,r]=(0,y.useState)(!1),[i,a]=(0,y.useState)(!1),[o,s]=(0,y.useState)(null),[c,l]=(0,y.useState)([]),[u,d]=(0,y.useState)(null),f=e.activeSessionId??null,p=(0,y.useRef)(new Map);(0,y.useEffect)(()=>{let e=!0;return sd().then(n=>{e&&(t(n),r(!0))}).catch(()=>r(!1)),ld().then(t=>e&&l(t)).catch(()=>{}),()=>{e=!1}},[]),(0,y.useEffect)(()=>{if(!f)return;let e=pd(f,e=>{if(r(!0),e.type===`provider_quota_snapshot`){t(t=>t.activeSessionId===f?{...t,providerQuota:e.snapshot}:t);return}t(t=>{let n=vd(t,t=>Qu(t,e));return _d(n,p.current),n})},()=>r(!1));return g(f).catch(()=>void 0),e},[f]);async function m(e){s(null),t(gd(await sd(e),p.current))}async function h(e){a(!0),s(null);try{let n=await cd(e);t(n.snapshot),_d(n.snapshot,p.current)}catch(e){s(e instanceof Error?e.message:String(e))}finally{a(!1)}}async function g(e){let n=await dd(e);t(t=>t.activeSessionId===e?{...t,providerQuota:n}:t)}async function _(){d(null),l(await ld())}async function v(e){d(e),l(await ud(e))}async function b(e){if(!f){s(`Choose a workspace before sending a message`);return}a(!0),s(null);try{await fd(f,e)}catch(e){let n=e instanceof Error?e.message:String(e);s(n),t(e=>{let t=vd(e,e=>[...e,{id:`client-error:${Date.now()}`,type:`error`,message:n}]);return _d(t,p.current),t})}finally{a(!1)}}return{model:e,connected:n,running:i,error:o,fsEntries:c,fsPath:u,openSession:m,createSession:h,browseRoots:_,browsePath:v,submitPrompt:b}}function gd(e,t){let n=e.activeSessionId,r=n?t.get(n):null;return r?{...e,timeline:{...e.timeline,events:r}}:e}function _d(e,t){e.activeSessionId&&t.set(e.activeSessionId,e.timeline.events)}function vd(e,t){return{...e,timeline:{...e.timeline,events:t(e.timeline.events)}}}function yd(){return(0,b.jsx)(Xu,{runtime:hd()})}(0,v.createRoot)(document.getElementById(`root`)).render((0,b.jsx)(y.StrictMode,{children:(0,b.jsx)(yd,{})}));