@hyperpuncher/pi-ui 0.47.0 → 0.47.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +24 -17
- package/dist/npm/server-main.js +1 -1
- package/package.json +1 -1
- package/static/build/chunks/{code-theme-h8xf95gx.js → code-theme-pvx0m83p.js} +1 -1
- package/static/build/chunks/{index-tj848246.js → index-vtmc6jvm.js} +1 -1
- package/static/build/chunks/{main-f40c0hm2.js → main-6b6epn84.js} +5 -5
- package/static/build/chunks/{main-hq8q8mc5.js → main-scnj6yst.js} +46 -46
- package/static/build/chunks/{workspace-review-pme5emmj.js → workspace-review-51kesnmm.js} +12 -12
- package/static/build/main.js +2 -2
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{A,B as Bu,C as Pi,D as yd,F as Er,G as _s,a as Ur,b as ta,c as na,e as Kr,f as ia,g as Js,h as ea,i as Qr,j as oa,k as Zr,n as sa,o as so,p as ao,q as ei,r as aa,s as Wu,t as gd,u as la,v as ca,w as lo,x as lr,y as ua,z as vd}from"./main-hq8q8mc5.js";import{H as Hh}from"./main-e1326455.js";import{_ as ro,qa as Jr,ra as io,sa as oo}from"./main-f40c0hm2.js";import{gc as Zu,hc as Ju,ic as Et,jc as _r}from"./main-d7db5p71.js";import{kc as xs,lc as un,mc as Du,nc as xr}from"./main-2yyq3124.js";import{oc as Bh,rc as Em}from"./main-kt1z40p6.js";function Qi(e){let t=[];for(let n of e){let r=Kr.get(n);if(r==null)throw Error(`getResolvedLanguages: ${n} is not resolved. Please resolve languages before calling getResolvedLanguages`);t.push(r)}return t}function Zi(e){for(let t of Array.isArray(e)?e:[e])if(!Kr.has(t))return!1;return!0}async function Ji(e){let t=[],n=[];for(let r of e){if(r==="text"||r==="ansi")continue;let i=ea(r)??Js(r);if("then"in i)n.push(i);else t.push(i)}if(n.length>0)await Promise.all(n).then((r)=>{for(let i of r){if(i==null)throw Error("resolvedLanguages: unable to resolve language");t.push(i)}});return t}function eo(e){return Ur.getResolvedThemes(e)}async function to(e){for(let n of e)ta(n);let t=await Ur.resolveThemes(e);for(let n=0;n<e.length;n++)na(e[n],t[n]);return t}var co=Bh(Hh(),1),Gr=Symbol("IGNORE_RESPONSE"),Vh=1e4,Yr=class extends Error{constructor(){super("WorkerPoolManager: operation canceled because the pool terminated")}},no=class extends Error{constructor(){super("WorkerPoolManager: operation canceled before the task completed")}},da=class{options;highlighter;preferredHighlighter;renderOptions;renderOptionsRequestVersion=0;renderOptionsVersion=0;initialized=!1;workers=[];queuedTasks=[];queuedTaskByInstance=new Map;taskByHighlightKey=new Map;activeTaskById=new Map;activeRequestByInstance=new Map;nextRequestId=0;themeSubscribers=new Set;workersFailed=!1;statSubscribers=new Set;fileCache;diffCache;_queuedBroadcast;lifecycleGeneration=0;constructor(e,{langs:t,theme:n=ro,useTokenTransformer:r=!1,lineDiffType:i="word-alt",maxLineDiffLength:o=1000,tokenizeMaxLineLength:s=1000,preferredHighlighter:a="shiki-js"}){this.options=e,this.preferredHighlighter=a,this.renderOptions={theme:n,useTokenTransformer:r,lineDiffType:i,maxLineDiffLength:o,tokenizeMaxLineLength:s},this.fileCache=new co.default.LRUMap(e.totalASTLRUCacheSize??100),this.diffCache=new co.default.LRUMap(e.totalASTLRUCacheSize??100),this.queueInitialization(t)}isWorkingPool(){return!this.workersFailed}getFileResultCache(e){return e.cacheKey!=null?this.fileCache.get(e.cacheKey):void 0}getDiffResultCache(e){return e.cacheKey!=null?this.diffCache.get(e.cacheKey):void 0}inspectCaches(){let{fileCache:e,diffCache:t}=this;return{fileCache:e,diffCache:t}}evictFileFromCache(e){try{return this.fileCache.delete(e)!==void 0}finally{this.queueBroadcastStateChanges()}}evictDiffFromCache(e){try{return this.diffCache.delete(e)!==void 0}finally{this.queueBroadcastStateChanges()}}async setRenderOptions({theme:e=this.renderOptions.theme??ro,useTokenTransformer:t=this.renderOptions.useTokenTransformer??!1,lineDiffType:n=this.renderOptions.lineDiffType??"word-alt",maxLineDiffLength:r=this.renderOptions.maxLineDiffLength??1000,tokenizeMaxLineLength:i=this.renderOptions.tokenizeMaxLineLength??1000}){let{lifecycleGeneration:o}=this,s=++this.renderOptionsRequestVersion,a=()=>this.isCurrentLifecycle(o)&&this.renderOptionsRequestVersion===s;try{let l={theme:e,useTokenTransformer:t,lineDiffType:n,maxLineDiffLength:r,tokenizeMaxLineLength:i};if(!this.isInitialized())await this.initialize();if(!a()||lr(l,this.renderOptions))return;let d=Qr(e),u=[];if(!sa(l.theme,this.renderOptions.theme))if(ao(d))u=eo(d);else u=await to(d);if(!a())return;if(this.highlighter!=null)oa(u,this.highlighter);else{let c=await Zr({themes:d,langs:["text"],preferredHighlighter:this.preferredHighlighter});if(!a())return;this.highlighter=c}let f=this.setRenderOptionsOnWorkers(l,u);this.renderOptions=l,this.renderOptionsVersion++,this.diffCache.clear(),this.fileCache.clear(),this.invalidateRenderTasks();for(let c of this.themeSubscribers)c.onThemeChange();await f}catch(l){if(l instanceof Yr||!a())return;throw l}}getPreferredHighlighter(){return this.preferredHighlighter}getFileRenderOptions(){let{tokenizeMaxLineLength:e,theme:t,useTokenTransformer:n}=this.renderOptions;return{theme:t,useTokenTransformer:n,tokenizeMaxLineLength:e}}getDiffRenderOptions(){return{...this.renderOptions}}async setRenderOptionsOnWorkers(e,t){if(this.workersFailed)return;if(!this.isInitialized())await this.initialize();let n=[];for(let r of this.workers){if(!r.initialized)throw console.log({managedWorker:r}),Error("setRenderOptionsOnWorkers: Somehow we have an uninitialized worker");n.push(new Promise((i,o)=>{let s=this.generateRequestId(),a={type:"set-render-options",id:s,request:{type:"set-render-options",id:s,renderOptions:e,resolvedThemes:t},resolve:i,reject:o,requestStart:Date.now()};this.activeTaskById.set(s,a),r.pendingSetupRequestId=s,r.worker.postMessage(a.request)}))}await Promise.all(n)}subscribeToThemeChanges(e){return this.themeSubscribers.add(e),this.queueBroadcastStateChanges(),()=>{this.unsubscribeToThemeChanges(e),this.queueBroadcastStateChanges()}}unsubscribeToThemeChanges(e){this.themeSubscribers.delete(e),this.queueBroadcastStateChanges()}subscribeToStatChanges(e){return this.statSubscribers.add(e),e(this.getStats()),()=>{this.statSubscribers.delete(e)}}queueBroadcastStateChanges(){if(this._queuedBroadcast!=null)return;this._queuedBroadcast=requestAnimationFrame(this._broadcastStateChanges)}_broadcastStateChanges=()=>{if(this._queuedBroadcast!=null)cancelAnimationFrame(this._queuedBroadcast),this._queuedBroadcast=void 0;let e=this.getStats();for(let t of this.statSubscribers)t(e)};cleanUpTasks(e){this.detachInstanceFromQueuedTasks(e);let t=this.activeRequestByInstance.get(e);if(t!=null){let n=this.activeTaskById.get(t);if(Lt(n)){if(this.detachInstanceFromRenderTask(n,e),!n.primeCache&&n.instances.size===0)this.removeActiveTask(n)}else this.activeTaskById.delete(t)}this.activeRequestByInstance.delete(e),this.queueBroadcastStateChanges()}isInitialized(){return this.initialized===!0}async initialize(e=[]){if(this.initialized===!0)return;else if(this.initialized===!1){let{lifecycleGeneration:t}=this;this.initialized=new Promise((n,r)=>{(async()=>{try{let i=Qr(this.renderOptions.theme),o=[];if(ao(i))o=eo(i);else o=await to(i);if(!this.isCurrentLifecycle(t)){n();return}let s=[];if(Zi(e))s=Qi(e);else s=await Ji(e);if(!this.isCurrentLifecycle(t)){n();return}let[a]=await Promise.all([Zr({themes:i,langs:["text",...e],preferredHighlighter:this.preferredHighlighter}),this.initializeWorkers(o,s)]);if(!this.isCurrentLifecycle(t)){this.terminateWorkers(),n();return}this.highlighter=a,this.initialized=!0,this.diffCache.clear(),this.fileCache.clear(),this.drainQueue(),this.queueBroadcastStateChanges(),n()}catch(i){if(i instanceof Yr||!this.isCurrentLifecycle(t)){n();return}this.initialized=!1,this.workersFailed=!0,this.cancelActiveWorkerTasks(),this.terminateWorkers(),this.activeTaskById.clear();for(let o of this.queuedTasks)this.rejectRenderTaskCallbacks(o,Xr(i));this.queueBroadcastStateChanges(),r(i)}})()}),this.queueBroadcastStateChanges()}else return this.initialized}async initializeWorkers(e,t){this.workersFailed=!1;let n=[],r=io(),i=r>0?oo():void 0;if(this.workers.length>0)this.terminateWorkers();for(let a=0;a<(this.options.poolSize??8);a++){let l=this.options.workerFactory(),d={worker:l,requestId:void 0,pendingSetupRequestId:void 0,initialized:!1,langs:new Set(["text",...t.map(({name:u})=>u)]),customExtensionsVersion:0};l.addEventListener("message",(u)=>{this.handleWorkerMessage(d,u.data)}),l.addEventListener("error",(u)=>this.handleWorkerError(d,u)),this.workers.push(d),n.push(new Promise((u,f)=>{let c=this.generateRequestId(),m={type:"initialize",id:c,request:{type:"initialize",id:c,renderOptions:this.renderOptions,preferredHighlighter:this.preferredHighlighter,resolvedThemes:e,resolvedLanguages:t,customExtensionsVersion:i!=null?r:void 0,customExtensionMap:i},resolve(){d.initialized=!0,u()},reject:f,requestStart:Date.now()};d.pendingSetupRequestId=c,this.activeTaskById.set(c,m),this.executeTask(d,m)}))}let o=this.options.workerInitializationTimeout??Vh,s;try{await Promise.race([Promise.all(n),new Promise((a,l)=>{s=setTimeout(()=>{l(Error(`WorkerPoolManager: worker initialization timed out after ${o}ms`))},o)})])}finally{if(s!=null)clearTimeout(s)}}handleWorkerError(e,t){console.error("Worker error:",t,e);let{pendingSetupRequestId:n}=e;if(n==null)return;let r=this.activeTaskById.get(n);if(r?.type!=="initialize")return;r.reject(Xr(t)),this.cleanWorkerAndTask(e,r)}drainQueue=()=>{if(this._queuedDrain=void 0,this.initialized!==!0||this.queuedTasks.length===0)return;for(let e=0;e<this.queuedTasks.length;){let t=this.queuedTasks[e];if(this.hasActiveRequest(t)){e++;continue}let n=ra(t),r=this.getAvailableWorker(n);if(r==null)break;this.queuedTasks.splice(e,1),this.assignWorkerToTask(t,r),this.resolveLanguagesAndExecuteTask(r,t,n)}this.queueBroadcastStateChanges()};highlightFileAST(e,t){let n=this.getFileResultCache(t);if(so(t)||n!=null&&ei(n.options,this.getFileRenderOptions()))return;if(!this.hasMatchingFileInstanceTask(e,t))this.submitTask(e,{type:"file",file:t})}primeFileHighlightCache(e){if(!this.isWorkingPool())return Promise.reject(Error("WorkerPoolManager.primeFileHighlightCache: worker pool is not working"));let t=this.getOrCreateFileHighlightCacheTask(e);return t!=null?this.createRenderTaskCallbacks(t):Promise.resolve()}getOrCreateFileHighlightCacheTask(e){if(e.cacheKey==null){console.warn(`WorkerPoolManager.primeFileHighlightCache: priming highlight cache requires file.cacheKey; skipping "${e.name}".`);return}let t=this.getFileResultCache(e),n=this.getFileHighlightKey(e);if(n==null||so(e)||t!=null&&ei(t.options,this.getFileRenderOptions()))return;let r=this.getTaskByHighlightKey(n);if(r!=null)return r.primeCache=!0,r.type==="file"?r:void 0;else{let i=this.submitCacheTask({type:"file",file:e},n);return i.type==="file"?i:void 0}}getPlainFileAST(e,t,n,r){if(this.highlighter==null){this.queueInitialization();return}return aa(e,this.highlighter,this.renderOptions,{forcePlainText:!0,startingLine:t,totalLines:n,lines:r})}highlightDiffAST(e,t){let n=this.getDiffResultCache(t);if(lo(t)||n!=null&&lr(n.options,this.getDiffRenderOptions()))return;if(!this.hasMatchingDiffInstanceTask(e,t))this.submitTask(e,{type:"diff",diff:t})}primeDiffHighlightCache(e){if(!this.isWorkingPool())return Promise.reject(Error("WorkerPoolManager.primeDiffHighlightCache: worker pool is not working"));let t=this.getOrCreateDiffHighlightCacheTask(e);return t!=null?this.createRenderTaskCallbacks(t):Promise.resolve()}getOrCreateDiffHighlightCacheTask(e){if(e.cacheKey==null){console.warn(`WorkerPoolManager.primeDiffHighlightCache: priming highlight cache requires diff.cacheKey; skipping "${e.prevName??e.name}" -> "${e.name}".`);return}let t=this.getDiffResultCache(e),n=this.getDiffHighlightKey(e);if(n==null||lo(e)||t!=null&&lr(t.options,this.getDiffRenderOptions()))return;let r=this.getTaskByHighlightKey(n);if(r!=null)return r.primeCache=!0,r.type==="diff"?r:void 0;else{let i=this.submitCacheTask({type:"diff",diff:e},n);return i.type==="diff"?i:void 0}}getPlainDiffAST(e,t,n,r,i){return this.highlighter!=null?ua(e,this.highlighter,this.renderOptions,{forcePlainText:!0,startingLine:t,totalLines:n,expandedHunks:r,collapsedContextThreshold:i}):void 0}terminate(){this.lifecycleGeneration++,this.cancelActiveWorkerTasks(),this.terminateWorkers();let e=new Yr;for(let t of this.queuedTasks)this.rejectRenderTaskCallbacks(t,e);this.fileCache.clear(),this.diffCache.clear(),this.activeRequestByInstance.clear(),this.queuedTasks.length=0,this.queuedTaskByInstance.clear(),this.taskByHighlightKey.clear(),this.activeTaskById.clear(),this.highlighter=void 0,this.initialized=!1,this.workersFailed=!1,this.queueBroadcastStateChanges()}isCurrentLifecycle(e){return this.lifecycleGeneration===e}queueInitialization(e){this.initialize(e).catch((t)=>{console.error(t)})}cancelActiveWorkerTasks(){let e=new Yr;for(let t of this.activeTaskById.values())if("reject"in t)t.reject(e);else if(Lt(t))this.rejectRenderTaskCallbacks(t,e)}terminateWorkers(){for(let e of this.workers)e.worker.terminate();this.workers.length=0}getStats(){return{managerState:(()=>{if(this.initialized===!1)return"waiting";if(this.initialized!==!0)return"initializing";return"initialized"})(),totalWorkers:this.workers.length,workersFailed:this.workersFailed,busyWorkers:this.workers.filter((e)=>e.requestId!=null||e.pendingSetupRequestId!=null).length,queuedTasks:this.queuedTasks.length,activeTasks:this.activeTaskById.size,themeSubscribers:this.themeSubscribers.size,fileCacheSize:this.fileCache.size,diffCacheSize:this.diffCache.size}}submitTask(e,t){if(this.initialized===!1)this.queueInitialization();let n=this.getHighlightKeyForRequest(t),r=n!=null?this.getTaskByHighlightKey(n):void 0;if(r!=null){this.detachInstanceFromQueuedTasks(e,r),this.addInstanceToTask(r,e),this.queueBroadcastStateChanges();return}this.detachInstanceFromQueuedTasks(e);let i=this.generateRequestId(),o=Date.now(),{renderOptionsVersion:s}=this,a=(()=>{switch(t.type){case"file":return{type:"file",id:i,request:{...t,id:i},instances:new Set([e]),primeCache:!1,highlightKey:n,callbacks:new Set,renderOptionsVersion:s,requestStart:o};case"diff":return{type:"diff",id:i,request:{...t,id:i},instances:new Set([e]),primeCache:!1,highlightKey:n,callbacks:new Set,renderOptionsVersion:s,requestStart:o}}})();this.enqueueRenderTask(a,e)}submitCacheTask(e,t){if(this.initialized===!1)this.queueInitialization();let n=this.generateRequestId(),r=Date.now(),{renderOptionsVersion:i}=this,o=(()=>{switch(e.type){case"file":return{type:"file",id:n,request:{...e,id:n},instances:new Set,primeCache:!0,highlightKey:t,callbacks:new Set,renderOptionsVersion:i,requestStart:r};case"diff":return{type:"diff",id:n,request:{...e,id:n},instances:new Set,primeCache:!0,highlightKey:t,callbacks:new Set,renderOptionsVersion:i,requestStart:r}}})();return this.enqueueRenderTask(o),o}enqueueRenderTask(e,t){if(this.queuedTasks.push(e),t!=null)this.queuedTaskByInstance.set(t,e);if(e.highlightKey!=null)this.taskByHighlightKey.set(e.highlightKey,e);this.queueDrain()}async resolveLanguagesAndExecuteTask(e,t,n){try{let r=n.filter((o)=>!ia(o));if(r.length>0)Zr({themes:Qr(this.renderOptions.theme),langs:["text",...r],preferredHighlighter:this.preferredHighlighter}).catch((o)=>{console.error(o)});let i=n.filter((o)=>!e.langs.has(o));if(i.length>0)if(Zi(i))t.request.resolvedLanguages=Qi(i);else t.request.resolvedLanguages=await Ji(i);if(!this.activeTaskById.has(t.id)){if(e.requestId===t.id){if(this.cleanWorkerAndTask(e,t),this.queueBroadcastStateChanges(),this.queuedTasks.length>0)this.queueDrain()}return}this.executeTask(e,t)}catch(r){if(this.rejectRenderTaskCallbacks(t,Xr(r)),this.cleanWorkerAndTask(e,t),this.queueBroadcastStateChanges(),this.queuedTasks.length>0)this.queueDrain()}}handleWorkerMessage(e,t){let n=this.activeTaskById.get(t.id);try{if(n==null)throw Gr;else if(t.type==="error"){let r=Error(t.error);if(t.stack)r.stack=t.stack;if("reject"in n)n.reject(r);else if(Lt(n))this.notifyHighlightError(n,r),this.rejectRenderTaskCallbacks(n,r);else throw Error("handleWorkerMessage: unknown task type");throw r}else switch(t.requestType){case"initialize":if(n.type!=="initialize")throw Error("handleWorkerMessage: task/response dont match");this.syncCustomExtensionVersion(e,n.request),n.resolve();break;case"set-render-options":if(n.type!=="set-render-options")throw Error("handleWorkerMessage: task/response dont match");n.resolve();break;case"file":{if(n.type!=="file")throw Error("handleWorkerMessage: task/response dont match");let{result:r,options:i}=t;if(!this.isCurrentRenderTask(n)||!ei(i,this.getFileRenderOptions()))throw Gr;let{request:o}=n;if(this.syncCustomExtensionVersion(e,o),n.cacheKeyAtDispatch!=null)this.fileCache.set(n.cacheKeyAtDispatch,{result:r,options:i});this.resolveRenderTaskCallbacks(n),this.notifyFileInstances(n,r,i);break}case"diff":{if(n.type!=="diff")throw Error("handleWorkerMessage: task/response dont match");let{result:r,options:i}=t;if(!this.isCurrentRenderTask(n)||!lr(i,this.getDiffRenderOptions()))throw Gr;let{request:o}=n;if(this.syncCustomExtensionVersion(e,o),n.cacheKeyAtDispatch!=null)this.diffCache.set(n.cacheKeyAtDispatch,{result:r,options:i});this.resolveRenderTaskCallbacks(n),this.notifyDiffInstances(n,r,i);break}}}catch(r){if(r!==Gr)console.error(r,n,t)}if(this.cleanWorkerAndTask(e,n,t.id),this.queueBroadcastStateChanges(),this.queuedTasks.length>0)this.queueDrain()}_queuedDrain;queueDrain(){if(this._queuedDrain!=null)return;this._queuedDrain=Promise.resolve().then(this.drainQueue),this.queueBroadcastStateChanges()}assignWorkerToTask(e,t){if(t.requestId=e.id,Lt(e))this.clearQueuedInstanceRequests(e),this.trackInstanceRequests(e);this.activeTaskById.set(e.id,e)}cleanWorkerAndTask(e,t,n=t?.id){if(e.requestId===n)e.requestId=void 0;if(e.pendingSetupRequestId===n)e.pendingSetupRequestId=void 0;if(t!=null){if(Lt(t))this.rejectRenderTaskCallbacks(t,new no),this.clearInstanceRequests(t),this.clearHighlightKey(t);this.activeTaskById.delete(t.id)}}executeTask(e,t){if(Oh(t.request))this.maybeAttachCustomExtensions(e,t.request);if(!this.activeTaskById.has(t.id))this.assignWorkerToTask(t,e);for(let n of ra(t))e.langs.add(n);try{if(t.type==="file")t.cacheKeyAtDispatch=t.request.file.cacheKey;else if(t.type==="diff")t.cacheKeyAtDispatch=t.request.diff.cacheKey;e.worker.postMessage(t.request)}catch(n){if(console.error("Failed to post message to worker:",n),Lt(t))this.notifyHighlightError(t,n),this.rejectRenderTaskCallbacks(t,Xr(n));else if("reject"in t)t.reject(n);if(this.cleanWorkerAndTask(e,t),this.queuedTasks.length>0)this.queueDrain()}this.queueBroadcastStateChanges()}maybeAttachCustomExtensions(e,t){if(t.customExtensionsVersion!=null)return;let n=io();if(e.customExtensionsVersion>=n)return;t.customExtensionsVersion=n,t.customExtensionMap=oo()}syncCustomExtensionVersion(e,t){if(t.customExtensionsVersion==null)return;e.customExtensionsVersion=t.customExtensionsVersion}getAvailableWorker(e){let t;for(let n of this.workers){if(n.requestId!=null||n.pendingSetupRequestId!=null||!n.initialized)continue;if(t=n,e.length===0)break;let r=!0;for(let i of e)if(!n.langs.has(i)){r=!1;break}if(r)break}return t}getFileHighlightKey(e){if(e.cacheKey==null)return;return`file:${e.cacheKey}:${this.renderOptionsVersion}`}getDiffHighlightKey(e){if(e.cacheKey==null)return;return`diff:${e.cacheKey}:${this.renderOptionsVersion}`}getHighlightKeyForRequest(e){switch(e.type){case"file":return this.getFileHighlightKey(e.file);case"diff":return this.getDiffHighlightKey(e.diff)}}hasActiveRequest(e){for(let t of ar(e))if(this.activeRequestByInstance.has(t))return!0;return!1}addInstanceToTask(e,t){if(e.type==="file")e.instances.add(t);else e.instances.add(t);if(this.activeTaskById.has(e.id))this.activeRequestByInstance.set(t,e.id);else this.queuedTaskByInstance.set(t,e)}detachInstanceFromQueuedTasks(e,t){let n=this.queuedTaskByInstance.get(e);if(n==null||n===t)return;if(this.queuedTaskByInstance.delete(e),this.detachInstanceFromRenderTask(n,e),!n.primeCache&&n.instances.size===0)this.removeQueuedTask(n)}detachInstanceFromRenderTask(e,t){if(e.type==="file")e.instances.delete(t);else e.instances.delete(t)}removeQueuedTask(e){let t=this.queuedTasks.indexOf(e);if(t!==-1)this.queuedTasks.splice(t,1);this.rejectRenderTaskCallbacks(e,new no),this.clearQueuedInstanceRequests(e),this.clearHighlightKey(e)}removeActiveTask(e){this.rejectRenderTaskCallbacks(e,new no),this.clearInstanceRequests(e),this.clearHighlightKey(e),this.activeTaskById.delete(e.id)}createRenderTaskCallbacks(e){return new Promise((t,n)=>{e.callbacks.add({resolve:t,reject:n})})}resolveRenderTaskCallbacks(e){for(let t of e.callbacks)t.resolve();e.callbacks.clear()}rejectRenderTaskCallbacks(e,t){for(let n of e.callbacks)n.reject(t);e.callbacks.clear()}invalidateRenderTasks(){for(let e=this.queuedTasks.length-1;e>=0;e--){let t=this.queuedTasks[e];if(t.renderOptionsVersion!==this.renderOptionsVersion)this.removeQueuedTask(t)}for(let e of Array.from(this.activeTaskById.values()))if(Lt(e)&&e.renderOptionsVersion!==this.renderOptionsVersion)this.removeActiveTask(e)}clearQueuedInstanceRequests(e){for(let t of ar(e))if(this.queuedTaskByInstance.get(t)===e)this.queuedTaskByInstance.delete(t)}clearHighlightKey(e){if(e.highlightKey!=null&&this.taskByHighlightKey.get(e.highlightKey)===e)this.taskByHighlightKey.delete(e.highlightKey)}trackInstanceRequests(e){for(let t of ar(e))this.activeRequestByInstance.set(t,e.id)}clearInstanceRequests(e){for(let t of ar(e))if(this.activeRequestByInstance.get(t)===e.id)this.activeRequestByInstance.delete(t)}notifyFileInstances(e,t,n){for(let r of e.instances)if(this.activeRequestByInstance.get(r)===e.id)r.onHighlightSuccess(e.request.file,t,n)}notifyDiffInstances(e,t,n){for(let r of e.instances)if(this.activeRequestByInstance.get(r)===e.id)r.onHighlightSuccess(e.request.diff,t,n)}notifyHighlightError(e,t){for(let n of ar(e))if(this.activeRequestByInstance.get(n)===e.id)n.onHighlightError(t)}hasMatchingFileInstanceTask(e,t){for(let n of this.iterateRenderTasks())if(n.type==="file"&&this.isCurrentRenderTask(n)&&n.instances.has(e)&&ca(t,n.request.file))return!0;return!1}hasMatchingDiffInstanceTask(e,t){for(let n of this.iterateRenderTasks())if(n.type==="diff"&&this.isCurrentRenderTask(n)&&n.instances.has(e)&&la(n.request.diff,t))return!0;return!1}getTaskByHighlightKey(e){let t=this.taskByHighlightKey.get(e);return t!=null&&this.isCurrentRenderTask(t)?t:void 0}isCurrentRenderTask(e){return e.renderOptionsVersion===this.renderOptionsVersion}*iterateRenderTasks(){for(let e of this.queuedTasks)yield e;for(let e of this.activeTaskById.values())if(Lt(e))yield e}generateRequestId(){return`req_${++this.nextRequestId}`}};function Oh(e){return e.type==="initialize"||e.type==="file"||e.type==="diff"}function ra(e){let t=new Set;if(e.type==="initialize"||e.type==="set-render-options")return[];switch(e.type){case"file":t.add(e.request.file.lang??Jr(e.request.file.name));break;case"diff":t.add(e.request.diff.lang??Jr(e.request.diff.name)),t.add(e.request.diff.lang??Jr(e.request.diff.prevName??"-"))}return t.delete("text"),Array.from(t)}function Lt(e){return e?.type==="file"||e?.type==="diff"}function ar(e){return e.instances}function Xr(e){if(e instanceof Error)return e;if(e!=null&&typeof e==="object"){if("error"in e&&e.error instanceof Error)return e.error;if("message"in e&&typeof e.message==="string")return Error(e.message)}return Error(String(e))}var cr;function uo({poolOptions:e,highlighterOptions:t}){return cr??=new da(e,t),cr}function ho(){if(cr==null)return;cr.terminate(),cr=void 0}function rn(){return{childIdByNameId:new Map,childIds:[],childPositionById:new Map,childVisibleChunkSums:null,totalChildSubtreeNodeCount:0,totalChildVisibleSubtreeCount:0}}function fo(){return{childIdByNameId:null,childIds:[],childPositionById:null,childVisibleChunkSums:null,totalChildSubtreeNodeCount:0,totalChildVisibleSubtreeCount:0}}function Ft(e,t){if(t.childIdByNameId!=null)return t.childIdByNameId;let n=new Map;for(let r of t.childIds){let i=e[r];if(i!=null)n.set(i.nameId,r)}return t.childIdByNameId=n,n}function Sn(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];if(r!=null)t.set(r,n)}return e.childPositionById=t,t}function Cn(e,t){if(e.childPositionById!=null)e.childPositionById.set(t,e.childIds.length);e.childIds.push(t)}function po(e,t){if(e.childPositionById==null)return;for(let n=t;n<e.childIds.length;n++){let r=e.childIds[n];if(r!=null)e.childPositionById.set(r,n)}}function on(e,t){let n=0,r=0;for(let i of t.childIds){let o=e[i];if(o==null)continue;n+=o.subtreeNodeCount,r+=o.visibleSubtreeCount}t.totalChildSubtreeNodeCount=n,t.totalChildVisibleSubtreeCount=r,Bt(e,t)}function ti(e,t,n,r){if(e.totalChildSubtreeNodeCount+=n,e.totalChildVisibleSubtreeCount+=r,e.childVisibleChunkSums==null||r===0)return;let i=Sn(e).get(t);if(i===void 0)return;let o=i>>5;e.childVisibleChunkSums[o]+=r}function ni(e,t,n){let r=t.childVisibleChunkSums;if(r!=null){let o=n,s=0;for(let a of r){if(o<a){let l=qh(e,t,s,o);return{...l,childVisibleIndex:n-l.localVisibleIndex}}o-=a,s+=32}throw Error(`Visible child index ${String(n)} is out of range`)}let i=n;for(let o=0;o<t.childIds.length;o++){let s=t.childIds[o];if(s==null)continue;let a=e[s];if(a==null)continue;if(i<a.visibleSubtreeCount)return{childIndex:o,childVisibleIndex:n-i,localVisibleIndex:i};i-=a.visibleSubtreeCount}throw Error(`Visible child index ${String(n)} is out of range`)}function ha(e,t,n){let r=0,i=t.childVisibleChunkSums,o=0;if(i!=null){let s=n>>5;for(let a=0;a<s;a+=1)r+=i[a]??0;o=s<<5}for(let s=o;s<n;s+=1){let a=t.childIds[s];if(a==null)continue;let l=e[a];if(l==null)continue;r+=l.visibleSubtreeCount}return r}function Bt(e,t){if(t.childIds.length<128){t.childVisibleChunkSums=null;return}let n=Math.ceil(t.childIds.length/32),r=new Int32Array(n);for(let i=0;i<t.childIds.length;i++){let o=t.childIds[i];if(o==null)continue;let s=e[o];if(s==null)continue;r[i>>5]+=s.visibleSubtreeCount}t.childVisibleChunkSums=r}function qh(e,t,n,r){let i=Math.min(t.childIds.length,n+32),o=r;for(let s=n;s<i;s++){let a=t.childIds[s];if(a==null)continue;let l=e[a];if(l==null)continue;if(o<l.visibleSubtreeCount)return{childIndex:s,localVisibleIndex:o};o-=l.visibleSubtreeCount}throw Error(`Visible child index ${String(r)} is out of range`)}function Le(e,t,n=0){return e<<4|n<<3|t}function ze(e){return e.depthAndFlags>>>4}function ur(e){return(e.depthAndFlags&8)>>3}function R(e){return(e.depthAndFlags&8)!==0}function fa(e){return e.depthAndFlags&7}function ue(e,t){return(fa(e)&t)!==0}function kn(e,t){e.depthAndFlags|=t}function pa(e,t){e.depthAndFlags=Le(t,fa(e),ur(e))}var ma=Symbol("benchmarkInstrumentation");function ga(e,t){if(t==null)return e;return Object.defineProperty(e,ma,{configurable:!0,enumerable:!1,value:t,writable:!1}),e}function dr(e){if(e==null)return null;return e[ma]??null}function E(e,t,n){if(e==null)return n();return e.measurePhase(t,n)}function xn(e,t,n){if(!Number.isFinite(n)||e==null)return;e.setCounter(t,n)}function va(e){return e>=48&&e<=57}function zh(e){let t=[],n=0,r=0;while(r<e.length){while(r<e.length&&!va(e.charCodeAt(r)))r+=1;if(r>=e.length)break;if(r>n)t.push(e.slice(n,r));let i=0;while(r<e.length&&va(e.charCodeAt(r)))i=i*10+(e.charCodeAt(r)-48),r+=1;t.push(i),n=r}if(n<e.length||t.length===0)t.push(e.slice(n));return t}function sn(e){let t=e.toLowerCase();return{lowerValue:t,tokens:zh(t)}}function Wh(e,t){let n=Math.min(e.length,t.length);for(let r=0;r<n;r++){let i=e[r],o=t[r];if(i===o)continue;if(typeof i==="number"&&typeof o==="number")return i<o?-1:1;let s=String(i),a=String(o);if(s!==a)return s<a?-1:1}if(e.length!==t.length)return e.length<t.length?-1:1;return 0}function hr(e,t){if(e.tokens.length===1&&t.tokens.length===1&&typeof e.tokens[0]==="string"&&typeof t.tokens[0]==="string"){if(e.lowerValue===t.lowerValue)return 0;return e.lowerValue<t.lowerValue?-1:1}let n=Wh(e.tokens,t.tokens);if(n!==0)return n;if(e.lowerValue!==t.lowerValue)return e.lowerValue<t.lowerValue?-1:1;return 0}function ya(e,t,n){let r=hr(n(e),n(t));if(r!==0)return r;if(e===t)return 0;return e<t?-1:1}function $h(e,t){return ya(e,t,sn)}function ri(e,t){if(t!==e.segments.length-1)return 1;return e.isDirectory?1:0}function jh(e,t){let n=Math.min(e.segments.length,t.segments.length);for(let r=0;r<n;r++){let i=e.segments[r],o=t.segments[r];if(i===o)continue;let s=ri(e,r);if(s!==ri(t,r))return s===1?-1:1;return $h(i,o)}if(e.segments.length!==t.segments.length)return e.segments.length<t.segments.length?-1:1;if(e.isDirectory===t.isDirectory)return 0;return e.isDirectory?-1:1}function ba(e,t){return jh(e,t)}function wa(e,t,n){let r=(o)=>{let s=n.get(o);if(s!=null)return s;let a=sn(o);return n.set(o,a),a},i=Math.min(e.segments.length,t.segments.length);for(let o=0;o<i;o++){let s=e.segments[o],a=t.segments[o];if(s===a)continue;let l=ri(e,o);if(l!==ri(t,o))return l===1?-1:1;return ya(s,a,r)}if(e.segments.length!==t.segments.length)return e.segments.length<t.segments.length?-1:1;if(e.isDirectory===t.isDirectory)return 0;return e.isDirectory?-1:1}function fr(e,t){let n=e.sortKeyById[t];if(n!==void 0)return n;let r=e.valueById[t],i=sn(r);return e.sortKeyById[t]=i,i}function mo(e={}){return{flattenEmptyDirectories:e.flattenEmptyDirectories!==!1,sort:e.sort??"default"}}function Ia(e){let t=e.length>0&&e.charCodeAt(e.length-1)===47,n=t?e.length-1:e.length,r=[],i=0;for(let o=0;o<n;o++){if(e.charCodeAt(o)!==47)continue;r.push(e.slice(i,o)),i=o+1}return r.push(e.slice(i,n)),{hasTrailingSlash:t,segments:r}}function an(e){let{hasTrailingSlash:t,segments:n}=Ia(e);return{basename:n[n.length-1]??"",isDirectory:t,path:e,segments:n}}function ii(e){if(e.length===0)return{requiresDirectory:!1,segments:[]};let{hasTrailingSlash:t,segments:n}=Ia(e);return{requiresDirectory:t,segments:n}}function oi(){let e=new Map;return e.set("",0),{idByValue:e,valueById:[""],sortKeyById:[sn("")]}}function at(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 Ge(e,t){let n=e.valueById[t];if(n===void 0)throw Error(`Unknown segment ID: ${String(t)}`);return n}var go=Symbol("pathStorePreparedInputKind");function ka(e,t){return e[go]=t,e}function Sa(e){return{basename:e.basename,depth:e.segments.length,isDirectory:e.isDirectory,path:e.path,segments:e.segments}}function xa(e,t,n){if(n==="default")return ba(e,t);return n(Sa(e),Sa(t))}function Kh(){return{depthAndFlags:Le(0,3,1),nameId:0,parentId:0,subtreeNodeCount:1,visibleSubtreeCount:1}}function Uh(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 Ca(e){return e.isDirectory?e.segments.length:e.segments.length-1}function Gh(e){return Array.isArray(e)&&e.every((t)=>t!=null&&typeof t==="object"&&typeof t.path==="string"&&Array.isArray(t.segments)&&typeof t.basename==="string"&&typeof t.isDirectory==="boolean")}function Yh(e){return Array.isArray(e)&&e.every((t)=>typeof t==="string")}function _a(e,t={}){return si(e,t).map((n)=>n.path)}function Ea(e,t={}){let n=si(e,t);return ka({paths:n.map((r)=>r.path),preparedPaths:n},"prepared")}function Ta(e){let t=e.length,n=!1;for(let r=0;r<t;r+=1){let i=e[r];if(i.length>0&&i.charCodeAt(i.length-1)===47){n=!0;break}}return ka({paths:e,presortedPaths:e,presortedPathsContainDirectories:n},"presorted")}function Pa(e){let t=e,n=t.preparedPaths;if(t[go]==="prepared"&&n!=null)return n;if(!Gh(n))throw Error("preparedInput must come from PathStore.prepareInput()");return n}function Ra(e){let t=e;if(t[go]==="presorted"&&t.presortedPaths!=null)return t.presortedPaths;return Yh(t.presortedPaths)?t.presortedPaths:null}function Da(e){let t=e;return typeof t.presortedPathsContainDirectories==="boolean"?t.presortedPathsContainDirectories:null}function si(e,t={}){let n=mo(t),r=dr(t);xn(r,"workload.inputFiles",e.length);let i=E(r,"store.preparePathEntries.parse",()=>e.map((o)=>an(o)));return E(r,"store.preparePathEntries.sort",()=>i.sort((o,s)=>xa(o,s,n.sort))),i}var ai=class{directories=new Map;directoryStack=[0];presortedDirectoryNodeIds=[];initialExpandedPathSet;createdDirectoriesAllExpanded=!1;createdDirectoryCount=0;lastPreparedPath=null;nodes=[Kh()];options;instrumentation;segmentSortKeyCache=new Map;segmentTable=oi();hasDeferredDirectoryIndexes=!1;constructor(e={}){this.instrumentation=dr(e),this.options=mo(e);let t=e.initialExpandedPaths??null;if(t==null||t.length===0)this.initialExpandedPathSet=null;else{let n=new Set,r=t.length;for(let i=0;i<r;i+=1){let o=t[i],s=o.length;n.add(s>0&&o.charCodeAt(s-1)===47?o.slice(0,s-1):o)}this.initialExpandedPathSet=n,this.createdDirectoriesAllExpanded=!0}this.directories.set(0,rn())}appendPaths(e){return E(this.instrumentation,"store.builder.appendPaths.parse",()=>this.appendPreparedPaths(e.map((t)=>an(t))))}appendPreparedPaths(e,t=!0){return this.createdDirectoriesAllExpanded=!1,E(this.instrumentation,"store.builder.appendPreparedPaths",()=>{for(let n of e)this.appendPreparedPath(n,t)}),this}appendPresortedPaths(e,t=null){return E(this.instrumentation,"store.builder.appendPresortedPaths",()=>{if(t===!1){this.appendPresortedFilePaths(e);return}this.createdDirectoriesAllExpanded=!1;let n=null,r=0,i=this.nodes,o=this.segmentTable,s=o.idByValue,a=o.valueById,l=this.directoryStack,d=0,u="",f=0;for(let c of e){if(n===c)throw Error(`Duplicate path: "${c}"`);let m=c.length>0&&c.charCodeAt(c.length-1)===47,p=m?c.length-1:c.length,g=0,v=0;if(n!=null)if(u.length>0&&c.length>u.length&&c.startsWith(u))g=f,v=u.length;else{let y=Math.min(p,n.length),S=!0;for(let k=0;k<y;k++){let T=c.charCodeAt(k);if(T!==n.charCodeAt(k)){S=!1;break}if(T===47)g++,v=k+1}if(S&&m&&y===p&&n.length>p&&n.charCodeAt(p)===47)g++,v=p+1}d=g,r=g;let I=v,C=c.indexOf("/",I);while(C>=0&&C<p){let y=l[d];if(y===void 0)throw Error("Directory stack underflow while building the path store");r++;let S=c.slice(I,C),k=s.get(S);if(k===void 0)k=a.length,s.set(S,k),a.push(S);let T=i.length;i.push({depthAndFlags:Le(r,0,1),nameId:k,parentId:y,subtreeNodeCount:1,visibleSubtreeCount:1}),this.recordCreatedDirectoryPath(c.slice(0,C)),d++,l[d]=T,I=C+1,C=c.indexOf("/",I)}if(m){if(I<p){let S=l[d];if(S===void 0)throw Error(`Unable to resolve directory parent for "${c}"`);r++;let k=c.slice(I,p),T=s.get(k);if(T===void 0)T=a.length,s.set(k,T),a.push(k);let O=i.length;i.push({depthAndFlags:Le(r,0,1),nameId:T,parentId:S,subtreeNodeCount:1,visibleSubtreeCount:1}),d++,l[d]=O,I=p+1}let y=l[d];if(y===void 0)throw Error(`Unable to resolve directory node for "${c}"`);this.promoteDirectoryToExplicit(y,c)}else{let y=l[d];if(y===void 0)throw Error(`Unable to resolve file parent for "${c}"`);let S=c.slice(I),k=s.get(S);if(k===void 0)k=a.length,s.set(S,k),a.push(S);i.push({depthAndFlags:Le(r+1,0),nameId:k,parentId:y,subtreeNodeCount:1,visibleSubtreeCount:1})}if(I!==u.length)u=c.substring(0,I),f=r;n=c}if(l.length=d+1,n!=null)this.lastPreparedPath=an(n);this.hasDeferredDirectoryIndexes=!0}),this}appendPresortedFilePaths(e){let t=null,n=0,r=this.nodes,i=this.segmentTable,o=i.idByValue,s=i.valueById,a=this.directoryStack,l=0,d="",u=0;for(let f of e){if(t===f)throw Error(`Duplicate path: "${f}"`);let c=f.length,m=0,p=0;if(t!=null)if(d.length>0&&f.length>d.length&&f.startsWith(d))m=u,p=d.length;else{let S=Math.min(c,t.length);for(let k=0;k<S;k++){let T=f.charCodeAt(k);if(T!==t.charCodeAt(k))break;if(T===47)m++,p=k+1}}l=m,n=m;let g=p,v=f.indexOf("/",g);while(v>=0){let S=a[l];if(S===void 0)throw Error("Directory stack underflow while building the path store");n++;let k=f.slice(g,v),T=o.get(k);if(T===void 0)T=s.length,o.set(k,T),s.push(k);let O=r.length;r.push({depthAndFlags:Le(n,0,1),nameId:T,parentId:S,subtreeNodeCount:1,visibleSubtreeCount:1}),this.recordCreatedDirectoryPath(f.slice(0,v)),this.presortedDirectoryNodeIds.push(O),l++,a[l]=O,g=v+1,v=f.indexOf("/",g)}let I=a[l];if(I===void 0)throw Error(`Unable to resolve file parent for "${f}"`);let C=f.slice(g),y=o.get(C);if(y===void 0)y=s.length,o.set(C,y),s.push(C);if(r.push({depthAndFlags:Le(n+1,0),nameId:y,parentId:I,subtreeNodeCount:1,visibleSubtreeCount:1}),g!==d.length)d=f.substring(0,g),u=n;t=f}if(a.length=l+1,t!=null)this.lastPreparedPath=an(t);this.hasDeferredDirectoryIndexes=!0}finish(e={}){let t=e.skipSubtreeCountPass===!0;if(this.hasDeferredDirectoryIndexes)E(this.instrumentation,"store.builder.buildDirectoryIndexes",()=>this.buildPresortedFinish(t)),this.hasDeferredDirectoryIndexes=!1;else if(!t)E(this.instrumentation,"store.builder.computeSubtreeCounts",()=>this.computeSubtreeCounts(0));return{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(),this.hasDeferredDirectoryIndexes=!1;if(this.lastPreparedPath!=null){if(e.path===this.lastPreparedPath.path)throw Error(`Duplicate path: "${e.path}"`);if(t){if((this.options.sort==="default"?wa(this.lastPreparedPath,e,this.segmentSortKeyCache):xa(this.lastPreparedPath,e,this.options.sort))>0)throw Error(`Builder input must be sorted before appendPaths(): "${e.path}"`)}}let n=this.lastPreparedPath,r=Ca(e),i=n==null?0:Ca(n),o=n==null?0:Uh(n.segments,e.segments),s=Math.min(o,r,i);this.directoryStack.length=s+1;for(let l=s;l<r;l++){let d=this.directoryStack[this.directoryStack.length-1];if(d===void 0)throw Error("Directory stack underflow while building the path store");let u=t?this.getOrCreateDirectoryChild(d,e.segments[l]):this.createDirectoryChild(d,e.segments[l]);this.directoryStack.push(u)}if(e.isDirectory){let l=this.directoryStack[this.directoryStack.length-1];if(l===void 0)throw Error(`Unable to resolve directory node for "${e.path}"`);this.promoteDirectoryToExplicit(l,e.path),this.lastPreparedPath=e;return}let a=this.directoryStack[this.directoryStack.length-1];if(a===void 0)throw Error(`Unable to resolve file parent for "${e.path}"`);if(t)this.createFileChild(a,e.basename,e.path);else this.createFileChildUnchecked(a,e.basename);this.lastPreparedPath=e}recordCreatedDirectoryPath(e){if(!this.createdDirectoriesAllExpanded||this.initialExpandedPathSet==null)return;if(this.createdDirectoryCount+=1,!this.initialExpandedPathSet.has(e))this.createdDirectoriesAllExpanded=!1}createFileChild(e,t,n){let r=at(this.segmentTable,t),i=this.getDirectoryIndex(e),o=i.childIdByNameId;if(o!=null){if(o.get(r)!==void 0)throw Error(`Path collides with an existing entry: "${n}"`)}let s=this.nodes[e];if(s===void 0)throw Error(`Unknown parent node ID: ${String(e)}`);let a=this.nodes.length;if(this.nodes.push({depthAndFlags:Le(ze(s)+1,0),nameId:r,parentId:e,subtreeNodeCount:1,visibleSubtreeCount:1}),o!=null)o.set(r,a);return Cn(i,a),a}createFileChildUnchecked(e,t){let n=at(this.segmentTable,t),r=this.getDirectoryIndex(e),i=this.nodes[e];if(i===void 0)throw Error(`Unknown parent node ID: ${String(e)}`);let o=this.nodes.length;if(this.nodes.push({depthAndFlags:Le(ze(i)+1,0),nameId:n,parentId:e,subtreeNodeCount:1,visibleSubtreeCount:1}),r.childIdByNameId!=null)r.childIdByNameId.set(n,o);return Cn(r,o),o}getOrCreateDirectoryChild(e,t){let n=at(this.segmentTable,t),r=this.getDirectoryIndex(e);if(r.childIdByNameId!=null){let s=r.childIdByNameId.get(n);if(s!==void 0){let a=this.nodes[s];if(a!=null&&!R(a))throw Error(`Path collides with an existing file while creating directory "${t}"`);return s}}let i=this.nodes[e];if(i===void 0)throw Error(`Unknown parent node ID: ${String(e)}`);let o=this.nodes.length;if(this.nodes.push({depthAndFlags:Le(ze(i)+1,0,1),nameId:n,parentId:e,subtreeNodeCount:1,visibleSubtreeCount:1}),r.childIdByNameId!=null)r.childIdByNameId.set(n,o);return Cn(r,o),this.directories.set(o,rn()),o}createDirectoryChild(e,t){let n=at(this.segmentTable,t),r=this.getDirectoryIndex(e),i=this.nodes[e];if(i===void 0)throw Error(`Unknown parent node ID: ${String(e)}`);let o=this.nodes.length;if(this.nodes.push({depthAndFlags:Le(ze(i)+1,0,1),nameId:n,parentId:e,subtreeNodeCount:1,visibleSubtreeCount:1}),r.childIdByNameId!=null)r.childIdByNameId.set(n,o);return Cn(r,o),this.directories.set(o,rn()),o}promoteDirectoryToExplicit(e,t){let n=this.nodes[e];if(n===void 0)throw Error(`Unknown directory node ID: ${String(e)}`);if(!R(n))throw Error(`Path is not a directory: "${t}"`);if(ue(n,1))throw Error(`Duplicate path: "${t}"`);kn(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,fo());let r=-1,i=null;for(let o=1;o<t.length;o++){let s=t[o];if(s==null)continue;if(R(s)){let l=fo();n.set(o,l),r=o,i=l}let a;if(s.parentId===r)a=i;else a=n.get(s.parentId),r=s.parentId,i=a??null;if(a!=null)a.childIds.push(o)}if(e)return;for(let o=t.length-1;o>=1;o--){let s=t[o];if(s==null)continue;let a=t[s.parentId];if(a!=null)a.subtreeNodeCount+=s.subtreeNodeCount,a.visibleSubtreeCount+=s.visibleSubtreeCount}}buildDirectoryIndexes(){let e=this.nodes;for(let t=1;t<e.length;t++){let n=e[t];if(n==null)continue;if(R(n))this.directories.set(t,rn());let r=this.directories.get(n.parentId);if(r!=null){if(r.childIdByNameId!=null)r.childIdByNameId.set(n.nameId,t);Cn(r,t)}}}computeSubtreeCounts(e){let t=this.nodes[e];if(t===void 0)throw Error(`Unknown node ID: ${String(e)}`);if(!R(t))return t.subtreeNodeCount=1,t.visibleSubtreeCount=1,1;let n=this.getDirectoryIndex(e),r=1;for(let i of n.childIds)r+=this.computeSubtreeCounts(i);return on(this.nodes,n),t.subtreeNodeCount=r,t.visibleSubtreeCount=r,r}};function Ma(e,t="closed",n=null){let r=Xh(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 Aa(){return{affectedAncestorIds:new Set,affectedNodeIds:new Set,events:[]}}function Xh(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 Na(e,t){if(ue(t,2))return!0;if(e.defaultExpansion==="open")return!0;if(e.defaultExpansion==="closed")return!1;return ze(t)<=e.defaultExpansion}function _e(e,t,n=e.snapshot.nodes[t]){if(n==null||!R(n))return!1;if(e.directoriesOpenByDefault&&!e.hasCollapsedDirectoryOverrides)return!0;if(e.collapsedDirectoryIds.has(t))return!1;if(e.expandedDirectoryIds.has(t))return!0;return Na(e,n)}function Ht(e,t,n,r=e.snapshot.nodes[t]){if(r==null||!R(r))return;let i=Na(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 La(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 Vt(e,t){return e.directoryLoadInfoById.get(t)?.state??"loaded"}function Fa(e,t){let n=La(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 Ba(e,t){let n=La(e,t);n.activeAttemptId=null,n.errorMessage=null,n.state="unloaded"}function Ha(e,t,n){let r=e.directoryLoadInfoById.get(t);if(r==null||r.activeAttemptId!==n)return!1;return r.activeAttemptId=null,r.errorMessage=null,r.state="loaded",!0}function Va(e,t,n){return e.directoryLoadInfoById.get(t)?.activeAttemptId===n}function Oa(e,t,n,r){let i=e.directoryLoadInfoById.get(t);if(i==null||i.activeAttemptId!==n)return!1;return i.activeAttemptId=null,i.errorMessage=r??null,i.state="error",!0}function qa(e,t){e.directoryLoadInfoById.delete(t)}function Ka(e,t,n){let r=n,i=e.listeners.get(t);if(i!=null)i.add(r);else e.listeners.set(t,new Set([r]));return()=>{let o=e.listeners.get(t);if(o==null)return;if(o.delete(r),o.size===0)e.listeners.delete(t)}}function Ua(e){return{affectedAncestorIds:e.affectedAncestorIds??[],affectedNodeIds:e.affectedNodeIds??[],canonicalChanged:!0,operation:"add",path:e.path,projectionChanged:e.projectionChanged,visibleCountDelta:null}}function Ga(e){return{affectedAncestorIds:e.affectedAncestorIds??[],affectedNodeIds:e.affectedNodeIds??[],canonicalChanged:!0,operation:"remove",path:e.path,projectionChanged:e.projectionChanged,recursive:e.recursive,visibleCountDelta:null}}function Ya(e){return{affectedAncestorIds:e.affectedAncestorIds??[],affectedNodeIds:e.affectedNodeIds??[],canonicalChanged:!0,from:e.from,operation:"move",projectionChanged:e.projectionChanged,to:e.to,visibleCountDelta:null}}function Xa(e){return{affectedAncestorIds:e.affectedAncestorIds??[],affectedNodeIds:e.affectedNodeIds??[],canonicalChanged:!1,operation:"expand",path:e.path,projectionChanged:!0,visibleCountDelta:null}}function Qa(e){return{affectedAncestorIds:e.affectedAncestorIds??[],affectedNodeIds:e.affectedNodeIds??[],canonicalChanged:!1,operation:"collapse",path:e.path,projectionChanged:!0,visibleCountDelta:null}}function Za(e){return{affectedAncestorIds:e.affectedAncestorIds??[],affectedNodeIds:e.affectedNodeIds??[],canonicalChanged:!1,operation:"mark-directory-unloaded",path:e.path,projectionChanged:e.projectionChanged,visibleCountDelta:null}}function Ja(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 el(e){return{affectedAncestorIds:e.affectedAncestorIds??[],affectedNodeIds:e.affectedNodeIds??[],attemptId:e.attemptId,canonicalChanged:e.childEvents.some((t)=>t.canonicalChanged),childEvents:e.childEvents,operation:"apply-child-patch",path:e.path,projectionChanged:e.projectionChanged,visibleCountDelta:null}}function tl(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 nl(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 rl(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 Fe(e,t,n){return{...n,visibleCountDelta:yo(e)-t}}function il(e,t){let n=yo(e),r=Aa();e.transactionStack.push(r);try{t()}catch(i){throw Wa(e,r,!1),i}Wa(e,r,!0,yo(e)-n)}function Ze(e,t){let n=e.instrumentation;if(n==null){za(e,t);return}E(n,"store.events.record",()=>za(e,t))}function za(e,t){let n=e.transactionStack[e.transactionStack.length-1]??null;if(n==null){vo(e,t);return}n.events.push(t),Jh(n,t)}function Wa(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 a=e.instrumentation;if(a==null)$a(i,t);else E(a,"store.events.batch.merge",()=>$a(i,t));return}let o=Qh(t,r),s=e.instrumentation;if(s==null){vo(e,o);return}E(s,"store.events.batch.commit",()=>vo(e,o))}function Qh(e,t){return{affectedAncestorIds:[...e.affectedAncestorIds],affectedNodeIds:[...e.affectedNodeIds],canonicalChanged:e.events.some((n)=>n.canonicalChanged),events:[...e.events],operation:"batch",projectionChanged:e.events.some((n)=>n.projectionChanged),visibleCountDelta:t}}function Zh(e,t){for(let n of t.affectedAncestorIds)e.affectedAncestorIds.add(n);for(let n of t.affectedNodeIds)e.affectedNodeIds.add(n)}function $a(e,t){for(let n of t.events)e.events.push(n);Zh(e,t)}function Jh(e,t){for(let n of t.affectedNodeIds)e.affectedNodeIds.add(n);for(let n of t.affectedAncestorIds)e.affectedAncestorIds.add(n)}function vo(e,t){let n=e.instrumentation;if(n==null){ja(e,t);return}E(n,"store.events.emit",()=>ja(e,t))}function ja(e,t){e.listeners.get(t.operation)?.forEach((n)=>n(t)),e.listeners.get("*")?.forEach((n)=>n(t))}function yo(e){return e.snapshot.nodes[e.snapshot.rootId]?.visibleSubtreeCount??0}function Ct(e,t){if(e.snapshot.options.flattenEmptyDirectories!==!0)return null;let n=e.snapshot.nodes[t];if(n==null||!R(n)||ue(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 o=e.snapshot.nodes[i];if(o==null||!R(o))return null;return i}function kt(e,t){let n=t;while(!0){let r=Ct(e,n);if(r==null)return n;n=r}}function _n(e,t){let n=[t],r=t;while(!0){let i=Ct(e,r);if(i==null)return n;n.push(i),r=i}}function li(e,t){let n=t==null?e.snapshot.rootId:Be(e,t);if(n==null)return[];return tf(e,n)}function wo(e,t){let n=an(t),r=n.isDirectory?n.segments:n.segments.slice(0,-1),i=Ot(e,df(e,r)),{createdNodeIds:o,directoryId:s}=nf(e,r),a=new Set(o),l=s;if(n.isDirectory){let u=D(e,s);if(ue(u,1))throw Error(`Path already exists: "${t}"`);kn(u,1),e.pathCacheByNodeId.set(s,{path:t,version:e.pathCacheVersion}),a.add(s)}else l=of(e,s,n.basename),a.add(l);qt(e,s);let d=Ot(e,s);return Ua({affectedAncestorIds:Ye(e,l),affectedNodeIds:[...a],path:t,projectionChanged:dl(i,d)})}function Io(e,t,n){let r=Be(e,t);if(r==null)throw Error(`Path does not exist: "${t}"`);let i=D(e,r);if(ue(i,2))throw Error("The root node cannot be removed");if(R(i)&&ie(e,r).childIds.length>0&&n.recursive!==!0)throw Error(`Cannot remove a non-empty directory without recursive: "${t}"`);let o=i.parentId,s=Ot(e,o),a=ul(e,r);ko(e,o,r,i.nameId),xo(e,o),qt(e,o);let l=Ot(e,o);return Ga({affectedAncestorIds:Ye(e,o),affectedNodeIds:a,path:t,projectionChanged:dl(s,l),recursive:n.recursive===!0})}function So(e,t,n,r){let i=Be(e,t);if(i==null)throw Error(`Source path does not exist: "${t}"`);let o=D(e,i);if(ue(o,2))throw Error("The root node cannot be moved");let s=r.collision??"error",a=cf(e,i,n),l=Ot(e,o.parentId),d=Ot(e,a.parentId),u=Ge(e.snapshot.segmentTable,o.nameId),f=at(e.snapshot.segmentTable,a.basename);if(a.parentId===o.parentId&&u===a.basename)return null;if(R(o)&&ff(e,i,a.parentId))throw Error("Cannot move a directory into one of its descendants");let c=Ft(e.snapshot.nodes,ie(e,a.parentId)).get(f),m=a.existingNodeId??c??null;if(m!=null&&m!==i){if(uf(e,m,s,ur(o))==="skip")return null}let p=o.parentId;if(ko(e,p,i,o.nameId),o.parentId=a.parentId,o.nameId=f,e.pathCacheByNodeId.delete(i),fl(e,i),Co(e,a.parentId,i),xo(e,p),e.pathCacheVersion++,qt(e,p),a.parentId!==p)qt(e,a.parentId);let g=Ot(e,p),v=Ot(e,a.parentId);return Ya({affectedAncestorIds:[...new Set([...Ye(e,p),...Ye(e,a.parentId)])],affectedNodeIds:[i],from:t,projectionChanged:hl([l,d],[g,v]),to:te(e,i)})}function ef(e,t){let n=e.pathCacheByNodeId.get(t);return n!=null&&n.version===e.pathCacheVersion?n.path:null}function ol(e,t,n){return e.pathCacheByNodeId.set(t,{path:n,version:e.pathCacheVersion}),n}function te(e,t){let n=D(e,t),r=ef(e,t);if(r!=null)return r;if(ue(n,2))return ol(e,t,"");let i=te(e,n.parentId),o=Ge(e.snapshot.segmentTable,n.nameId),s=i.length===0?o:`${i}${o}`;return ol(e,t,R(n)?`${s}/`:s)}function qt(e,t){let n=e.instrumentation;if(n==null){al(e,t);return}E(n,"store.recomputeCountsUpwardFrom",()=>al(e,t))}function pr(e,t){let n=[[t,0]],{nodes:r,directories:i}=e.snapshot;while(n.length>0){let o=n[n.length-1],s=o[0],a=r[s];if(a==null||!R(a)){bo(e,s,a,!0),n.pop();continue}let l=i.get(s);if(l==null||o[1]>=l.childIds.length){bo(e,s,a,!0),n.pop();continue}let d=l.childIds[o[1]++];n.push([d,0])}}function Ye(e,t){let n=[],r=t;while(r!=null){let i=D(e,r);if(n.push(r),r===e.snapshot.rootId)break;r=i.parentId}return n}function Be(e,t){if(t.length===0)return e.snapshot.rootId;let n=ii(t);return cl(e,n.segments,n.requiresDirectory)}function cl(e,t,n){let r=e.snapshot.rootId;for(let o of t){let s=e.snapshot.segmentTable.idByValue.get(o);if(s===void 0)return null;let a=ie(e,r),l=Ft(e.snapshot.nodes,a).get(s);if(l===void 0)return null;r=l}let i=D(e,r);if(n&&!R(i))return null;return r}function ie(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 D(e,t){let n=e.snapshot.nodes[t];if(n===void 0||ue(n,4))throw Error(`Unknown node ID: ${String(t)}`);return n}function tf(e,t){let n=e.snapshot.nodes[t];if(n===void 0||ue(n,4))return[];if(!R(n))return[te(e,t)];if(ie(e,t).childIds.length===0)return ue(n,1)&&!ue(n,2)?[te(e,t)]:[];let r=[],i=[{childIndex:0,nodeId:t}];while(i.length>0){let o=i[i.length-1];if(o==null)break;let s=e.snapshot.nodes[o.nodeId];if(s===void 0||ue(s,4)){i.pop();continue}if(!R(s)){r.push(te(e,o.nodeId)),i.pop();continue}let a=ie(e,o.nodeId);if(a.childIds.length===0){if(ue(s,1)&&!ue(s,2))r.push(te(e,o.nodeId));i.pop();continue}let l=a.childIds[o.childIndex];if(l==null){i.pop();continue}o.childIndex++,i.push({childIndex:0,nodeId:l})}return r}function nf(e,t){let n=[],r=e.snapshot.rootId;for(let i of t){let o=at(e.snapshot.segmentTable,i),s=ie(e,r),a=Ft(e.snapshot.nodes,s).get(o);if(a!==void 0){if(!R(D(e,a)))throw Error(`Cannot create a directory that collides with an existing file: "${i}"`);r=a;continue}r=rf(e,r,o),n.push(r)}return{createdNodeIds:n,directoryId:r}}function rf(e,t,n){let r=D(e,t),i=e.snapshot.nodes.length;if(e.snapshot.nodes.push({depthAndFlags:Le(ze(r)+1,0,1),nameId:n,parentId:t,subtreeNodeCount:1,visibleSubtreeCount:1}),e.snapshot.directories.set(i,rn()),Co(e,t,i),e.collapseNewDirectoriesByDefault)e.collapsedDirectoryIds.add(i),e.hasCollapsedDirectoryOverrides=!0;return e.activeNodeCount++,i}function of(e,t,n){let r=at(e.snapshot.segmentTable,n),i=ie(e,t);if(Ft(e.snapshot.nodes,i).has(r))throw Error(`Path already exists: "${pf(e,t,n)}"`);let o=D(e,t),s=e.snapshot.nodes.length;return e.snapshot.nodes.push({depthAndFlags:Le(ze(o)+1,0),nameId:r,parentId:t,subtreeNodeCount:1,visibleSubtreeCount:1}),Co(e,t,s),e.activeNodeCount++,s}function sf(e,t,n){let r=0,i=t.childIds.length;while(r<i){let o=r+i>>>1,s=t.childIds[o];if(s==null){i=o;continue}if(af(e,n,s)<0)i=o;else r=o+1}return r}function Co(e,t,n){let r=ie(e,t),i=D(e,n);Ft(e.snapshot.nodes,r).set(i.nameId,n),ti(r,n,i.subtreeNodeCount,i.visibleSubtreeCount);let o=sf(e,r,n);r.childIds.splice(o,0,n),po(r,o),Bt(e.snapshot.nodes,r)}function ko(e,t,n,r){let i=ie(e,t),o=Sn(i),s=o.get(n)??-1;Ft(e.snapshot.nodes,i).delete(r),o.delete(n);let a=e.snapshot.nodes[n];if(a!=null)ti(i,n,-a.subtreeNodeCount,-a.visibleSubtreeCount);if(s>=0)i.childIds.splice(s,1),po(i,s),Bt(e.snapshot.nodes,i)}function af(e,t,n){let r=e.snapshot.options.sort;if(r==="default")return lf(e,t,n);return r(sl(e,t),sl(e,n))}function lf(e,t,n){let r=D(e,t),i=D(e,n),o=R(r);if(o!==R(i))return o?-1:1;let s=hr(fr(e.snapshot.segmentTable,r.nameId),fr(e.snapshot.segmentTable,i.nameId));if(s!==0)return s;let a=Ge(e.snapshot.segmentTable,r.nameId),l=Ge(e.snapshot.segmentTable,i.nameId);if(a!==l)return a<l?-1:1;return t<n?-1:1}function sl(e,t){let n=D(e,t),r=te(e,t),i=R(n),o=i?r.slice(0,-1):r;return{basename:Ge(e.snapshot.segmentTable,n.nameId),depth:ze(n),isDirectory:i,path:r,segments:o.length===0?[]:o.split("/")}}function cf(e,t,n){let r=D(e,t),i=Be(e,n);if(i!=null){let d=D(e,i);if(R(d))return{basename:Ge(e.snapshot.segmentTable,r.nameId),existingNodeId:null,parentId:i};let u=ii(n).segments;return{basename:u[u.length-1]??"",existingNodeId:i,parentId:d.parentId}}let o=ii(n),s=o.segments[o.segments.length-1]??"",a=o.segments.slice(0,-1),l=a.length===0?e.snapshot.rootId:cl(e,a,!0);if(l==null)throw Error(`Destination parent does not exist: "${n}"`);return{basename:s,existingNodeId:null,parentId:l}}function uf(e,t,n,r){if(n==="skip")return"skip";if(n==="error")throw Error(`Destination already exists: "${te(e,t)}"`);let i=D(e,t);if(ur(i)!==r)throw Error("replace collision requires the same source and destination kinds");if(R(i)&&ie(e,t).childIds.length>0)throw Error("replace collision does not support non-empty directories");let{parentId:o,nameId:s}=i;return ul(e,t),ko(e,o,t,s),xo(e,o),qt(e,o),"handled"}function ul(e,t){let n=[],r=[{nodeId:t,visitedChildren:!1}];while(r.length>0){let i=r.pop();if(i==null)break;let o=D(e,i.nodeId);if(i.visitedChildren||!R(o)){if(R(o))e.snapshot.directories.delete(i.nodeId);if(kn(o,4),e.pathCacheByNodeId.delete(i.nodeId),e.collapsedDirectoryIds.delete(i.nodeId))e.hasCollapsedDirectoryOverrides=e.collapsedDirectoryIds.size>0;e.expandedDirectoryIds.delete(i.nodeId),qa(e,i.nodeId),e.activeNodeCount--,n.push(i.nodeId);continue}r.push({nodeId:i.nodeId,visitedChildren:!0});let s=ie(e,i.nodeId);for(let a=s.childIds.length-1;a>=0;a--){let l=s.childIds[a];if(l!=null)r.push({nodeId:l,visitedChildren:!1})}}return n}function xo(e,t){let n=t;while(n!=null){let r=D(e,n);if(!R(r)||ue(r,2))return;if(ie(e,n).childIds.length>0)return;kn(r,1),n=r.parentId===n?null:r.parentId}}function df(e,t){let n=e.snapshot.rootId;for(let r of t){let i=e.snapshot.segmentTable.idByValue.get(r);if(i==null)break;let o=Ft(e.snapshot.nodes,ie(e,n)).get(i);if(o==null)break;if(!R(D(e,o)))break;n=o}return n}function Ot(e,t){let n=hf(e,t);if(n==null)return null;let r=kt(e,n),i=D(e,r),o=n===r?null:_n(e,n).map((s)=>te(e,s));return JSON.stringify({flattenedSegmentPaths:o,hasChildren:ie(e,r).childIds.length>0,path:te(e,r),terminalKind:ur(i)})}function dl(e,t){return hl([e],[t])}function hl(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 hf(e,t){let n=t;while(n!=null){let r=D(e,n);if(!R(r)||ue(r,2))return null;if(!_e(e,n,r))return n;n=r.parentId}return null}function fl(e,t){let n=D(e,t);if(pa(n,(t===e.snapshot.rootId?-1:ze(D(e,n.parentId)))+1),!R(n))return;let r=ie(e,t);for(let i of r.childIds)fl(e,i)}function ff(e,t,n){let r=n;while(r!=null){if(r===t)return!0;let i=D(e,r);if(r===e.snapshot.rootId)return!1;r=i.parentId}return!1}function bo(e,t,n=D(e,t),r=!1){let i=e.instrumentation;if(i==null){ll(e,t,n,r);return}E(i,"store.recomputeNodeCounts",()=>ll(e,t,n,r))}function al(e,t){let n=t;while(n!=null){let r=D(e,n),i=r.subtreeNodeCount,o=r.visibleSubtreeCount;if(bo(e,n,r),n===e.snapshot.rootId)return;let s=r.subtreeNodeCount-i,a=r.visibleSubtreeCount-o,l=r.parentId;if(s!==0||a!==0)ti(ie(e,l),n,s,a);n=l}}function ll(e,t,n,r){if(!R(n)){n.subtreeNodeCount=1,n.visibleSubtreeCount=1;return}let i=ie(e,t);if(r){let a=e.instrumentation;if(a==null)on(e.snapshot.nodes,i);else E(a,"store.recomputeNodeCounts.rebuildChildAggregates",()=>on(e.snapshot.nodes,i))}let o=1+i.totalChildSubtreeNodeCount,s=i.totalChildVisibleSubtreeCount;if(n.subtreeNodeCount=o,ue(n,2)){n.visibleSubtreeCount=s;return}n.visibleSubtreeCount=Ct(e,t)!=null?s:_e(e,t,n)?1+s:1}function pf(e,t,n){let r=te(e,t);return r.length===0?n:`${r}${n}`}function En(e){return e!=null&&!ue(e,4)}function ci(e,t){let n=e.snapshot.nodes[t];if(!En(n)||!R(n)||ue(n,2))return null;return n}function mf(e){let t=0;for(let[n,r]of e.pathCacheByNodeId){if(r.version!==e.pathCacheVersion)continue;if(!En(e.snapshot.nodes[n]))continue;t+=1}return t}function gf(e){return Math.max(0,e.valueById.length-1)}function pl(e){return{activeNodeCount:e.activeNodeCount,cachedPathEntryCount:mf(e),loadInfoEntryCount:e.directoryLoadInfoById.size,segmentCount:gf(e.snapshot.segmentTable),totalNodeSlotCount:Math.max(0,e.snapshot.nodes.length-1)}}function vf(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 ml(e){let t=[],n=[];for(let r of e.collapsedDirectoryIds)if(ci(e,r)!=null)t.push(te(e,r));for(let r of e.expandedDirectoryIds)if(ci(e,r)!=null)n.push(te(e,r));return{collapsedPaths:t,expandedPaths:n}}function gl(e){let t=[];for(let[n,r]of e.directoryLoadInfoById){if(ci(e,n)==null||Vt(e,n)==="loaded")continue;t.push({info:{activeAttemptId:null,errorMessage:r.errorMessage,nextAttemptId:r.nextAttemptId,state:r.state},path:te(e,n)})}return t}function vl(e,t){e.collapsedDirectoryIds.clear(),e.hasCollapsedDirectoryOverrides=!1,e.expandedDirectoryIds.clear();for(let n of t.expandedPaths){let r=Be(e,n);if(r==null)continue;Ht(e,r,!0,D(e,r))}for(let n of t.collapsedPaths){let r=Be(e,n);if(r==null)continue;Ht(e,r,!1,D(e,r))}}function yl(e,t){e.directoryLoadInfoById.clear();for(let n of t){let r=Be(e,n.path);if(r==null)continue;if(ci(e,r)==null)continue;e.directoryLoadInfoById.set(r,{activeAttemptId:null,errorMessage:n.info.errorMessage,nextAttemptId:n.info.nextAttemptId,state:n.info.state})}}function yf(e){e.pathCacheVersion+=1,e.pathCacheByNodeId.clear(),e.pathCacheByNodeId.set(e.snapshot.rootId,{path:"",version:e.pathCacheVersion})}function bf(e){let t=e.snapshot.segmentTable,n=oi();for(let r of e.snapshot.nodes){if(!En(r))continue;if(ue(r,2)){r.nameId=0;continue}r.nameId=at(n,Ge(t,r.nameId))}e.snapshot.segmentTable=n}function wf(e){for(let[t,n]of e.snapshot.directories){let r=e.snapshot.nodes[t];if(!En(r)||!R(r)){e.snapshot.directories.delete(t);continue}let i=n.childIds.filter((o)=>{let s=e.snapshot.nodes[o];return En(s)&&s.parentId===t});n.childIds=i,n.childIdByNameId=new Map(i.map((o)=>[D(e,o).nameId,o])),n.childPositionById=new Map(i.map((o,s)=>[o,s])),on(e.snapshot.nodes,n)}}function If(e){let t=e.snapshot.nodes.length-1;while(t>e.snapshot.rootId){let n=e.snapshot.nodes[t];if(En(n))break;t-=1}e.snapshot.nodes.length=t+1}function Sf(e){let t=ml(e),n=gl(e);E(e.instrumentation,"store.cleanup.stable.clearPathCaches",()=>yf(e)),E(e.instrumentation,"store.cleanup.stable.rebuildSegmentTable",()=>bf(e)),E(e.instrumentation,"store.cleanup.stable.rebuildDirectoryIndexes",()=>wf(e)),E(e.instrumentation,"store.cleanup.stable.trimTrailingRemovedNodeSlots",()=>If(e)),E(e.instrumentation,"store.cleanup.stable.restoreExpansionOverrides",()=>vl(e,t)),E(e.instrumentation,"store.cleanup.stable.restoreDirectoryLoadInfos",()=>yl(e,n)),E(e.instrumentation,"store.cleanup.stable.recomputeCounts",()=>pr(e,e.snapshot.rootId))}function Cf(e){let t=ml(e),n=gl(e),r=E(e.instrumentation,"store.cleanup.aggressive.listPaths",()=>li(e)),i=ga({...e.snapshot.options},e.instrumentation),o=E(e.instrumentation,"store.cleanup.aggressive.rebuildSnapshot",()=>{let s=new ai(i);return s.appendPaths(r),s.finish()});e.snapshot=o,e.activeNodeCount=o.nodes.length-1,e.pathCacheByNodeId=new Map([[o.rootId,{path:"",version:0}]]),e.pathCacheVersion=0,E(e.instrumentation,"store.cleanup.aggressive.restoreExpansionOverrides",()=>vl(e,t)),E(e.instrumentation,"store.cleanup.aggressive.restoreDirectoryLoadInfos",()=>yl(e,n)),E(e.instrumentation,"store.cleanup.aggressive.recomputeCounts",()=>pr(e,e.snapshot.rootId))}function bl(e){for(let t of e.directoryLoadInfoById.values())if(t.state==="loading"&&t.activeAttemptId!=null)return!0;return!1}function wl(e,t){let n=pl(e);if(t==="stable")E(e.instrumentation,"store.cleanup.stable",()=>Sf(e));else E(e.instrumentation,"store.cleanup.aggressive",()=>Cf(e));let r=pl(e);return vf(t,t==="stable",n,r)}var kf=64;function xf(e,t){let n=t+2;if(n<=e.length)return e;let r=e.length;while(r<n)r*=2;let i=new Int32Array(r);return i.fill(-1),i.set(e),i}function Ee(e){return D(e,e.snapshot.rootId).visibleSubtreeCount}function kl(e,t,n,r){let i=D(e,t.terminalNodeId),o=Math.max(1,i.visibleSubtreeCount);return Math.min(r-1,n+o-1)}function _f(e,t,n,r){return{ancestorPaths:r,index:t.index,posInSet:t.posInSet,row:mr(e,t.cursor),setSize:t.setSize,subtreeEndIndex:kl(e,t.cursor,t.index,n)}}function xl(e,t,n,r,i,o){let s=ie(e,t),{childIndex:a,childVisibleIndex:l,localVisibleIndex:d}=ni(e.snapshot.nodes,s,n),u=s.childIds[a];if(u==null)throw Error(`Visible index ${String(n)} is out of range`);return Ef(e,u,d,r+l,i+1,a,s.childIds.length,o)}function Ef(e,t,n,r,i,o,s,a){if(!R(D(e,t))){if(n===0)return{ancestors:a,cursor:{headNodeId:t,terminalNodeId:t,visibleDepth:i},index:r,posInSet:o,setSize:s};throw Error(`Visible index ${String(n)} is out of range for file`)}let l=Al(e,t,i);if(n===0)return{ancestors:a,cursor:l,index:r,posInSet:o,setSize:s};let d=D(e,l.terminalNodeId);if(!R(d)||!_e(e,l.terminalNodeId,d))throw Error(`Visible index ${String(n)} is out of range for collapsed directory`);return xl(e,l.terminalNodeId,n-1,r+1,l.visibleDepth,[...a,{cursor:l,index:r,posInSet:o,setSize:s}])}function _l(e,t){let n=Ee(e);if(t<0||t>=n)return null;let r=xl(e,e.snapshot.rootId,t,0,-1,[]),i=r.ancestors.map((s)=>te(e,s.cursor.terminalNodeId)),o=null;return{ancestorPaths:i,get ancestorRows(){if(o!=null)return o;let s=[],a=[];for(let l of r.ancestors){let d=_f(e,l,n,[...a]);s.push(d),a.push(d.row.path)}return o=s,o},index:r.index,posInSet:r.posInSet,row:mr(e,r.cursor),setSize:r.setSize,subtreeEndIndex:kl(e,r.cursor,r.index,n)}}function El(e,t,n){let r=e.instrumentation,i=Ee(e);if(i<=0||n<t)return[];let o=Math.max(0,Math.min(t,i-1)),s=Math.max(o,Math.min(n,i-1));if(r==null){if(o===0)return Rf(e,s+1);let f=[],c=Il(e,o);for(let m=o;m<=s&&c!=null;m++){let p=mr(e,c);f.push(p),c=Sl(e,c)}return f}let a=[],l=0,d=0,u=E(r,"store.getVisibleSlice.selectFirstRow",()=>Il(e,o));for(let f=o;f<=s&&u!=null;f++){let c=E(r,"store.getVisibleSlice.materializeRow",()=>mr(e,u));if(a.push(c),c.isFlattened)l++,d+=c.flattenedSegments?.length??0;u=E(r,"store.getVisibleSlice.advanceCursor",()=>Sl(e,u))}return xn(r,"workload.visibleRowsRead",a.length),xn(r,"workload.flattenedRowsRead",l),xn(r,"workload.flattenedSegmentsRead",d),a}function Eo(e,t=Ee(e)){let n=e.instrumentation;if(n==null)return Cl(e,t);return E(n,"store.getVisibleTreeProjection",()=>Cl(e,t))}function Tl(e){return Pf(Eo(e))}function Pl(e,t){let n=Be(e,t);if(n==null||n===e.snapshot.rootId)return null;if(R(D(e,n))&&kt(e,n)!==n)return null;let r=0,i=n,{nodes:o,rootId:s}=e.snapshot;while(i!==s){let a=D(e,i).parentId,l=ie(e,a),d=Sn(l).get(i);if(d==null)throw Error(`Child ${String(i)} was not found in its parent index`);if(r+=ha(o,l,d),a!==s){let u=D(e,a),f=Ct(e,a);if(!_e(e,a,u)&&f!==i)return null;if(kt(e,a)===a)r+=1}i=a}return r}function Rl(e,t){let n=Be(e,t);if(n==null)throw Error(`Path does not exist: "${t}"`);let r=D(e,n);if(!R(r))throw Error(`Path is not a directory: "${t}"`);if(_e(e,n,r))return null;return Ht(e,n,!0,r),qt(e,n),Xa({affectedAncestorIds:Ye(e,n),affectedNodeIds:[n],path:t,projectionChanged:!0})}function Dl(e,t){let n=Be(e,t);if(n==null)throw Error(`Path does not exist: "${t}"`);let r=D(e,n);if(!R(r))throw Error(`Path is not a directory: "${t}"`);if(!_e(e,n,r))return null;return Ht(e,n,!1,r),qt(e,n),Qa({affectedAncestorIds:Ye(e,n),affectedNodeIds:[n],path:t,projectionChanged:!0})}function Il(e,t){if(t<0||t>=Ee(e))return null;return Ml(e,e.snapshot.rootId,t,-1)}function Ml(e,t,n,r){let i=ie(e,t),o=e.instrumentation,{childIndex:s,localVisibleIndex:a}=o==null?ni(e.snapshot.nodes,i,n):E(o,"store.getVisibleSlice.selectChildIndex",()=>ni(e.snapshot.nodes,i,n)),l=i.childIds[s];if(l!=null)return _o(e,l,a,r+1);throw Error(`Visible index ${String(n)} is out of range`)}function _o(e,t,n,r){if(!R(D(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=Al(e,t,r);if(n===0)return i;let o=D(e,i.terminalNodeId);if(!R(o)||!_e(e,i.terminalNodeId,o))throw Error(`Visible index ${String(n)} is out of range for collapsed directory`);return Ml(e,i.terminalNodeId,n-1,i.visibleDepth)}function Al(e,t,n){if(!R(D(e,t)))return{headNodeId:t,terminalNodeId:t,visibleDepth:n};if(e.instrumentation==null)return{headNodeId:t,terminalNodeId:kt(e,t),visibleDepth:n};return{headNodeId:t,terminalNodeId:E(e.instrumentation,"store.getVisibleSlice.flatten.resolveTerminalDirectory",()=>kt(e,t)),visibleDepth:n}}function Tf(e,t){let n=D(e,t);if(!R(n))return!0;let r=n.parentId;if(r===e.snapshot.rootId)return!0;return Ct(e,r)!==t}function Sl(e,t){let n=D(e,t.terminalNodeId);if(R(n)){let o=ie(e,t.terminalNodeId);if(_e(e,t.terminalNodeId,n)&&o.childIds.length>0){let s=o.childIds[0];return s==null?null:_o(e,s,0,t.visibleDepth+1)}}let{terminalNodeId:r,visibleDepth:i}=t;while(!0){let o=D(e,r);if(r===e.snapshot.rootId)return null;let s=o.parentId,a=ie(e,s),l=Sn(a).get(r)??-1;if(l<0)throw Error(`Child ${String(r)} was not found in its parent index`);let d=a.childIds[l+1]??null;if(d!=null)return _o(e,d,0,i);if(Tf(e,r))i--;r=s}}function Pf(e){let t=e.paths.length,n=Array(t);for(let r=0;r<t;r+=1){let i=e.getParentIndex(r);n[r]={index:r,parentPath:i>=0?e.paths[i]??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 Cl(e,t){let n=Array(t),r=new Int32Array(t),i=new Int32Array(t),o=new Int32Array(t),s=new Int32Array(kf);s.fill(-1);let a=0,{nodes:l,directories:d,segmentTable:u}=e.snapshot,f=[[d.get(e.snapshot.rootId),0,-1,""]],c=e.snapshot.options.flattenEmptyDirectories,m=e.pathCacheByNodeId,p=e.pathCacheVersion,g=u.valueById;while(f.length>0&&a<t){let S=f[f.length-1],k=S[0];if(S[1]>=k.childIds.length){f.pop();continue}let T=S[1],O=k.childIds[S[1]++],pe=l[O],Z=S[2]+1,me=S[3];s=xf(s,Z);let J,U=O;if(!R(pe)){let ae=m.get(O);J=ae!=null&&ae.version===p?ae.path:`${me}${g[pe.nameId]}`}else U=c?kt(e,O):O,J=U===O?`${me}${g[pe.nameId]}/`:te(e,U);r[a]=s[Z],n[a]=J,i[a]=T,o[a]=k.childIds.length,s[Z+1]=a,a+=1;let B=l[U];if(B!=null&&R(B)&&_e(e,U,B))f.push([d.get(U),0,Z,J])}if(a<t)n.length=a;let v=r.subarray(0,a),I=i.subarray(0,a),C=o.subarray(0,a),y=null;return{getParentIndex(S){return S<0||S>=a?-1:v[S]??-1},paths:n,posInSetByIndex:I,setSizeByIndex:C,get visibleIndexByPath(){if(y==null){y=new Map;for(let S=0;S<a;S+=1)y.set(n[S]??"",S)}return y}}}function Rf(e,t){let n=Array(t),r=0,{nodes:i,directories:o,segmentTable:s}=e.snapshot,a=[[o.get(e.snapshot.rootId),0,-1]],l=s.valueById,d=e.snapshot.options.flattenEmptyDirectories,u=e.pathCacheByNodeId,f=e.pathCacheVersion;while(a.length>0&&r<t){let c=a[a.length-1],m=c[0];if(c[1]>=m.childIds.length){a.pop();continue}let p=m.childIds[c[1]++],g=i[p],v=c[2]+1;if(!R(g)){let S=u.get(p);n[r++]={depth:v,flattenedSegments:void 0,hasChildren:!1,id:p,isExpanded:!1,isFlattened:!1,isLoading:!1,kind:"file",loadState:void 0,name:l[g.nameId],path:S!=null&&S.version===f?S.path:te(e,p)};continue}let I=d?kt(e,p):p,C={headNodeId:p,terminalNodeId:I,visibleDepth:v};n[r++]=mr(e,C);let y=i[I];if(y!=null&&R(y)&&_e(e,I,y))a.push([o.get(I),0,v])}if(r<t)n.length=r;return n}function mr(e,t){let n=D(e,t.terminalNodeId),r=R(n)?Df(e,t):null,i=te(e,t.terminalNodeId),o=Ge(e.snapshot.segmentTable,n.nameId),s=R(n)&&ie(e,t.terminalNodeId).childIds.length>0,a=t.headNodeId!==t.terminalNodeId,l=e.instrumentation,d=a?l==null?_n(e,t.headNodeId).map((u)=>{let f=D(e,u);return{isTerminal:u===t.terminalNodeId,name:Ge(e.snapshot.segmentTable,f.nameId),nodeId:u,path:te(e,u)}}):E(l,"store.getVisibleSlice.flatten.collectSegments",()=>_n(e,t.headNodeId).map((u)=>{let f=D(e,u);return{isTerminal:u===t.terminalNodeId,name:Ge(e.snapshot.segmentTable,f.nameId),nodeId:u,path:te(e,u)}})):void 0;return{depth:t.visibleDepth,flattenedSegments:d,hasChildren:s,id:t.terminalNodeId,isExpanded:R(n)&&_e(e,t.terminalNodeId,n),isFlattened:a,isLoading:r==="loading",kind:R(n)?"directory":"file",loadState:r==null||r==="loaded"?void 0:r,name:o,path:i}}function Df(e,t){if(t.headNodeId===t.terminalNodeId)return Vt(e,t.terminalNodeId);let n=_n(e,t.headNodeId),r=!1,i=!1;for(let o of n){let s=Vt(e,o);if(s==="loading")return"loading";if(s==="error"){i=!0;continue}if(s==="unloaded")r=!0}if(i)return"error";if(r)return"unloaded";return"loaded"}var Nl=8;function Ll(e){let{nodes:t,directories:n,rootId:r,options:i}=e,o=t.length,s=new Int32Array(o),a=new Int32Array(o),l=new Int32Array(o),d=new Int32Array(o),u=new Int32Array(o),f=new Int32Array(o),c=new Int32Array(o);for(let v=0;v<o;v+=1){let I=t[v];if(I==null)continue;s[v]=I.parentId,a[v]=I.nameId,l[v]=I.depthAndFlags,d[v]=I.subtreeNodeCount,u[v]=I.visibleSubtreeCount}let m=0;for(let v of n.values())m+=v.childIds.length;let p=new Int32Array(m),g=0;for(let[v,I]of n){let C=I.childIds;f[v]=g,c[v]=C.length;for(let y=0;y<C.length;y+=1)p[g]=C[y],g+=1}return{nodeCount:o,rootId:r,flattenEmptyDirectories:i.flattenEmptyDirectories===!0,parentId:s,nameId:a,depthAndFlags:l,subtreeNodeCount:d,visibleSubtreeCount:u,childStart:f,childCount:c,childIdsFlat:p}}function Fl(e){let{nodeCount:t,rootId:n,flattenEmptyDirectories:r,depthAndFlags:i,subtreeNodeCount:o,visibleSubtreeCount:s,childStart:a,childCount:l,childIdsFlat:d}=e;for(let p=t-1;p>=1;p-=1){if((i[p]&Nl)===0)continue;let g=a[p],v=l[p],I=0,C=0;for(let S=0;S<v;S+=1){let k=d[g+S];I+=o[k],C+=s[k]}o[p]=1+I;let y;if(r&&v===1)y=(i[d[g]]&Nl)!==0?C:1+C;else y=1+C;s[p]=y}let u=a[n],f=l[n],c=0,m=0;for(let p=0;p<f;p+=1){let g=d[u+p];c+=o[g],m+=s[g]}o[n]=1+c,s[n]=m}function Mf(e){let{directories:t,nodes:n,options:r,rootId:i,presortedDirectoryNodeIds:o}=e.snapshot,s=r.flattenEmptyDirectories===!0,a=(m)=>{let p=n[m];if(p==null||!R(p))return;let g=t.get(m);if(g==null)throw Error(`Unknown directory child index for node ${String(m)}`);let v=g.childIds,I=v.length,C=0,y=0;for(let k=0;k<I;k++){let T=v[k];if(T==null)continue;let O=n[T];C+=O.subtreeNodeCount,y+=O.visibleSubtreeCount}if(g.totalChildSubtreeNodeCount=C,g.totalChildVisibleSubtreeCount=y,I>=128)Bt(n,g);p.subtreeNodeCount=1+C;let S;if(s&&I===1){let k=n[v[0]];S=k!=null&&R(k)?y:1+y}else S=1+y;p.visibleSubtreeCount=S};if(o!=null)for(let m=o.length-1;m>=0;m--)a(o[m]);else for(let m=n.length-1;m>=1;m--)a(m);let l=n[i],d=t.get(i);if(l==null||d==null)return;let u=d.childIds,f=0,c=0;for(let m=0;m<u.length;m++){let p=u[m];if(p==null)continue;let g=n[p];f+=g.subtreeNodeCount,c+=g.visibleSubtreeCount}d.totalChildSubtreeNodeCount=f,d.totalChildVisibleSubtreeCount=c,Bt(n,d),l.subtreeNodeCount=1+f,l.visibleSubtreeCount=c}function Af(e){let{directories:t,nodes:n,rootId:r}=e.snapshot,i=Ll(e.snapshot);Fl(i);let{subtreeNodeCount:o,visibleSubtreeCount:s}=i;for(let a=0;a<n.length;a+=1){let l=n[a];if(l==null)continue;l.subtreeNodeCount=o[a],l.visibleSubtreeCount=s[a]}for(let[a,l]of t){let d=l.childIds,u=d.length,f=0,c=0;for(let m=0;m<u;m++){let p=d[m];if(p==null)continue;let g=n[p];f+=g.subtreeNodeCount,c+=g.visibleSubtreeCount}if(l.totalChildSubtreeNodeCount=f,l.totalChildVisibleSubtreeCount=c,a===r||u>=128)Bt(n,l)}}function Nf(e){return e.initialExpansion==="open"&&(e.initialExpandedPaths==null||e.initialExpandedPaths.length===0)}var ui=class e{#e;constructor(t={}){let n=dr(t),r=E(n,"store.builder.create",()=>new ai(t));if(t.preparedInput!=null){let a=Ra(t.preparedInput);if(a!=null)r.appendPresortedPaths(a,Da(t.preparedInput));else r.appendPreparedPaths(Pa(t.preparedInput),!1)}else{let a=t.paths??[];if(t.presorted===!0)r.appendPaths(a);else r.appendPreparedPaths(E(n,"store.preparePathEntries",()=>si(a,t)))}let i=E(n,"store.builder.finish",()=>r.finish({skipSubtreeCountPass:!0})),o=E(n,"store.state.detectAllDirectoriesExpanded",()=>(t.initialExpansion??"closed")==="closed"&&r.didMatchAllInitialExpandedPaths());if(this.#e=E(n,"store.state.create",()=>Ma(i,o?"open":t.initialExpansion??"closed",n)),o)this.#e.collapseNewDirectoriesByDefault=!0;let s=o?this.#e.snapshot.directories.size-1:E(n,"store.state.initializeExpandedPaths",()=>this.initializeExpandedPaths(t.initialExpandedPaths));if(o||Nf(t)||(t.initialExpansion??"closed")==="closed"&&s===this.#e.snapshot.directories.size-1||(t.initialExpandedPaths?.length??0)>0&&E(n,"store.state.checkAllDirectoriesExpanded",()=>this.hasAllDirectoriesExpanded()))if(t.useSoaCountSweep===!0)E(n,"store.state.initializeOpenVisibleCountsViaSoa",()=>Af(this.#e));else E(n,"store.state.initializeOpenVisibleCounts",()=>Mf(this.#e));else E(n,"store.state.recomputeCounts",()=>pr(this.#e,this.#e.snapshot.rootId))}static preparePaths(t,n={}){return _a(t,n)}static prepareInput(t,n={}){return Ea(t,n)}static preparePresortedInput(t){return Ta(t)}list(t){return E(this.#e.instrumentation,"store.list",()=>li(this.#e,t))}add(t){E(this.#e.instrumentation,"store.add",()=>{let n=Ee(this.#e);Ze(this.#e,Fe(this.#e,n,wo(this.#e,t)))})}remove(t,n={}){E(this.#e.instrumentation,"store.remove",()=>{let r=Ee(this.#e);Ze(this.#e,Fe(this.#e,r,Io(this.#e,t,n)))})}move(t,n,r={}){E(this.#e.instrumentation,"store.move",()=>{let i=Ee(this.#e),o=So(this.#e,t,n,r);if(o!=null)Ze(this.#e,Fe(this.#e,i,o))})}batch(t){il(this.#e,()=>{if(typeof t==="function"){t(this);return}for(let n of t)switch(n.type){case"add":this.add(n.path);break;case"remove":this.remove(n.path,{recursive:n.recursive});break;case"move":this.move(n.from,n.to,{collision:n.collision});break}})}getVisibleCount(){return E(this.#e.instrumentation,"store.getVisibleCount",()=>Ee(this.#e))}getVisibleSlice(t,n){return E(this.#e.instrumentation,"store.getVisibleSlice",()=>El(this.#e,t,n))}getVisibleRowContext(t){return E(this.#e.instrumentation,"store.getVisibleRowContext",()=>_l(this.#e,t))}getVisibleTreeProjection(){return Tl(this.#e)}getVisibleTreeProjectionData(t){return Eo(this.#e,t)}getVisibleIndex(t){return E(this.#e.instrumentation,"store.getVisibleIndex",()=>Pl(this.#e,t))}getPathInfo(t){return E(this.#e.instrumentation,"store.getPathInfo",()=>{let n=Be(this.#e,t);if(n==null)return null;let r=D(this.#e,n);return{depth:ze(r),kind:R(r)?"directory":"file",path:te(this.#e,n)}})}isExpanded(t){return E(this.#e.instrumentation,"store.isExpanded",()=>{let n=this.requireDirectoryNodeId(t),r=D(this.#e,n);return _e(this.#e,n,r)})}expand(t){E(this.#e.instrumentation,"store.expand",()=>{let n=Ee(this.#e),r=Rl(this.#e,t);if(r!=null)Ze(this.#e,Fe(this.#e,n,r))})}collapse(t){E(this.#e.instrumentation,"store.collapse",()=>{let n=Ee(this.#e),r=Dl(this.#e,t);if(r!=null)Ze(this.#e,Fe(this.#e,n,r))})}on(t,n){return Ka(this.#e,t,n)}getDirectoryLoadState(t){let n=this.requireDirectoryNodeId(t);return Vt(this.#e,n)}markDirectoryUnloaded(t){E(this.#e.instrumentation,"store.markDirectoryUnloaded",()=>{let n=this.requireDirectoryNodeId(t);if(ie(this.#e,n).childIds.length>0)throw Error(`Cannot mark a directory with known children as unloaded: "${t}"`);let r=Ee(this.#e);Ba(this.#e,n),Ze(this.#e,Fe(this.#e,r,Za({affectedAncestorIds:Ye(this.#e,n),affectedNodeIds:[n],path:t,projectionChanged:this.isDirectoryProjectionVisible(n)})))})}beginChildLoad(t){return E(this.#e.instrumentation,"store.beginChildLoad",()=>{let n=this.requireDirectoryNodeId(t),r=Ee(this.#e),i=Fa(this.#e,n);return Ze(this.#e,Fe(this.#e,r,Ja({affectedAncestorIds:Ye(this.#e,n),affectedNodeIds:[n],attemptId:i.attemptId,path:t,projectionChanged:this.isDirectoryProjectionVisible(n),reused:i.reused}))),i})}applyChildPatch(t,n){return E(this.#e.instrumentation,"store.applyChildPatch",()=>{let r=this.resolveActiveDirectoryNodeId(t.nodeId);if(r==null||Vt(this.#e,r)!=="loading"||!Va(this.#e,r,t.attemptId))return!1;let i=te(this.#e,r);this.validateChildPatch(i,n);let o=Ee(this.#e),s=[];for(let l of n.operations){Lf(i,l);let d=Ee(this.#e);switch(l.type){case"add":s.push(Fe(this.#e,d,wo(this.#e,l.path)));break;case"remove":s.push(Fe(this.#e,d,Io(this.#e,l.path,{recursive:l.recursive})));break;case"move":{let u=So(this.#e,l.from,l.to,{collision:l.collision});if(u!=null)s.push(Fe(this.#e,d,u));break}}}let a=s.some((l)=>l.projectionChanged)||this.isDirectoryProjectionVisible(r);return Ze(this.#e,Fe(this.#e,o,el({affectedAncestorIds:Ye(this.#e,r),affectedNodeIds:[r],attemptId:t.attemptId,childEvents:s,path:te(this.#e,r),projectionChanged:a}))),!0})}completeChildLoad(t){return E(this.#e.instrumentation,"store.completeChildLoad",()=>{let n=this.resolveActiveDirectoryNodeId(t.nodeId);if(n==null)return!1;let r=Ee(this.#e),i=Ha(this.#e,n,t.attemptId);return Ze(this.#e,Fe(this.#e,r,tl({affectedAncestorIds:Ye(this.#e,n),affectedNodeIds:[n],attemptId:t.attemptId,path:te(this.#e,n),projectionChanged:this.isDirectoryProjectionVisible(n),stale:!i}))),i})}failChildLoad(t,n){return E(this.#e.instrumentation,"store.failChildLoad",()=>{let r=this.resolveActiveDirectoryNodeId(t.nodeId);if(r==null)return!1;let i=Ee(this.#e),o=Oa(this.#e,r,t.attemptId,n);return Ze(this.#e,Fe(this.#e,i,nl({affectedAncestorIds:Ye(this.#e,r),affectedNodeIds:[r],attemptId:t.attemptId,errorMessage:n,path:te(this.#e,r),projectionChanged:this.isDirectoryProjectionVisible(r),stale:!o}))),o})}cleanup(t={}){return E(this.#e.instrumentation,"store.cleanup",()=>{if(this.#e.transactionStack.length>0)throw Error("Cleanup cannot run during an open batch or transaction.");if(bl(this.#e))throw Error("Cleanup cannot run while directory loads are active.");let n=Ee(this.#e),r=wl(this.#e,t.mode??"stable");return Ze(this.#e,Fe(this.#e,n,rl({...r,affectedAncestorIds:[],affectedNodeIds:[],projectionChanged:r.idsPreserved===!1}))),r})}getNodeCount(){return this.#e.activeNodeCount}initializeExpandedPaths(t){if(t==null||t.length===0)return 0;let n=0,r=[],i=[],o=0,s=null,a=this.#e.snapshot.segmentTable,l=a.valueById,d=this.#e.snapshot.nodes,u=new Map;for(let f of t){if(s!=null&&f<s)s=null,o=0,r.length=0,i.length=0;let c=f.length>0&&f.charCodeAt(f.length-1)===47?f.length-1:f.length;if(c===0){s=f,o=c,r.length=0,i.length=0;continue}let m=0,p=0;if(s!=null){let y=Math.min(c,o),S=!0;for(let k=0;k<y;k+=1){let T=f.charCodeAt(k);if(T!==s.charCodeAt(k)){S=!1;break}if(T===47)m+=1,p=k+1}if(S){if(y===o&&c>y&&f.charCodeAt(y)===47)m+=1,p=y+1;else if(y===c&&o>y&&s.charCodeAt(y)===47)m+=1,p=c+1}m=Math.min(m,i.length)}let g=m===0?this.#e.snapshot.rootId:i[m-1]??this.#e.snapshot.rootId,v=m,I=!0,C=p;while(C<=c){let y=f.indexOf("/",C),S=y===-1||y>c?c:y,k=f.slice(C,S),T=ie(this.#e,g).childIds,O=v===m?r[v]??0:0,pe=O,Z,me=u.get(k)??sn(k);u.set(k,me);let J=(U,B)=>{for(pe=U;pe<B;pe+=1){let ae=T[pe],Ce=d[ae],z=l[Ce.nameId];if(z===k)return Z=ae,!0;let le=hr(fr(a,Ce.nameId),me);if(le>0||le===0&&z>k)return!1}return!1};if(!J(O,T.length)&&O>0)J(0,O);if(Z===void 0){I=!1;break}if(!R(D(this.#e,Z))){I=!1;break}if(r[v]=pe,i[v]=Z,g=Z,v+=1,S===c)break;C=S+1}if(s=f,o=c,r.length=v,i.length=v,!I){s=null,o=0,r.length=0,i.length=0;continue}for(let y=m;y<v;y+=1){let S=i[y];if(S==null)continue;let k=D(this.#e,S);if(_e(this.#e,S,k))continue;Ht(this.#e,S,!0,k),n+=1}}return n}hasAllDirectoriesExpanded(){for(let t of this.#e.snapshot.directories.keys()){if(t===this.#e.snapshot.rootId)continue;let n=D(this.#e,t);if(!_e(this.#e,t,n))return!1}return!0}requireDirectoryNodeId(t){let n=Be(this.#e,t);if(n==null)throw Error(`Path does not exist: "${t}"`);if(!R(D(this.#e,n)))throw Error(`Path is not a directory: "${t}"`);return n}resolveActiveDirectoryNodeId(t){try{if(!R(D(this.#e,t)))throw Error(`Node is not a directory: ${String(t)}`);return t}catch{return null}}isDirectoryProjectionVisible(t){let n=t;while(n!==this.#e.snapshot.rootId){let r=D(this.#e,n).parentId;if(r!==this.#e.snapshot.rootId){let i=D(this.#e,r),o=Ct(this.#e,r);if(!_e(this.#e,r,i)&&o!==n)return!1}n=r}return!0}validateChildPatch(t,n){new e({paths:this.list(t),presorted:!0,sort:this.#e.snapshot.options.sort}).batch(n.operations)}};function Lf(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 Ff=[`<symbol id="file-tree-builtin-bash" viewBox="0 0 16 16">
|
|
1
|
+
import{A,B as Hu,C as Mi,D as bd,F as Pr,G as Es,a as Yr,b as na,c as ra,e as Gr,f as oa,g as ea,h as ta,i as Jr,j as sa,k as ei,n as aa,o as co,p as uo,q as ni,r as la,s as $u,t as vd,u as ca,v as ua,w as ho,x as cr,y as da,z as yd}from"./main-scnj6yst.js";import{H as Vh}from"./main-e1326455.js";import{_ as so,qa as ti,ra as ao,sa as lo}from"./main-6b6epn84.js";import{gc as Ju,hc as ed,ic as Tt,jc as Tr}from"./main-d7db5p71.js";import{kc as _s,lc as dn,mc as Mu,nc as Er}from"./main-2yyq3124.js";import{oc as Hh,rc as Rm}from"./main-kt1z40p6.js";function eo(e){let t=[];for(let n of e){let r=Gr.get(n);if(r==null)throw Error(`getResolvedLanguages: ${n} is not resolved. Please resolve languages before calling getResolvedLanguages`);t.push(r)}return t}function to(e){for(let t of Array.isArray(e)?e:[e])if(!Gr.has(t))return!1;return!0}async function no(e){let t=[],n=[];for(let r of e){if(r==="text"||r==="ansi")continue;let i=ta(r)??ea(r);if("then"in i)n.push(i);else t.push(i)}if(n.length>0)await Promise.all(n).then((r)=>{for(let i of r){if(i==null)throw Error("resolvedLanguages: unable to resolve language");t.push(i)}});return t}function ro(e){return Yr.getResolvedThemes(e)}async function io(e){for(let n of e)na(n);let t=await Yr.resolveThemes(e);for(let n=0;n<e.length;n++)ra(e[n],t[n]);return t}var fo=Hh(Vh(),1),Xr=Symbol("IGNORE_RESPONSE"),Oh=1e4,Qr=class extends Error{constructor(){super("WorkerPoolManager: operation canceled because the pool terminated")}},oo=class extends Error{constructor(){super("WorkerPoolManager: operation canceled before the task completed")}},ha=class{options;highlighter;preferredHighlighter;renderOptions;renderOptionsRequestVersion=0;renderOptionsVersion=0;initialized=!1;workers=[];queuedTasks=[];queuedTaskByInstance=new Map;taskByHighlightKey=new Map;activeTaskById=new Map;activeRequestByInstance=new Map;nextRequestId=0;themeSubscribers=new Set;workersFailed=!1;statSubscribers=new Set;fileCache;diffCache;_queuedBroadcast;lifecycleGeneration=0;constructor(e,{langs:t,theme:n=so,useTokenTransformer:r=!1,lineDiffType:i="word-alt",maxLineDiffLength:o=1000,tokenizeMaxLineLength:s=1000,preferredHighlighter:a="shiki-js"}){this.options=e,this.preferredHighlighter=a,this.renderOptions={theme:n,useTokenTransformer:r,lineDiffType:i,maxLineDiffLength:o,tokenizeMaxLineLength:s},this.fileCache=new fo.default.LRUMap(e.totalASTLRUCacheSize??100),this.diffCache=new fo.default.LRUMap(e.totalASTLRUCacheSize??100),this.queueInitialization(t)}isWorkingPool(){return!this.workersFailed}getFileResultCache(e){return e.cacheKey!=null?this.fileCache.get(e.cacheKey):void 0}getDiffResultCache(e){return e.cacheKey!=null?this.diffCache.get(e.cacheKey):void 0}inspectCaches(){let{fileCache:e,diffCache:t}=this;return{fileCache:e,diffCache:t}}evictFileFromCache(e){try{return this.fileCache.delete(e)!==void 0}finally{this.queueBroadcastStateChanges()}}evictDiffFromCache(e){try{return this.diffCache.delete(e)!==void 0}finally{this.queueBroadcastStateChanges()}}async setRenderOptions({theme:e=this.renderOptions.theme??so,useTokenTransformer:t=this.renderOptions.useTokenTransformer??!1,lineDiffType:n=this.renderOptions.lineDiffType??"word-alt",maxLineDiffLength:r=this.renderOptions.maxLineDiffLength??1000,tokenizeMaxLineLength:i=this.renderOptions.tokenizeMaxLineLength??1000}){let{lifecycleGeneration:o}=this,s=++this.renderOptionsRequestVersion,a=()=>this.isCurrentLifecycle(o)&&this.renderOptionsRequestVersion===s;try{let l={theme:e,useTokenTransformer:t,lineDiffType:n,maxLineDiffLength:r,tokenizeMaxLineLength:i};if(!this.isInitialized())await this.initialize();if(!a()||cr(l,this.renderOptions))return;let d=Jr(e),u=[];if(!aa(l.theme,this.renderOptions.theme))if(uo(d))u=ro(d);else u=await io(d);if(!a())return;if(this.highlighter!=null)sa(u,this.highlighter);else{let c=await ei({themes:d,langs:["text"],preferredHighlighter:this.preferredHighlighter});if(!a())return;this.highlighter=c}let f=this.setRenderOptionsOnWorkers(l,u);this.renderOptions=l,this.renderOptionsVersion++,this.diffCache.clear(),this.fileCache.clear(),this.invalidateRenderTasks();for(let c of this.themeSubscribers)c.onThemeChange();await f}catch(l){if(l instanceof Qr||!a())return;throw l}}getPreferredHighlighter(){return this.preferredHighlighter}getFileRenderOptions(){let{tokenizeMaxLineLength:e,theme:t,useTokenTransformer:n}=this.renderOptions;return{theme:t,useTokenTransformer:n,tokenizeMaxLineLength:e}}getDiffRenderOptions(){return{...this.renderOptions}}async setRenderOptionsOnWorkers(e,t){if(this.workersFailed)return;if(!this.isInitialized())await this.initialize();let n=[];for(let r of this.workers){if(!r.initialized)throw console.log({managedWorker:r}),Error("setRenderOptionsOnWorkers: Somehow we have an uninitialized worker");n.push(new Promise((i,o)=>{let s=this.generateRequestId(),a={type:"set-render-options",id:s,request:{type:"set-render-options",id:s,renderOptions:e,resolvedThemes:t},resolve:i,reject:o,requestStart:Date.now()};this.activeTaskById.set(s,a),r.pendingSetupRequestId=s,r.worker.postMessage(a.request)}))}await Promise.all(n)}subscribeToThemeChanges(e){return this.themeSubscribers.add(e),this.queueBroadcastStateChanges(),()=>{this.unsubscribeToThemeChanges(e),this.queueBroadcastStateChanges()}}unsubscribeToThemeChanges(e){this.themeSubscribers.delete(e),this.queueBroadcastStateChanges()}subscribeToStatChanges(e){return this.statSubscribers.add(e),e(this.getStats()),()=>{this.statSubscribers.delete(e)}}queueBroadcastStateChanges(){if(this._queuedBroadcast!=null)return;this._queuedBroadcast=requestAnimationFrame(this._broadcastStateChanges)}_broadcastStateChanges=()=>{if(this._queuedBroadcast!=null)cancelAnimationFrame(this._queuedBroadcast),this._queuedBroadcast=void 0;let e=this.getStats();for(let t of this.statSubscribers)t(e)};cleanUpTasks(e){this.detachInstanceFromQueuedTasks(e);let t=this.activeRequestByInstance.get(e);if(t!=null){let n=this.activeTaskById.get(t);if(Ft(n)){if(this.detachInstanceFromRenderTask(n,e),!n.primeCache&&n.instances.size===0)this.removeActiveTask(n)}else this.activeTaskById.delete(t)}this.activeRequestByInstance.delete(e),this.queueBroadcastStateChanges()}isInitialized(){return this.initialized===!0}async initialize(e=[]){if(this.initialized===!0)return;else if(this.initialized===!1){let{lifecycleGeneration:t}=this;this.initialized=new Promise((n,r)=>{(async()=>{try{let i=Jr(this.renderOptions.theme),o=[];if(uo(i))o=ro(i);else o=await io(i);if(!this.isCurrentLifecycle(t)){n();return}let s=[];if(to(e))s=eo(e);else s=await no(e);if(!this.isCurrentLifecycle(t)){n();return}let[a]=await Promise.all([ei({themes:i,langs:["text",...e],preferredHighlighter:this.preferredHighlighter}),this.initializeWorkers(o,s)]);if(!this.isCurrentLifecycle(t)){this.terminateWorkers(),n();return}this.highlighter=a,this.initialized=!0,this.diffCache.clear(),this.fileCache.clear(),this.drainQueue(),this.queueBroadcastStateChanges(),n()}catch(i){if(i instanceof Qr||!this.isCurrentLifecycle(t)){n();return}this.initialized=!1,this.workersFailed=!0,this.cancelActiveWorkerTasks(),this.terminateWorkers(),this.activeTaskById.clear();for(let o of this.queuedTasks)this.rejectRenderTaskCallbacks(o,Zr(i));this.queueBroadcastStateChanges(),r(i)}})()}),this.queueBroadcastStateChanges()}else return this.initialized}async initializeWorkers(e,t){this.workersFailed=!1;let n=[],r=ao(),i=r>0?lo():void 0;if(this.workers.length>0)this.terminateWorkers();for(let a=0;a<(this.options.poolSize??8);a++){let l=this.options.workerFactory(),d={worker:l,requestId:void 0,pendingSetupRequestId:void 0,initialized:!1,langs:new Set(["text",...t.map(({name:u})=>u)]),customExtensionsVersion:0};l.addEventListener("message",(u)=>{this.handleWorkerMessage(d,u.data)}),l.addEventListener("error",(u)=>this.handleWorkerError(d,u)),this.workers.push(d),n.push(new Promise((u,f)=>{let c=this.generateRequestId(),m={type:"initialize",id:c,request:{type:"initialize",id:c,renderOptions:this.renderOptions,preferredHighlighter:this.preferredHighlighter,resolvedThemes:e,resolvedLanguages:t,customExtensionsVersion:i!=null?r:void 0,customExtensionMap:i},resolve(){d.initialized=!0,u()},reject:f,requestStart:Date.now()};d.pendingSetupRequestId=c,this.activeTaskById.set(c,m),this.executeTask(d,m)}))}let o=this.options.workerInitializationTimeout??Oh,s;try{await Promise.race([Promise.all(n),new Promise((a,l)=>{s=setTimeout(()=>{l(Error(`WorkerPoolManager: worker initialization timed out after ${o}ms`))},o)})])}finally{if(s!=null)clearTimeout(s)}}handleWorkerError(e,t){console.error("Worker error:",t,e);let{pendingSetupRequestId:n}=e;if(n==null)return;let r=this.activeTaskById.get(n);if(r?.type!=="initialize")return;r.reject(Zr(t)),this.cleanWorkerAndTask(e,r)}drainQueue=()=>{if(this._queuedDrain=void 0,this.initialized!==!0||this.queuedTasks.length===0)return;for(let e=0;e<this.queuedTasks.length;){let t=this.queuedTasks[e];if(this.hasActiveRequest(t)){e++;continue}let n=ia(t),r=this.getAvailableWorker(n);if(r==null)break;this.queuedTasks.splice(e,1),this.assignWorkerToTask(t,r),this.resolveLanguagesAndExecuteTask(r,t,n)}this.queueBroadcastStateChanges()};highlightFileAST(e,t){let n=this.getFileResultCache(t);if(co(t)||n!=null&&ni(n.options,this.getFileRenderOptions()))return;if(!this.hasMatchingFileInstanceTask(e,t))this.submitTask(e,{type:"file",file:t})}primeFileHighlightCache(e){if(!this.isWorkingPool())return Promise.reject(Error("WorkerPoolManager.primeFileHighlightCache: worker pool is not working"));let t=this.getOrCreateFileHighlightCacheTask(e);return t!=null?this.createRenderTaskCallbacks(t):Promise.resolve()}getOrCreateFileHighlightCacheTask(e){if(e.cacheKey==null){console.warn(`WorkerPoolManager.primeFileHighlightCache: priming highlight cache requires file.cacheKey; skipping "${e.name}".`);return}let t=this.getFileResultCache(e),n=this.getFileHighlightKey(e);if(n==null||co(e)||t!=null&&ni(t.options,this.getFileRenderOptions()))return;let r=this.getTaskByHighlightKey(n);if(r!=null)return r.primeCache=!0,r.type==="file"?r:void 0;else{let i=this.submitCacheTask({type:"file",file:e},n);return i.type==="file"?i:void 0}}getPlainFileAST(e,t,n,r){if(this.highlighter==null){this.queueInitialization();return}return la(e,this.highlighter,this.renderOptions,{forcePlainText:!0,startingLine:t,totalLines:n,lines:r})}highlightDiffAST(e,t){let n=this.getDiffResultCache(t);if(ho(t)||n!=null&&cr(n.options,this.getDiffRenderOptions()))return;if(!this.hasMatchingDiffInstanceTask(e,t))this.submitTask(e,{type:"diff",diff:t})}primeDiffHighlightCache(e){if(!this.isWorkingPool())return Promise.reject(Error("WorkerPoolManager.primeDiffHighlightCache: worker pool is not working"));let t=this.getOrCreateDiffHighlightCacheTask(e);return t!=null?this.createRenderTaskCallbacks(t):Promise.resolve()}getOrCreateDiffHighlightCacheTask(e){if(e.cacheKey==null){console.warn(`WorkerPoolManager.primeDiffHighlightCache: priming highlight cache requires diff.cacheKey; skipping "${e.prevName??e.name}" -> "${e.name}".`);return}let t=this.getDiffResultCache(e),n=this.getDiffHighlightKey(e);if(n==null||ho(e)||t!=null&&cr(t.options,this.getDiffRenderOptions()))return;let r=this.getTaskByHighlightKey(n);if(r!=null)return r.primeCache=!0,r.type==="diff"?r:void 0;else{let i=this.submitCacheTask({type:"diff",diff:e},n);return i.type==="diff"?i:void 0}}getPlainDiffAST(e,t,n,r,i){return this.highlighter!=null?da(e,this.highlighter,this.renderOptions,{forcePlainText:!0,startingLine:t,totalLines:n,expandedHunks:r,collapsedContextThreshold:i}):void 0}terminate(){this.lifecycleGeneration++,this.cancelActiveWorkerTasks(),this.terminateWorkers();let e=new Qr;for(let t of this.queuedTasks)this.rejectRenderTaskCallbacks(t,e);this.fileCache.clear(),this.diffCache.clear(),this.activeRequestByInstance.clear(),this.queuedTasks.length=0,this.queuedTaskByInstance.clear(),this.taskByHighlightKey.clear(),this.activeTaskById.clear(),this.highlighter=void 0,this.initialized=!1,this.workersFailed=!1,this.queueBroadcastStateChanges()}isCurrentLifecycle(e){return this.lifecycleGeneration===e}queueInitialization(e){this.initialize(e).catch((t)=>{console.error(t)})}cancelActiveWorkerTasks(){let e=new Qr;for(let t of this.activeTaskById.values())if("reject"in t)t.reject(e);else if(Ft(t))this.rejectRenderTaskCallbacks(t,e)}terminateWorkers(){for(let e of this.workers)e.worker.terminate();this.workers.length=0}getStats(){return{managerState:(()=>{if(this.initialized===!1)return"waiting";if(this.initialized!==!0)return"initializing";return"initialized"})(),totalWorkers:this.workers.length,workersFailed:this.workersFailed,busyWorkers:this.workers.filter((e)=>e.requestId!=null||e.pendingSetupRequestId!=null).length,queuedTasks:this.queuedTasks.length,activeTasks:this.activeTaskById.size,themeSubscribers:this.themeSubscribers.size,fileCacheSize:this.fileCache.size,diffCacheSize:this.diffCache.size}}submitTask(e,t){if(this.initialized===!1)this.queueInitialization();let n=this.getHighlightKeyForRequest(t),r=n!=null?this.getTaskByHighlightKey(n):void 0;if(r!=null){this.detachInstanceFromQueuedTasks(e,r),this.addInstanceToTask(r,e),this.queueBroadcastStateChanges();return}this.detachInstanceFromQueuedTasks(e);let i=this.generateRequestId(),o=Date.now(),{renderOptionsVersion:s}=this,a=(()=>{switch(t.type){case"file":return{type:"file",id:i,request:{...t,id:i},instances:new Set([e]),primeCache:!1,highlightKey:n,callbacks:new Set,renderOptionsVersion:s,requestStart:o};case"diff":return{type:"diff",id:i,request:{...t,id:i},instances:new Set([e]),primeCache:!1,highlightKey:n,callbacks:new Set,renderOptionsVersion:s,requestStart:o}}})();this.enqueueRenderTask(a,e)}submitCacheTask(e,t){if(this.initialized===!1)this.queueInitialization();let n=this.generateRequestId(),r=Date.now(),{renderOptionsVersion:i}=this,o=(()=>{switch(e.type){case"file":return{type:"file",id:n,request:{...e,id:n},instances:new Set,primeCache:!0,highlightKey:t,callbacks:new Set,renderOptionsVersion:i,requestStart:r};case"diff":return{type:"diff",id:n,request:{...e,id:n},instances:new Set,primeCache:!0,highlightKey:t,callbacks:new Set,renderOptionsVersion:i,requestStart:r}}})();return this.enqueueRenderTask(o),o}enqueueRenderTask(e,t){if(this.queuedTasks.push(e),t!=null)this.queuedTaskByInstance.set(t,e);if(e.highlightKey!=null)this.taskByHighlightKey.set(e.highlightKey,e);this.queueDrain()}async resolveLanguagesAndExecuteTask(e,t,n){try{let r=n.filter((o)=>!oa(o));if(r.length>0)ei({themes:Jr(this.renderOptions.theme),langs:["text",...r],preferredHighlighter:this.preferredHighlighter}).catch((o)=>{console.error(o)});let i=n.filter((o)=>!e.langs.has(o));if(i.length>0)if(to(i))t.request.resolvedLanguages=eo(i);else t.request.resolvedLanguages=await no(i);if(!this.activeTaskById.has(t.id)){if(e.requestId===t.id){if(this.cleanWorkerAndTask(e,t),this.queueBroadcastStateChanges(),this.queuedTasks.length>0)this.queueDrain()}return}this.executeTask(e,t)}catch(r){if(this.rejectRenderTaskCallbacks(t,Zr(r)),this.cleanWorkerAndTask(e,t),this.queueBroadcastStateChanges(),this.queuedTasks.length>0)this.queueDrain()}}handleWorkerMessage(e,t){let n=this.activeTaskById.get(t.id);try{if(n==null)throw Xr;else if(t.type==="error"){let r=Error(t.error);if(t.stack)r.stack=t.stack;if("reject"in n)n.reject(r);else if(Ft(n))this.notifyHighlightError(n,r),this.rejectRenderTaskCallbacks(n,r);else throw Error("handleWorkerMessage: unknown task type");throw r}else switch(t.requestType){case"initialize":if(n.type!=="initialize")throw Error("handleWorkerMessage: task/response dont match");this.syncCustomExtensionVersion(e,n.request),n.resolve();break;case"set-render-options":if(n.type!=="set-render-options")throw Error("handleWorkerMessage: task/response dont match");n.resolve();break;case"file":{if(n.type!=="file")throw Error("handleWorkerMessage: task/response dont match");let{result:r,options:i}=t;if(!this.isCurrentRenderTask(n)||!ni(i,this.getFileRenderOptions()))throw Xr;let{request:o}=n;if(this.syncCustomExtensionVersion(e,o),n.cacheKeyAtDispatch!=null)this.fileCache.set(n.cacheKeyAtDispatch,{result:r,options:i});this.resolveRenderTaskCallbacks(n),this.notifyFileInstances(n,r,i);break}case"diff":{if(n.type!=="diff")throw Error("handleWorkerMessage: task/response dont match");let{result:r,options:i}=t;if(!this.isCurrentRenderTask(n)||!cr(i,this.getDiffRenderOptions()))throw Xr;let{request:o}=n;if(this.syncCustomExtensionVersion(e,o),n.cacheKeyAtDispatch!=null)this.diffCache.set(n.cacheKeyAtDispatch,{result:r,options:i});this.resolveRenderTaskCallbacks(n),this.notifyDiffInstances(n,r,i);break}}}catch(r){if(r!==Xr)console.error(r,n,t)}if(this.cleanWorkerAndTask(e,n,t.id),this.queueBroadcastStateChanges(),this.queuedTasks.length>0)this.queueDrain()}_queuedDrain;queueDrain(){if(this._queuedDrain!=null)return;this._queuedDrain=Promise.resolve().then(this.drainQueue),this.queueBroadcastStateChanges()}assignWorkerToTask(e,t){if(t.requestId=e.id,Ft(e))this.clearQueuedInstanceRequests(e),this.trackInstanceRequests(e);this.activeTaskById.set(e.id,e)}cleanWorkerAndTask(e,t,n=t?.id){if(e.requestId===n)e.requestId=void 0;if(e.pendingSetupRequestId===n)e.pendingSetupRequestId=void 0;if(t!=null){if(Ft(t))this.rejectRenderTaskCallbacks(t,new oo),this.clearInstanceRequests(t),this.clearHighlightKey(t);this.activeTaskById.delete(t.id)}}executeTask(e,t){if(qh(t.request))this.maybeAttachCustomExtensions(e,t.request);if(!this.activeTaskById.has(t.id))this.assignWorkerToTask(t,e);for(let n of ia(t))e.langs.add(n);try{if(t.type==="file")t.cacheKeyAtDispatch=t.request.file.cacheKey;else if(t.type==="diff")t.cacheKeyAtDispatch=t.request.diff.cacheKey;e.worker.postMessage(t.request)}catch(n){if(console.error("Failed to post message to worker:",n),Ft(t))this.notifyHighlightError(t,n),this.rejectRenderTaskCallbacks(t,Zr(n));else if("reject"in t)t.reject(n);if(this.cleanWorkerAndTask(e,t),this.queuedTasks.length>0)this.queueDrain()}this.queueBroadcastStateChanges()}maybeAttachCustomExtensions(e,t){if(t.customExtensionsVersion!=null)return;let n=ao();if(e.customExtensionsVersion>=n)return;t.customExtensionsVersion=n,t.customExtensionMap=lo()}syncCustomExtensionVersion(e,t){if(t.customExtensionsVersion==null)return;e.customExtensionsVersion=t.customExtensionsVersion}getAvailableWorker(e){let t;for(let n of this.workers){if(n.requestId!=null||n.pendingSetupRequestId!=null||!n.initialized)continue;if(t=n,e.length===0)break;let r=!0;for(let i of e)if(!n.langs.has(i)){r=!1;break}if(r)break}return t}getFileHighlightKey(e){if(e.cacheKey==null)return;return`file:${e.cacheKey}:${this.renderOptionsVersion}`}getDiffHighlightKey(e){if(e.cacheKey==null)return;return`diff:${e.cacheKey}:${this.renderOptionsVersion}`}getHighlightKeyForRequest(e){switch(e.type){case"file":return this.getFileHighlightKey(e.file);case"diff":return this.getDiffHighlightKey(e.diff)}}hasActiveRequest(e){for(let t of lr(e))if(this.activeRequestByInstance.has(t))return!0;return!1}addInstanceToTask(e,t){if(e.type==="file")e.instances.add(t);else e.instances.add(t);if(this.activeTaskById.has(e.id))this.activeRequestByInstance.set(t,e.id);else this.queuedTaskByInstance.set(t,e)}detachInstanceFromQueuedTasks(e,t){let n=this.queuedTaskByInstance.get(e);if(n==null||n===t)return;if(this.queuedTaskByInstance.delete(e),this.detachInstanceFromRenderTask(n,e),!n.primeCache&&n.instances.size===0)this.removeQueuedTask(n)}detachInstanceFromRenderTask(e,t){if(e.type==="file")e.instances.delete(t);else e.instances.delete(t)}removeQueuedTask(e){let t=this.queuedTasks.indexOf(e);if(t!==-1)this.queuedTasks.splice(t,1);this.rejectRenderTaskCallbacks(e,new oo),this.clearQueuedInstanceRequests(e),this.clearHighlightKey(e)}removeActiveTask(e){this.rejectRenderTaskCallbacks(e,new oo),this.clearInstanceRequests(e),this.clearHighlightKey(e),this.activeTaskById.delete(e.id)}createRenderTaskCallbacks(e){return new Promise((t,n)=>{e.callbacks.add({resolve:t,reject:n})})}resolveRenderTaskCallbacks(e){for(let t of e.callbacks)t.resolve();e.callbacks.clear()}rejectRenderTaskCallbacks(e,t){for(let n of e.callbacks)n.reject(t);e.callbacks.clear()}invalidateRenderTasks(){for(let e=this.queuedTasks.length-1;e>=0;e--){let t=this.queuedTasks[e];if(t.renderOptionsVersion!==this.renderOptionsVersion)this.removeQueuedTask(t)}for(let e of Array.from(this.activeTaskById.values()))if(Ft(e)&&e.renderOptionsVersion!==this.renderOptionsVersion)this.removeActiveTask(e)}clearQueuedInstanceRequests(e){for(let t of lr(e))if(this.queuedTaskByInstance.get(t)===e)this.queuedTaskByInstance.delete(t)}clearHighlightKey(e){if(e.highlightKey!=null&&this.taskByHighlightKey.get(e.highlightKey)===e)this.taskByHighlightKey.delete(e.highlightKey)}trackInstanceRequests(e){for(let t of lr(e))this.activeRequestByInstance.set(t,e.id)}clearInstanceRequests(e){for(let t of lr(e))if(this.activeRequestByInstance.get(t)===e.id)this.activeRequestByInstance.delete(t)}notifyFileInstances(e,t,n){for(let r of e.instances)if(this.activeRequestByInstance.get(r)===e.id)r.onHighlightSuccess(e.request.file,t,n)}notifyDiffInstances(e,t,n){for(let r of e.instances)if(this.activeRequestByInstance.get(r)===e.id)r.onHighlightSuccess(e.request.diff,t,n)}notifyHighlightError(e,t){for(let n of lr(e))if(this.activeRequestByInstance.get(n)===e.id)n.onHighlightError(t)}hasMatchingFileInstanceTask(e,t){for(let n of this.iterateRenderTasks())if(n.type==="file"&&this.isCurrentRenderTask(n)&&n.instances.has(e)&&ua(t,n.request.file))return!0;return!1}hasMatchingDiffInstanceTask(e,t){for(let n of this.iterateRenderTasks())if(n.type==="diff"&&this.isCurrentRenderTask(n)&&n.instances.has(e)&&ca(n.request.diff,t))return!0;return!1}getTaskByHighlightKey(e){let t=this.taskByHighlightKey.get(e);return t!=null&&this.isCurrentRenderTask(t)?t:void 0}isCurrentRenderTask(e){return e.renderOptionsVersion===this.renderOptionsVersion}*iterateRenderTasks(){for(let e of this.queuedTasks)yield e;for(let e of this.activeTaskById.values())if(Ft(e))yield e}generateRequestId(){return`req_${++this.nextRequestId}`}};function qh(e){return e.type==="initialize"||e.type==="file"||e.type==="diff"}function ia(e){let t=new Set;if(e.type==="initialize"||e.type==="set-render-options")return[];switch(e.type){case"file":t.add(e.request.file.lang??ti(e.request.file.name));break;case"diff":t.add(e.request.diff.lang??ti(e.request.diff.name)),t.add(e.request.diff.lang??ti(e.request.diff.prevName??"-"))}return t.delete("text"),Array.from(t)}function Ft(e){return e?.type==="file"||e?.type==="diff"}function lr(e){return e.instances}function Zr(e){if(e instanceof Error)return e;if(e!=null&&typeof e==="object"){if("error"in e&&e.error instanceof Error)return e.error;if("message"in e&&typeof e.message==="string")return Error(e.message)}return Error(String(e))}var ur;function po({poolOptions:e,highlighterOptions:t}){return ur??=new ha(e,t),ur}function mo(){if(ur==null)return;ur.terminate(),ur=void 0}function on(){return{childIdByNameId:new Map,childIds:[],childPositionById:new Map,childVisibleChunkSums:null,totalChildSubtreeNodeCount:0,totalChildVisibleSubtreeCount:0}}function go(){return{childIdByNameId:null,childIds:[],childPositionById:null,childVisibleChunkSums:null,totalChildSubtreeNodeCount:0,totalChildVisibleSubtreeCount:0}}function Bt(e,t){if(t.childIdByNameId!=null)return t.childIdByNameId;let n=new Map;for(let r of t.childIds){let i=e[r];if(i!=null)n.set(i.nameId,r)}return t.childIdByNameId=n,n}function Cn(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];if(r!=null)t.set(r,n)}return e.childPositionById=t,t}function kn(e,t){if(e.childPositionById!=null)e.childPositionById.set(t,e.childIds.length);e.childIds.push(t)}function vo(e,t){if(e.childPositionById==null)return;for(let n=t;n<e.childIds.length;n++){let r=e.childIds[n];if(r!=null)e.childPositionById.set(r,n)}}function sn(e,t){let n=0,r=0;for(let i of t.childIds){let o=e[i];if(o==null)continue;n+=o.subtreeNodeCount,r+=o.visibleSubtreeCount}t.totalChildSubtreeNodeCount=n,t.totalChildVisibleSubtreeCount=r,Ht(e,t)}function ri(e,t,n,r){if(e.totalChildSubtreeNodeCount+=n,e.totalChildVisibleSubtreeCount+=r,e.childVisibleChunkSums==null||r===0)return;let i=Cn(e).get(t);if(i===void 0)return;let o=i>>5;e.childVisibleChunkSums[o]+=r}function ii(e,t,n){let r=t.childVisibleChunkSums;if(r!=null){let o=n,s=0;for(let a of r){if(o<a){let l=zh(e,t,s,o);return{...l,childVisibleIndex:n-l.localVisibleIndex}}o-=a,s+=32}throw Error(`Visible child index ${String(n)} is out of range`)}let i=n;for(let o=0;o<t.childIds.length;o++){let s=t.childIds[o];if(s==null)continue;let a=e[s];if(a==null)continue;if(i<a.visibleSubtreeCount)return{childIndex:o,childVisibleIndex:n-i,localVisibleIndex:i};i-=a.visibleSubtreeCount}throw Error(`Visible child index ${String(n)} is out of range`)}function fa(e,t,n){let r=0,i=t.childVisibleChunkSums,o=0;if(i!=null){let s=n>>5;for(let a=0;a<s;a+=1)r+=i[a]??0;o=s<<5}for(let s=o;s<n;s+=1){let a=t.childIds[s];if(a==null)continue;let l=e[a];if(l==null)continue;r+=l.visibleSubtreeCount}return r}function Ht(e,t){if(t.childIds.length<128){t.childVisibleChunkSums=null;return}let n=Math.ceil(t.childIds.length/32),r=new Int32Array(n);for(let i=0;i<t.childIds.length;i++){let o=t.childIds[i];if(o==null)continue;let s=e[o];if(s==null)continue;r[i>>5]+=s.visibleSubtreeCount}t.childVisibleChunkSums=r}function zh(e,t,n,r){let i=Math.min(t.childIds.length,n+32),o=r;for(let s=n;s<i;s++){let a=t.childIds[s];if(a==null)continue;let l=e[a];if(l==null)continue;if(o<l.visibleSubtreeCount)return{childIndex:s,localVisibleIndex:o};o-=l.visibleSubtreeCount}throw Error(`Visible child index ${String(r)} is out of range`)}function Le(e,t,n=0){return e<<4|n<<3|t}function ze(e){return e.depthAndFlags>>>4}function dr(e){return(e.depthAndFlags&8)>>3}function R(e){return(e.depthAndFlags&8)!==0}function pa(e){return e.depthAndFlags&7}function ue(e,t){return(pa(e)&t)!==0}function xn(e,t){e.depthAndFlags|=t}function ma(e,t){e.depthAndFlags=Le(t,pa(e),dr(e))}var ga=Symbol("benchmarkInstrumentation");function va(e,t){if(t==null)return e;return Object.defineProperty(e,ga,{configurable:!0,enumerable:!1,value:t,writable:!1}),e}function hr(e){if(e==null)return null;return e[ga]??null}function E(e,t,n){if(e==null)return n();return e.measurePhase(t,n)}function _n(e,t,n){if(!Number.isFinite(n)||e==null)return;e.setCounter(t,n)}function ya(e){return e>=48&&e<=57}function Wh(e){let t=[],n=0,r=0;while(r<e.length){while(r<e.length&&!ya(e.charCodeAt(r)))r+=1;if(r>=e.length)break;if(r>n)t.push(e.slice(n,r));let i=0;while(r<e.length&&ya(e.charCodeAt(r)))i=i*10+(e.charCodeAt(r)-48),r+=1;t.push(i),n=r}if(n<e.length||t.length===0)t.push(e.slice(n));return t}function an(e){let t=e.toLowerCase();return{lowerValue:t,tokens:Wh(t)}}function $h(e,t){let n=Math.min(e.length,t.length);for(let r=0;r<n;r++){let i=e[r],o=t[r];if(i===o)continue;if(typeof i==="number"&&typeof o==="number")return i<o?-1:1;let s=String(i),a=String(o);if(s!==a)return s<a?-1:1}if(e.length!==t.length)return e.length<t.length?-1:1;return 0}function fr(e,t){if(e.tokens.length===1&&t.tokens.length===1&&typeof e.tokens[0]==="string"&&typeof t.tokens[0]==="string"){if(e.lowerValue===t.lowerValue)return 0;return e.lowerValue<t.lowerValue?-1:1}let n=$h(e.tokens,t.tokens);if(n!==0)return n;if(e.lowerValue!==t.lowerValue)return e.lowerValue<t.lowerValue?-1:1;return 0}function ba(e,t,n){let r=fr(n(e),n(t));if(r!==0)return r;if(e===t)return 0;return e<t?-1:1}function jh(e,t){return ba(e,t,an)}function oi(e,t){if(t!==e.segments.length-1)return 1;return e.isDirectory?1:0}function Kh(e,t){let n=Math.min(e.segments.length,t.segments.length);for(let r=0;r<n;r++){let i=e.segments[r],o=t.segments[r];if(i===o)continue;let s=oi(e,r);if(s!==oi(t,r))return s===1?-1:1;return jh(i,o)}if(e.segments.length!==t.segments.length)return e.segments.length<t.segments.length?-1:1;if(e.isDirectory===t.isDirectory)return 0;return e.isDirectory?-1:1}function wa(e,t){return Kh(e,t)}function Ia(e,t,n){let r=(o)=>{let s=n.get(o);if(s!=null)return s;let a=an(o);return n.set(o,a),a},i=Math.min(e.segments.length,t.segments.length);for(let o=0;o<i;o++){let s=e.segments[o],a=t.segments[o];if(s===a)continue;let l=oi(e,o);if(l!==oi(t,o))return l===1?-1:1;return ba(s,a,r)}if(e.segments.length!==t.segments.length)return e.segments.length<t.segments.length?-1:1;if(e.isDirectory===t.isDirectory)return 0;return e.isDirectory?-1:1}function pr(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 yo(e={}){return{flattenEmptyDirectories:e.flattenEmptyDirectories!==!1,sort:e.sort??"default"}}function Sa(e){let t=e.length>0&&e.charCodeAt(e.length-1)===47,n=t?e.length-1:e.length,r=[],i=0;for(let o=0;o<n;o++){if(e.charCodeAt(o)!==47)continue;r.push(e.slice(i,o)),i=o+1}return r.push(e.slice(i,n)),{hasTrailingSlash:t,segments:r}}function ln(e){let{hasTrailingSlash:t,segments:n}=Sa(e);return{basename:n[n.length-1]??"",isDirectory:t,path:e,segments:n}}function si(e){if(e.length===0)return{requiresDirectory:!1,segments:[]};let{hasTrailingSlash:t,segments:n}=Sa(e);return{requiresDirectory:t,segments:n}}function ai(){let e=new Map;return e.set("",0),{idByValue:e,valueById:[""],sortKeyById:[an("")]}}function at(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 Ge(e,t){let n=e.valueById[t];if(n===void 0)throw Error(`Unknown segment ID: ${String(t)}`);return n}var bo=Symbol("pathStorePreparedInputKind");function xa(e,t){return e[bo]=t,e}function Ca(e){return{basename:e.basename,depth:e.segments.length,isDirectory:e.isDirectory,path:e.path,segments:e.segments}}function _a(e,t,n){if(n==="default")return wa(e,t);return n(Ca(e),Ca(t))}function Uh(){return{depthAndFlags:Le(0,3,1),nameId:0,parentId:0,subtreeNodeCount:1,visibleSubtreeCount:1}}function Gh(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 ka(e){return e.isDirectory?e.segments.length:e.segments.length-1}function Yh(e){return Array.isArray(e)&&e.every((t)=>t!=null&&typeof t==="object"&&typeof t.path==="string"&&Array.isArray(t.segments)&&typeof t.basename==="string"&&typeof t.isDirectory==="boolean")}function Xh(e){return Array.isArray(e)&&e.every((t)=>typeof t==="string")}function Ea(e,t={}){return li(e,t).map((n)=>n.path)}function Ta(e,t={}){let n=li(e,t);return xa({paths:n.map((r)=>r.path),preparedPaths:n},"prepared")}function Pa(e){let t=e.length,n=!1;for(let r=0;r<t;r+=1){let i=e[r];if(i.length>0&&i.charCodeAt(i.length-1)===47){n=!0;break}}return xa({paths:e,presortedPaths:e,presortedPathsContainDirectories:n},"presorted")}function Ra(e){let t=e,n=t.preparedPaths;if(t[bo]==="prepared"&&n!=null)return n;if(!Yh(n))throw Error("preparedInput must come from PathStore.prepareInput()");return n}function Da(e){let t=e;if(t[bo]==="presorted"&&t.presortedPaths!=null)return t.presortedPaths;return Xh(t.presortedPaths)?t.presortedPaths:null}function Ma(e){let t=e;return typeof t.presortedPathsContainDirectories==="boolean"?t.presortedPathsContainDirectories:null}function li(e,t={}){let n=yo(t),r=hr(t);_n(r,"workload.inputFiles",e.length);let i=E(r,"store.preparePathEntries.parse",()=>e.map((o)=>ln(o)));return E(r,"store.preparePathEntries.sort",()=>i.sort((o,s)=>_a(o,s,n.sort))),i}var ci=class{directories=new Map;directoryStack=[0];presortedDirectoryNodeIds=[];initialExpandedPathSet;createdDirectoriesAllExpanded=!1;createdDirectoryCount=0;lastPreparedPath=null;nodes=[Uh()];options;instrumentation;segmentSortKeyCache=new Map;segmentTable=ai();hasDeferredDirectoryIndexes=!1;constructor(e={}){this.instrumentation=hr(e),this.options=yo(e);let t=e.initialExpandedPaths??null;if(t==null||t.length===0)this.initialExpandedPathSet=null;else{let n=new Set,r=t.length;for(let i=0;i<r;i+=1){let o=t[i],s=o.length;n.add(s>0&&o.charCodeAt(s-1)===47?o.slice(0,s-1):o)}this.initialExpandedPathSet=n,this.createdDirectoriesAllExpanded=!0}this.directories.set(0,on())}appendPaths(e){return E(this.instrumentation,"store.builder.appendPaths.parse",()=>this.appendPreparedPaths(e.map((t)=>ln(t))))}appendPreparedPaths(e,t=!0){return this.createdDirectoriesAllExpanded=!1,E(this.instrumentation,"store.builder.appendPreparedPaths",()=>{for(let n of e)this.appendPreparedPath(n,t)}),this}appendPresortedPaths(e,t=null){return E(this.instrumentation,"store.builder.appendPresortedPaths",()=>{if(t===!1){this.appendPresortedFilePaths(e);return}this.createdDirectoriesAllExpanded=!1;let n=null,r=0,i=this.nodes,o=this.segmentTable,s=o.idByValue,a=o.valueById,l=this.directoryStack,d=0,u="",f=0;for(let c of e){if(n===c)throw Error(`Duplicate path: "${c}"`);let m=c.length>0&&c.charCodeAt(c.length-1)===47,p=m?c.length-1:c.length,g=0,v=0;if(n!=null)if(u.length>0&&c.length>u.length&&c.startsWith(u))g=f,v=u.length;else{let y=Math.min(p,n.length),S=!0;for(let k=0;k<y;k++){let T=c.charCodeAt(k);if(T!==n.charCodeAt(k)){S=!1;break}if(T===47)g++,v=k+1}if(S&&m&&y===p&&n.length>p&&n.charCodeAt(p)===47)g++,v=p+1}d=g,r=g;let I=v,C=c.indexOf("/",I);while(C>=0&&C<p){let y=l[d];if(y===void 0)throw Error("Directory stack underflow while building the path store");r++;let S=c.slice(I,C),k=s.get(S);if(k===void 0)k=a.length,s.set(S,k),a.push(S);let T=i.length;i.push({depthAndFlags:Le(r,0,1),nameId:k,parentId:y,subtreeNodeCount:1,visibleSubtreeCount:1}),this.recordCreatedDirectoryPath(c.slice(0,C)),d++,l[d]=T,I=C+1,C=c.indexOf("/",I)}if(m){if(I<p){let S=l[d];if(S===void 0)throw Error(`Unable to resolve directory parent for "${c}"`);r++;let k=c.slice(I,p),T=s.get(k);if(T===void 0)T=a.length,s.set(k,T),a.push(k);let O=i.length;i.push({depthAndFlags:Le(r,0,1),nameId:T,parentId:S,subtreeNodeCount:1,visibleSubtreeCount:1}),d++,l[d]=O,I=p+1}let y=l[d];if(y===void 0)throw Error(`Unable to resolve directory node for "${c}"`);this.promoteDirectoryToExplicit(y,c)}else{let y=l[d];if(y===void 0)throw Error(`Unable to resolve file parent for "${c}"`);let S=c.slice(I),k=s.get(S);if(k===void 0)k=a.length,s.set(S,k),a.push(S);i.push({depthAndFlags:Le(r+1,0),nameId:k,parentId:y,subtreeNodeCount:1,visibleSubtreeCount:1})}if(I!==u.length)u=c.substring(0,I),f=r;n=c}if(l.length=d+1,n!=null)this.lastPreparedPath=ln(n);this.hasDeferredDirectoryIndexes=!0}),this}appendPresortedFilePaths(e){let t=null,n=0,r=this.nodes,i=this.segmentTable,o=i.idByValue,s=i.valueById,a=this.directoryStack,l=0,d="",u=0;for(let f of e){if(t===f)throw Error(`Duplicate path: "${f}"`);let c=f.length,m=0,p=0;if(t!=null)if(d.length>0&&f.length>d.length&&f.startsWith(d))m=u,p=d.length;else{let S=Math.min(c,t.length);for(let k=0;k<S;k++){let T=f.charCodeAt(k);if(T!==t.charCodeAt(k))break;if(T===47)m++,p=k+1}}l=m,n=m;let g=p,v=f.indexOf("/",g);while(v>=0){let S=a[l];if(S===void 0)throw Error("Directory stack underflow while building the path store");n++;let k=f.slice(g,v),T=o.get(k);if(T===void 0)T=s.length,o.set(k,T),s.push(k);let O=r.length;r.push({depthAndFlags:Le(n,0,1),nameId:T,parentId:S,subtreeNodeCount:1,visibleSubtreeCount:1}),this.recordCreatedDirectoryPath(f.slice(0,v)),this.presortedDirectoryNodeIds.push(O),l++,a[l]=O,g=v+1,v=f.indexOf("/",g)}let I=a[l];if(I===void 0)throw Error(`Unable to resolve file parent for "${f}"`);let C=f.slice(g),y=o.get(C);if(y===void 0)y=s.length,o.set(C,y),s.push(C);if(r.push({depthAndFlags:Le(n+1,0),nameId:y,parentId:I,subtreeNodeCount:1,visibleSubtreeCount:1}),g!==d.length)d=f.substring(0,g),u=n;t=f}if(a.length=l+1,t!=null)this.lastPreparedPath=ln(t);this.hasDeferredDirectoryIndexes=!0}finish(e={}){let t=e.skipSubtreeCountPass===!0;if(this.hasDeferredDirectoryIndexes)E(this.instrumentation,"store.builder.buildDirectoryIndexes",()=>this.buildPresortedFinish(t)),this.hasDeferredDirectoryIndexes=!1;else if(!t)E(this.instrumentation,"store.builder.computeSubtreeCounts",()=>this.computeSubtreeCounts(0));return{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(),this.hasDeferredDirectoryIndexes=!1;if(this.lastPreparedPath!=null){if(e.path===this.lastPreparedPath.path)throw Error(`Duplicate path: "${e.path}"`);if(t){if((this.options.sort==="default"?Ia(this.lastPreparedPath,e,this.segmentSortKeyCache):_a(this.lastPreparedPath,e,this.options.sort))>0)throw Error(`Builder input must be sorted before appendPaths(): "${e.path}"`)}}let n=this.lastPreparedPath,r=ka(e),i=n==null?0:ka(n),o=n==null?0:Gh(n.segments,e.segments),s=Math.min(o,r,i);this.directoryStack.length=s+1;for(let l=s;l<r;l++){let d=this.directoryStack[this.directoryStack.length-1];if(d===void 0)throw Error("Directory stack underflow while building the path store");let u=t?this.getOrCreateDirectoryChild(d,e.segments[l]):this.createDirectoryChild(d,e.segments[l]);this.directoryStack.push(u)}if(e.isDirectory){let l=this.directoryStack[this.directoryStack.length-1];if(l===void 0)throw Error(`Unable to resolve directory node for "${e.path}"`);this.promoteDirectoryToExplicit(l,e.path),this.lastPreparedPath=e;return}let a=this.directoryStack[this.directoryStack.length-1];if(a===void 0)throw Error(`Unable to resolve file parent for "${e.path}"`);if(t)this.createFileChild(a,e.basename,e.path);else this.createFileChildUnchecked(a,e.basename);this.lastPreparedPath=e}recordCreatedDirectoryPath(e){if(!this.createdDirectoriesAllExpanded||this.initialExpandedPathSet==null)return;if(this.createdDirectoryCount+=1,!this.initialExpandedPathSet.has(e))this.createdDirectoriesAllExpanded=!1}createFileChild(e,t,n){let r=at(this.segmentTable,t),i=this.getDirectoryIndex(e),o=i.childIdByNameId;if(o!=null){if(o.get(r)!==void 0)throw Error(`Path collides with an existing entry: "${n}"`)}let s=this.nodes[e];if(s===void 0)throw Error(`Unknown parent node ID: ${String(e)}`);let a=this.nodes.length;if(this.nodes.push({depthAndFlags:Le(ze(s)+1,0),nameId:r,parentId:e,subtreeNodeCount:1,visibleSubtreeCount:1}),o!=null)o.set(r,a);return kn(i,a),a}createFileChildUnchecked(e,t){let n=at(this.segmentTable,t),r=this.getDirectoryIndex(e),i=this.nodes[e];if(i===void 0)throw Error(`Unknown parent node ID: ${String(e)}`);let o=this.nodes.length;if(this.nodes.push({depthAndFlags:Le(ze(i)+1,0),nameId:n,parentId:e,subtreeNodeCount:1,visibleSubtreeCount:1}),r.childIdByNameId!=null)r.childIdByNameId.set(n,o);return kn(r,o),o}getOrCreateDirectoryChild(e,t){let n=at(this.segmentTable,t),r=this.getDirectoryIndex(e);if(r.childIdByNameId!=null){let s=r.childIdByNameId.get(n);if(s!==void 0){let a=this.nodes[s];if(a!=null&&!R(a))throw Error(`Path collides with an existing file while creating directory "${t}"`);return s}}let i=this.nodes[e];if(i===void 0)throw Error(`Unknown parent node ID: ${String(e)}`);let o=this.nodes.length;if(this.nodes.push({depthAndFlags:Le(ze(i)+1,0,1),nameId:n,parentId:e,subtreeNodeCount:1,visibleSubtreeCount:1}),r.childIdByNameId!=null)r.childIdByNameId.set(n,o);return kn(r,o),this.directories.set(o,on()),o}createDirectoryChild(e,t){let n=at(this.segmentTable,t),r=this.getDirectoryIndex(e),i=this.nodes[e];if(i===void 0)throw Error(`Unknown parent node ID: ${String(e)}`);let o=this.nodes.length;if(this.nodes.push({depthAndFlags:Le(ze(i)+1,0,1),nameId:n,parentId:e,subtreeNodeCount:1,visibleSubtreeCount:1}),r.childIdByNameId!=null)r.childIdByNameId.set(n,o);return kn(r,o),this.directories.set(o,on()),o}promoteDirectoryToExplicit(e,t){let n=this.nodes[e];if(n===void 0)throw Error(`Unknown directory node ID: ${String(e)}`);if(!R(n))throw Error(`Path is not a directory: "${t}"`);if(ue(n,1))throw Error(`Duplicate path: "${t}"`);xn(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,go());let r=-1,i=null;for(let o=1;o<t.length;o++){let s=t[o];if(s==null)continue;if(R(s)){let l=go();n.set(o,l),r=o,i=l}let a;if(s.parentId===r)a=i;else a=n.get(s.parentId),r=s.parentId,i=a??null;if(a!=null)a.childIds.push(o)}if(e)return;for(let o=t.length-1;o>=1;o--){let s=t[o];if(s==null)continue;let a=t[s.parentId];if(a!=null)a.subtreeNodeCount+=s.subtreeNodeCount,a.visibleSubtreeCount+=s.visibleSubtreeCount}}buildDirectoryIndexes(){let e=this.nodes;for(let t=1;t<e.length;t++){let n=e[t];if(n==null)continue;if(R(n))this.directories.set(t,on());let r=this.directories.get(n.parentId);if(r!=null){if(r.childIdByNameId!=null)r.childIdByNameId.set(n.nameId,t);kn(r,t)}}}computeSubtreeCounts(e){let t=this.nodes[e];if(t===void 0)throw Error(`Unknown node ID: ${String(e)}`);if(!R(t))return t.subtreeNodeCount=1,t.visibleSubtreeCount=1,1;let n=this.getDirectoryIndex(e),r=1;for(let i of n.childIds)r+=this.computeSubtreeCounts(i);return sn(this.nodes,n),t.subtreeNodeCount=r,t.visibleSubtreeCount=r,r}};function Aa(e,t="closed",n=null){let r=Qh(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 Na(){return{affectedAncestorIds:new Set,affectedNodeIds:new Set,events:[]}}function Qh(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 La(e,t){if(ue(t,2))return!0;if(e.defaultExpansion==="open")return!0;if(e.defaultExpansion==="closed")return!1;return ze(t)<=e.defaultExpansion}function _e(e,t,n=e.snapshot.nodes[t]){if(n==null||!R(n))return!1;if(e.directoriesOpenByDefault&&!e.hasCollapsedDirectoryOverrides)return!0;if(e.collapsedDirectoryIds.has(t))return!1;if(e.expandedDirectoryIds.has(t))return!0;return La(e,n)}function Vt(e,t,n,r=e.snapshot.nodes[t]){if(r==null||!R(r))return;let i=La(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 Fa(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 Ot(e,t){return e.directoryLoadInfoById.get(t)?.state??"loaded"}function Ba(e,t){let n=Fa(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 Ha(e,t){let n=Fa(e,t);n.activeAttemptId=null,n.errorMessage=null,n.state="unloaded"}function Va(e,t,n){let r=e.directoryLoadInfoById.get(t);if(r==null||r.activeAttemptId!==n)return!1;return r.activeAttemptId=null,r.errorMessage=null,r.state="loaded",!0}function Oa(e,t,n){return e.directoryLoadInfoById.get(t)?.activeAttemptId===n}function qa(e,t,n,r){let i=e.directoryLoadInfoById.get(t);if(i==null||i.activeAttemptId!==n)return!1;return i.activeAttemptId=null,i.errorMessage=r??null,i.state="error",!0}function za(e,t){e.directoryLoadInfoById.delete(t)}function Ua(e,t,n){let r=n,i=e.listeners.get(t);if(i!=null)i.add(r);else e.listeners.set(t,new Set([r]));return()=>{let o=e.listeners.get(t);if(o==null)return;if(o.delete(r),o.size===0)e.listeners.delete(t)}}function Ga(e){return{affectedAncestorIds:e.affectedAncestorIds??[],affectedNodeIds:e.affectedNodeIds??[],canonicalChanged:!0,operation:"add",path:e.path,projectionChanged:e.projectionChanged,visibleCountDelta:null}}function Ya(e){return{affectedAncestorIds:e.affectedAncestorIds??[],affectedNodeIds:e.affectedNodeIds??[],canonicalChanged:!0,operation:"remove",path:e.path,projectionChanged:e.projectionChanged,recursive:e.recursive,visibleCountDelta:null}}function Xa(e){return{affectedAncestorIds:e.affectedAncestorIds??[],affectedNodeIds:e.affectedNodeIds??[],canonicalChanged:!0,from:e.from,operation:"move",projectionChanged:e.projectionChanged,to:e.to,visibleCountDelta:null}}function Qa(e){return{affectedAncestorIds:e.affectedAncestorIds??[],affectedNodeIds:e.affectedNodeIds??[],canonicalChanged:!1,operation:"expand",path:e.path,projectionChanged:!0,visibleCountDelta:null}}function Za(e){return{affectedAncestorIds:e.affectedAncestorIds??[],affectedNodeIds:e.affectedNodeIds??[],canonicalChanged:!1,operation:"collapse",path:e.path,projectionChanged:!0,visibleCountDelta:null}}function Ja(e){return{affectedAncestorIds:e.affectedAncestorIds??[],affectedNodeIds:e.affectedNodeIds??[],canonicalChanged:!1,operation:"mark-directory-unloaded",path:e.path,projectionChanged:e.projectionChanged,visibleCountDelta:null}}function el(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 tl(e){return{affectedAncestorIds:e.affectedAncestorIds??[],affectedNodeIds:e.affectedNodeIds??[],attemptId:e.attemptId,canonicalChanged:e.childEvents.some((t)=>t.canonicalChanged),childEvents:e.childEvents,operation:"apply-child-patch",path:e.path,projectionChanged:e.projectionChanged,visibleCountDelta:null}}function nl(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 rl(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 il(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 Fe(e,t,n){return{...n,visibleCountDelta:Io(e)-t}}function ol(e,t){let n=Io(e),r=Na();e.transactionStack.push(r);try{t()}catch(i){throw $a(e,r,!1),i}$a(e,r,!0,Io(e)-n)}function Ze(e,t){let n=e.instrumentation;if(n==null){Wa(e,t);return}E(n,"store.events.record",()=>Wa(e,t))}function Wa(e,t){let n=e.transactionStack[e.transactionStack.length-1]??null;if(n==null){wo(e,t);return}n.events.push(t),ef(n,t)}function $a(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 a=e.instrumentation;if(a==null)ja(i,t);else E(a,"store.events.batch.merge",()=>ja(i,t));return}let o=Zh(t,r),s=e.instrumentation;if(s==null){wo(e,o);return}E(s,"store.events.batch.commit",()=>wo(e,o))}function Zh(e,t){return{affectedAncestorIds:[...e.affectedAncestorIds],affectedNodeIds:[...e.affectedNodeIds],canonicalChanged:e.events.some((n)=>n.canonicalChanged),events:[...e.events],operation:"batch",projectionChanged:e.events.some((n)=>n.projectionChanged),visibleCountDelta:t}}function Jh(e,t){for(let n of t.affectedAncestorIds)e.affectedAncestorIds.add(n);for(let n of t.affectedNodeIds)e.affectedNodeIds.add(n)}function ja(e,t){for(let n of t.events)e.events.push(n);Jh(e,t)}function ef(e,t){for(let n of t.affectedNodeIds)e.affectedNodeIds.add(n);for(let n of t.affectedAncestorIds)e.affectedAncestorIds.add(n)}function wo(e,t){let n=e.instrumentation;if(n==null){Ka(e,t);return}E(n,"store.events.emit",()=>Ka(e,t))}function Ka(e,t){e.listeners.get(t.operation)?.forEach((n)=>n(t)),e.listeners.get("*")?.forEach((n)=>n(t))}function Io(e){return e.snapshot.nodes[e.snapshot.rootId]?.visibleSubtreeCount??0}function Ct(e,t){if(e.snapshot.options.flattenEmptyDirectories!==!0)return null;let n=e.snapshot.nodes[t];if(n==null||!R(n)||ue(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 o=e.snapshot.nodes[i];if(o==null||!R(o))return null;return i}function kt(e,t){let n=t;while(!0){let r=Ct(e,n);if(r==null)return n;n=r}}function En(e,t){let n=[t],r=t;while(!0){let i=Ct(e,r);if(i==null)return n;n.push(i),r=i}}function ui(e,t){let n=t==null?e.snapshot.rootId:Be(e,t);if(n==null)return[];return nf(e,n)}function Co(e,t){let n=ln(t),r=n.isDirectory?n.segments:n.segments.slice(0,-1),i=qt(e,hf(e,r)),{createdNodeIds:o,directoryId:s}=rf(e,r),a=new Set(o),l=s;if(n.isDirectory){let u=D(e,s);if(ue(u,1))throw Error(`Path already exists: "${t}"`);xn(u,1),e.pathCacheByNodeId.set(s,{path:t,version:e.pathCacheVersion}),a.add(s)}else l=sf(e,s,n.basename),a.add(l);zt(e,s);let d=qt(e,s);return Ga({affectedAncestorIds:Ye(e,l),affectedNodeIds:[...a],path:t,projectionChanged:hl(i,d)})}function ko(e,t,n){let r=Be(e,t);if(r==null)throw Error(`Path does not exist: "${t}"`);let i=D(e,r);if(ue(i,2))throw Error("The root node cannot be removed");if(R(i)&&ie(e,r).childIds.length>0&&n.recursive!==!0)throw Error(`Cannot remove a non-empty directory without recursive: "${t}"`);let o=i.parentId,s=qt(e,o),a=dl(e,r);Eo(e,o,r,i.nameId),To(e,o),zt(e,o);let l=qt(e,o);return Ya({affectedAncestorIds:Ye(e,o),affectedNodeIds:a,path:t,projectionChanged:hl(s,l),recursive:n.recursive===!0})}function xo(e,t,n,r){let i=Be(e,t);if(i==null)throw Error(`Source path does not exist: "${t}"`);let o=D(e,i);if(ue(o,2))throw Error("The root node cannot be moved");let s=r.collision??"error",a=uf(e,i,n),l=qt(e,o.parentId),d=qt(e,a.parentId),u=Ge(e.snapshot.segmentTable,o.nameId),f=at(e.snapshot.segmentTable,a.basename);if(a.parentId===o.parentId&&u===a.basename)return null;if(R(o)&&pf(e,i,a.parentId))throw Error("Cannot move a directory into one of its descendants");let c=Bt(e.snapshot.nodes,ie(e,a.parentId)).get(f),m=a.existingNodeId??c??null;if(m!=null&&m!==i){if(df(e,m,s,dr(o))==="skip")return null}let p=o.parentId;if(Eo(e,p,i,o.nameId),o.parentId=a.parentId,o.nameId=f,e.pathCacheByNodeId.delete(i),pl(e,i),_o(e,a.parentId,i),To(e,p),e.pathCacheVersion++,zt(e,p),a.parentId!==p)zt(e,a.parentId);let g=qt(e,p),v=qt(e,a.parentId);return Xa({affectedAncestorIds:[...new Set([...Ye(e,p),...Ye(e,a.parentId)])],affectedNodeIds:[i],from:t,projectionChanged:fl([l,d],[g,v]),to:te(e,i)})}function tf(e,t){let n=e.pathCacheByNodeId.get(t);return n!=null&&n.version===e.pathCacheVersion?n.path:null}function sl(e,t,n){return e.pathCacheByNodeId.set(t,{path:n,version:e.pathCacheVersion}),n}function te(e,t){let n=D(e,t),r=tf(e,t);if(r!=null)return r;if(ue(n,2))return sl(e,t,"");let i=te(e,n.parentId),o=Ge(e.snapshot.segmentTable,n.nameId),s=i.length===0?o:`${i}${o}`;return sl(e,t,R(n)?`${s}/`:s)}function zt(e,t){let n=e.instrumentation;if(n==null){ll(e,t);return}E(n,"store.recomputeCountsUpwardFrom",()=>ll(e,t))}function mr(e,t){let n=[[t,0]],{nodes:r,directories:i}=e.snapshot;while(n.length>0){let o=n[n.length-1],s=o[0],a=r[s];if(a==null||!R(a)){So(e,s,a,!0),n.pop();continue}let l=i.get(s);if(l==null||o[1]>=l.childIds.length){So(e,s,a,!0),n.pop();continue}let d=l.childIds[o[1]++];n.push([d,0])}}function Ye(e,t){let n=[],r=t;while(r!=null){let i=D(e,r);if(n.push(r),r===e.snapshot.rootId)break;r=i.parentId}return n}function Be(e,t){if(t.length===0)return e.snapshot.rootId;let n=si(t);return ul(e,n.segments,n.requiresDirectory)}function ul(e,t,n){let r=e.snapshot.rootId;for(let o of t){let s=e.snapshot.segmentTable.idByValue.get(o);if(s===void 0)return null;let a=ie(e,r),l=Bt(e.snapshot.nodes,a).get(s);if(l===void 0)return null;r=l}let i=D(e,r);if(n&&!R(i))return null;return r}function ie(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 D(e,t){let n=e.snapshot.nodes[t];if(n===void 0||ue(n,4))throw Error(`Unknown node ID: ${String(t)}`);return n}function nf(e,t){let n=e.snapshot.nodes[t];if(n===void 0||ue(n,4))return[];if(!R(n))return[te(e,t)];if(ie(e,t).childIds.length===0)return ue(n,1)&&!ue(n,2)?[te(e,t)]:[];let r=[],i=[{childIndex:0,nodeId:t}];while(i.length>0){let o=i[i.length-1];if(o==null)break;let s=e.snapshot.nodes[o.nodeId];if(s===void 0||ue(s,4)){i.pop();continue}if(!R(s)){r.push(te(e,o.nodeId)),i.pop();continue}let a=ie(e,o.nodeId);if(a.childIds.length===0){if(ue(s,1)&&!ue(s,2))r.push(te(e,o.nodeId));i.pop();continue}let l=a.childIds[o.childIndex];if(l==null){i.pop();continue}o.childIndex++,i.push({childIndex:0,nodeId:l})}return r}function rf(e,t){let n=[],r=e.snapshot.rootId;for(let i of t){let o=at(e.snapshot.segmentTable,i),s=ie(e,r),a=Bt(e.snapshot.nodes,s).get(o);if(a!==void 0){if(!R(D(e,a)))throw Error(`Cannot create a directory that collides with an existing file: "${i}"`);r=a;continue}r=of(e,r,o),n.push(r)}return{createdNodeIds:n,directoryId:r}}function of(e,t,n){let r=D(e,t),i=e.snapshot.nodes.length;if(e.snapshot.nodes.push({depthAndFlags:Le(ze(r)+1,0,1),nameId:n,parentId:t,subtreeNodeCount:1,visibleSubtreeCount:1}),e.snapshot.directories.set(i,on()),_o(e,t,i),e.collapseNewDirectoriesByDefault)e.collapsedDirectoryIds.add(i),e.hasCollapsedDirectoryOverrides=!0;return e.activeNodeCount++,i}function sf(e,t,n){let r=at(e.snapshot.segmentTable,n),i=ie(e,t);if(Bt(e.snapshot.nodes,i).has(r))throw Error(`Path already exists: "${mf(e,t,n)}"`);let o=D(e,t),s=e.snapshot.nodes.length;return e.snapshot.nodes.push({depthAndFlags:Le(ze(o)+1,0),nameId:r,parentId:t,subtreeNodeCount:1,visibleSubtreeCount:1}),_o(e,t,s),e.activeNodeCount++,s}function af(e,t,n){let r=0,i=t.childIds.length;while(r<i){let o=r+i>>>1,s=t.childIds[o];if(s==null){i=o;continue}if(lf(e,n,s)<0)i=o;else r=o+1}return r}function _o(e,t,n){let r=ie(e,t),i=D(e,n);Bt(e.snapshot.nodes,r).set(i.nameId,n),ri(r,n,i.subtreeNodeCount,i.visibleSubtreeCount);let o=af(e,r,n);r.childIds.splice(o,0,n),vo(r,o),Ht(e.snapshot.nodes,r)}function Eo(e,t,n,r){let i=ie(e,t),o=Cn(i),s=o.get(n)??-1;Bt(e.snapshot.nodes,i).delete(r),o.delete(n);let a=e.snapshot.nodes[n];if(a!=null)ri(i,n,-a.subtreeNodeCount,-a.visibleSubtreeCount);if(s>=0)i.childIds.splice(s,1),vo(i,s),Ht(e.snapshot.nodes,i)}function lf(e,t,n){let r=e.snapshot.options.sort;if(r==="default")return cf(e,t,n);return r(al(e,t),al(e,n))}function cf(e,t,n){let r=D(e,t),i=D(e,n),o=R(r);if(o!==R(i))return o?-1:1;let s=fr(pr(e.snapshot.segmentTable,r.nameId),pr(e.snapshot.segmentTable,i.nameId));if(s!==0)return s;let a=Ge(e.snapshot.segmentTable,r.nameId),l=Ge(e.snapshot.segmentTable,i.nameId);if(a!==l)return a<l?-1:1;return t<n?-1:1}function al(e,t){let n=D(e,t),r=te(e,t),i=R(n),o=i?r.slice(0,-1):r;return{basename:Ge(e.snapshot.segmentTable,n.nameId),depth:ze(n),isDirectory:i,path:r,segments:o.length===0?[]:o.split("/")}}function uf(e,t,n){let r=D(e,t),i=Be(e,n);if(i!=null){let d=D(e,i);if(R(d))return{basename:Ge(e.snapshot.segmentTable,r.nameId),existingNodeId:null,parentId:i};let u=si(n).segments;return{basename:u[u.length-1]??"",existingNodeId:i,parentId:d.parentId}}let o=si(n),s=o.segments[o.segments.length-1]??"",a=o.segments.slice(0,-1),l=a.length===0?e.snapshot.rootId:ul(e,a,!0);if(l==null)throw Error(`Destination parent does not exist: "${n}"`);return{basename:s,existingNodeId:null,parentId:l}}function df(e,t,n,r){if(n==="skip")return"skip";if(n==="error")throw Error(`Destination already exists: "${te(e,t)}"`);let i=D(e,t);if(dr(i)!==r)throw Error("replace collision requires the same source and destination kinds");if(R(i)&&ie(e,t).childIds.length>0)throw Error("replace collision does not support non-empty directories");let{parentId:o,nameId:s}=i;return dl(e,t),Eo(e,o,t,s),To(e,o),zt(e,o),"handled"}function dl(e,t){let n=[],r=[{nodeId:t,visitedChildren:!1}];while(r.length>0){let i=r.pop();if(i==null)break;let o=D(e,i.nodeId);if(i.visitedChildren||!R(o)){if(R(o))e.snapshot.directories.delete(i.nodeId);if(xn(o,4),e.pathCacheByNodeId.delete(i.nodeId),e.collapsedDirectoryIds.delete(i.nodeId))e.hasCollapsedDirectoryOverrides=e.collapsedDirectoryIds.size>0;e.expandedDirectoryIds.delete(i.nodeId),za(e,i.nodeId),e.activeNodeCount--,n.push(i.nodeId);continue}r.push({nodeId:i.nodeId,visitedChildren:!0});let s=ie(e,i.nodeId);for(let a=s.childIds.length-1;a>=0;a--){let l=s.childIds[a];if(l!=null)r.push({nodeId:l,visitedChildren:!1})}}return n}function To(e,t){let n=t;while(n!=null){let r=D(e,n);if(!R(r)||ue(r,2))return;if(ie(e,n).childIds.length>0)return;xn(r,1),n=r.parentId===n?null:r.parentId}}function hf(e,t){let n=e.snapshot.rootId;for(let r of t){let i=e.snapshot.segmentTable.idByValue.get(r);if(i==null)break;let o=Bt(e.snapshot.nodes,ie(e,n)).get(i);if(o==null)break;if(!R(D(e,o)))break;n=o}return n}function qt(e,t){let n=ff(e,t);if(n==null)return null;let r=kt(e,n),i=D(e,r),o=n===r?null:En(e,n).map((s)=>te(e,s));return JSON.stringify({flattenedSegmentPaths:o,hasChildren:ie(e,r).childIds.length>0,path:te(e,r),terminalKind:dr(i)})}function hl(e,t){return fl([e],[t])}function fl(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 ff(e,t){let n=t;while(n!=null){let r=D(e,n);if(!R(r)||ue(r,2))return null;if(!_e(e,n,r))return n;n=r.parentId}return null}function pl(e,t){let n=D(e,t);if(ma(n,(t===e.snapshot.rootId?-1:ze(D(e,n.parentId)))+1),!R(n))return;let r=ie(e,t);for(let i of r.childIds)pl(e,i)}function pf(e,t,n){let r=n;while(r!=null){if(r===t)return!0;let i=D(e,r);if(r===e.snapshot.rootId)return!1;r=i.parentId}return!1}function So(e,t,n=D(e,t),r=!1){let i=e.instrumentation;if(i==null){cl(e,t,n,r);return}E(i,"store.recomputeNodeCounts",()=>cl(e,t,n,r))}function ll(e,t){let n=t;while(n!=null){let r=D(e,n),i=r.subtreeNodeCount,o=r.visibleSubtreeCount;if(So(e,n,r),n===e.snapshot.rootId)return;let s=r.subtreeNodeCount-i,a=r.visibleSubtreeCount-o,l=r.parentId;if(s!==0||a!==0)ri(ie(e,l),n,s,a);n=l}}function cl(e,t,n,r){if(!R(n)){n.subtreeNodeCount=1,n.visibleSubtreeCount=1;return}let i=ie(e,t);if(r){let a=e.instrumentation;if(a==null)sn(e.snapshot.nodes,i);else E(a,"store.recomputeNodeCounts.rebuildChildAggregates",()=>sn(e.snapshot.nodes,i))}let o=1+i.totalChildSubtreeNodeCount,s=i.totalChildVisibleSubtreeCount;if(n.subtreeNodeCount=o,ue(n,2)){n.visibleSubtreeCount=s;return}n.visibleSubtreeCount=Ct(e,t)!=null?s:_e(e,t,n)?1+s:1}function mf(e,t,n){let r=te(e,t);return r.length===0?n:`${r}${n}`}function Tn(e){return e!=null&&!ue(e,4)}function di(e,t){let n=e.snapshot.nodes[t];if(!Tn(n)||!R(n)||ue(n,2))return null;return n}function gf(e){let t=0;for(let[n,r]of e.pathCacheByNodeId){if(r.version!==e.pathCacheVersion)continue;if(!Tn(e.snapshot.nodes[n]))continue;t+=1}return t}function vf(e){return Math.max(0,e.valueById.length-1)}function ml(e){return{activeNodeCount:e.activeNodeCount,cachedPathEntryCount:gf(e),loadInfoEntryCount:e.directoryLoadInfoById.size,segmentCount:vf(e.snapshot.segmentTable),totalNodeSlotCount:Math.max(0,e.snapshot.nodes.length-1)}}function yf(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 gl(e){let t=[],n=[];for(let r of e.collapsedDirectoryIds)if(di(e,r)!=null)t.push(te(e,r));for(let r of e.expandedDirectoryIds)if(di(e,r)!=null)n.push(te(e,r));return{collapsedPaths:t,expandedPaths:n}}function vl(e){let t=[];for(let[n,r]of e.directoryLoadInfoById){if(di(e,n)==null||Ot(e,n)==="loaded")continue;t.push({info:{activeAttemptId:null,errorMessage:r.errorMessage,nextAttemptId:r.nextAttemptId,state:r.state},path:te(e,n)})}return t}function yl(e,t){e.collapsedDirectoryIds.clear(),e.hasCollapsedDirectoryOverrides=!1,e.expandedDirectoryIds.clear();for(let n of t.expandedPaths){let r=Be(e,n);if(r==null)continue;Vt(e,r,!0,D(e,r))}for(let n of t.collapsedPaths){let r=Be(e,n);if(r==null)continue;Vt(e,r,!1,D(e,r))}}function bl(e,t){e.directoryLoadInfoById.clear();for(let n of t){let r=Be(e,n.path);if(r==null)continue;if(di(e,r)==null)continue;e.directoryLoadInfoById.set(r,{activeAttemptId:null,errorMessage:n.info.errorMessage,nextAttemptId:n.info.nextAttemptId,state:n.info.state})}}function bf(e){e.pathCacheVersion+=1,e.pathCacheByNodeId.clear(),e.pathCacheByNodeId.set(e.snapshot.rootId,{path:"",version:e.pathCacheVersion})}function wf(e){let t=e.snapshot.segmentTable,n=ai();for(let r of e.snapshot.nodes){if(!Tn(r))continue;if(ue(r,2)){r.nameId=0;continue}r.nameId=at(n,Ge(t,r.nameId))}e.snapshot.segmentTable=n}function If(e){for(let[t,n]of e.snapshot.directories){let r=e.snapshot.nodes[t];if(!Tn(r)||!R(r)){e.snapshot.directories.delete(t);continue}let i=n.childIds.filter((o)=>{let s=e.snapshot.nodes[o];return Tn(s)&&s.parentId===t});n.childIds=i,n.childIdByNameId=new Map(i.map((o)=>[D(e,o).nameId,o])),n.childPositionById=new Map(i.map((o,s)=>[o,s])),sn(e.snapshot.nodes,n)}}function Sf(e){let t=e.snapshot.nodes.length-1;while(t>e.snapshot.rootId){let n=e.snapshot.nodes[t];if(Tn(n))break;t-=1}e.snapshot.nodes.length=t+1}function Cf(e){let t=gl(e),n=vl(e);E(e.instrumentation,"store.cleanup.stable.clearPathCaches",()=>bf(e)),E(e.instrumentation,"store.cleanup.stable.rebuildSegmentTable",()=>wf(e)),E(e.instrumentation,"store.cleanup.stable.rebuildDirectoryIndexes",()=>If(e)),E(e.instrumentation,"store.cleanup.stable.trimTrailingRemovedNodeSlots",()=>Sf(e)),E(e.instrumentation,"store.cleanup.stable.restoreExpansionOverrides",()=>yl(e,t)),E(e.instrumentation,"store.cleanup.stable.restoreDirectoryLoadInfos",()=>bl(e,n)),E(e.instrumentation,"store.cleanup.stable.recomputeCounts",()=>mr(e,e.snapshot.rootId))}function kf(e){let t=gl(e),n=vl(e),r=E(e.instrumentation,"store.cleanup.aggressive.listPaths",()=>ui(e)),i=va({...e.snapshot.options},e.instrumentation),o=E(e.instrumentation,"store.cleanup.aggressive.rebuildSnapshot",()=>{let s=new ci(i);return s.appendPaths(r),s.finish()});e.snapshot=o,e.activeNodeCount=o.nodes.length-1,e.pathCacheByNodeId=new Map([[o.rootId,{path:"",version:0}]]),e.pathCacheVersion=0,E(e.instrumentation,"store.cleanup.aggressive.restoreExpansionOverrides",()=>yl(e,t)),E(e.instrumentation,"store.cleanup.aggressive.restoreDirectoryLoadInfos",()=>bl(e,n)),E(e.instrumentation,"store.cleanup.aggressive.recomputeCounts",()=>mr(e,e.snapshot.rootId))}function wl(e){for(let t of e.directoryLoadInfoById.values())if(t.state==="loading"&&t.activeAttemptId!=null)return!0;return!1}function Il(e,t){let n=ml(e);if(t==="stable")E(e.instrumentation,"store.cleanup.stable",()=>Cf(e));else E(e.instrumentation,"store.cleanup.aggressive",()=>kf(e));let r=ml(e);return yf(t,t==="stable",n,r)}var xf=64;function _f(e,t){let n=t+2;if(n<=e.length)return e;let r=e.length;while(r<n)r*=2;let i=new Int32Array(r);return i.fill(-1),i.set(e),i}function Ee(e){return D(e,e.snapshot.rootId).visibleSubtreeCount}function xl(e,t,n,r){let i=D(e,t.terminalNodeId),o=Math.max(1,i.visibleSubtreeCount);return Math.min(r-1,n+o-1)}function Ef(e,t,n,r){return{ancestorPaths:r,index:t.index,posInSet:t.posInSet,row:gr(e,t.cursor),setSize:t.setSize,subtreeEndIndex:xl(e,t.cursor,t.index,n)}}function _l(e,t,n,r,i,o){let s=ie(e,t),{childIndex:a,childVisibleIndex:l,localVisibleIndex:d}=ii(e.snapshot.nodes,s,n),u=s.childIds[a];if(u==null)throw Error(`Visible index ${String(n)} is out of range`);return Tf(e,u,d,r+l,i+1,a,s.childIds.length,o)}function Tf(e,t,n,r,i,o,s,a){if(!R(D(e,t))){if(n===0)return{ancestors:a,cursor:{headNodeId:t,terminalNodeId:t,visibleDepth:i},index:r,posInSet:o,setSize:s};throw Error(`Visible index ${String(n)} is out of range for file`)}let l=Nl(e,t,i);if(n===0)return{ancestors:a,cursor:l,index:r,posInSet:o,setSize:s};let d=D(e,l.terminalNodeId);if(!R(d)||!_e(e,l.terminalNodeId,d))throw Error(`Visible index ${String(n)} is out of range for collapsed directory`);return _l(e,l.terminalNodeId,n-1,r+1,l.visibleDepth,[...a,{cursor:l,index:r,posInSet:o,setSize:s}])}function El(e,t){let n=Ee(e);if(t<0||t>=n)return null;let r=_l(e,e.snapshot.rootId,t,0,-1,[]),i=r.ancestors.map((s)=>te(e,s.cursor.terminalNodeId)),o=null;return{ancestorPaths:i,get ancestorRows(){if(o!=null)return o;let s=[],a=[];for(let l of r.ancestors){let d=Ef(e,l,n,[...a]);s.push(d),a.push(d.row.path)}return o=s,o},index:r.index,posInSet:r.posInSet,row:gr(e,r.cursor),setSize:r.setSize,subtreeEndIndex:xl(e,r.cursor,r.index,n)}}function Tl(e,t,n){let r=e.instrumentation,i=Ee(e);if(i<=0||n<t)return[];let o=Math.max(0,Math.min(t,i-1)),s=Math.max(o,Math.min(n,i-1));if(r==null){if(o===0)return Df(e,s+1);let f=[],c=Sl(e,o);for(let m=o;m<=s&&c!=null;m++){let p=gr(e,c);f.push(p),c=Cl(e,c)}return f}let a=[],l=0,d=0,u=E(r,"store.getVisibleSlice.selectFirstRow",()=>Sl(e,o));for(let f=o;f<=s&&u!=null;f++){let c=E(r,"store.getVisibleSlice.materializeRow",()=>gr(e,u));if(a.push(c),c.isFlattened)l++,d+=c.flattenedSegments?.length??0;u=E(r,"store.getVisibleSlice.advanceCursor",()=>Cl(e,u))}return _n(r,"workload.visibleRowsRead",a.length),_n(r,"workload.flattenedRowsRead",l),_n(r,"workload.flattenedSegmentsRead",d),a}function Ro(e,t=Ee(e)){let n=e.instrumentation;if(n==null)return kl(e,t);return E(n,"store.getVisibleTreeProjection",()=>kl(e,t))}function Pl(e){return Rf(Ro(e))}function Rl(e,t){let n=Be(e,t);if(n==null||n===e.snapshot.rootId)return null;if(R(D(e,n))&&kt(e,n)!==n)return null;let r=0,i=n,{nodes:o,rootId:s}=e.snapshot;while(i!==s){let a=D(e,i).parentId,l=ie(e,a),d=Cn(l).get(i);if(d==null)throw Error(`Child ${String(i)} was not found in its parent index`);if(r+=fa(o,l,d),a!==s){let u=D(e,a),f=Ct(e,a);if(!_e(e,a,u)&&f!==i)return null;if(kt(e,a)===a)r+=1}i=a}return r}function Dl(e,t){let n=Be(e,t);if(n==null)throw Error(`Path does not exist: "${t}"`);let r=D(e,n);if(!R(r))throw Error(`Path is not a directory: "${t}"`);if(_e(e,n,r))return null;return Vt(e,n,!0,r),zt(e,n),Qa({affectedAncestorIds:Ye(e,n),affectedNodeIds:[n],path:t,projectionChanged:!0})}function Ml(e,t){let n=Be(e,t);if(n==null)throw Error(`Path does not exist: "${t}"`);let r=D(e,n);if(!R(r))throw Error(`Path is not a directory: "${t}"`);if(!_e(e,n,r))return null;return Vt(e,n,!1,r),zt(e,n),Za({affectedAncestorIds:Ye(e,n),affectedNodeIds:[n],path:t,projectionChanged:!0})}function Sl(e,t){if(t<0||t>=Ee(e))return null;return Al(e,e.snapshot.rootId,t,-1)}function Al(e,t,n,r){let i=ie(e,t),o=e.instrumentation,{childIndex:s,localVisibleIndex:a}=o==null?ii(e.snapshot.nodes,i,n):E(o,"store.getVisibleSlice.selectChildIndex",()=>ii(e.snapshot.nodes,i,n)),l=i.childIds[s];if(l!=null)return Po(e,l,a,r+1);throw Error(`Visible index ${String(n)} is out of range`)}function Po(e,t,n,r){if(!R(D(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=Nl(e,t,r);if(n===0)return i;let o=D(e,i.terminalNodeId);if(!R(o)||!_e(e,i.terminalNodeId,o))throw Error(`Visible index ${String(n)} is out of range for collapsed directory`);return Al(e,i.terminalNodeId,n-1,i.visibleDepth)}function Nl(e,t,n){if(!R(D(e,t)))return{headNodeId:t,terminalNodeId:t,visibleDepth:n};if(e.instrumentation==null)return{headNodeId:t,terminalNodeId:kt(e,t),visibleDepth:n};return{headNodeId:t,terminalNodeId:E(e.instrumentation,"store.getVisibleSlice.flatten.resolveTerminalDirectory",()=>kt(e,t)),visibleDepth:n}}function Pf(e,t){let n=D(e,t);if(!R(n))return!0;let r=n.parentId;if(r===e.snapshot.rootId)return!0;return Ct(e,r)!==t}function Cl(e,t){let n=D(e,t.terminalNodeId);if(R(n)){let o=ie(e,t.terminalNodeId);if(_e(e,t.terminalNodeId,n)&&o.childIds.length>0){let s=o.childIds[0];return s==null?null:Po(e,s,0,t.visibleDepth+1)}}let{terminalNodeId:r,visibleDepth:i}=t;while(!0){let o=D(e,r);if(r===e.snapshot.rootId)return null;let s=o.parentId,a=ie(e,s),l=Cn(a).get(r)??-1;if(l<0)throw Error(`Child ${String(r)} was not found in its parent index`);let d=a.childIds[l+1]??null;if(d!=null)return Po(e,d,0,i);if(Pf(e,r))i--;r=s}}function Rf(e){let t=e.paths.length,n=Array(t);for(let r=0;r<t;r+=1){let i=e.getParentIndex(r);n[r]={index:r,parentPath:i>=0?e.paths[i]??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 kl(e,t){let n=Array(t),r=new Int32Array(t),i=new Int32Array(t),o=new Int32Array(t),s=new Int32Array(xf);s.fill(-1);let a=0,{nodes:l,directories:d,segmentTable:u}=e.snapshot,f=[[d.get(e.snapshot.rootId),0,-1,""]],c=e.snapshot.options.flattenEmptyDirectories,m=e.pathCacheByNodeId,p=e.pathCacheVersion,g=u.valueById;while(f.length>0&&a<t){let S=f[f.length-1],k=S[0];if(S[1]>=k.childIds.length){f.pop();continue}let T=S[1],O=k.childIds[S[1]++],pe=l[O],Z=S[2]+1,me=S[3];s=_f(s,Z);let J,U=O;if(!R(pe)){let ae=m.get(O);J=ae!=null&&ae.version===p?ae.path:`${me}${g[pe.nameId]}`}else U=c?kt(e,O):O,J=U===O?`${me}${g[pe.nameId]}/`:te(e,U);r[a]=s[Z],n[a]=J,i[a]=T,o[a]=k.childIds.length,s[Z+1]=a,a+=1;let B=l[U];if(B!=null&&R(B)&&_e(e,U,B))f.push([d.get(U),0,Z,J])}if(a<t)n.length=a;let v=r.subarray(0,a),I=i.subarray(0,a),C=o.subarray(0,a),y=null;return{getParentIndex(S){return S<0||S>=a?-1:v[S]??-1},paths:n,posInSetByIndex:I,setSizeByIndex:C,get visibleIndexByPath(){if(y==null){y=new Map;for(let S=0;S<a;S+=1)y.set(n[S]??"",S)}return y}}}function Df(e,t){let n=Array(t),r=0,{nodes:i,directories:o,segmentTable:s}=e.snapshot,a=[[o.get(e.snapshot.rootId),0,-1]],l=s.valueById,d=e.snapshot.options.flattenEmptyDirectories,u=e.pathCacheByNodeId,f=e.pathCacheVersion;while(a.length>0&&r<t){let c=a[a.length-1],m=c[0];if(c[1]>=m.childIds.length){a.pop();continue}let p=m.childIds[c[1]++],g=i[p],v=c[2]+1;if(!R(g)){let S=u.get(p);n[r++]={depth:v,flattenedSegments:void 0,hasChildren:!1,id:p,isExpanded:!1,isFlattened:!1,isLoading:!1,kind:"file",loadState:void 0,name:l[g.nameId],path:S!=null&&S.version===f?S.path:te(e,p)};continue}let I=d?kt(e,p):p,C={headNodeId:p,terminalNodeId:I,visibleDepth:v};n[r++]=gr(e,C);let y=i[I];if(y!=null&&R(y)&&_e(e,I,y))a.push([o.get(I),0,v])}if(r<t)n.length=r;return n}function gr(e,t){let n=D(e,t.terminalNodeId),r=R(n)?Mf(e,t):null,i=te(e,t.terminalNodeId),o=Ge(e.snapshot.segmentTable,n.nameId),s=R(n)&&ie(e,t.terminalNodeId).childIds.length>0,a=t.headNodeId!==t.terminalNodeId,l=e.instrumentation,d=a?l==null?En(e,t.headNodeId).map((u)=>{let f=D(e,u);return{isTerminal:u===t.terminalNodeId,name:Ge(e.snapshot.segmentTable,f.nameId),nodeId:u,path:te(e,u)}}):E(l,"store.getVisibleSlice.flatten.collectSegments",()=>En(e,t.headNodeId).map((u)=>{let f=D(e,u);return{isTerminal:u===t.terminalNodeId,name:Ge(e.snapshot.segmentTable,f.nameId),nodeId:u,path:te(e,u)}})):void 0;return{depth:t.visibleDepth,flattenedSegments:d,hasChildren:s,id:t.terminalNodeId,isExpanded:R(n)&&_e(e,t.terminalNodeId,n),isFlattened:a,isLoading:r==="loading",kind:R(n)?"directory":"file",loadState:r==null||r==="loaded"?void 0:r,name:o,path:i}}function Mf(e,t){if(t.headNodeId===t.terminalNodeId)return Ot(e,t.terminalNodeId);let n=En(e,t.headNodeId),r=!1,i=!1;for(let o of n){let s=Ot(e,o);if(s==="loading")return"loading";if(s==="error"){i=!0;continue}if(s==="unloaded")r=!0}if(i)return"error";if(r)return"unloaded";return"loaded"}var Ll=8;function Fl(e){let{nodes:t,directories:n,rootId:r,options:i}=e,o=t.length,s=new Int32Array(o),a=new Int32Array(o),l=new Int32Array(o),d=new Int32Array(o),u=new Int32Array(o),f=new Int32Array(o),c=new Int32Array(o);for(let v=0;v<o;v+=1){let I=t[v];if(I==null)continue;s[v]=I.parentId,a[v]=I.nameId,l[v]=I.depthAndFlags,d[v]=I.subtreeNodeCount,u[v]=I.visibleSubtreeCount}let m=0;for(let v of n.values())m+=v.childIds.length;let p=new Int32Array(m),g=0;for(let[v,I]of n){let C=I.childIds;f[v]=g,c[v]=C.length;for(let y=0;y<C.length;y+=1)p[g]=C[y],g+=1}return{nodeCount:o,rootId:r,flattenEmptyDirectories:i.flattenEmptyDirectories===!0,parentId:s,nameId:a,depthAndFlags:l,subtreeNodeCount:d,visibleSubtreeCount:u,childStart:f,childCount:c,childIdsFlat:p}}function Bl(e){let{nodeCount:t,rootId:n,flattenEmptyDirectories:r,depthAndFlags:i,subtreeNodeCount:o,visibleSubtreeCount:s,childStart:a,childCount:l,childIdsFlat:d}=e;for(let p=t-1;p>=1;p-=1){if((i[p]&Ll)===0)continue;let g=a[p],v=l[p],I=0,C=0;for(let S=0;S<v;S+=1){let k=d[g+S];I+=o[k],C+=s[k]}o[p]=1+I;let y;if(r&&v===1)y=(i[d[g]]&Ll)!==0?C:1+C;else y=1+C;s[p]=y}let u=a[n],f=l[n],c=0,m=0;for(let p=0;p<f;p+=1){let g=d[u+p];c+=o[g],m+=s[g]}o[n]=1+c,s[n]=m}function Af(e){let{directories:t,nodes:n,options:r,rootId:i,presortedDirectoryNodeIds:o}=e.snapshot,s=r.flattenEmptyDirectories===!0,a=(m)=>{let p=n[m];if(p==null||!R(p))return;let g=t.get(m);if(g==null)throw Error(`Unknown directory child index for node ${String(m)}`);let v=g.childIds,I=v.length,C=0,y=0;for(let k=0;k<I;k++){let T=v[k];if(T==null)continue;let O=n[T];C+=O.subtreeNodeCount,y+=O.visibleSubtreeCount}if(g.totalChildSubtreeNodeCount=C,g.totalChildVisibleSubtreeCount=y,I>=128)Ht(n,g);p.subtreeNodeCount=1+C;let S;if(s&&I===1){let k=n[v[0]];S=k!=null&&R(k)?y:1+y}else S=1+y;p.visibleSubtreeCount=S};if(o!=null)for(let m=o.length-1;m>=0;m--)a(o[m]);else for(let m=n.length-1;m>=1;m--)a(m);let l=n[i],d=t.get(i);if(l==null||d==null)return;let u=d.childIds,f=0,c=0;for(let m=0;m<u.length;m++){let p=u[m];if(p==null)continue;let g=n[p];f+=g.subtreeNodeCount,c+=g.visibleSubtreeCount}d.totalChildSubtreeNodeCount=f,d.totalChildVisibleSubtreeCount=c,Ht(n,d),l.subtreeNodeCount=1+f,l.visibleSubtreeCount=c}function Nf(e){let{directories:t,nodes:n,rootId:r}=e.snapshot,i=Fl(e.snapshot);Bl(i);let{subtreeNodeCount:o,visibleSubtreeCount:s}=i;for(let a=0;a<n.length;a+=1){let l=n[a];if(l==null)continue;l.subtreeNodeCount=o[a],l.visibleSubtreeCount=s[a]}for(let[a,l]of t){let d=l.childIds,u=d.length,f=0,c=0;for(let m=0;m<u;m++){let p=d[m];if(p==null)continue;let g=n[p];f+=g.subtreeNodeCount,c+=g.visibleSubtreeCount}if(l.totalChildSubtreeNodeCount=f,l.totalChildVisibleSubtreeCount=c,a===r||u>=128)Ht(n,l)}}function Lf(e){return e.initialExpansion==="open"&&(e.initialExpandedPaths==null||e.initialExpandedPaths.length===0)}var vr=class e{#e;constructor(t={}){let n=hr(t),r=E(n,"store.builder.create",()=>new ci(t));if(t.preparedInput!=null){let a=Da(t.preparedInput);if(a!=null)r.appendPresortedPaths(a,Ma(t.preparedInput));else r.appendPreparedPaths(Ra(t.preparedInput),!1)}else{let a=t.paths??[];if(t.presorted===!0)r.appendPaths(a);else r.appendPreparedPaths(E(n,"store.preparePathEntries",()=>li(a,t)))}let i=E(n,"store.builder.finish",()=>r.finish({skipSubtreeCountPass:!0})),o=E(n,"store.state.detectAllDirectoriesExpanded",()=>(t.initialExpansion??"closed")==="closed"&&r.didMatchAllInitialExpandedPaths());if(this.#e=E(n,"store.state.create",()=>Aa(i,o?"open":t.initialExpansion??"closed",n)),o)this.#e.collapseNewDirectoriesByDefault=!0;let s=o?this.#e.snapshot.directories.size-1:E(n,"store.state.initializeExpandedPaths",()=>this.initializeExpandedPaths(t.initialExpandedPaths));if(o||Lf(t)||(t.initialExpansion??"closed")==="closed"&&s===this.#e.snapshot.directories.size-1||(t.initialExpandedPaths?.length??0)>0&&E(n,"store.state.checkAllDirectoriesExpanded",()=>this.hasAllDirectoriesExpanded()))if(t.useSoaCountSweep===!0)E(n,"store.state.initializeOpenVisibleCountsViaSoa",()=>Nf(this.#e));else E(n,"store.state.initializeOpenVisibleCounts",()=>Af(this.#e));else E(n,"store.state.recomputeCounts",()=>mr(this.#e,this.#e.snapshot.rootId))}static preparePaths(t,n={}){return Ea(t,n)}static prepareInput(t,n={}){return Ta(t,n)}static preparePresortedInput(t){return Pa(t)}list(t){return E(this.#e.instrumentation,"store.list",()=>ui(this.#e,t))}add(t){E(this.#e.instrumentation,"store.add",()=>{let n=Ee(this.#e);Ze(this.#e,Fe(this.#e,n,Co(this.#e,t)))})}remove(t,n={}){E(this.#e.instrumentation,"store.remove",()=>{let r=Ee(this.#e);Ze(this.#e,Fe(this.#e,r,ko(this.#e,t,n)))})}move(t,n,r={}){E(this.#e.instrumentation,"store.move",()=>{let i=Ee(this.#e),o=xo(this.#e,t,n,r);if(o!=null)Ze(this.#e,Fe(this.#e,i,o))})}batch(t){ol(this.#e,()=>{if(typeof t==="function"){t(this);return}for(let n of t)switch(n.type){case"add":this.add(n.path);break;case"remove":this.remove(n.path,{recursive:n.recursive});break;case"move":this.move(n.from,n.to,{collision:n.collision});break}})}getVisibleCount(){return E(this.#e.instrumentation,"store.getVisibleCount",()=>Ee(this.#e))}getVisibleSlice(t,n){return E(this.#e.instrumentation,"store.getVisibleSlice",()=>Tl(this.#e,t,n))}getVisibleRowContext(t){return E(this.#e.instrumentation,"store.getVisibleRowContext",()=>El(this.#e,t))}getVisibleTreeProjection(){return Pl(this.#e)}getVisibleTreeProjectionData(t){return Ro(this.#e,t)}getVisibleIndex(t){return E(this.#e.instrumentation,"store.getVisibleIndex",()=>Rl(this.#e,t))}getPathInfo(t){return E(this.#e.instrumentation,"store.getPathInfo",()=>{let n=Be(this.#e,t);if(n==null)return null;let r=D(this.#e,n);return{depth:ze(r),kind:R(r)?"directory":"file",path:te(this.#e,n)}})}isExpanded(t){return E(this.#e.instrumentation,"store.isExpanded",()=>{let n=this.requireDirectoryNodeId(t),r=D(this.#e,n);return _e(this.#e,n,r)})}expand(t){E(this.#e.instrumentation,"store.expand",()=>{let n=Ee(this.#e),r=Dl(this.#e,t);if(r!=null)Ze(this.#e,Fe(this.#e,n,r))})}collapse(t){E(this.#e.instrumentation,"store.collapse",()=>{let n=Ee(this.#e),r=Ml(this.#e,t);if(r!=null)Ze(this.#e,Fe(this.#e,n,r))})}on(t,n){return Ua(this.#e,t,n)}getDirectoryLoadState(t){let n=this.requireDirectoryNodeId(t);return Ot(this.#e,n)}markDirectoryUnloaded(t){E(this.#e.instrumentation,"store.markDirectoryUnloaded",()=>{let n=this.requireDirectoryNodeId(t);if(ie(this.#e,n).childIds.length>0)throw Error(`Cannot mark a directory with known children as unloaded: "${t}"`);let r=Ee(this.#e);Ha(this.#e,n),Ze(this.#e,Fe(this.#e,r,Ja({affectedAncestorIds:Ye(this.#e,n),affectedNodeIds:[n],path:t,projectionChanged:this.isDirectoryProjectionVisible(n)})))})}beginChildLoad(t){return E(this.#e.instrumentation,"store.beginChildLoad",()=>{let n=this.requireDirectoryNodeId(t),r=Ee(this.#e),i=Ba(this.#e,n);return Ze(this.#e,Fe(this.#e,r,el({affectedAncestorIds:Ye(this.#e,n),affectedNodeIds:[n],attemptId:i.attemptId,path:t,projectionChanged:this.isDirectoryProjectionVisible(n),reused:i.reused}))),i})}applyChildPatch(t,n){return E(this.#e.instrumentation,"store.applyChildPatch",()=>{let r=this.resolveActiveDirectoryNodeId(t.nodeId);if(r==null||Ot(this.#e,r)!=="loading"||!Oa(this.#e,r,t.attemptId))return!1;let i=te(this.#e,r);this.validateChildPatch(i,n);let o=Ee(this.#e),s=[];for(let l of n.operations){Ff(i,l);let d=Ee(this.#e);switch(l.type){case"add":s.push(Fe(this.#e,d,Co(this.#e,l.path)));break;case"remove":s.push(Fe(this.#e,d,ko(this.#e,l.path,{recursive:l.recursive})));break;case"move":{let u=xo(this.#e,l.from,l.to,{collision:l.collision});if(u!=null)s.push(Fe(this.#e,d,u));break}}}let a=s.some((l)=>l.projectionChanged)||this.isDirectoryProjectionVisible(r);return Ze(this.#e,Fe(this.#e,o,tl({affectedAncestorIds:Ye(this.#e,r),affectedNodeIds:[r],attemptId:t.attemptId,childEvents:s,path:te(this.#e,r),projectionChanged:a}))),!0})}completeChildLoad(t){return E(this.#e.instrumentation,"store.completeChildLoad",()=>{let n=this.resolveActiveDirectoryNodeId(t.nodeId);if(n==null)return!1;let r=Ee(this.#e),i=Va(this.#e,n,t.attemptId);return Ze(this.#e,Fe(this.#e,r,nl({affectedAncestorIds:Ye(this.#e,n),affectedNodeIds:[n],attemptId:t.attemptId,path:te(this.#e,n),projectionChanged:this.isDirectoryProjectionVisible(n),stale:!i}))),i})}failChildLoad(t,n){return E(this.#e.instrumentation,"store.failChildLoad",()=>{let r=this.resolveActiveDirectoryNodeId(t.nodeId);if(r==null)return!1;let i=Ee(this.#e),o=qa(this.#e,r,t.attemptId,n);return Ze(this.#e,Fe(this.#e,i,rl({affectedAncestorIds:Ye(this.#e,r),affectedNodeIds:[r],attemptId:t.attemptId,errorMessage:n,path:te(this.#e,r),projectionChanged:this.isDirectoryProjectionVisible(r),stale:!o}))),o})}cleanup(t={}){return E(this.#e.instrumentation,"store.cleanup",()=>{if(this.#e.transactionStack.length>0)throw Error("Cleanup cannot run during an open batch or transaction.");if(wl(this.#e))throw Error("Cleanup cannot run while directory loads are active.");let n=Ee(this.#e),r=Il(this.#e,t.mode??"stable");return Ze(this.#e,Fe(this.#e,n,il({...r,affectedAncestorIds:[],affectedNodeIds:[],projectionChanged:r.idsPreserved===!1}))),r})}getNodeCount(){return this.#e.activeNodeCount}initializeExpandedPaths(t){if(t==null||t.length===0)return 0;let n=0,r=[],i=[],o=0,s=null,a=this.#e.snapshot.segmentTable,l=a.valueById,d=this.#e.snapshot.nodes,u=new Map;for(let f of t){if(s!=null&&f<s)s=null,o=0,r.length=0,i.length=0;let c=f.length>0&&f.charCodeAt(f.length-1)===47?f.length-1:f.length;if(c===0){s=f,o=c,r.length=0,i.length=0;continue}let m=0,p=0;if(s!=null){let y=Math.min(c,o),S=!0;for(let k=0;k<y;k+=1){let T=f.charCodeAt(k);if(T!==s.charCodeAt(k)){S=!1;break}if(T===47)m+=1,p=k+1}if(S){if(y===o&&c>y&&f.charCodeAt(y)===47)m+=1,p=y+1;else if(y===c&&o>y&&s.charCodeAt(y)===47)m+=1,p=c+1}m=Math.min(m,i.length)}let g=m===0?this.#e.snapshot.rootId:i[m-1]??this.#e.snapshot.rootId,v=m,I=!0,C=p;while(C<=c){let y=f.indexOf("/",C),S=y===-1||y>c?c:y,k=f.slice(C,S),T=ie(this.#e,g).childIds,O=v===m?r[v]??0:0,pe=O,Z,me=u.get(k)??an(k);u.set(k,me);let J=(U,B)=>{for(pe=U;pe<B;pe+=1){let ae=T[pe],Ce=d[ae],z=l[Ce.nameId];if(z===k)return Z=ae,!0;let le=fr(pr(a,Ce.nameId),me);if(le>0||le===0&&z>k)return!1}return!1};if(!J(O,T.length)&&O>0)J(0,O);if(Z===void 0){I=!1;break}if(!R(D(this.#e,Z))){I=!1;break}if(r[v]=pe,i[v]=Z,g=Z,v+=1,S===c)break;C=S+1}if(s=f,o=c,r.length=v,i.length=v,!I){s=null,o=0,r.length=0,i.length=0;continue}for(let y=m;y<v;y+=1){let S=i[y];if(S==null)continue;let k=D(this.#e,S);if(_e(this.#e,S,k))continue;Vt(this.#e,S,!0,k),n+=1}}return n}hasAllDirectoriesExpanded(){for(let t of this.#e.snapshot.directories.keys()){if(t===this.#e.snapshot.rootId)continue;let n=D(this.#e,t);if(!_e(this.#e,t,n))return!1}return!0}requireDirectoryNodeId(t){let n=Be(this.#e,t);if(n==null)throw Error(`Path does not exist: "${t}"`);if(!R(D(this.#e,n)))throw Error(`Path is not a directory: "${t}"`);return n}resolveActiveDirectoryNodeId(t){try{if(!R(D(this.#e,t)))throw Error(`Node is not a directory: ${String(t)}`);return t}catch{return null}}isDirectoryProjectionVisible(t){let n=t;while(n!==this.#e.snapshot.rootId){let r=D(this.#e,n).parentId;if(r!==this.#e.snapshot.rootId){let i=D(this.#e,r),o=Ct(this.#e,r);if(!_e(this.#e,r,i)&&o!==n)return!1}n=r}return!0}validateChildPatch(t,n){new e({paths:this.list(t),presorted:!0,sort:this.#e.snapshot.options.sort}).batch(n.operations)}};function Ff(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 Bf=[`<symbol id="file-tree-builtin-bash" viewBox="0 0 16 16">
|
|
2
2
|
<path fill="currentColor" d="M8 1C2.24 1 1 2.24 1 8s1.24 7 7 7 7-1.24 7-7-1.24-7-7-7" class="bg" opacity=".2"/>
|
|
3
3
|
<path fill="currentColor" d="M11.5 11a.5.5 0 0 1 0 1h-3a.5.5 0 0 1 0-1zM7 6.75C7 6.42 6.64 6 6 6s-1 .42-1 .75q-.01.25.22.41.26.21.89.35.74.14 1.28.53c.37.29.61.7.61 1.21 0 .87-.68 1.5-1.5 1.7v.55a.5.5 0 0 1-1 0v-.56c-.82-.18-1.5-.82-1.5-1.69a.5.5 0 0 1 1 0c0 .33.36.75 1 .75s1-.42 1-.75q.01-.25-.22-.41a2 2 0 0 0-.89-.35q-.74-.14-1.28-.53A1.5 1.5 0 0 1 4 6.75c0-.87.68-1.5 1.5-1.7V4.5a.5.5 0 0 1 1 0v.56c.82.18 1.5.82 1.5 1.69a.5.5 0 0 1-1 0" class="fg-stroke"/>
|
|
4
4
|
</symbol>`,`<symbol id="file-tree-builtin-c" viewBox="0 0 16 16">
|
|
@@ -58,7 +58,7 @@ import{A,B as Bu,C as Pi,D as yd,F as Er,G as _s,a as Ur,b as ta,c as na,e as Kr
|
|
|
58
58
|
</symbol>`,`<symbol id="file-tree-builtin-zip" viewBox="0 0 16 16">
|
|
59
59
|
<path fill="currentColor" d="M4.585 2a2 2 0 0 1 1.028.285l1.788 1.072a1 1 0 0 0 .514.143H12A2 2 0 0 1 13.935 5H0V4a2 2 0 0 1 2-2z" class="bg" opacity=".5"/>
|
|
60
60
|
<path fill="currentColor" fill-rule="evenodd" d="M14 12a2 2 0 0 1-2 2H2a2 2 0 0 1-2-2v-1.25h1v-1H0V6h14zM9.9 8.25c-.883 0-1.9.5-1.9.5H7v1h1v1s1.017.5 1.9.5c.884 0 1.6-.672 1.6-1.5s-.716-1.5-1.6-1.5M2 9.75v1h1v-1zm2 0v1h1v-1zm2 0v1h1v-1zm-5-1v1h1v-1zm2 0v1h1v-1zm2 0v1h1v-1z" class="fg" clip-rule="evenodd"/>
|
|
61
|
-
</symbol>`],
|
|
61
|
+
</symbol>`],Hf=[`<symbol id="file-tree-builtin-astro" viewBox="0 0 16 16">
|
|
62
62
|
<path fill="currentColor" d="M6.08 13.92c-.63-.57-.81-1.79-.55-2.67.45.56 1.08.73 1.73.83 1 .15 1.99.1 2.92-.37l.32-.19q.13.38.08.78a2.1 2.1 0 0 1-.9 1.5q-.3.24-.61.43c-.64.44-.81.95-.57 1.69l.02.08a1.7 1.7 0 0 1-.74-.64 2 2 0 0 1-.3-.98q0-.27-.02-.52-.07-.61-.61-.62a.7.7 0 0 0-.75.6z" class="bg" opacity=".6"/>
|
|
63
63
|
<path fill="currentColor" d="M2.5 11.1s1.86-.9 3.72-.9l1.4-4.39c.05-.21.2-.36.38-.36s.33.15.38.36l1.4 4.38c2.2 0 3.72.92 3.72.92l-3.16-8.69q-.13-.4-.45-.42H6.11q-.3.02-.45.42z" class="fg"/>
|
|
64
64
|
</symbol>`,`<symbol id="file-tree-builtin-babel" viewBox="0 0 16 16">
|
|
@@ -147,10 +147,10 @@ import{A,B as Bu,C as Pi,D as yd,F as Er,G as _s,a as Ur,b as ta,c as na,e as Kr
|
|
|
147
147
|
</symbol>`,`<symbol id="file-tree-builtin-zig" viewBox="0 0 16 16">
|
|
148
148
|
<path fill="currentColor" d="m14.73 1.5-7.29 8.82h4.17l-1.73 2.04H5.76L1.27 14.5l7.3-8.91H4.39l1.73-2.05h4.12z"/>
|
|
149
149
|
<path fill="currentColor" d="M5.21 3.54 3.56 5.6h-.55v4.73h.83L2.1 12.36H1V3.54zm9.79 0v8.82h-4.3l1.74-2.04h.55V5.68h-.83l1.74-2.14z"/>
|
|
150
|
-
</symbol>`];function
|
|
150
|
+
</symbol>`];function Ol(e,t){if(t.length===0)return e;return e.replace("</svg>",`
|
|
151
151
|
${t.join(`
|
|
152
152
|
`)}
|
|
153
|
-
</svg>`)}var
|
|
153
|
+
</svg>`)}var Hl=Ol(`<svg data-icon-sprite aria-hidden="true" width="0" height="0">
|
|
154
154
|
<symbol id="file-tree-icon-chevron" viewBox="0 0 16 16">
|
|
155
155
|
<path d="M12.4697 5.46973C12.7626 5.17684 13.2374 5.17684 13.5303 5.46973C13.8232 5.76262 13.8232 6.23738 13.5303 6.53028L8.53028 11.5303C8.23738 11.8232 7.76262 11.8232 7.46973 11.5303L2.46973 6.53028C2.17684 6.23738 2.17684 5.76262 2.46973 5.46973C2.76262 5.17684 3.23738 5.17684 3.53028 5.46973L8 9.93946L12.4697 5.46973Z" fill="currentcolor"/>
|
|
156
156
|
</symbol>
|
|
@@ -167,7 +167,7 @@ import{A,B as Bu,C as Pi,D as yd,F as Er,G as _s,a as Ur,b as ta,c as na,e as Kr
|
|
|
167
167
|
<symbol id="file-tree-icon-ellipsis" viewBox="0 0 16 16">
|
|
168
168
|
<path d="M5 8.5a1.5 1.5 0 1 1-3 0 1.5 1.5 0 0 1 3 0M9.5 8.5a1.5 1.5 0 1 1-3 0 1.5 1.5 0 0 1 3 0M14 8.5a1.5 1.5 0 1 1-3 0 1.5 1.5 0 0 1 3 0" />
|
|
169
169
|
</symbol>
|
|
170
|
-
</svg>`,
|
|
170
|
+
</svg>`,Bf),Vf={minimal:`<svg data-icon-sprite aria-hidden="true" width="0" height="0">
|
|
171
171
|
<symbol id="file-tree-icon-chevron" viewBox="0 0 16 16">
|
|
172
172
|
<path d="M12.4697 5.46973C12.7626 5.17684 13.2374 5.17684 13.5303 5.46973C13.8232 5.76262 13.8232 6.23738 13.5303 6.53028L8.53028 11.5303C8.23738 11.8232 7.76262 11.8232 7.46973 11.5303L2.46973 6.53028C2.17684 6.23738 2.17684 5.76262 2.46973 5.46973C2.76262 5.17684 3.23738 5.17684 3.53028 5.46973L8 9.93946L12.4697 5.46973Z" fill="currentcolor"/>
|
|
173
173
|
</symbol>
|
|
@@ -184,7 +184,7 @@ import{A,B as Bu,C as Pi,D as yd,F as Er,G as _s,a as Ur,b as ta,c as na,e as Kr
|
|
|
184
184
|
<symbol id="file-tree-icon-ellipsis" viewBox="0 0 16 16">
|
|
185
185
|
<path d="M5 8.5a1.5 1.5 0 1 1-3 0 1.5 1.5 0 0 1 3 0M9.5 8.5a1.5 1.5 0 1 1-3 0 1.5 1.5 0 0 1 3 0M14 8.5a1.5 1.5 0 1 1-3 0 1.5 1.5 0 0 1 3 0" />
|
|
186
186
|
</symbol>
|
|
187
|
-
</svg>`,standard:
|
|
187
|
+
</svg>`,standard:Hl,complete:Ol(Hl,Hf)},Of={".babelrc":"babel",".babelrc.json":"babel",".bash_profile":"bash",".bashrc":"bash",".browserslistrc":"browserslist",".dockerignore":"docker",".eslintignore":"eslint",".eslintrc":"eslint",".eslintrc.cjs":"eslint",".eslintrc.js":"eslint",".eslintrc.json":"eslint",".eslintrc.yaml":"eslint",".eslintrc.yml":"eslint",".gitattributes":"git",".gitignore":"git",".gitkeep":"git",".gitmodules":"git",".oxlintrc.json":"oxc",".postcssrc":"postcss",".postcssrc.json":"postcss",".postcssrc.yaml":"postcss",".postcssrc.yml":"postcss",".prettierignore":"prettier",".prettierrc":"prettier",".prettierrc.cjs":"prettier",".prettierrc.js":"prettier",".prettierrc.json":"prettier",".prettierrc.mjs":"prettier",".prettierrc.toml":"prettier",".prettierrc.yaml":"prettier",".prettierrc.yml":"prettier",".stylelintignore":"stylelint",".stylelintrc":"stylelint",".stylelintrc.cjs":"stylelint",".stylelintrc.js":"stylelint",".stylelintrc.json":"stylelint",".stylelintrc.mjs":"stylelint",".stylelintrc.yaml":"stylelint",".stylelintrc.yml":"stylelint",".terraform.lock.hcl":"terraform",".zprofile":"bash",".zshenv":"bash",".zshrc":"bash","babel.config.cjs":"babel","babel.config.js":"babel","babel.config.json":"babel","babel.config.mjs":"babel","biome.json":"biome","biome.jsonc":"biome","bootstrap.bundle.js":"bootstrap","bootstrap.bundle.min.js":"bootstrap","bootstrap.css":"bootstrap","bootstrap.js":"bootstrap","bootstrap.min.css":"bootstrap","bootstrap.min.js":"bootstrap","bun.lock":"bun","bun.lockb":"bun","bunfig.toml":"bun","claude.md":"claude","compose.yaml":"docker","compose.yml":"docker","docker-compose.override.yml":"docker","docker-compose.yaml":"docker","docker-compose.yml":"docker",dockerfile:"docker","eslint.config.cjs":"eslint","eslint.config.js":"eslint","eslint.config.mjs":"eslint","eslint.config.mts":"eslint","eslint.config.ts":"eslint",gemfile:"ruby","next.config.js":"nextjs","next.config.mjs":"nextjs","next.config.mts":"nextjs","next.config.ts":"nextjs","postcss.config.cjs":"postcss","postcss.config.js":"postcss","postcss.config.mjs":"postcss","postcss.config.ts":"postcss","prettier.config.cjs":"prettier","prettier.config.js":"prettier","prettier.config.mjs":"prettier",rakefile:"ruby","readme.md":"markdown","stylelint.config.cjs":"stylelint","stylelint.config.js":"stylelint","stylelint.config.mjs":"stylelint","svgo.config.cjs":"svgo","svgo.config.js":"svgo","svgo.config.mjs":"svgo","svgo.config.ts":"svgo","tailwind.config.cjs":"tailwind","tailwind.config.js":"tailwind","tailwind.config.mjs":"tailwind","tailwind.config.ts":"tailwind","vite.config.js":"vite","vite.config.mjs":"vite","vite.config.mts":"vite","vite.config.ts":"vite","webpack.config.babel.js":"webpack","webpack.config.cjs":"webpack","webpack.config.js":"webpack","webpack.config.mjs":"webpack","webpack.config.ts":"webpack"},qf={"7z":"zip",astro:"astro",AUTHORS:"text",avif:"image",bash:"bash",bmp:"image",bz2:"zip",c:"c",cc:"cpp",cfg:"text",CHANGELOG:"text",cjs:"javascript","code-workspace":"vscode",conf:"text",CONTRIBUTORS:"text",cpp:"cpp",csh:"bash",css:"css",csv:"table",cts:"typescript",cxx:"cpp",db:"database",editorconfig:"text",env:"text","env.development":"text","env.local":"text","env.production":"text",eot:"font",erb:"ruby",fish:"bash",gemspec:"ruby",gif:"image",go:"go",gql:"graphql",graphql:"graphql",gz:"zip",h:"c",hh:"cpp",hpp:"cpp",htm:"html",html:"html",hxx:"cpp",icns:"image",ico:"image",ini:"text",inl:"cpp",jar:"zip",jpeg:"image",jpg:"image",js:"javascript",json:"json",json5:"json",jsonc:"json",jsonl:"json",jsx:"javascript",ksh:"bash",less:"css",LICENSE:"text",log:"text",markdown:"markdown",mcp:"mcp",md:"markdown",mdx:"markdown","mdx.tsx":"markdown",mjs:"javascript",mm:"cpp",mts:"typescript",ods:"table",otf:"font",png:"image",postcss:"css",py:"python",pyi:"python",pyw:"python",pyx:"python",rake:"ruby",rar:"zip",rb:"ruby",rs:"rust",rst:"text",rtf:"text",sass:"css",scss:"css",sh:"bash",sql:"database",sqlite:"database",sqlite3:"database",styl:"css",svelte:"svelte",svg:"svg",swift:"swift",tar:"zip",tf:"terraform",tfstate:"terraform",tfvars:"terraform",tgz:"zip",tif:"image",tiff:"image",ts:"typescript",tsv:"table",tsx:"typescript",ttf:"font",txt:"text",vue:"vue",war:"zip",wasm:"wasm",wast:"wasm",wat:"wasm",webp:"image",woff:"font",woff2:"font",xhtml:"html",xls:"table",xlsx:"table",xz:"zip",yaml:"yml",yml:"yml",zig:"zig",zip:"zip",zsh:"bash"},zf={jsx:"react",sass:"sass",scss:"sass",tsx:"react"},Vl=new Set(["bash","c","cpp","css","database","default","font","git","go","html","image","javascript","json","markdown","mcp","python","ruby","rust","swift","table","text","typescript","zip"]),Wf=new Set(["complete"]);function ql(e){return Vf[e==="none"?"minimal":e]}function zl(e){return`file-tree-builtin-${e}`}function Wl(e){return e!=="none"&&Wf.has(e)}function $l(e,t,n){if(e==="minimal"||e==="none")return;let r=e==="complete",i=Of[t.toLowerCase()];if(i!=null){if(r||Vl.has(i))return i}for(let o of n){if(r){let a=zf[o];if(a!=null)return a}let s=qf[o];if(s!=null){if(r||Vl.has(s))return s}}return"default"}var Do="file-tree-container",hi="data-file-tree-style",Mo="data-file-tree-unsafe-css",jl="data-file-tree-scrollbar-measure",Ao="data-file-tree-scrollbar-gutter-measured",Kl="--trees-scrollbar-gutter-measured";var yr="header",br="context-menu",Ul="context-menu-trigger";function $f(e){return e.spriteSheet!=null||e.remap!=null||e.byFileName!=null||e.byFileExtension!=null||e.byFileNameContains!=null}function Pn(e){if(e==null)return{set:"complete",colored:!0};if(typeof e==="string")return{set:e,colored:!0};return{...e,set:e.set??($f(e)?"none":"complete"),colored:e.colored??!0}}var fi={compact:{itemHeight:24,factor:0.8},default:{itemHeight:30,factor:1},relaxed:{itemHeight:36,factor:1.2}};function Gl(e,t){if(typeof e==="number")return{itemHeight:t??fi.default.itemHeight,factor:e};let n=fi[e??"default"];return{itemHeight:t??n.itemHeight,factor:n.factor}}var pi=fi.default.itemHeight;var mi=`@layer base {
|
|
188
188
|
:host {
|
|
189
189
|
--trees-accent: var(--trees-accent-override, #009fff);
|
|
190
190
|
--trees-fg: var(--trees-fg-override, var(--trees-theme-sidebar-fg, light-dark(#6c6c71, #adadb1)));
|
|
@@ -1276,16 +1276,16 @@ import{A,B as Bu,C as Pi,D as yd,F as Er,G as _s,a as Ur,b as ta,c as na,e as Kr
|
|
|
1276
1276
|
}
|
|
1277
1277
|
|
|
1278
1278
|
@layer theme, unsafe;
|
|
1279
|
-
`;function
|
|
1279
|
+
`;function gi(e){return`@layer base, unsafe;
|
|
1280
1280
|
@layer base {
|
|
1281
1281
|
${e}
|
|
1282
|
-
}`}function
|
|
1282
|
+
}`}function Yl(e){return`@layer base, unsafe;
|
|
1283
1283
|
@layer unsafe {
|
|
1284
1284
|
${e}
|
|
1285
|
-
}`}var Yl=new WeakMap;function $f(e){let t=Yl.get(e);if(t!=null)return t;let n=document.createElement("div");n.setAttribute($l,"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(),Yl.set(e,i),i}function Xl(e,t){if(!e.isConnected)return;let n=$f(t);if(n==null)return;let r=t.querySelector(`style[${Ro}]`),i=r instanceof HTMLStyleElement?r:document.createElement("style");if(!(r instanceof HTMLStyleElement))i.setAttribute(Ro,""),t.appendChild(i);i.textContent=`:host { ${jl}: ${n}px; }`}var mi;function jf(e){if(typeof CSSStyleSheet<"u"&&typeof CSSStyleSheet.prototype.replaceSync==="function"&&"adoptedStyleSheets"in e){if(mi==null)mi=new CSSStyleSheet,mi.replaceSync(pi(Do));let t=!1;try{e.adoptedStyleSheets=[mi],t=!0}catch{}if(t){e.querySelector(`style[${di}]`)?.remove();return}}if(e.querySelector("style[data-file-tree-style]")==null){let t=document.createElement("style");t.setAttribute(di,""),t.textContent=pi(Do),e.prepend(t)}}function gi(e,t){Kf(e,t),jf(t),Xl(e,t)}function Kf(e,t){let n=e.querySelector('template[shadowrootmode="open"], template[data-file-tree-shadowrootmode="open"]');if(!(n instanceof HTMLTemplateElement))return;if(t.childNodes.length>0)return;if(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 t=this.shadowRoot??this.attachShadow({mode:"open"});gi(this,t)}}if(customElements.define(To,e),typeof document<"u")for(let t of Array.from(document.querySelectorAll(To))){if(!(t instanceof HTMLElement))continue;gi(t,t.shadowRoot??t.attachShadow({mode:"open"}))}}var Ql=(e)=>e.startsWith("f::")?e.slice(3):e;function Uf(e){let t=e.lastIndexOf("/");if(t<0)return{parentPath:"",baseName:e};return{parentPath:e.slice(0,t),baseName:e.slice(t+1)}}function Gf(e,t){return e===""?t:`${e}/${t}`}function Zl({files:e,path:t,isFolder:n,nextBasename:r}){let i=Ql(t),o=r.trim();if(o.length===0)return{error:"Name cannot be empty."};if(o.includes("/"))return{error:'Name cannot include "/".'};let{parentPath:s,baseName:a}=Uf(i);if(o===a)return{nextFiles:e,sourcePath:i,destinationPath:i,isFolder:n};let l=Gf(s,o),d=Array(e.length),u=new Set;if(!n){let p=`${l}/`,g=!1;for(let v=0;v<e.length;v++){let I=e[v];if(I!==i&&I.startsWith(p))return{error:`"${l}" already exists.`};let C=I===i?l:I;if(u.has(C))return{error:`"${l}" already exists.`};if(u.add(C),d[v]=C,I===i)g=!0}if(!g)return{error:"Could not find the selected file to rename."};return{nextFiles:d,sourcePath:i,destinationPath:l,isFolder:n}}let f=`${i}/`,c=`${l}/`,m=0;for(let p=0;p<e.length;p++){let g=e[p],v=g===i||g.startsWith(f);if(!v&&(g===l||g.startsWith(c)))return{error:`"${l}" already exists.`};let I=v?`${l}${g.slice(i.length)}`:g;if(u.has(I))return{error:`"${l}" already exists.`};if(u.add(I),d[p]=I,v)m++}if(m===0)return{error:"Could not find the selected folder to rename."};return{nextFiles:d,sourcePath:i,destinationPath:l,isFolder:n}}function Yf(e){return e.endsWith("/")}function Xf(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 Qf(e){let t=[],n=new Set;for(let i of e){if(n.has(i))continue;n.add(i),t.push(i)}let r=new Set;for(let i of t.toSorted((o,s)=>{if(o.length!==s.length)return o.length-s.length;return o.localeCompare(s)})){let o=(i.endsWith("/")?i.slice(0,-1):i).split("/"),s=!1;for(let a=0;a<o.length-1;a+=1){let l=`${o.slice(0,a+1).join("/")}/`;if(!r.has(l))continue;s=!0;break}if(s)continue;r.add(i)}return t.filter((i)=>r.has(i))}function Jl(e,t){return t.includes(e)?Qf(t):[e]}function ec(e,t){if(e===t)return!0;if(e==null||t==null)return!1;return e.kind===t.kind&&e.directoryPath===t.directoryPath&&e.flattenedSegmentPath===t.flattenedSegmentPath&&e.hoveredPath===t.hoveredPath}function Mo(e,t){return{draggedPaths:e,target:t}}function Ao(e,t){if(t.kind!=="directory"||t.directoryPath==null)return!1;for(let n of e){if(!Yf(n))continue;if(t.directoryPath===n||t.directoryPath.startsWith(n))return!0}return!1}function Zf(e,t){if(t.kind==="root"||t.directoryPath==null)return Xf(e);return t.directoryPath}function tc(e,t){let n=e.map((r)=>{let i=Zf(r,t);if(i===r)return null;return{from:r,to:i,type:"move"}}).filter((r)=>r!=null);if(n.length===0)return null;return{operations:n,result:{draggedPaths:e,operation:n.length===1?"move":"batch",target:t}}}function Jf(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 No(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 o=i.paths;if(r==null)return{paths:o,preparedInput:i};if(!Jf(ui.preparePaths(r,n==null?{}:{sort:n}),o))throw Error(`FileTree ${t} received paths and preparedInput for different path lists`);return{paths:o,preparedInput:i}}function Lo(e){return e.operation==="add"||e.operation==="remove"||e.operation==="move"||e.operation==="batch"}function ep(e,t,n){if(e===t)return n;let r=t.endsWith("/")?t:`${t}/`;if(!e.startsWith(r))return e;return`${n.endsWith("/")?n:`${n}/`}${e.slice(r.length)}`}function tp(e,t){if(e===t)return!0;let n=t.endsWith("/")?t:`${t}/`;return e.startsWith(n)}function Pn(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 tp(e,t.path)?n?e:null:e;case"move":return ep(e,t.from,t.to);case"batch":{let r=e;for(let i of t.events)if(r=Pn(r,i,n),r==null)return null;return r}}}function vi(e){return{canonicalChanged:e.canonicalChanged,projectionChanged:e.projectionChanged,visibleCountDelta:e.visibleCountDelta}}function nc(e){switch(e.operation){case"add":return{...vi(e),operation:"add",path:e.path};case"remove":return{...vi(e),operation:"remove",path:e.path,recursive:e.recursive};case"move":return{...vi(e),from:e.from,operation:"move",to:e.to}}}function np(e){return{...vi(e),events:e.events.filter((t)=>t.operation==="add"||t.operation==="remove"||t.operation==="move").map((t)=>nc(t)),operation:"batch"}}function rc(e){switch(e.operation){case"add":case"remove":case"move":return nc(e);case"batch":return np(e);default:return null}}function yi(e,t){if(e.size!==t.length)return!1;for(let n of t)if(!e.has(n))return!1;return!0}function xt(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((r,i)=>`${n.slice(0,i+1).join("/")}/`)}function bi(e){return xt(e).at(-1)??null}function Fo(e,t){if(t==null)return e;return e.startsWith(t)?e.slice(t.length):e}function yr(e){return e.endsWith("/")}var Bo=(e)=>e.toLowerCase();function ic(e){let t=e.endsWith("/")?e.slice(0,-1):e,n=t.lastIndexOf("/");return n<0?t:t.slice(n+1)}function Ho(e){return e.endsWith("/")?e.slice(0,-1):e}function Vo(e,t){return t&&!e.endsWith("/")?`${e}/`:e}var oc=(e)=>{let t=e.trim();if(t.length===0)return"";return(t.includes("\\")?t.replaceAll("\\","/"):t).toLowerCase()};var Oo=Symbol("FILE_TREE_RENAME_VIEW"),rp=512,ip=512;function op(e){return e==="top"||e==="center"?e:"nearest"}function sp(e,t,n){if(e===0)return-1;if(n!=null){let r=t(n);if(r!=null)return r;let i=xt(n);for(let o=i.length-1;o>=0;o-=1){let s=i[o];if(s==null)continue;let a=t(s);if(a!=null)return a}}return 0}function ap(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??((i)=>e.visibleIndexByPath.get(i)??null);return{focusedIndex:sp(e.paths.length,r,t),getParentIndex:e.getParentIndex,paths:e.paths,posInSetByIndex:e.posInSetByIndex,setSizeByIndex:e.setSizeByIndex}}var sc=class e{static{Object.defineProperty(e.prototype,Oo,{configurable:!0,value(){return{cancel:()=>{this.#_e()},commit:()=>{this.#Ee()},getPath:()=>this.#s,getValue:()=>this.#g,isActive:()=>this.#s!=null,setValue:(t)=>{this.#Te(t)}}},writable:!0})}#e;#t=new Set;#c=new Map;#u=null;#a=null;#V=new Map;#O=new Map;#v=-1;#r=null;#y=!1;#T=(t)=>-1;#b=new Map;#m=null;#h=null;#w=null;#I=null;#f=null;#q;#z;#N;#i=[];#W=new Int32Array(0);#$=new Int32Array(0);#Z=void 0;#P=!1;#s=null;#g="";#R=!1;#x=new Set;#j=[];#K;#U=null;#l=null;#L=null;#M=null;#k=null;#F=null;#J=null;#xe=0;#S=null;#o=new Set;#G=0;#n;#ne=0;#re=!1;#p=0;#Y;constructor(t){let{dragAndDrop:n,fileTreeSearchMode:r,initialSearchQuery:i,initialSelectedPaths:o,renaming:s,onSearchChange:a,paths:l,preparedInput:d,...u}=t,f=No({paths:l,preparedInput:d},"constructor",u.sort);if(this.#e=u,n!=null&&n!==!1)this.#u=n===!0?{}:n;if(this.#P=s!=null&&s!==!1,s!=null&&s!==!1&&s!==!0)this.#Z=s.canRename,this.#z=s.onError,this.#q=s.onRename;this.#N=a,this.#K=r??"hide-non-matches",this.#n=this.#oe(f.paths,f.preparedInput);let c=o?.map((p)=>this.#A(p)).filter((p)=>p!=null)??[],m=c.at(-1)??null;if(c.length>0)this.#o=new Set(c),this.#S=m,this.#G=1;if(this.#H(m,!1),i!=null)this.#X(i,!1);this.#Y=this.#Ce()}destroy(){this.#Y?.(),this.#Y=null,this.#c.clear(),this.#t.clear(),this.#b.clear(),this.#a=null,this.#ae()}focusFirstItem(){if(this.#_().length>0)this.#E(0)}focusLastItem(){if(this.#p<=0)return;this.#D(),this.#E(this.#p-1)}focusNextItem(){this.#Se(1)}focusParentItem(){if(this.#r==null)return;let t=bi(this.#r);if(t==null)return;let n=this.#B(t);if(n>=0)this.#E(n)}focusPath(t){let n=this.#n.getPathInfo(t)?.path??null;if(n==null)return;this.#D();let r=this.#B(n);if(r>=0)this.#E(r)}scrollToPath(t,n){let r=this.#n.getPathInfo(t)?.path??null;if(r==null)return;this.#D();let i=this.#He(r);if(i<0)return;if(this.#le(i)==null)return;if(n?.focus!==!1)this.#E(i,!1);this.#J={id:this.#xe+=1,offset:op(n?.offset),visibleIndex:i},this.#d()}focusMountedPathFromInput(t){let n=this.#n.getPathInfo(t)?.path??null;if(n==null)return;let r=this.#B(n);if(r>=0)this.#E(r)}focusNearestPath(t){let n=this.resolveNearestVisiblePath(t);if(n==null)return null;let r=this.#B(n);if(r>=0)return this.#E(r),this.#_()[r]??n;return null}focusPreviousItem(){this.#Se(-1)}getFocusedIndex(){return this.#v}getFocusedItem(){return this.#r==null?null:this.#ce(this.#r)}getFocusedPath(){return this.#r}getScrollRequest(){return this.#J}clearScrollRequest(t){if(this.#J?.id===t)this.#J=null}resolveNearestVisiblePath(t){let n=this.#_();if(this.#p===0)return null;if(t==null)return this.#r??n[0]??null;let r=this.#n.getPathInfo(t)?.path??t,i=this.#B(r);if(i>=0)return n[i]??r;let o=this.#Pe(r);if(o!=null)return o;return this.#r??n[0]??null}getSelectedPaths(){return[...this.#o]}getSelectionVersion(){return this.#G}getVisibleCount(){return this.#p}getVisibleRows(t,n){if(n<t||this.#p===0)return[];let r=Math.max(0,t),i=Math.min(this.#p-1,n);if(i<r)return[];let o=i-r+1;if(this.#k==null&&!this.#y&&i>=this.#i.length&&o<=ip){let s=[];for(let a=r;a<=i;a+=1){let l=this.#n.getVisibleRowContext(a);if(l==null)break;s.push(this.#ue(l))}return s}if(!this.#y&&i>=this.#i.length)this.#D();if(this.#k!=null){let s=Array.from({length:i-r+1},(u,f)=>this.#ve(r+f)),a=new Map,l=s[0]??-1,d=l;for(let u=1;u<=s.length;u+=1){let f=s[u];if(f!=null&&f===d+1){d=f;continue}if(l>=0)this.#n.getVisibleSlice(l,d).forEach((c,m)=>{a.set(l+m,c)});if(f==null){l=-1,d=-1;continue}l=f,d=f}return Array.from({length:i-r+1},(u,f)=>{let c=r+f,m=this.#ve(c),p=a.get(m),g=this.#i[m];if(p==null||g==null)throw Error(`Missing projection row for filtered visible index ${String(c)}`);return this.#ie(p,c,m,{ancestorPaths:this.#fe(m),path:g})})}return this.#n.getVisibleSlice(r,i).map((s,a)=>{let l=r+a,d=this.#i[l];if(d==null)throw Error(`Missing projection path for visible index ${String(l)}`);return this.#ie(s,l,l,{ancestorPaths:this.#fe(l),path:d})})}getStickyRowCandidates(t,n){if(this.#k!=null)return null;if(this.#p===0||t<=0||n<=0)return[];let r=[];for(let i=0;i<this.#p;i+=1){let o=t+i*n,s=Math.min(this.#p-1,Math.floor(o/n)),a=this.#de(s,i)??(s>0?this.#de(s-1,i):void 0);if(a==null)break;r.push({row:this.#ue(a),subtreeEndIndex:a.subtreeEndIndex})}return r}getItem(t){let n=this.#n.getPathInfo(t);return n==null?null:this.#ce(n.path,n)}resolveMountedDirectoryPathFromInput(t){let n=this.#n.getPathInfo(t);return n?.kind==="directory"?n.path:null}toggleMountedDirectoryFromInput(t){let n=this.resolveMountedDirectoryPathFromInput(t);if(n==null)return;this.#ke(n)}selectAllVisiblePaths(){this.#D();let t=[...this.#_()];this.#C(t,this.#r??this.#S)}selectOnlyPath(t){let n=this.#A(t);if(n==null)return;this.#C([n],n)}selectOnlyMountedPathFromInput(t){this.#C([t],t)}selectPath(t){let n=this.#A(t);if(n==null||this.#o.has(n))return;this.#C([...this.#o,n])}deselectPath(t){let n=this.#A(t);if(n==null||!this.#o.has(n))return;this.#C([...this.#o].filter((r)=>r!==n))}toggleFocusedSelection(){if(this.#r==null)return;this.togglePathSelectionFromInput(this.#r)}togglePathSelection(t){let n=this.#A(t);if(n==null)return;if(this.#o.has(n)){this.deselectPath(n);return}this.selectPath(n)}togglePathSelectionFromInput(t){let n=this.#A(t);if(n==null)return;if(this.#o.has(n)){this.#C([...this.#o].filter((r)=>r!==n),n);return}this.#C([...this.#o,n],n)}selectPathRange(t,n){let r=this.#A(t);if(r==null)return;this.#D();let i=this.#S,o=i==null?-1:this.#te(i),s=this.#te(r);if(o===-1||s===-1){let f=n?[...this.#o,r]:[r];this.#C(f,r);return}let[a,l]=o<=s?[o,s]:[s,o],d=this.#_().slice(a,l+1),u=n?[...this.#o,...d]:d;this.#C(u,i)}extendSelectionFromFocused(t){if(this.#r==null)return;let n=this.#v;if(n===-1)return;let r=Math.min(this.#p-1,Math.max(0,n+t));if(r===n)return;if(!this.#y&&r>=this.#i.length)this.#D();let i=this.#_(),o=i[n]??null,s=i[r]??null;if(o==null||s==null)return;let a=new Set(this.#o);if(a.has(o)&&a.has(s))a.delete(o);else a.add(s);this.#C([...a],this.#S??o,!1),this.#E(r)}getDragAndDropConfig(){return this.#u}isDragAndDropEnabled(){return this.#u!=null}getDragSession(){if(this.#a==null)return null;return{draggedPaths:[...this.#a.draggedPaths],primaryPath:this.#a.primaryPath,target:this.#a.target==null?null:{...this.#a.target}}}startDrag(t){if(this.#u==null)return!1;let n=this.#A(t);if(n==null)return!1;if(this.#l!=null&&this.#l.length>0)return!1;let r=this.getSelectedPaths(),i=Jl(n,r);if(this.#u.canDrag?.(i)===!1)return!1;if(!r.includes(n))this.#C([n],n,!1);return this.#Q(n),this.#a={draggedPaths:i,primaryPath:n,target:null},this.#d(),!0}setDragTarget(t){let n=this.#a;if(n==null)return;let r=t;if(r!=null){let i=Mo(n.draggedPaths,r);if(Ao(n.draggedPaths,r)||this.#u?.canDrop?.(i)===!1)r=null}if(ec(n.target,r))return;this.#a={...n,target:r},this.#d()}cancelDrag(){if(this.#a==null)return;this.#a=null,this.#d()}completeDrag(){let t=this.#a;if(t==null)return!1;this.#a=null;let n=t.target==null?null:{...t.target};if(n==null)return this.#d(),!1;let r=Mo(t.draggedPaths,n);if(Ao(t.draggedPaths,n)||this.#u?.canDrop?.(r)===!1)return this.#d(),!1;let i=tc(t.draggedPaths,n);if(i==null)return this.#d(),!1;try{if(i.operations.length===1){let o=i.operations[0];if(o==null||o.type!=="move")throw Error("Expected a single move operation for one-item drops");this.#n.move(o.from,o.to,{collision:o.collision})}else this.#Me(i.operations),this.#n.batch(i.operations)}catch(o){return this.#d(),this.#u?.onDropError?.(o instanceof Error?o.message:String(o),r),!1}return this.#u?.onDropComplete?.(i.result),!0}subscribe(t){return this.#t.add(t),t(),()=>{this.#t.delete(t)}}add(t){this.#n.add(t)}remove(t,n={}){this.#n.remove(t,n)}move(t,n,r={}){this.#n.move(t,n,r)}batch(t){this.#n.batch(t)}onMutation(t,n){let r=t,i=n,o=this.#c.get(r);if(o==null)o=new Set,this.#c.set(r,o);return o.add(i),()=>{let s=this.#c.get(r);if(s?.delete(i),s?.size===0)this.#c.delete(r)}}setSearch(t){this.#X(t,!0)}openSearch(t=""){this.#X(t,!0)}closeSearch(){this.#X(null,!0)}isSearchOpen(){return this.#l!==null}getSearchValue(){return this.#l??""}getSearchMatchingPaths(){return this.#j}focusNextSearchMatch(){this.#ye(1)}focusPreviousSearchMatch(){this.#ye(-1)}startRenaming(t=this.#r??"",n={}){if(!this.#P)return!1;let r=this.#n.getPathInfo(t);if(r==null)return!1;let i=r.path,o=yr(i),s=Ho(i);if(this.#Z?.({isFolder:o,path:s})===!1)return!1;for(let a of xt(i))if(!this.#n.isExpanded(a))this.#n.expand(a);if(this.#C([i],i,!1),this.#l!=null)this.#X(null,!1),this.#N?.(this.#l);return this.#Q(i),this.#s=i,this.#g=ic(i),this.#R=n.removeIfCanceled??!1,this.#d(),!0}#_e(){if(this.#s==null)return;let t=this.#s,n=this.#R;if(this.#s=null,this.#g="",this.#R=!1,n){this.remove(t,yr(t)?{recursive:!0}:void 0);return}this.#Q(t),this.#d()}#Ee(){let t=this.#s;if(t==null)return;if(this.#R&&this.#g.trim().length===0){this.#s=null,this.#g="",this.#R=!1,this.remove(t,yr(t)?{recursive:!0}:void 0);return}let n=yr(t),r=Zl({files:this.#n.list(),isFolder:n,nextBasename:this.#g,path:Ho(t)});if(this.#s=null,this.#g="",this.#R=!1,"error"in r){this.#Q(t),this.#z?.(r.error),this.#d();return}if(r.sourcePath===r.destinationPath){this.#Q(t),this.#d();return}this.#q?.({destinationPath:r.destinationPath,isFolder:r.isFolder,sourcePath:r.sourcePath}),this.move(Vo(r.sourcePath,n),Vo(r.destinationPath,n))}#Te(t){if(this.#s==null||this.#g===t)return;this.#g=t,this.#d()}resetPaths(t,n={}){let r=!Array.isArray(t),i=r?void 0:t,o=r?t:n,s=this.#n.list().length,a=this.#p,l=No({paths:i,preparedInput:o.preparedInput},"resetPaths",this.#e.sort),d=this.#oe(l.paths,l.preparedInput,o.initialExpandedPaths),u=this.#r,f=this.#s,c=this.getSelectedPaths(),m=this.#S;this.#Y?.(),this.#n=d,this.#b.clear(),this.#ae();let p=c.map((v)=>d.getPathInfo(v)?.path??null).filter((v)=>v!=null),g=!yi(this.#o,p);if(this.#o=new Set(p),g)this.#G+=1;if(this.#S=m==null?null:d.getPathInfo(m)?.path??null,this.#s=f==null?null:d.getPathInfo(f)?.path??null,this.#s==null)this.#g="",this.#R=!1;this.#H(u,u!=null||p.length>0||this.#S!=null),this.#Y=this.#Ce(),this.#d(),this.#we({canonicalChanged:!0,operation:"reset",pathCountAfter:l.paths.length,pathCountBefore:s,projectionChanged:!0,usedPreparedInput:o.preparedInput!=null,visibleCountDelta:this.#p-a})}#Pe(t){this.#D();let n=bi(t),r=Fo(t,n),i=null,o=null;for(let s of this.#_()){if(bi(s)!==n)continue;let a=Fo(s,n);if(a<r){i=s;continue}if(a>r){o=s;break}}return i??o}#B(t){let n=this.#te(t);if(n!==-1)return n;let r=xt(t);for(let i=r.length-1;i>=0;i-=1){let o=r[i];if(o==null)continue;let s=this.#te(o);if(s!==-1)return s}return this.#_().length>0?0:-1}#ce(t,n){let r=this.#b.get(t);if(r!=null)return r;let i=n??this.#n.getPathInfo(t);if(i==null)return null;let o=i.kind==="directory"?this.#Re(i.path):this.#De(i.path);return this.#b.set(i.path,o),o}#ie(t,n,r,i){return{ancestorPaths:i.ancestorPaths,depth:t.depth,flattenedSegments:t.flattenedSegments?.map((o)=>({isTerminal:o.isTerminal,name:o.name,path:o.path})),hasChildren:t.hasChildren,index:n,isExpanded:t.isExpanded,isFlattened:t.isFlattened,isFocused:i.path===this.#r,isSelected:this.#o.has(i.path),kind:t.kind,level:t.depth,name:t.name,path:i.path,posInSet:i.posInSet??this.#W[r]??0,setSize:i.setSize??this.#$[r]??0}}#ue(t){return this.#ie(t.row,t.index,t.index,{ancestorPaths:t.ancestorPaths,path:t.row.path,posInSet:t.posInSet,setSize:t.setSize})}#de(t,n){let r=this.#n.getVisibleRowContext(t);if(r==null)return;let i=r.ancestorRows[n];if(i!=null)return i;return n===r.ancestorRows.length&&r.row.kind==="directory"&&r.row.isExpanded?r:void 0}#he(t){let n=this.#V.get(t);if(n!=null)return n;let r=this.#T(t),i=r<0?[]:[...this.#he(r),r];return this.#V.set(t,i),i}#fe(t){let n=this.#O.get(t);if(n!=null)return n;let r=this.#he(t).map((i)=>this.#i[i]??"").filter((i)=>i!=="");return this.#O.set(t,r),r}#pe(t){this.#n.collapse(t)}#C(t,n=this.#S,r=!0){let i=[...new Set(t)],o=!yi(this.#o,i),s=this.#S!==n;if(!o&&!s)return;if(this.#o=new Set(i),this.#S=n,o)this.#G+=1;if(r)this.#d()}#Re(t){return{collapse:()=>{this.#pe(t)},deselect:()=>{this.deselectPath(t)},expand:()=>{this.#Ie(t)},focus:()=>{this.focusPath(t)},getPath:()=>t,isDirectory:()=>!0,isExpanded:()=>this.#n.isExpanded(t),isFocused:()=>this.#r===t,isSelected:()=>this.#o.has(t),select:()=>{this.selectPath(t)},toggleSelect:()=>{this.togglePathSelection(t)},toggle:()=>{this.#ke(t)}}}#De(t){return{deselect:()=>{this.deselectPath(t)},focus:()=>{this.focusPath(t)},getPath:()=>t,isDirectory:()=>!1,isFocused:()=>this.#r===t,isSelected:()=>this.#o.has(t),select:()=>{this.selectPath(t)},toggleSelect:()=>{this.togglePathSelection(t)}}}#Me(t){let n=this.#n.list();this.#oe(n).batch(t)}#oe(t,n,r){return new ui({...this.#e,paths:t,preparedInput:n==null?void 0:n,...r!==void 0?{initialExpandedPaths:r}:{}})}#se(){if(this.#I!=null)return this.#I;return this.#I=this.#n.list(),this.#I}#Ae(){if(this.#w!=null)return this.#w;let t=new Set;for(let n of this.#se()){t.add(n);for(let r of xt(n))t.add(r)}return this.#w=[...t].sort(),this.#w}#Ne(){if(this.#f!=null)return this.#f;return this.#f=this.#se().map(Bo),this.#f}#ee(){if(this.#m!=null)return this.#m;return this.#m=this.#Ae().filter((t)=>t.endsWith("/")),this.#m}#Le(){if(this.#h!=null)return this.#h;return this.#h=this.#ee().map(Bo),this.#h}#ae(){this.#m=null,this.#h=null,this.#w=null,this.#I=null,this.#f=null}#Fe(){return this.#ee().filter((t)=>this.#n.isExpanded(t))}#me(t){let n=new Set(this.#U??[]);if(t)for(let r of this.#o)for(let i of xt(r))n.add(i);this.#ge(n)}#ge(t){this.#re=!0;try{for(let n of this.#ee()){let r=t.has(n),i=this.#n.isExpanded(n);if(r&&!i)this.#n.expand(n);else if(!r&&i)this.#n.collapse(n)}}finally{this.#re=!1}}#Be(){if(this.#l==null||this.#l.length===0){this.#j=[],this.#k=null,this.#F=null,this.#M=null,this.#p=this.#ne;return}let t=this.#i;if(this.#j=t.filter((o)=>this.#x.has(o)),this.#K!=="hide-non-matches"||this.#x.size===0){this.#k=null,this.#F=null,this.#M=null,this.#p=this.#ne;return}let n=[],r=[],i=new Map;for(let[o,s]of t.entries()){if(this.#L?.has(s)!==!0)continue;i.set(s,r.length),n.push(o),r.push(s)}this.#k=n,this.#F=r,this.#M=i,this.#p=r.length}#_(){return this.#F??this.#i}#He(t){if(this.#F!=null)return this.#M?.get(t)??-1;return this.#n.getVisibleIndex(t)??-1}#ve(t){return this.#k?.[t]??t}#te(t){let n=this.#M?.get(t);if(n!=null)return n;return this.#n.getVisibleIndex(t)??-1}#ye(t){let n=this.#j;if(n.length===0)return;let r=this.#r,i=r==null?-1:n.indexOf(r),o=n[i<0?t>0?0:n.length-1:Math.min(n.length-1,Math.max(0,i+t))];if(o!=null)this.focusPath(o)}#X(t,n){let r=t==null?null:oc(t),i=this.#l;if(i===r)return;if(i==null&&r!=null)this.#U=this.#Fe();if(this.#l=r,r==null)this.#me(!0),this.#U=null,this.#x.clear(),this.#L=null,this.#H(this.#r,!0);else if(r.length===0)this.#me(!1),this.#x.clear(),this.#L=null,this.#H(this.#r,!0);else{let o=this.#be();this.#H(o,!0)}if(n)this.#N?.(this.#l),this.#d()}#be(){if(this.#l==null||this.#l.length===0)return this.#x.clear(),this.#r;let t=this.#l,n=this.#se(),r=this.#Ne(),i=[],o=new Set,s=null;for(let f=0;f<n.length;f+=1){if(!r[f].includes(t))continue;let c=n[f];i.push(c),o.add(c),s??=c}let a=this.#ee(),l=this.#Le();for(let f=0;f<a.length;f+=1){if(!l[f].includes(t))continue;let c=a[f];if(o.has(c))continue;i.push(c),o.add(c),s??=c}this.#x=o;let d=this.#K==="hide-non-matches"&&i.length>0?new Set:null;this.#L=d;let u=this.#K==="expand-matches"?new Set(this.#U??[]):new Set;for(let f of i){if(d!=null)d.add(f);if(f.endsWith("/"))u.add(f);for(let c of xt(f))if(u.add(c),d!=null)d.add(c)}return this.#ge(u),s??this.#r}#d(){for(let t of this.#t)t()}#we(t){this.#c.get(t.operation)?.forEach((n)=>{n(t)}),this.#c.get("*")?.forEach((n)=>{n(t)})}#Ie(t){for(let n of xt(t)){if(this.#n.isExpanded(n))continue;this.#n.expand(n)}if(!this.#n.isExpanded(t))this.#n.expand(t)}#Se(t){let n=this.#p;if(n===0)return;let r=this.#v===-1?0:this.#v,i=Math.min(n-1,Math.max(0,r+t));if(i!==r||this.#v===-1){if(!this.#y&&this.#k==null&&i>=this.#i.length)this.#D();this.#E(i)}}#H(t,n=!0){let r=this.#n.getVisibleCount();this.#ne=r;let i=ap(this.#n.getVisibleTreeProjectionData(n?void 0:Math.min(r,rp)),t,n?(o)=>this.#n.getVisibleIndex(o):void 0);this.#V.clear(),this.#O.clear(),this.#y=i.paths.length>=r,this.#T=i.getParentIndex,this.#i=i.paths,this.#W=i.posInSetByIndex,this.#$=i.setSizeByIndex,this.#Be(),this.#v=t==null?this.#_().length>0?0:-1:this.#B(t),this.#r=this.#v<0?null:this.#le(this.#v)}#le(t){let n=this.#_()[t];if(n!=null)return n;if(this.#k!=null)return null;return this.#n.getVisibleRowContext(t)?.row.path??null}#A(t){return this.#n.getPathInfo(t)?.path??null}#Q(t){if(t==null)return;let n=this.#B(t);if(n>=0)this.#E(n,!1)}#E(t,n=!0){let r=this.#le(t);if(r==null)return;if(this.#v===t&&this.#r===r)return;if(this.#v=t,this.#r=r,n)this.#d()}#D(){if(this.#y)return;this.#H(this.#r,!0)}#Ve(t){let n=Pn(this.#s,t);if(n==null&&this.#s!=null)this.#g="";this.#s=n;let r=Pn(this.#r,t,!0),i=[...this.#o].map((l)=>Pn(l,t)).filter((l)=>l!=null).map((l)=>this.#n.getPathInfo(l)?.path??null).filter((l)=>l!=null),o=Pn(this.#S,t),s=o==null?null:this.#n.getPathInfo(o)?.path??null,a=[...new Set(i)];if(!yi(this.#o,a))this.#o=new Set(a),this.#G+=1;return this.#S=s,r}#Ce(){return this.#n.on("*",(t)=>{if(this.#re)return;if(t.canonicalChanged)this.#b.clear(),this.#ae();if(this.#a!=null&&Lo(t))this.#a=null;let n=Lo(t)?this.#Ve(t):this.#r,r=this.#l!=null&&this.#l.length>0?this.#be():this.#l===""?this.#r:n,i=this.#l!=null||t.operation!=="expand"&&t.operation!=="collapse";this.#H(r,i),this.#d();let o=rc(t);if(o!=null)this.#we(o)})}#ke(t){if(this.#n.isExpanded(t)){this.#pe(t);return}this.#Ie(t)}};var ac=(e)=>{if(e==null||e.length===0)return"0";let t=`${e.length}`;for(let n of e)t+=`\x00${n.path}\x00${n.status}`;return t};function lc(e){let t=e.endsWith("/"),n="",r=-1;for(let i=0;i<=e.length;i+=1){if(!(e[i]==="/"||i===e.length)){if(r===-1)r=i;continue}if(r===-1)continue;if(n!=="")n+="/";n+=e.slice(r,i),r=-1}if(n==="")return null;return{isDirectory:t,path:n}}function cc(e){let t=e.endsWith("/")?e.slice(0,-1):e;if(t.length===0)return[];let n=[],r=0;for(;;){let i=t.indexOf("/",r);if(i===-1)break;n.push(t.slice(0,i+1)),r=i+1}return n}function lp(e,t){return t?`${e}/`:e}function qo(e,t=null){let n=ac(e==null?void 0:[...e]);if(n==="0")return null;if(t?.signature===n)return t;let r=new Map,i=new Set,o=new Set,s=new Map;for(let a of e??[]){let l=dc(a);if(l==null)continue;fc({canonicalPath:l.canonicalPath,changeCountByDirectoryPath:s,directoriesWithChanges:i,ignoredDirectoryPaths:o,isDirectory:l.isDirectory,status:a.status,statusByPath:r})}if(r.size===0)return null;return{changeCountByDirectoryPath:s,directoriesWithChanges:i,ignoredDirectoryPaths:o,signature:n,statusByPath:r}}function uc(e,t){let n=t?.remove??[],r=t?.set??[];if(n.length===0&&r.length===0)return e;let i=new Map(e?.statusByPath),o=new Set(e?.directoriesWithChanges),s=new Set(e?.ignoredDirectoryPaths),a=new Map(e?.changeCountByDirectoryPath),l=!1;for(let d of n){let u=hc(d);if(u==null)continue;l=cp({canonicalPath:u.canonicalPath,changeCountByDirectoryPath:a,directoriesWithChanges:o,ignoredDirectoryPaths:s,statusByPath:i})||l}for(let d of r){let u=dc(d);if(u==null)continue;l=fc({canonicalPath:u.canonicalPath,changeCountByDirectoryPath:a,directoriesWithChanges:o,ignoredDirectoryPaths:s,isDirectory:u.isDirectory,status:d.status,statusByPath:i})||l}if(!l)return e;if(i.size===0)return null;return{changeCountByDirectoryPath:a,directoriesWithChanges:o,ignoredDirectoryPaths:s,signature:hp(i),statusByPath:i}}function dc(e){return hc(e.path)}function hc(e){let t=lc(e);if(t==null)return;return{canonicalPath:lp(t.path,t.isDirectory),isDirectory:t.isDirectory}}function cp({canonicalPath:e,changeCountByDirectoryPath:t,directoriesWithChanges:n,ignoredDirectoryPaths:r,statusByPath:i}){let o=i.get(e);if(o==null)return!1;if(i.delete(e),o==="ignored"&&e.endsWith("/"))r.delete(e);return dp(t,n,e),!0}function fc({canonicalPath:e,changeCountByDirectoryPath:t,directoriesWithChanges:n,ignoredDirectoryPaths:r,isDirectory:i,status:o,statusByPath:s}){let a=s.get(e);if(a===o)return!1;if(a==null)up(t,n,e);if(s.set(e,o),o==="ignored"&&i)r.add(e);else if(i)r.delete(e);return!0}function up(e,t,n){for(let r of cc(n))e.set(r,(e.get(r)??0)+1),t.add(r)}function dp(e,t,n){for(let r of cc(n)){let i=(e.get(r)??0)-1;if(i>0)e.set(r,i);else e.delete(r),t.delete(r)}}function hp(e){let t=`${e.size}`;for(let[n,r]of e)t+=`\x00${n}\x00${r}`;return t}var fp=(e)=>e.trim().toLowerCase(),pp=(e)=>e.split("/").at(-1)??e,mp=(e)=>{let t=e.toLowerCase().split("."),n=[];for(let r=1;r<t.length;r+=1)n.push(t.slice(r).join("."));return n};function br(e,t){if(typeof e==="string")return{name:e,remappedFrom:t};return{...e,remappedFrom:t}}function pc(e){let t=Tn(e),n=t.remap,r=new Map;for(let[a,l]of Object.entries(t.byFileName??{}))r.set(a.toLowerCase(),l);let i=new Map;for(let[a,l]of Object.entries(t.byFileExtension??{}))i.set(fp(a),l);let o=Object.entries(t.byFileNameContains??{}).map(([a,l])=>[a.toLowerCase(),l]);return{resolveIcon:(a,l)=>{if(a==="file-tree-icon-file"&&l!=null){let u=pp(l),f=u.toLowerCase(),c=r.get(f);if(c!=null)return br(c,a);for(let[g,v]of o)if(f.includes(g))return br(v,a);let m=mp(u);for(let g of m){let v=i.get(g);if(v!=null)return br(v,a)}let p=Wl(t.set,u,m);if(p!=null&&t.set!=="none"){if(p==="default"){let g=n?.[a];if(g!=null)return br(g,a)}return{name:ql(p),remappedFrom:a,token:p}}}let d=n?.[a];if(d==null)return{name:a};return br(d,a)}}}var Y,bc,gp,ln,mc,Ci,wc,Ic,jo,zo,Wo,vp,wr={},Sc=[],ki=Array.isArray,Ko=Sc.slice,zt=Object.assign;function Uo(e){e&&e.parentNode&&e.remove()}function Dn(e,t,n){var r,i,o,s={};for(o in t)o=="key"?r=t[o]:o=="ref"&&typeof e!="function"?i=t[o]:s[o]=t[o];return arguments.length>2&&(s.children=arguments.length>3?Ko.call(arguments,2):n),Ii(e,s,r,i,null)}function Ii(e,t,n,r,i){var o={type:e,props:t,key:n,ref:r,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:i==null?++bc:i,__i:-1,__u:0};return i==null&&Y.vnode!=null&&Y.vnode(o),o}function pt(e){return e.children}function Si(e,t){this.props=e,this.context=t,this.__g=0}function Rn(e,t){if(t==null)return e.__?Rn(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"?Rn(e):null}function Cc(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 Cc(e)}}function gc(e){(8&e.__g||!(e.__g|=8)||!ln.push(e)||Ci++)&&mc==Y.debounceRendering||((mc=Y.debounceRendering)||queueMicrotask)(yp)}function yp(){for(var e,t,n,r,i,o,s,a,l=1;ln.length;)ln.length>l&&ln.sort(wc),e=ln.shift(),l=ln.length,8&e.__g&&(n=void 0,i=(r=(t=e).__v).__e,o=[],s=[],(a=t.__P)&&((n=zt({},r)).__v=r.__v+1,Y.vnode&&Y.vnode(n),Go(a,n,r,t.__n,a.namespaceURI,32&r.__u?[i]:null,o,i==null?Rn(r):i,!!(32&r.__u),s,a.ownerDocument),n.__v=r.__v,n.__.__k[n.__i]=n,_c(o,n,s),n.__e!=i&&Cc(n)));Ci=0}function kc(e,t,n,r,i,o,s,a,l,d,u,f){var c,m,p,g,v,I,C,y=r&&r.__k||Sc,S=t.length;for(l=bp(n,t,y,l,S),c=0;c<S;c++)(p=n.__k[c])!=null&&(m=p.__i==-1?wr:y[p.__i]||wr,p.__i=c,I=Go(e,p,m,i,o,s,a,l,d,u,f),g=p.__e,p.ref&&m.ref!=p.ref&&(m.ref&&Yo(m.ref,null,p),u.push(p.ref,p.__c||g,p)),v==null&&g!=null&&(v=g),(C=!!(4&p.__u))||m.__k===p.__k?l=xc(p,l,e,C):typeof p.type=="function"&&I!==void 0?l=I:g&&(l=g.nextSibling),p.__u&=-7);return n.__e=v,l}function bp(e,t,n,r,i){var o,s,a,l,d,u=n.length,f=u,c=0;for(e.__k=Array(i),o=0;o<i;o++)(s=t[o])!=null&&typeof s!="boolean"&&typeof s!="function"?(l=o+c,(s=e.__k[o]=typeof s=="string"||typeof s=="number"||typeof s=="bigint"||s.constructor==String?Ii(null,s,null,null,null):ki(s)?Ii(pt,{children:s},null,null,null):s.constructor==null&&s.__b>0?Ii(s.type,s.props,s.key,s.ref?s.ref:null,s.__v):s).__=e,s.__b=e.__b+1,a=null,(d=s.__i=wp(s,n,l,f))!=-1&&(f--,(a=n[d])&&(a.__u|=2)),a==null||a.__v==null?(d==-1&&(i>u?c--:i<u&&c++),typeof s.type!="function"&&(s.__u|=4)):d!=l&&(d==l-1?c--:d==l+1?c++:(d>l?c--:c++,s.__u|=4))):e.__k[o]=null;if(f)for(o=0;o<u;o++)(a=n[o])!=null&&(2&a.__u)==0&&(a.__e==r&&(r=Rn(a)),Tc(a,a));return r}function xc(e,t,n,r){var i,o;if(typeof e.type=="function"){for(i=e.__k,o=0;i&&o<i.length;o++)i[o]&&(i[o].__=e,t=xc(i[o],t,n,r));return t}e.__e!=t&&(r&&(t&&e.type&&!t.parentNode&&(t=Rn(e)),n.insertBefore(e.__e,t||null)),t=e.__e);do t=t&&t.nextSibling;while(t!=null&&t.nodeType==8);return t}function wp(e,t,n,r){var i,o,s,a=e.key,l=e.type,d=t[n],u=d!=null&&(2&d.__u)==0;if(d===null&&e.key==null||u&&a==d.key&&l==d.type)return n;if(r>(u?1:0)){for(i=n-1,o=n+1;i>=0||o<t.length;)if((d=t[s=i>=0?i--:o++])!=null&&(2&d.__u)==0&&a==d.key&&l==d.type)return s}return-1}function vc(e,t,n){t[0]=="-"?e.setProperty(t,n==null?"":n):e[t]=n==null?"":n}function wi(e,t,n,r,i){var o;e: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||vc(e.style,t,"");if(n)for(t in n)r&&n[t]==r[t]||vc(e.style,t,n[t])}else if(t[0]=="o"&&t[1]=="n")o=t!=(t=t.replace(Ic,"$1")),(t=t.slice(2))[0].toLowerCase()!=t[0]&&(t=t.toLowerCase()),e.__l||(e.__l={}),e.__l[t+o]=n,n?r?n.l=r.l:(n.l=jo,e.addEventListener(t,o?Wo:zo,o)):e.removeEventListener(t,o?Wo:zo,o);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==null?"":n;break e}catch(s){}typeof n=="function"||(n==null||n===!1&&t[4]!="-"?e.removeAttribute(t):e.setAttribute(t,t=="popover"&&n==1?"":n))}}function yc(e){return function(t){if(this.__l){var n=this.__l[t.type+e];if(t.u==null)t.u=jo++;else if(t.u<n.l)return;return n(Y.event?Y.event(t):t)}}}function Go(e,t,n,r,i,o,s,a,l,d,u){var f,c,m,p,g,v,I,C,y,S,k,T,O,pe,Z,me,J,U,B,ae,Ce,z=t.type;if(t.constructor!=null)return null;128&n.__u&&(l=!!(32&n.__u),n.__c.__z&&(a=t.__e=n.__e=(o=n.__c.__z)[0],n.__c.__z=null)),(f=Y.__b)&&f(t);e:if(typeof z=="function")try{if(C=t.props,y="prototype"in z&&z.prototype.render,S=(f=z.contextType)&&r[f.__c],k=f?S?S.props.value:f.__:r,n.__c?2&(c=t.__c=n.__c).__g&&(c.__g|=1,I=!0):(y?t.__c=c=new z(C,k):(t.__c=c=new Si(C,k),c.constructor=z,c.render=Sp),S&&S.sub(c),c.props=C,c.state||(c.state={}),c.context=k,c.__n=r,m=!0,c.__g|=8,c.__h=[],c._sb=[]),y&&c.__s==null&&(c.__s=c.state),y&&z.getDerivedStateFromProps!=null&&(c.__s==c.state&&(c.__s=zt({},c.__s)),zt(c.__s,z.getDerivedStateFromProps(C,c.__s))),p=c.props,g=c.state,c.__v=t,m)y&&z.getDerivedStateFromProps==null&&c.componentWillMount!=null&&c.componentWillMount(),y&&c.componentDidMount!=null&&c.__h.push(c.componentDidMount);else{if(y&&z.getDerivedStateFromProps==null&&C!==p&&c.componentWillReceiveProps!=null&&c.componentWillReceiveProps(C,k),!(4&c.__g)&&c.shouldComponentUpdate!=null&&c.shouldComponentUpdate(C,c.__s,k)===!1||t.__v==n.__v){for(t.__v!=n.__v&&(c.props=C,c.state=c.__s,c.__g&=-9),t.__e=n.__e,t.__k=n.__k,t.__k.some(function(le){le&&(le.__=t)}),T=0;T<c._sb.length;T++)c.__h.push(c._sb[T]);c._sb=[],c.__h.length&&s.push(c);break e}c.componentWillUpdate!=null&&c.componentWillUpdate(C,c.__s,k),y&&c.componentDidUpdate!=null&&c.__h.push(function(){c.componentDidUpdate(p,g,v)})}if(c.context=k,c.props=C,c.__P=e,c.__g&=-5,O=Y.__r,pe=0,y){for(c.state=c.__s,c.__g&=-9,O&&O(t),f=c.render(c.props,c.state,c.context),Z=0;Z<c._sb.length;Z++)c.__h.push(c._sb[Z]);c._sb=[]}else do c.__g&=-9,O&&O(t),f=c.render(c.props,c.state,c.context),c.state=c.__s;while(8&c.__g&&++pe<25);c.state=c.__s,c.getChildContext!=null&&(r=zt({},r,c.getChildContext())),y&&!m&&c.getSnapshotBeforeUpdate!=null&&(v=c.getSnapshotBeforeUpdate(p,g)),me=f,f!=null&&f.type===pt&&f.key==null&&(me=Ec(f.props.children)),a=kc(e,ki(me)?me:[me],t,n,r,i,o,s,a,l,d,u),t.__u&=-161,c.__h.length&&s.push(c),I&&(c.__g&=-4)}catch(le){if(t.__v=null,l||o!=null)if(le.then){for(J=0,U=!1,t.__u|=l?160:128,t.__c.__z=[],B=0;B<o.length;B++)(ae=o[B])==null||U||(ae.nodeType==8&&ae.data=="$s"?(J>0&&t.__c.__z.push(ae),J++,o[B]=null):ae.nodeType==8&&ae.data=="/$s"?(--J>0&&t.__c.__z.push(ae),U=J===0,a=o[B],o[B]=null):J>0&&(t.__c.__z.push(ae),o[B]=null));if(!U){for(;a&&a.nodeType==8&&a.nextSibling;)a=a.nextSibling;o[o.indexOf(a)]=null,t.__c.__z=[a]}t.__e=a}else{for(Ce=o.length;Ce--;)Uo(o[Ce]);$o(t)}else t.__e=n.__e,t.__k=n.__k,le.then||$o(t);Y.__e(le,t,n)}else a=t.__e=Ip(n.__e,t,n,r,i,o,s,l,d,u);return(f=Y.diffed)&&f(t),128&t.__u?void 0:a}function $o(e){e&&e.__c&&(e.__c.__g|=4),e&&e.__k&&e.__k.forEach($o)}function _c(e,t,n){for(var r=0;r<n.length;r++)Yo(n[r],n[++r],n[++r]);Y.__c&&Y.__c(t,e),e.some(function(i){try{e=i.__h,i.__h=[],e.some(function(o){o.call(i)})}catch(o){Y.__e(o,i.__v)}})}function Ec(e){return typeof e!="object"||e==null||e.__b&&e.__b>0?e:ki(e)?e.map(Ec):zt({},e)}function Ip(e,t,n,r,i,o,s,a,l,d){var u,f,c,m,p,g,v,I,C=n.props,y=t.props,S=t.type;if(S=="svg"?i="http://www.w3.org/2000/svg":S=="math"?i="http://www.w3.org/1998/Math/MathML":i||(i="http://www.w3.org/1999/xhtml"),o!=null){for(u=0;u<o.length;u++)if((p=o[u])&&"setAttribute"in p==!!S&&(S?p.localName==S:p.nodeType==3)){e=p,o[u]=null;break}}if(e==null){if(S==null)return d.createTextNode(y);e=d.createElementNS(i,S,y.is&&y),a&&(Y.__m&&Y.__m(t,o),a=!1),o=null}if(S==null)C===y||a&&e.data==y||(e.data=y);else{if(o=o&&Ko.call(e.childNodes),C=n.props||wr,!a&&o!=null)for(C={},u=0;u<e.attributes.length;u++)C[(p=e.attributes[u]).name]=p.value;for(u in C)if(p=C[u],u=="children");else if(u=="dangerouslySetInnerHTML")c=p;else if(!(u in y)){if(u=="value"&&"defaultValue"in y||u=="checked"&&"defaultChecked"in y)continue;wi(e,u,null,p,i)}for(u in I=1&n.__u,y)p=y[u],u=="children"?m=p:u=="dangerouslySetInnerHTML"?f=p:u=="value"?g=p:u=="checked"?v=p:a&&typeof p!="function"||C[u]===p&&!I||wi(e,u,p,C[u],i);if(f)a||c&&(f.__html==c.__html||f.__html==e.innerHTML)||(e.innerHTML=f.__html),t.__k=[];else if(c&&(e.innerHTML=""),kc(S=="template"?e.content:e,ki(m)?m:[m],t,n,r,S=="foreignObject"?"http://www.w3.org/1999/xhtml":i,o,s,o?o[0]:n.__k&&Rn(n,0),a,l,d),o!=null)for(u=o.length;u--;)Uo(o[u]);a||(u="value",S=="progress"&&g==null?e.removeAttribute("value"):g==null||g===e[u]&&(S!=="progress"||g)||wi(e,u,g,C[u],i),u="checked",v!=null&&v!=e[u]&&wi(e,u,v,C[u],i))}return e}function Yo(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(i){Y.__e(i,n)}}function Tc(e,t,n){var r,i;if(Y.unmount&&Y.unmount(e),(r=e.ref)&&(r.current&&r.current!=e.__e||Yo(r,null,t)),(r=e.__c)!=null){if(r.componentWillUnmount)try{r.componentWillUnmount()}catch(o){Y.__e(o,t)}r.__P=null}if(r=e.__k)for(i=0;i<r.length;i++)r[i]&&Tc(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 Sp(e,t,n){return this.constructor(e,n)}function xi(e,t){var n,r,i,o;t==document&&(t=document.documentElement),Y.__&&Y.__(e,t),r=(n=!!(e&&32&e.__u))?null:t.__k,e=t.__k=Dn(pt,null,[e]),i=[],o=[],Go(t,e,r||wr,wr,t.namespaceURI,r?null:t.firstChild?Ko.call(t.childNodes):null,i,r?r.__e:t.firstChild,n,o,t.ownerDocument),_c(i,e,o)}function Pc(e,t){e.__u|=32,xi(e,t)}Y={__e:function(e,t,n,r){for(var i,o,s;t=t.__;)if((i=t.__c)&&!(1&i.__g)){i.__g|=4;try{if((o=i.constructor)&&o.getDerivedStateFromError!=null&&(i.setState(o.getDerivedStateFromError(e)),s=8&i.__g),i.componentDidCatch!=null&&(i.componentDidCatch(e,r||{}),s=8&i.__g),s)return void(i.__g|=2)}catch(a){e=a}}throw Ci=0,e}},bc=0,gp=function(e){return e!=null&&e.constructor==null},Si.prototype.setState=function(e,t){var n;n=this.__s!=null&&this.__s!=this.state?this.__s:this.__s=zt({},this.state),typeof e=="function"&&(e=e(zt({},n),this.props)),e&&zt(n,e),e!=null&&this.__v&&(t&&this._sb.push(t),gc(this))},Si.prototype.forceUpdate=function(e){this.__v&&(this.__g|=4,e&&this.__h.push(e),gc(this))},Si.prototype.render=pt,ln=[],Ci=0,wc=function(e,t){return e.__v.__b-t.__v.__b},Ic=/(PointerCapture)$|Capture$/i,jo=0,zo=yc(!1),Wo=yc(!0),vp=0;var Cp=0;function x(e,t,n,r,i,o){t||(t={});var s,a,l=t;if("ref"in l&&typeof e!="function")for(a in l={},t)a=="ref"?s=t[a]:l[a]=t[a];var d={type:e,props:l,key:n,ref:s,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--Cp,__i:-1,__u:0,__source:i,__self:o};return Y.vnode&&Y.vnode(d),d}var kp=16,xp=16,_p={};function Mn({name:e,remappedFrom:t,token:n,width:r,height:i,viewBox:o,label:s,alignCapitals:a=!1}){let l=`#${e.replace(/^#/,"")}`,{width:d,height:u,viewBox:f}=_p[e]??{width:kp,height:xp},c=r??d,m=i??u,p=o??f??`0 0 ${d} ${u}`;return x("svg",{"data-icon-name":t??e,"data-icon-token":n,"data-align-capitals":a,...s!=null?{"aria-label":s,role:"img"}:{"aria-hidden":!0},viewBox:p,width:c,height:m,children:x("use",{href:l})})}var Rc=(e)=>e!==void 0&&/\s/.test(e),Ep=(e,t)=>{let n=(r)=>Rc(e[r-1])||Rc(e[r]);if(!n(t))return t;for(let r=1;r<e.length;r++){let i=t-r;if(i>0&&!n(i))return i;let o=t+r;if(o<e.length&&!n(o))return o}return t},Mc=(e)=>Ep(e,Math.ceil(e.length/2)),Dc=(e)=>{if(e.length<2)return[e,""];let t=Mc(e);return[e.slice(0,t),e.slice(t)]},Tp=(e)=>{if(e.length<4)return[e,""];let t=e.lastIndexOf(".")+1,n=e.length-t>10,r=t>=1&&!n?t:Mc(e);return[e.slice(0,r),e.slice(r)]},Pp=(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)]},Rp=(e,{splitIndex:t}={})=>{if(typeof t!=="number"){let n=Math.ceil(e.length/2);return[e.slice(0,n),e.slice(n)]}return[e.slice(0,t),e.slice(t)]},Dp=(e,{splitOffset:t}={})=>{if(typeof t!=="number"||t<=0||t>=e.length){let r=Math.ceil(e.length/2);return[e.slice(0,r),e.slice(r)]}let n=e.length-t;return[e.slice(0,n),e.slice(n)]},Mp=(e,{splitOffset:t}={})=>{if(typeof t!=="number"||t<=0||t>=e.length){let r=Math.ceil(e.length/2);return[e.slice(0,r),e.slice(r)]}let n=t;return[e.slice(0,n),e.slice(n)]};function Ap({children:e,marker:t,variant:n="default"}){return x("div",{"aria-hidden":!0,"data-truncate-marker-cell":!0,children:x("div",{"data-truncate-marker":!0,children:typeof t==="function"?t({children:e}):n==="fade"?x("span",{"data-truncate-fade":!0}):t})})}function Np(e){let{mode:t,children:n}=e;return x("div",{children:[x("div",{"data-truncate-content":"visible",children:t==="fruncate"?x("span",{children:n}):n}),x("div",{"data-truncate-content":"overflow","aria-hidden":!0,children:t==="fruncate"?x("span",{children:n}):n})]})}function Ac({children:e,mode:t="truncate",marker:n="…",variant:r="default",...i}){let o=x(Np,{mode:t,children:e},"content"),s=x(Ap,{marker:n,mode:t,variant:r},"marker");return x("div",{"data-truncate-container":t,"data-truncate-variant":r,...i,children:x("div",{"data-truncate-grid":!0,children:t==="truncate"?[o,s]:[s,o,x("div",{"data-truncate-fill":!0},"fill")]})})}function Ir({children:e,...t}){return x(Ac,{mode:"truncate",...t,children:e})}function Xo({children:e,...t}){return x(Ac,{mode:"fruncate",...t,children:e})}function Nc({children:e,contents:t,priority:n="end",split:r="center",minimumLength:i=12,className:o,style:s,...a}){let l=null,d=null;if(Array.isArray(t)){if(t.length!==2)return console.error("MiddleTruncate: contents must be an array of two items"),null;l=x(Ir,{...a,children:t[0]}),d=x(Xo,{...a,children:t[1]})}else{if(typeof e!=="string")return console.error("MiddleTruncate: children must be a string"),null;if(e.length===0)return x("div",{className:o,style:s});if(e.length<i)if(n==="end")return x(Xo,{...a,className:o,style:s,children:e});else return x(Ir,{...a,className:o,style:s,children:e});let u=null,f=null,c=null;if(typeof r==="string"){if(r==="center")u=Dc;else if(r==="extension")u=Tp;else if(r==="leaf-path")u=Pp}else if(typeof r==="number")u=Rp,f=r;else if(Array.isArray(r)){let[S,k]=r;if(c=k,S==="last")u=Dp;else if(S==="first")u=Mp}else if(typeof r==="function")u=r;u??=Dc;let[m,p]=u(e,{priority:n,variant:a.variant,splitIndex:typeof f==="number"?f:void 0,splitOffset:typeof c==="number"?c:void 0}),g=m.length>=p.length,v=n==="equal"&&!g,I=n==="equal"&&g,C={},y={};if(v)C.marker="";if(I)y.marker="";l=x(Ir,{...a,...C,children:m}),d=x(Xo,{...a,...y,children:p})}return x("div",{"data-truncate-group-container":"middle",className:o,style:s,children:[x("div",{"data-truncate-segment-priority":n==="start"||n==="equal"?"1":"2",children:l}),x("div",{"data-truncate-segment-priority":n==="end"||n==="equal"?"1":"2",children:d})]})}var Qo={endIndex:-1,startIndex:-1};function Lp(e,t,n){return Math.min(Math.max(e,t),n)}function Lc(e,t){return e<0||t<e?Qo:{endIndex:t,startIndex:e}}function Zo(e){return e.startIndex<0||e.endIndex<e.startIndex}function Fp(e,t){return Zo(e)?0:(e.endIndex-e.startIndex+1)*t}function Fc(e,t,n){if(t<=0)return-1;let r=t*n;if(e<=0)return 0;if(e>=r)return t;return Math.floor(e/n)}function Bp(e,t,n){if(t<=0||e<=0)return-1;if(e>=t*n)return t-1;return Math.ceil(e/n)-1}function Hp(e){let t=new Map;return e.forEach((n,r)=>{if(n.kind!=="directory"||!n.isExpanded)return;let i=n.ancestorPaths.length,o=t.get(i);if(o==null){t.set(i,[r]);return}o.push(r)}),t}function Vp(e,t){let n=0,r=e.length-1,i=-1;while(n<=r){let o=Math.floor((n+r)/2),s=e[o];if(s==null)break;if(s<=t){i=o,n=o+1;continue}r=o-1}return i}function Op(e){let t=new Map,n=[];for(let i=0;i<e.length;i+=1){let o=e[i];if(o==null)continue;let s=o.kind==="directory"&&o.isExpanded?[...o.ancestorPaths,o.path]:o.ancestorPaths,a=0;while(a<n.length&&a<s.length&&n[a]===s[a])a+=1;for(let l=n.length-1;l>=a;l-=1){let d=n[l];if(d!=null)t.set(d,i-1)}n.length=a;for(let l=a;l<s.length;l+=1){let d=s[l];if(d!=null)n.push(d)}}let r=e.length-1;for(let i of n)t.set(i,r);return t}function Jo(e,t,n){if(e.length===0||t<=0)return[];let r=Op(e),i=Hp(e),o=[];for(let s=0;s<e.length;s+=1){let a=i.get(s);if(a==null||a.length===0)break;let l=t+s*n,d=Vp(a,Math.min(e.length-1,Math.floor(l/n))),u=null;while(d>=0){let f=a[d],c=f==null?null:e[f]??null;if(c!=null&&(s===0||c.ancestorPaths[s-1]===o[s-1]?.path)){u=c;break}d-=1}if(u==null)break;o.push(u)}return o.map((s,a)=>{let l=a*n,d=(r.get(s.path)??e.length-1)+1;if(d>=e.length)return{row:s,top:l};let u=d*n-t;return{row:s,top:Math.min(l,u-n)}}).filter((s)=>s.top+n>0)}function Bc(e,t){let n=t.totalRowCount??e.length,r=n*t.itemHeight,i=Math.max(0,t.viewportHeight),o=Math.max(0,Math.floor(t.overscan)),s=Math.max(0,r-i),a=Lp(t.scrollTop,0,s),l=t.stickyRows??Jo(e,a,t.itemHeight),d=l.reduce((T,O)=>Math.max(T,O.top+t.itemHeight),0),u=Math.min(r,a+d),f=Math.max(0,i-d),c=Math.max(0,r-u),m=Fc(a,n,t.itemHeight),p=Fc(u,n,t.itemHeight),g=d<=0||m<0||m>=n?-1:m,v=g===-1?-1:Math.min(n-1,p-1),I=g===-1||v<g?0:v-g+1,C=f<=0||p>=n?Qo:Lc(p,Bp(u+f,n,t.itemHeight)),y=v+1,S=Zo(C)?Qo:Lc(Math.max(y,C.startIndex-o),Math.min(n-1,C.endIndex+o)),k=Fp(S,t.itemHeight);return{occlusion:{firstOccludedIndex:g,lastOccludedIndex:v,occludedCount:I},physical:{itemHeight:t.itemHeight,maxScrollTop:s,overscan:o,scrollTop:a,totalHeight:r,totalRowCount:n,viewportHeight:i},projected:{contentHeight:c,paneHeight:f,paneTop:u},sticky:{height:d,rows:l},visible:C,window:{endIndex:S.endIndex,height:k,offsetTop:Zo(S)?0:S.startIndex*t.itemHeight,startIndex:S.startIndex}}}var Hc={added:"A",deleted:"D",ignored:null,modified:"M",renamed:"R",untracked:"U"},Vc={added:"Git status: added",deleted:"Git status: deleted",ignored:"Git status: ignored",modified:"Git status: modified",renamed:"Git status: renamed",untracked:"Git status: untracked"},Oc="Contains git status items";function qc(e){if(e.current)return!0;return e.current=!0,!1}function es(e){let{currentScrollTop:t,focusedIndex:n,itemHeight:r,topInset:i=0,viewportHeight:o}=e;if(n<0)return null;let s=Math.max(0,i),a=n*r,l=a+r;if(a<t+s){let d=Math.max(0,a-s);return d===t?null:d}if(l>t+o){let d=l-o;return d===t?null:d}return null}function zc(e){let{currentScrollTop:t,focusedIndex:n,itemHeight:r,offset:i,topInset:o=0,totalHeight:s,viewportHeight:a}=e;if(i==="nearest")return es({currentScrollTop:t,focusedIndex:n,itemHeight:r,topInset:o,viewportHeight:a});if(n<0)return null;let l=Math.max(0,o),d=n*r,u=Math.max(0,a-l),f=i==="center"?l+Math.max(0,(u-r)/2):l,c=Math.max(0,s-a),m=Math.max(0,Math.min(d-f,c));return m===t?null:m}function Wc(e){let{currentScrollTop:t,focusedIndex:n,itemHeight:r,targetViewportOffset:i,totalHeight:o,viewportHeight:s}=e;if(n<0)return null;let a=Math.max(0,i),l=n*r,d=l+r,u=t+a,f=t+s;if(l>=u&&d<=f)return null;let c=Math.max(0,o-s),m=Math.max(0,Math.min(l-a,c));return m===t?null:m}function cn(e){if(e==null||!e.isConnected)return!1;if(e===document.body||e===document.documentElement)return!1;e.focus({preventScroll:!0});let t=e.getRootNode();if(t instanceof ShadowRoot)return t.activeElement===e;return document.activeElement===e}function Sr(e){let t=e.getRootNode();if(t instanceof ShadowRoot){let r=t.activeElement;return r instanceof HTMLElement?r:null}let n=document.activeElement;return n instanceof HTMLElement&&e.contains(n)?n:null}function An(e,t){if(e==null)return t;let n=e.getBoundingClientRect().height;if(n>0)return n;return e.clientHeight>0?e.clientHeight:t}function ts(e,t){return e!=null&&e>0?e:t}function $c(e){let t=e.borderBoxSize,n=Array.isArray(t)?t[0]:t;if(n!=null&&Number.isFinite(n.blockSize)&&n.blockSize>0)return n.blockSize;return e.contentRect.height>0?e.contentRect.height:null}function ns(e,t,n,r,i=0){let o=es({currentScrollTop:e.scrollTop,focusedIndex:t,itemHeight:n,topInset:i,viewportHeight:r});if(o==null)return!1;return e.scrollTop=o,!0}function jc(e,t,n,r,i,o,s=0){let a=zc({currentScrollTop:e.scrollTop,focusedIndex:t,itemHeight:n,offset:o,topInset:s,totalHeight:i,viewportHeight:r});if(a==null)return!1;return e.scrollTop=a,!0}function Nn(e,t,n,r,i,o){let s=Wc({currentScrollTop:e.scrollTop,focusedIndex:t,itemHeight:n,targetViewportOffset:o,totalHeight:i,viewportHeight:r});if(s==null)return!1;return e.scrollTop=s,!0}function rs(e,t,n,r){if(n.end<n.start)return null;if(e<n.start)return-t;if(e>n.end)return r;return null}function Kc(e){let{renamingPath:t,previousRenamingPath:n,hasRenderedInput:r}=e;if(t==null)return"reset";if(!r)return"reveal-canonical";if(n===t)return"ignore";return"focus-input"}function Uc({ariaLabel:e,isFlattened:t=!1,ref:n,value:r,onBlur:i,onInput:o}){return x("input",{ref:n,"data-item-rename-input":!0,...t?{"data-item-flattened-rename-input":!0}:{},"aria-label":e,value:r,onBlur:i,onInput:o,onClick:(s)=>s.stopPropagation(),onMouseDown:(s)=>s.stopPropagation(),onPointerDown:(s)=>s.stopPropagation()})}function Gc(e){let{row:t,mode:n,targetPath:r,ariaLabel:i,domId:o,isParked:s,itemHeight:a,features:l,state:d,extraStyle:u}=e,f=n==="sticky",c=t.ancestorPaths.at(-1)??"",m={};if(d.isFocusRinged)m["data-item-focused"]=!0;if(t.isSelected)m["data-item-selected"]=!0;if(d.isContextHovered)m["data-item-context-hover"]="true";if(d.isDragTarget)m["data-item-drag-target"]=!0;if(d.isDragging)m["data-item-dragging"]=!0;if(d.effectiveGitStatus!=null)m["data-item-git-status"]=d.effectiveGitStatus;if(d.containsGitChange)m["data-item-contains-git-change"]="true";return{"aria-expanded":!f&&t.kind==="directory"?t.isExpanded:void 0,"aria-haspopup":l.contextMenuEnabled?"menu":void 0,"aria-label":i,"aria-level":!f?t.level+1:void 0,"aria-posinset":!f?t.posInSet+1:void 0,"aria-selected":!f?t.isSelected?"true":"false":void 0,"aria-setsize":!f?t.setSize:void 0,"data-file-tree-sticky-path":f?r:void 0,"data-file-tree-sticky-row":f?"true":void 0,"data-item-context-menu-button-visibility":l.actionLaneEnabled?l.contextMenuButtonVisibility:void 0,"data-item-context-menu-trigger-mode":l.contextMenuEnabled?l.contextMenuTriggerMode:void 0,"data-item-has-context-menu-action-lane":l.actionLaneEnabled?"true":void 0,"data-item-has-git-lane":l.gitLaneActive?"true":void 0,"data-item-parent-path":c.length>0?c:void 0,"data-item-parked":s?"true":void 0,"data-item-path":r,"data-item-type":t.kind==="directory"?"folder":"file","data-type":"item",id:!f?o:void 0,role:!f?"treeitem":void 0,style:{minHeight:`${a}px`,...u},tabIndex:!f&&t.isFocused?0:-1,...m}}function Yc(e){let{event:t,mode:n,isSearchOpen:r,isDirectory:i}=e,o=t.ctrlKey||t.metaKey,s=t.shiftKey||o,a=t.shiftKey?{additive:o,kind:"range"}:o?{kind:"toggle"}:{kind:"single"};return{closeSearch:r,revealCanonical:n==="sticky",selection:a,toggleDirectory:!s&&i}}var Ln,ye,is,Xc,os=Object.is,Cr=0,iu=[],Ie=Y,Qc=Ie.__b,Zc=Ie.__r,Jc=Ie.diffed,eu=Ie.__c,tu=Ie.unmount,nu=Ie.__;function Ei(e,t){Ie.__h&&Ie.__h(ye,e,Cr||t),Cr=0;var n=ye.__H||(ye.__H={__:[],__h:[]});return e>=n.__.length&&n.__.push({}),n.__[e]}function lt(e){return Cr=1,qp(ou,e)}function qp(e,t,n){var r=Ei(Ln++,2);if(r.t=e,!r.__c&&(r.__=[n?n(t):ou(void 0,t),function(a){var l=r.__N?r.__N[0]:r.__[0],d=r.t(l,a);os(l,d)||(r.__N=[d,r.__[1]],r.__c.setState({}))}],r.__c=ye,!ye.__f)){var i=function(a,l,d){if(!r.__c.__H)return!0;var u=r.__c.__H.__.filter(function(c){return!!c.__c});if(u.every(function(c){return!c.__N}))return!o||o.call(this,a,l,d);var f=r.__c.props!==a;return u.forEach(function(c){if(c.__N){var m=c.__[0];c.__=c.__N,c.__N=void 0,os(m,c.__[0])||(f=!0)}}),o&&o.call(this,a,l,d)||f};ye.__f=!0;var{shouldComponentUpdate:o,componentWillUpdate:s}=ye;ye.componentWillUpdate=function(a,l,d){if(4&this.__g){var u=o;o=void 0,i(a,l,d),o=u}s&&s.call(this,a,l,d)},ye.shouldComponentUpdate=i}return r.__N||r.__}function as(e,t){var n=Ei(Ln++,3);!Ie.__s&&ls(n.__H,t)&&(n.__=e,n.u=t,ye.__H.__h.push(n))}function We(e,t){var n=Ei(Ln++,4);!Ie.__s&&ls(n.__H,t)&&(n.__=e,n.u=t,ye.__h.push(n))}function V(e){return Cr=5,_t(function(){return{current:e}},[])}function _t(e,t){var n=Ei(Ln++,7);return ls(n.__H,t)&&(n.__=e(),n.__H=t,n.__h=e),n.__}function Re(e,t){return Cr=8,_t(function(){return e},t)}function zp(){for(var e;e=iu.shift();)if(e.__P&&e.__H)try{e.__H.__h.forEach(_i),e.__H.__h.forEach(ss),e.__H.__h=[]}catch(t){e.__H.__h=[],Ie.__e(t,e.__v)}}Ie.__b=function(e){ye=null,Qc&&Qc(e)},Ie.__=function(e,t){e&&t.__k&&t.__k.__m&&(e.__m=t.__k.__m),nu&&nu(e,t)},Ie.__r=function(e){Zc&&Zc(e),Ln=0;var t=(ye=e.__c).__H;t&&(is===ye?(t.__h=[],ye.__h=[],t.__.forEach(function(n){n.__N&&(n.__=n.__N),n.u=n.__N=void 0})):(t.__h.forEach(_i),t.__h.forEach(ss),t.__h=[],Ln=0)),is=ye},Ie.diffed=function(e){Jc&&Jc(e);var t=e.__c;t&&t.__H&&(t.__H.__h.length&&(iu.push(t)!==1&&Xc===Ie.requestAnimationFrame||((Xc=Ie.requestAnimationFrame)||Wp)(zp)),t.__H.__.forEach(function(n){n.u&&(n.__H=n.u),n.u=void 0})),is=ye=null},Ie.__c=function(e,t){t.some(function(n){try{n.__h.forEach(_i),n.__h=n.__h.filter(function(r){return!r.__||ss(r)})}catch(r){t.some(function(i){i.__h&&(i.__h=[])}),t=[],Ie.__e(r,n.__v)}}),eu&&eu(e,t)},Ie.unmount=function(e){tu&&tu(e);var t,n=e.__c;n&&n.__H&&(n.__H.__.forEach(function(r){try{_i(r)}catch(i){t=i}}),n.__H=void 0,t&&Ie.__e(t,n.__v))};var ru=typeof requestAnimationFrame=="function";function Wp(e){var t,n=function(){clearTimeout(r),ru&&cancelAnimationFrame(t),setTimeout(e)},r=setTimeout(n,35);ru&&(t=requestAnimationFrame(n))}function _i(e){var t=ye,n=e.__c;typeof n=="function"&&(e.__c=void 0,n()),ye=t}function ss(e){var t=ye;e.__c=e.__(),ye=t}function ls(e,t){return!e||e.length!==t.length||t.some(function(n,r){return!os(n,e[r])})}function ou(e,t){return typeof t=="function"?t(e):t}function $p(e,t=null,n=null){let r=e.flattenedSegments;if(r==null||r.length===0)return t??e.name;return x("span",{"data-item-flattened-subitems":!0,children:r.map((i,o)=>{let s=o===r.length-1;return x(pt,{children:[x("span",{"data-item-flattened-subitem":i.path,"data-item-flattened-subitem-drag-target":n===i.path?"true":void 0,children:s&&t!=null?t:x(Ir,{children:i.name})}),o<r.length-1?" / ":""]},i.path)})})}function Bn(e){return e.isFlattened?e.flattenedSegments?.findLast((t)=>t.isTerminal)?.path??e.path:e.path}function us(e){let t=e.flattenedSegments;if(t==null||t.length===0)return e.name;return t.map((n)=>n.name).join(" / ")}function su(e,t,n,r){return e.map((i,o)=>{let s=o*n,a=i.subtreeEndIndex+1;if(a>=r)return{row:i.row,top:s};let l=a*n-t;return{row:i.row,top:Math.min(s,l-n)}}).filter((i)=>i.top+n>0)}function cs({controller:e,itemHeight:t,overscan:n,scrollTop:r,stickyFolders:i,viewportHeight:o}){let s=e.getVisibleCount(),a=i&&s>0?e.getStickyRowCandidates(r,t):[],l=a==null&&i&&s>0?e.getVisibleRows(0,s-1):[],d=Bc(l,{itemHeight:t,overscan:n,scrollTop:r,stickyRows:a==null?void 0:su(a,r,t,s),totalRowCount:s,viewportHeight:o}),u=i&&r<=0&&s>0?e.getStickyRowCandidates(1,t):[],f=u!=null&&r<=0?su(u,1,t,s):i&&r<=0&&l.length>0?Jo(l,1,t):d.sticky.rows;return{overlayHeight:f.reduce((c,m)=>Math.max(c,m.top+t),0),overlayRows:f,snapshot:d,visibleRows:l}}var jp=400,au=10,Fn=40,lu=18;function Kp(e,t,n){let r=e,i=document.elementFromPoint?.bind(document)??null,o=r.elementFromPoint?.(t,n)??i?.(t,n)??null;if(e instanceof ShadowRoot&&(o==null||!e.contains(o)))return Up(e,t,n);return o instanceof HTMLElement?o:null}function Up(e,t,n){let r=Array.from(e.querySelectorAll('[data-type="item"], [data-item-flattened-subitem]'));for(let i=r.length-1;i>=0;i--){let o=r[i],s=o.getBoundingClientRect();if(t>=s.left&&t<=s.right&&n>=s.top&&n<=s.bottom)return o}return null}function cu(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 o=t.dataset.itemParentPath??null;if(o==null||o.length===0)return{directoryPath:null,flattenedSegmentPath:null,hoveredPath:n,kind:"root"};return{directoryPath:o,flattenedSegmentPath:null,hoveredPath:n,kind:"directory"}}function uu(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 Gp(){return navigator.vendor!=="Apple Computer, Inc."}function Yp(e,t){let n=e-t.top;if(n<Fn)return-Math.ceil((Fn-Math.max(0,n))/Fn*lu);let r=t.bottom-e;if(r<Fn)return Math.ceil((Fn-Math.max(0,r))/Fn*lu);return 0}function Xp(e,t){if(e!=null){let n=Hc[e];if(n==null)return null;return{text:n,title:Vc[e]}}if(t)return{icon:{name:"file-tree-icon-dot",width:6,height:6},title:Oc};return null}function Qp(e,t,n){if(t==null||t.size===0)return null;let r=[];for(let i=e.length-1;i>=0;i-=1){let o=e[i],s=n.get(o);if(s!=null){for(let a of r)n.set(a,s);return s?"ignored":null}if(t.has(o)){n.set(o,!0);for(let a of r)n.set(a,!0);return"ignored"}r.push(o)}for(let i of r)n.set(i,!1);return null}function du(e){return e!=null&&"toggle"in e}function bu(e){return e.code==="Space"||e.key===" "||e.key==="Spacebar"}function Zp(e){return e.key.length===1&&/^[\p{L}\p{N}]$/u.test(e.key)&&!e.ctrlKey&&!e.metaKey&&!e.altKey}function Jp(e){if(e==null)return"";return`[data-item-section="spacing-item"][data-ancestor-path="${e.replaceAll("\\","\\\\").replaceAll('"',"\\\"")}"] { opacity: 1; }`}function wu(e){return e.shiftKey&&e.key==="F10"||e.key==="ContextMenu"}function em(e,t){if(t&&wu(e))return!0;if((e.ctrlKey||e.metaKey)&&bu(e))return!0;return e.key==="ArrowDown"||e.key==="ArrowLeft"||e.key==="ArrowRight"||e.key==="ArrowUp"}var tm=new Set(["ArrowDown","ArrowLeft","ArrowRight","ArrowUp","End","Home","PageDown","PageUp"]);function hu(e){for(let t of e.composedPath()){if(!(t instanceof HTMLElement))continue;if(t.dataset.fileTreeContextMenuRoot==="true")return!0;if(t.dataset.type==="context-menu-anchor"||t.dataset.type==="context-menu-trigger")return!0;if(t.getAttribute("slot")==="context-menu")return!0}return!1}function nm(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 rm(e,t){return{bottom:t,height:0,left:e,right:e,top:t,width:0,x:e,y:t}}function im(e,t){if(e==null)return t.offsetTop;let n=t.getBoundingClientRect(),r=e.getBoundingClientRect();return n.top-r.top}function fu(e,t,n){if(n==null){e.delete(t);return}e.set(t,n)}function pu(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 om(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 r=n.dataset.fileTreeStickyPath;if(r!=null)t.push(r)}return t}function sm(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 am(e,t,n,r,i,o,s){let a=Math.max(0,o-i),l=t?.getBoundingClientRect()??null,d=l==null||n==null?null:n.getBoundingClientRect().top-l.top,u=sm(e,r),f=l==null||u==null?null:u.getBoundingClientRect().top-l.top;return Math.max(0,Math.min(f??Math.max(d??0,a),Math.max(0,s-i)))}function mu(e,t){return{kind:e.kind,name:us(e),path:t}}function lm(e){return e==null?void 0:`${e}__tree`}function Iu(e,t,n){if(e==null)return;return`${e}__focused-item-${encodeURIComponent(t)}${n?"__parked":""}`}function gu(e){return e==="file-tree-icon-chevron"||e==="file-tree-icon-dot"||e==="file-tree-icon-file"||e==="file-tree-icon-lock"}function vu(e,t){if(e==null)return null;if("text"in e){if(e.parts!=null)return x("span",{title:e.title,children:e.parts.map((r,i)=>x("span",{style:{color:r.color},children:r.text},i))});return x("span",{title:e.title,children:e.text})}let n=typeof e.icon==="string"?gu(e.icon)?t(e.icon):{name:e.icon}:gu(e.icon.name)?(()=>{let r=t(e.icon.name),{name:i,...o}=e.icon;return{...r,...o}})():e.icon;return x("span",{title:e.title,children:x(Mn,{...n})})}function yu(e){if(e==null)return;cn(e.querySelector(["button:not([disabled])","[href]","input:not([disabled])","select:not([disabled])","textarea:not([disabled])",'[tabindex]:not([tabindex="-1"])'].join(", "))??e)}function cm(e,t,{actionLaneEnabled:n=!1,customDecoration:r=null,decorationLaneEnabled:i=!1,dragTargetFlattenedSegmentPath:o=null,gitDecoration:s=null,gitLaneActive:a=!1,renameInput:l=null,showDecorativeActionAffordance:d=!1}={}){let u=Bn(e);return x(pt,{children:[e.depth>0?x("div",{"data-item-section":"spacing",children:Array.from({length:e.depth}).map((f,c)=>x("div",{"data-item-section":"spacing-item","data-ancestor-path":e.ancestorPaths[c]},c))}):null,x("div",{"data-item-section":"icon",children:e.kind==="directory"?x(Mn,{...t("file-tree-icon-chevron")}):x(Mn,{...t("file-tree-icon-file",u)})}),x("div",{"data-item-section":"content",children:e.isFlattened?$p(e,l,o):l??x(Nc,{minimumLength:5,split:"extension",children:e.name})}),i?x("div",{"data-item-section":"decoration",children:r!=null?vu(r,t):null}):null,a?x("div",{"data-item-section":"git",children:vu(s,t)}):null,n?x("div",{"data-item-section":"action",children:d?x("span",{"aria-hidden":"true","data-item-action-affordance":"decorative",children:x(Mn,{...t("file-tree-icon-ellipsis")})}):null}):null]})}function Ti(e,t,n,r={}){let{controller:i,renameView:o,visualFocusPath:s,contextHoverPath:a,draggedPathSet:l,dragTarget:d,dragAndDropEnabled:u,shouldSuppressContextMenu:f,handleRowDragStart:c,handleRowDragEnd:m,handleRowTouchStart:p,instanceId:g,itemHeight:v,gitStatusByPath:I,ignoredGitDirectories:C,ignoredInheritanceCache:y,directoriesWithGitChanges:S,gitLaneActive:k,contextMenuEnabled:T,contextMenuTriggerMode:O,contextMenuButtonTriggerEnabled:pe,contextMenuButtonVisibility:Z,contextMenuRightClickEnabled:me,registerRenameInput:J,registerButton:U,resolveIcon:B,renderDecorationForRow:ae,openContextMenuForRow:Ce,onRowClick:z,onKeyDown:le}=e,X=Bn(t),{isParked:be=!1,mode:oe="flow",style:bt}=r,Ve=oe==="sticky",ct=I?.get(X)??null??Qp(t.ancestorPaths,C,y),Rt=t.kind==="directory"&&(S?.has(X)??!1),nt=ae(t,X),je=Xp(ct,Rt),Te=T&&pe,Oe=nt!=null||k||Te,Ut=Te&&Z==="always",ke=o.getPath()===X,wt=ke?o.getValue():"",Ke=Ve||!ke?null:x(Uc,{ref:J,ariaLabel:`Rename ${us(t)}`,isFlattened:t.isFlattened,value:wt,onBlur:()=>{o.commit()},onInput:(we)=>{o.setValue(we.currentTarget.value)}}),Gt=cm(t,B,{actionLaneEnabled:Te,customDecoration:nt,decorationLaneEnabled:Oe,dragTargetFlattenedSegmentPath:d?.flattenedSegmentPath??null,gitDecoration:je,gitLaneActive:k,renameInput:Ke,showDecorativeActionAffordance:Ut}),rt={...Gc({ariaLabel:us(t),domId:t.isFocused?Iu(g,X,be):void 0,extraStyle:bt,features:{actionLaneEnabled:Te,contextMenuButtonVisibility:Te?Z:null,contextMenuEnabled:T,contextMenuTriggerMode:T?O:null,gitLaneActive:k},isParked:be,itemHeight:v,mode:oe,row:t,state:{containsGitChange:Rt,effectiveGitStatus:ct,isContextHovered:a===X,isDragTarget:d?.kind==="directory"&&d.directoryPath===X,isDragging:l?.has(X)===!0,isFocusRinged:t.isFocused&&s===X},targetPath:X}),key:n,onContextMenu:T||u?(we)=>{if(f()){we.preventDefault();return}if(!T)return;if(we.preventDefault(),!me)return;i.focusMountedPathFromInput(X),Ce(t,X,{anchorRect:rm(we.clientX,we.clientY),source:"right-click"})}:void 0,onFocus:!Ve?()=>{i.focusMountedPathFromInput(X)}:void 0,onKeyDown:!Ve?le:void 0,ref:(we)=>{U(X,we)}};if(!Ve&&ke)return x("div",{...rt,children:Gt});return x("button",{...rt,type:"button",draggable:u&&!be,onDragEnd:u&&!be?m:void 0,onDragStart:u&&!be?(we)=>{c(we,t,X)}:void 0,onMouseDown:(we)=>{if(Ve){we.preventDefault();return}if(i.isSearchOpen())we.preventDefault()},onTouchStart:u&&!be?(we)=>{p(we,t,X)}:void 0,onClick:(we)=>{z(we,t,X,oe)},children:Gt})}function um(e,t,n){if(t.end<t.start)return[];return e.controller.getVisibleRows(t.start,t.end).filter((r)=>!n.has(Bn(r))).map((r,i)=>Ti(e,r,t.start+i))}function ds({composition:e,controller:t,gitStatusByPath:n,ignoredGitDirectories:r,directoriesWithGitChanges:i,icons:o,instanceId:s,itemHeight:a=fi,overscan:l=10,renamingEnabled:d=!1,renderRowDecoration:u,searchBlurBehavior:f="close",searchEnabled:c=!1,searchFakeFocus:m=!1,slotHost:p,stickyFolders:g=!1,initialViewportHeight:v=420}){let I=V(null),C=V(null),y=V(!1),S=V(null),k=V(null),T=V(null),O=V(null),pe=V(null),Z=V(new Map),me=V(new Map),J=V(()=>{}),U=V(null),B=V(0),ae=V(!1),Ce=V(null);if(Ce.current!==t)ae.current=!1,Ce.current=t;let z=V(!1),le=V(null),X=V(null),be=V(!1),oe=V(null),bt=V(null),Ve=V(null),ct=V(null),Rt=V(null),nt=V(null),je=V(null),Te=V(null),Oe=V(!1),Ut=V(null),ke=V(null),wt=V(null),Ke=V(null),Gt=_t(()=>new Map,[]),[,rt]=lt(0),we=V(!1),[ut,it]=lt(null),[fn,Yt]=lt(null),[Dt,pn]=lt(null),[Ue,Ae]=lt(null),[Wi,he]=lt(0),[G,mn]=lt(null),dt=V(G);dt.current=G;let Mt=V(null),Xt=V(null),Qt=V(null),Zt=V(null),w=V(null),M=V(!1),H=()=>{Xt.current=null,Qt.current=null,Zt.current=null},j=(h,b)=>{Xt.current=h,Qt.current=null,Zt.current=b==null?null:{path:h,scrollTop:b}},It=(h,b)=>{Xt.current=null,Qt.current={path:h,viewportOffset:b},Zt.current=null},Jt=V(f==="retain"&&t.isSearchOpen()),[Yn,Ms]=lt(m);as(()=>{if(!m)Ms(!1)},[m]);let As=V(!1),$i=Re(()=>{As.current=!0,Ms((h)=>h?!1:h)},[]),[jd,Kd]=lt(()=>cs({controller:t,itemHeight:a,overscan:l,scrollTop:0,stickyFolders:g,viewportHeight:v})),[Ud,Gd]=lt(!1);as(()=>{Gd(!0)},[]);let qe=e?.contextMenu?.enabled===!0||e?.contextMenu?.render!=null||e?.contextMenu?.onOpen!=null||e?.contextMenu?.onClose!=null,gn=e?.contextMenu?.triggerMode??(qe?"right-click":"both"),vn=gn==="both"||gn==="button",Ns=e?.contextMenu?.buttonVisibility??"when-needed",Yd=gn==="both"||gn==="right-click";We(()=>{let h=T.current;if(h==null)return;let b=(_)=>{if(!(_ instanceof CustomEvent))return;let P=_.detail?.path??null;w.current=P,Yt(P),Ae(P==null?null:"pointer")},N=(_)=>{if(!(_ instanceof CustomEvent))return;M.current=_.detail?.disabled===!0};return h.addEventListener("file-tree-debug-set-context-menu-trigger",b),h.addEventListener("file-tree-debug-set-scroll-suppression",N),()=>{h.removeEventListener("file-tree-debug-set-context-menu-trigger",b),h.removeEventListener("file-tree-debug-set-scroll-suppression",N)}},[]);let Xd=Re((h,b)=>{fu(Z.current,h,b)},[]),Qd=Re((h,b)=>{fu(me.current,h,b)},[]),Zd=Re((h)=>{k.current=h},[]),Xn=Re((h)=>pu(h,me.current,Z.current),[]),Ls=n!=null||r!=null||i!=null,{resolveIcon:Fs}=_t(()=>pc(o),[o]),Qn=t[Oo](),yn=Qn.getPath(),ji=yn!=null,ht=t.isSearchOpen(),Jd=t.getSearchValue(),W=t.getFocusedPath(),ne=t.getFocusedIndex(),en=t.getScrollRequest(),St=t.isDragAndDropEnabled(),Zn=t.getDragSession(),eh=_t(()=>Zn==null?null:new Set(Zn.draggedPaths),[Zn]),th=Zn?.target??null,Jn=Zn?.primaryPath??null,Bs=lm(s),{overlayHeight:nh,overlayRows:rh,snapshot:xe,visibleRows:Lr}=jd,Pe=xe.physical.viewportHeight,ot=_t(()=>({end:xe.window.endIndex,start:xe.window.startIndex}),[xe.window.endIndex,xe.window.startIndex]),er=rh,Hs=xe.sticky.rows,tn=xe.physical.totalHeight,bn=xe.sticky.height,Fr=_t(()=>new Set(Hs.map((h)=>Bn(h.row))),[Hs]),Ki=ne>=0&&ne>=ot.start&&ne<=ot.end,ih=Re((h,b)=>u?.({item:mu(h,b),row:h})??null,[u]),Vs=Re((h)=>{if(cn(h==null?null:Z.current.get(h)??null))return!0;return cn(T.current)},[]),Br=Re((h)=>{Vs(t.focusNearestPath(h))},[t,Vs]),Os=V(Br);Os.current=Br;let wn=V(!0),Ui=V(()=>{}),Qe=Re((h=!0)=>{let b=dt.current;if(b==null)return;if(wn.current=wn.current&&h,mn(null),e?.contextMenu?.onClose?.(),wn.current)Br(b.path)},[e?.contextMenu,Br]);Ui.current=Qe;let tr=Re((h)=>{let b=h==null?null:im(T.current,h);pn((N)=>N===b?N:b)},[]),qs=Re((h,b,N)=>{let _=t.getItem(b);if(_==null)return;let P=Xn(b);if(P?.dataset.fileTreeStickyRow==="true"){let F=O.current;j(b,F?.scrollTop??null),z.current=!0,it((ce)=>ce===b?ce:b)}_.focus(),tr(P),wn.current=!0,mn({anchorRect:N?.anchorRect??null,item:mu(h,b),path:b,source:N?.source??"keyboard"})},[t,Xn,tr]),oh=Re((h)=>{if(!d)return;if(t.isSearchOpen()){let b=O.current,N=An(b,Pe);oe.current=ne<0||b==null?null:Math.max(0,Math.min(ne*a-b.scrollTop,Math.max(0,N-a))),be.current=!0}if(t.startRenaming(h)===!1)return;Ae("focus"),rt((b)=>b+1)},[t,ne,a,d,Pe]),Hr=Re((h,{restoreTreeFocus:b=!0,targetOffset:N="live-overlay"}={})=>{let _=O.current;if(_==null)return!1;t.focusPath(h);let P=t.getFocusedIndex();if(P<0)return!1;let F=t.getVisibleRows(P,P)[0]??null;if(F==null)return!1;let ce=An(_,Pe),L=t.getVisibleCount()*a,ee=N==="sticky-parents"?F.ancestorPaths.length*a:cs({controller:t,itemHeight:a,overscan:l,scrollTop:_.scrollTop,stickyFolders:g,viewportHeight:ce}).snapshot.sticky.height;return z.current=!0,Nn(_,P,a,ce,L,ee),J.current(),Mt.current=b?h:null,!0},[t,a,l,Pe,g]),sh=()=>y.current===!0||Ke.current!=null||Oe.current===!0,zs=(h)=>typeof window.requestAnimationFrame==="function"?window.requestAnimationFrame(()=>{h()}):window.setTimeout(h,16),ah=(h)=>{if(h==null)return;if(typeof window.cancelAnimationFrame==="function"){window.cancelAnimationFrame(h);return}window.clearTimeout(h)},At=()=>{if(ct.current!=null)clearTimeout(ct.current),ct.current=null;Ve.current=null},Vr=()=>{nt.current?.remove(),nt.current=null},nr=()=>{ah(bt.current),bt.current=null,Rt.current=null},Ws=(h)=>{let b=T.current?.getRootNode();if(b instanceof ShadowRoot){b.append(h);return}document.body.append(h)},rr=()=>{if(Te.current?.(),Te.current=null,Ke.current!=null)clearTimeout(Ke.current),Ke.current=null;if(Oe.current=!1,Ut.current=null,wt.current=null,ke.current!=null)ke.current.setAttribute("draggable","true"),ke.current.style.removeProperty("touch-action"),ke.current=null;Vr(),At(),nr(),je.current=null},Or=(h,b)=>{let N=T.current?.getRootNode(),_=cu(Kp(N instanceof ShadowRoot?N:document,h,b));return t.setDragTarget(_),t.getDragSession()?.target??null},Gi=(h)=>{let b=t.getDragAndDropConfig()?.openOnDropDelay??800;if(h==null||h.kind!=="directory"||h.directoryPath==null||b<=0){At();return}let N=t.getItem(h.directoryPath),_=du(N)?N:null;if(_==null||_.isExpanded()){At();return}let P=`${h.directoryPath}::${h.flattenedSegmentPath??""}`;if(Ve.current===P)return;At(),Ve.current=P,ct.current=setTimeout(()=>{let F=t.getDragSession()?.target;if(F?.kind!=="directory"||F.directoryPath!==h.directoryPath||F.flattenedSegmentPath!==h.flattenedSegmentPath)return;_.expand()},b)},$s=()=>{bt.current=null;let h=Rt.current,b=O.current;if(h==null||b==null||t.getDragSession()==null)return;let N=b.getBoundingClientRect(),_=Yp(h.clientY,N);if(_===0)return;let P=Math.max(0,b.scrollHeight-b.clientHeight),F=Math.max(0,Math.min(P,b.scrollTop+_));if(F!==b.scrollTop)b.scrollTop=F,J.current();Gi(Or(h.clientX,h.clientY)),bt.current=zs($s)},js=(h,b)=>{Rt.current={clientX:h,clientY:b},bt.current??=zs($s)},lh=(h,b,N)=>{let _=h.currentTarget;if(_==null)return;if(rr(),Vr(),At(),nr(),t.startDrag(N)===!1){h.preventDefault();return}if(je.current=b,h.dataTransfer!=null){if(h.dataTransfer.effectAllowed="move",h.dataTransfer.dropEffect="move",h.dataTransfer.setData("text/plain",N),Gp()){let P=uu(_),F=_.getBoundingClientRect();Object.assign(P.style,{height:`${F.height}px`,opacity:"0.85",transform:"translate3d(-9999px, 0px, 0)",width:`${F.width}px`}),Ws(P),nt.current=P,h.dataTransfer.setDragImage(P,Math.max(0,h.clientX-F.left),Math.max(0,h.clientY-F.top))}}},ch=()=>{Vr(),At(),nr(),je.current=null,t.cancelDrag()},uh=(h,b,N)=>{if(Ke.current!=null||Oe.current)return;let _=h.touches[0],P=h.currentTarget;if(_==null||P==null)return;wt.current={clientX:_.clientX,clientY:_.clientY},ke.current=P,P.setAttribute("draggable","false");let F=(ee={})=>{let se=ee.restoreNativeDraggable??!Oe.current;if(Ke.current!=null)clearTimeout(Ke.current),Ke.current=null;if(document.removeEventListener("touchmove",ce),document.removeEventListener("touchend",L),document.removeEventListener("touchcancel",L),Te.current===F)Te.current=null;if(se){if(P.setAttribute("draggable","true"),ke.current===P)ke.current=null;wt.current=null}},ce=(ee)=>{let se=ee.touches[0],re=wt.current;if(se==null||re==null)return;let fe=se.clientX-re.clientX,De=se.clientY-re.clientY;if(fe*fe+De*De<=au*au)return;F()},L=()=>{F()};document.addEventListener("touchmove",ce,{passive:!0}),document.addEventListener("touchend",L),document.addEventListener("touchcancel",L),Te.current=F,Ke.current=setTimeout(()=>{if(F({restoreNativeDraggable:!1}),t.startDrag(N)===!1){if(P.setAttribute("draggable","true"),ke.current===P)ke.current=null;wt.current=null;return}Oe.current=!0,ke.current=P,P.setAttribute("draggable","false"),P.style.setProperty("touch-action","none"),je.current=b;let ee=P.getBoundingClientRect(),se=uu(P);Object.assign(se.style,{height:`${ee.height}px`,opacity:"0.85",transform:`translate3d(${ee.left}px, ${ee.top}px, 0)`,width:`${ee.width}px`}),Ws(se),nt.current=se,Ut.current={x:_.clientX-ee.left,y:_.clientY-ee.top};let re=(st)=>{let Se=st.touches[0];if(Se==null)return;st.preventDefault();let Q=Ut.current;if(Q!=null&&nt.current!=null)nt.current.style.transform=`translate3d(${Se.clientX-Q.x}px, ${Se.clientY-Q.y}px, 0)`;Gi(Or(Se.clientX,Se.clientY)),js(Se.clientX,Se.clientY)},fe=(st)=>{let Se=st.changedTouches[0];if(Se!=null)Or(Se.clientX,Se.clientY);t.completeDrag(),rr()},De=()=>{t.cancelDrag(),rr()};Te.current=()=>{document.removeEventListener("touchmove",re),document.removeEventListener("touchend",fe),document.removeEventListener("touchcancel",De)},document.addEventListener("touchmove",re,{passive:!1}),document.addEventListener("touchend",fe),document.addEventListener("touchcancel",De)},jp)},Ks=(h)=>{if(G!=null){if(h.key==="Escape"){Qe(),h.preventDefault(),h.stopPropagation();return}if(tm.has(h.key))h.preventDefault(),h.stopPropagation();return}if(Qn.isActive()){if(h.isComposing||h.keyCode===229)return;if(h.key==="Escape")Qn.cancel();else if(h.key==="Enter")Qn.commit();else return;Ae("focus"),rt((ve)=>ve+1),h.preventDefault(),h.stopPropagation();return}if(d&&h.key==="F2"){oh(W??void 0),h.preventDefault(),h.stopPropagation();return}if(ht){if(h.key==="Escape")be.current=!1,oe.current=null,t.closeSearch();else if(h.key==="Enter"){let ve=t.getFocusedPath();if(ve!=null)t.selectOnlyPath(ve);let ft=O.current,jr=An(ft,Pe);oe.current=ne<0||ft==null?null:Math.max(0,Math.min(ne*a-ft.scrollTop,Math.max(0,jr-a))),be.current=!0,t.closeSearch()}else if(h.key==="ArrowDown")t.focusNextSearchMatch();else if(h.key==="ArrowUp")t.focusPreviousSearchMatch();else return;Ae("focus"),rt((ve)=>ve+1),h.preventDefault(),h.stopPropagation();return}if(c&&Zp(h)){t.openSearch(h.key),rt((ve)=>ve+1),h.preventDefault(),h.stopPropagation();return}let b=qe&&wu(h),N=em(h,qe),_=N&&T.current!=null?Sr(T.current):null,P=N?new Set(om(T.current)):new Set,F=_?.dataset.fileTreeStickyPath??null,ce=_?.dataset.fileTreeStickyRow==="true"&&F!=null;if(ce&&F!==W&&P.has(F)){let ve=O.current;j(F,ve?.scrollTop??null),t.focusPath(F)}let L=t.getFocusedPath(),ee=t.getFocusedIndex(),se=t.getFocusedItem();if(se==null)return;let re=du(se)?se:null,fe=L!=null&&(Fr.has(L)||ce&&F===L&&P.has(L)),De=h.key==="ArrowDown"||h.key==="ArrowUp"||h.key==="ArrowRight"&&re!=null&&re.isExpanded(),st=h.key==="ArrowLeft"&&fe&&re!=null&&re.isExpanded(),Se=O.current,Q=!0;if(h.shiftKey&&h.key==="ArrowDown")t.extendSelectionFromFocused(1);else if(h.shiftKey&&h.key==="ArrowUp")t.extendSelectionFromFocused(-1);else if(b&&L!=null&&ee>=0){let ve=t.getVisibleRows(ee,ee)[0]??null,ft=pu(L,me.current,Z.current);if(ve==null||ft==null)Q=!1;else qs(ve,L)}else if((h.ctrlKey||h.metaKey)&&bu(h))t.toggleFocusedSelection();else if((h.ctrlKey||h.metaKey)&&h.key.toLowerCase()==="a")t.selectAllVisiblePaths();else switch(h.key){case"ArrowDown":t.focusNextItem();break;case"ArrowUp":t.focusPreviousItem();break;case"ArrowRight":if(re==null||re.isExpanded())t.focusNextItem();else re.expand();break;case"ArrowLeft":if(re!=null&&re.isExpanded())re.collapse();else t.focusParentItem();break;case"Home":t.focusFirstItem();break;case"End":t.focusLastItem();break;default:Q=!1}if(!Q)return;Ae("focus");let ge=t.getFocusedPath(),Ne=ge!=null&&(Fr.has(ge)||P.has(ge)),Wr=De&&ge!==L,$r=b&&ce&&F===L&&ge===L;if((fe||$r)&&ge!=null&&(Wr&&Ne||$r))j(ge,Se?.scrollTop??null),z.current=!0,it((ve)=>ve===ge?ve:ge);else{let ve=h.key==="ArrowUp"&&fe&&ge!==L;if(ge!=null&&(ve||st&&ge===L))It(ge,am(T.current,Se,_,L,a,bn,Pe)),z.current=!0,it((ft)=>ft===ge?ft:ge);else H()}rt((ve)=>ve+1),h.preventDefault(),h.stopPropagation()};We(()=>{if(!c||!ht)return;if(Jt.current){Jt.current=!1;return}cn(pe.current)},[ht,c]),We(()=>{let h=k.current;switch(Kc({hasRenderedInput:h!=null,previousRenamingPath:X.current,renamingPath:yn})){case"reset":X.current=null;return;case"reveal-canonical":if(yn!=null)Hr(yn,{restoreTreeFocus:!1,targetOffset:"live-overlay"});return;case"ignore":return;case"focus-input":if(h!=null)Mt.current=null,X.current=yn,cn(h),h.select();return}},[ot.end,ot.start,yn,Hr,Fr]),We(()=>{let h=T.current;if(h==null)return;let b=null,N=()=>{if(b==null)return;clearTimeout(b),b=null},_=()=>{let ce=Sr(h)?.dataset.itemPath??null;it((L)=>L===ce?L:ce)},P=()=>{N(),z.current=!0,_()},F=(ce)=>{let L=ce.relatedTarget;if(L==null){N(),b=setTimeout(()=>{if(b=null,Sr(h)!=null){_();return}z.current=!1,it(null)},0);return}if(!(L instanceof Node)||!h.contains(L)){N(),z.current=!1,it(null);return}let ee=L instanceof HTMLElement?L.dataset.itemPath??null:null;it((se)=>se===ee?se:ee)};return h.addEventListener("focusin",P),h.addEventListener("focusout",F),()=>{N(),h.removeEventListener("focusin",P),h.removeEventListener("focusout",F)}},[]),We(()=>{let h=T.current;if(h==null)return;if(xe.physical.scrollTop<=0)h.dataset.scrollAtTop="true";else delete h.dataset.scrollAtTop},[xe.physical.scrollTop]),We(()=>{let h=null,b=O.current,N=S.current,_=T.current;if(b==null)return;U.current=An(b,v);let P=()=>{let Q=t.getVisibleCount(),ge=ts(U.current,v),Ne=Math.max(0,Q*a-ge);if(b.scrollTop>Ne)b.scrollTop=Ne;Kd(cs({controller:t,itemHeight:a,overscan:l,scrollTop:Math.min(b.scrollTop,Ne),stickyFolders:g,viewportHeight:ge}))};if(!ae.current){ae.current=!0;let Q=t.getFocusedIndex();if(Q>=0){let ge=ts(U.current,v),Ne=t.getVisibleRows(Q,Q)[0]??null;ns(b,Q,a,ge,g&&Ne!=null?Math.max(0,Math.min(Ne.ancestorPaths.length*a,Math.max(0,ge-a))):0)}}J.current=P;let F=t.subscribe(()=>{if(qc(we))rt((Q)=>Q+1);P()}),ce=()=>{if(M.current===!0)return;if(N!=null)N.dataset.isScrolling??="";if(_!=null)_.dataset.isScrolling??="";if(y.current=!0,h!=null)clearTimeout(h);h=setTimeout(()=>{if(N!=null)delete N.dataset.isScrolling;if(_!=null)delete _.dataset.isScrolling;y.current=!1,he((Q)=>Q+1),h=null},50)},L=null,ee=()=>{if(_!=null)delete _.dataset.overlayReveal;if(L!=null)clearTimeout(L),L=null},se=()=>{if(_==null||M.current===!0)return;if(b.scrollTop>0)return;if(_.dataset.overlayReveal="true",L!=null)clearTimeout(L);L=setTimeout(()=>{ee()},200)},re=()=>{if(P(),b.scrollTop>0)ee();if(dt.current!=null&&y.current)Ui.current();if(M.current===!0){y.current=!1;return}Yt((Q)=>Q==null?Q:null),ce()},fe=()=>{ce(),se()},De=new Set(["ArrowUp","ArrowDown","ArrowLeft","ArrowRight","PageUp","PageDown","Home","End"," ","Spacebar"]),st=(Q)=>{if(!De.has(Q.key))return;fe()};b.addEventListener("scroll",re,{passive:!0}),b.addEventListener("wheel",fe,{passive:!0}),b.addEventListener("touchmove",fe,{passive:!0}),b.addEventListener("keydown",st);let Se=typeof ResizeObserver<"u"?new ResizeObserver((Q)=>{U.current=(Q[0]==null?null:$c(Q[0]))??An(b,v),P()}):null;return Se?.observe(b),()=>{if(J.current=()=>{},F(),b.removeEventListener("scroll",re),b.removeEventListener("wheel",fe),b.removeEventListener("touchmove",fe),b.removeEventListener("keydown",st),h!=null)clearTimeout(h);if(L!=null)clearTimeout(L);if(N!=null)delete N.dataset.isScrolling;if(_!=null)delete _.dataset.isScrolling,delete _.dataset.overlayReveal;y.current=!1,U.current=null,Se?.disconnect()}},[t,v,a,l,g]),We(()=>{if(qe||G==null)return;Qe(!1)},[Qe,qe,G]);let Us=_t(()=>G==null?null:`${G.path}::${G.source}`,[G]);We(()=>{if(Us==null){p?.clearSlotContent(vr);return}let h=dt.current;if(h==null)return;let b=C.current??I.current;if(b==null)return;let N={anchorElement:b,anchorRect:h.anchorRect??nm(b.getBoundingClientRect()),close:(P)=>{Ui.current(P?.restoreFocus??!0)},restoreFocus:()=>{if(!wn.current)return;Os.current(dt.current?.path??null)}},_=e?.contextMenu?.render?.(h.item,N)??null;return p?.setSlotContent(vr,_),e?.contextMenu?.onOpen?.(h.item,N),yu(_),queueMicrotask(()=>{if(_==null||!_.isConnected)return;if(document.activeElement!==_)return;yu(_)}),()=>{p?.clearSlotContent(vr)}},[Us,e?.contextMenu,p]),We(()=>{if(G!=null&&t.getItem(G.path)==null)Qe()},[Qe,G,t]),We(()=>{if(G==null)return;let h=T.current?.getRootNode(),b=h instanceof ShadowRoot?h.host:T.current,N=(P)=>{let F=P.target;if(!(F instanceof Node))return;if(hu(P))return;if(I.current?.contains(F)===!0)return;if(b?.contains(F)===!0)return;Qe()},_=(P)=>{if(P.key==="Escape")P.preventDefault(),P.stopPropagation(),Qe()};return document.addEventListener("mousedown",N,!0),document.addEventListener("keydown",_,!0),()=>{document.removeEventListener("mousedown",N,!0),document.removeEventListener("keydown",_,!0)}},[Qe,G]),We(()=>{let h=O.current,b=T.current;if(h==null||b==null){le.current=W;return}let N=W==null?null:Z.current.get(W)??null,_=Sr(b),P=_?.dataset.itemPath??null,F=ji&&k.current===_,ce=c&&pe.current===_,L=be.current&&!ht,ee=oe.current??0,se=Mt.current,re=Xt.current,fe=Qt.current,De=Zt.current,st=_!=null,Se=z.current||st,Q=le.current!==W,ge=re!=null&&re===W&&W!=null,Ne=!1,Wr=!1;if(en!=null&&en.id!==B.current){B.current=en.id;let Xi=en.visibleIndex,Zs=t.getVisibleRows(Xi,Xi)[0]??null;if(Zs!=null){let Fh=g?Math.max(0,Math.min(Zs.ancestorPaths.length*a,Math.max(0,Pe-a))):bn;Ne=!0,Wr=jc(h,Xi,a,Pe,tn,en.offset,Fh)}t.clearScrollRequest(en.id)}let $r=!Ne&&L&&Nn(h,ne,a,Pe,tn,ee),ve=!Ne&&se!=null&&se===W&&Nn(h,ne,a,Pe,tn,bn),ft=!Ne&&fe!=null&&fe.path===W&&Nn(h,ne,a,Pe,tn,fe.viewportOffset),jr=!Ne&&De!=null&&De.path===W&&h.scrollTop!==De.scrollTop;if(jr)h.scrollTop=De.scrollTop;if(jr||Wr||ve||ft||$r||Se&&Q&&se!==W&&!ge&&ns(h,ne,a,Pe,bn))J.current();if(Ne){le.current=W;return}if(!Se){le.current=W;return}if(F){le.current=W;return}if(ce&&!L){le.current=W;return}if(N==null){if(L&&ne>=0)Nn(h,ne,a,Pe,tn,ee),J.current();le.current=W;return}if(Q||L||se===W||re===W||fe?.path===W||De?.path===W||P==null||P!==W){if(cn(N),se===W)Mt.current=null;if(re===W)Xt.current=null;if(fe?.path===W)Qt.current=null;if(De?.path===W)Zt.current=null;be.current=!1,oe.current=null}le.current=W},[t,ne,W,Ki,a,ji,ht,ot,Pe,c,en,g,bn,tn,Lr]);let dh=ne>=0&&ne>=xe.visible.startIndex&&ne<=xe.visible.endIndex,hh=W!=null&&er.some((h)=>Bn(h.row)===W),fh=dh||hh,ph=vn&&z.current===!0&&fh?W:null,mh=Ue==="pointer"?fn:null,nn=G?.path??w.current??mh??ph??fn,Gs=G?.source==="right-click";We(()=>{if(y.current&&G==null)return;tr(Xn(nn))},[G,Xn,ot,Pe,Wi,er,nn,tr,Lr]);let gh=Re((h)=>{if(y.current)return;if(hu(h))return;let b=h.target;if(!(b instanceof HTMLElement))return;if(b.closest?.('[data-type="context-menu-trigger"]')!=null)return;let N=b.closest?.('[data-file-tree-sticky-row="true"]'),_=b.closest?.('[data-type="item"]'),P=N instanceof HTMLElement?N.dataset.fileTreeStickyPath??null:_ instanceof HTMLElement?_.dataset.itemPath??null:null;if(P!=null)Ae((F)=>F==="pointer"?F:"pointer");Yt((F)=>F===P?F:P)},[]),vh=Re(()=>{Yt(null)},[]);We(()=>{if(!St)return;let h=()=>{rr(),t.cancelDrag()};return window.addEventListener("dragend",h),()=>{window.removeEventListener("dragend",h),rr(),t.cancelDrag()}},[t,St]);let yh=(h)=>{if(!St||t.getDragSession()==null||Oe.current)return;let b=cu(h.target instanceof HTMLElement?h.target:null);if(t.setDragTarget(b),Gi(t.getDragSession()?.target??null),js(h.clientX,h.clientY),h.dataTransfer!=null)h.dataTransfer.dropEffect="move";h.preventDefault()},bh=(h)=>{if(!St||t.getDragSession()==null||Oe.current)return;let b=h.relatedTarget;if(b instanceof Node&&T.current?.contains(b)===!0)return;At(),nr(),t.setDragTarget(null)},wh=(h)=>{if(!St||t.getDragSession()==null||Oe.current)return;h.preventDefault(),Or(h.clientX,h.clientY),t.completeDrag(),Vr(),At(),nr(),je.current=null},ir=xe.window.height,Ih=xe.window.offsetTop,Sh=Math.min(0,Pe-ir),Ch=Math.min(0,Pe-ir-bn),kh=ut===W||be.current,In=W!=null&&kh&&!Ki&&ne>=0?Lr[ne]??t.getVisibleRows(ne,ne)[0]??null:null,Ys=In==null?null:rs(ne,a,ot,ir),Nt=je.current,xh=Jn!=null&&Nt!=null&&Nt.path===Jn&&Nt.index>=ot.start&&Nt.index<=ot.end,or=Jn!=null&&Nt!=null&&Nt.path===Jn&&!xh&&Nt.path!==In?.path?Nt:null,Xs=or==null?null:rs(or.index,a,ot,ir),_h=Jp((ne>=0?Lr[ne]??t.getVisibleRows(ne,ne)[0]??null:null)?.ancestorPaths.at(-1)??null),Eh=ht&&W!=null?Iu(s,W,!Ki):void 0,Th=G?.path??(ht?W:ut),Ph=G?.path??fn,sr=Xn(nn),Yi=qe&&vn&&!Gs&&!ji&&sr!=null&&Dt!=null&&nn!=null,Rh=qe&&(Yi||G!=null),qr=G?.anchorRect,Qs=qr==null&&sr!=null&&Dt!=null&&(G!=null||Yi)?Dt:null,Dh=qr!=null?{left:`${qr.left}px`,position:"fixed",right:"auto",top:`${qr.top}px`}:Qs!=null?{top:`${Qs}px`}:void 0,Mh=Gs?{opacity:"0"}:void 0,Ah=Re((h,b,N,_)=>{let P=Yc({event:{ctrlKey:h.ctrlKey,metaKey:h.metaKey,shiftKey:h.shiftKey},isDirectory:b.kind==="directory",isSearchOpen:ht,mode:_}),F=P.toggleDirectory&&b.kind==="directory",ce=F?t.resolveMountedDirectoryPathFromInput(N):null;if(F&&ce==null)return;let L=ce??N;switch(P.selection.kind){case"range":t.selectPathRange(L,P.selection.additive);break;case"toggle":t.togglePathSelectionFromInput(L);break;case"single":t.selectOnlyMountedPathFromInput(L);break}let ee=h.currentTarget instanceof HTMLElement?h.currentTarget:null,se=b.index>=xe.visible.startIndex&&b.index<=xe.visible.endIndex,re=_==="flow"&&se&&ee!=null&&ee.dataset.itemParked!=="true";if(t.focusMountedPathFromInput(L),re)z.current=!0,it((fe)=>fe===L?fe:L),Ae("focus");if(F)t.toggleMountedDirectoryFromInput(L);if(P.closeSearch)t.closeSearch();if(P.revealCanonical)Hr(L,{targetOffset:"sticky-parents"})},[t,ht,xe.visible.endIndex,xe.visible.startIndex,Hr]),Nh=()=>{if(y.current)return;if(!vn)return;if(nn==null||sr==null)return;let h=t.getItem(nn);if(h==null)return;tr(sr),wn.current=!0,mn({anchorRect:null,item:{kind:h.isDirectory()?"directory":"file",name:sr.getAttribute("aria-label")??nn,path:h.getPath()},path:h.getPath(),source:"button"})},zr={contextHoverPath:Ph,contextMenuButtonTriggerEnabled:vn,contextMenuButtonVisibility:Ns,contextMenuEnabled:qe,contextMenuRightClickEnabled:Yd,contextMenuTriggerMode:gn,controller:t,directoriesWithGitChanges:i,dragAndDropEnabled:St,draggedPathSet:eh,dragTarget:th,gitLaneActive:Ls,gitStatusByPath:n,handleRowDragEnd:ch,handleRowDragStart:lh,handleRowTouchStart:uh,ignoredGitDirectories:r,ignoredInheritanceCache:Gt,instanceId:s,itemHeight:a,onKeyDown:Ks,onRowClick:Ah,openContextMenuForRow:qs,registerButton:Xd,registerRenameInput:Zd,renameView:Qn,renderDecorationForRow:ih,resolveIcon:Fs,shouldSuppressContextMenu:sh,visualFocusPath:Th},Lh={...zr,registerButton:Qd};return x("div",{ref:T,id:Bs,"data-file-tree-context-menu-button-visibility":qe&&vn?Ns:void 0,"data-file-tree-context-menu-trigger-mode":qe?gn:void 0,"data-file-tree-has-context-menu-action-lane":qe&&vn?"true":void 0,"data-file-tree-has-git-lane":Ls?"true":void 0,"data-file-tree-virtualized-root":"true",onDragLeave:St?bh:void 0,onDragOver:St?yh:void 0,onDrop:St?wh:void 0,onKeyDown:Ks,onPointerLeave:qe?vh:void 0,onPointerOver:qe?gh:void 0,role:"tree",tabIndex:-1,style:{outline:"none",position:"relative"},children:[x("style",{"data-file-tree-guide-style":"true",dangerouslySetInnerHTML:{__html:_h}}),x("slot",{name:gr,"data-type":"header-slot"}),c?x("div",{"data-file-tree-search-container":!0,"data-open":ht?"true":"false",children:x("input",{ref:pe,"aria-activedescendant":Eh,"aria-controls":Bs,placeholder:"Search…","data-file-tree-search-input":!0,"data-file-tree-search-input-fake-focus":Yn?"true":void 0,value:Jd,onBlur:()=>{if(f==="retain"&&!As.current)return;t.closeSearch()},onFocus:$i,onPointerDown:$i,onInput:(h)=>{$i();let b=h.currentTarget;t.setSearch(b.value)}})}):null,x("div",{ref:O,"data-file-tree-virtualized-scroll":"true",children:[g&&Ud&&er.length>0?x("div",{"aria-hidden":"true","data-file-tree-sticky-overlay":"true",children:x("div",{"data-file-tree-sticky-overlay-content":"true",style:{height:`${nh}px`},children:er.map((h,b)=>Ti(Lh,h.row,`sticky:${Bn(h.row)}`,{mode:"sticky",style:{left:"0",position:"absolute",right:"0",top:`${h.top}px`,zIndex:`${er.length-b}`}}))})}):null,x("div",{ref:S,"data-file-tree-virtualized-list":"true",style:{height:`${tn}px`},children:[x("div",{"data-file-tree-virtualized-sticky-offset":"true","aria-hidden":"true",style:{height:`${Ih}px`}}),x("div",{"data-file-tree-virtualized-sticky":"true",style:{height:`${ir}px`,top:`${Sh}px`,bottom:`${Ch}px`},children:[um(zr,ot,Fr),In!=null&&Ys!=null?Ti(zr,In,`parked:${In.path}`,{isParked:!0,style:{left:"0",opacity:"0",pointerEvents:Jn===In.path?"none":void 0,position:"absolute",right:"0",top:`${Ys}px`}}):null,or!=null&&Xs!=null?Ti(zr,or,`parked-drag:${or.path}`,{isParked:!0,style:{left:"0",opacity:"0",pointerEvents:"none",position:"absolute",right:"0",top:`${Xs}px`}}):null]})]})]}),qe?x("div",{ref:I,"data-type":"context-menu-anchor","data-visible":Rh?"true":"false",style:Dh,children:[x("button",{ref:C,type:"button","data-type":Kl,"aria-label":"Options","aria-haspopup":"menu","aria-expanded":G!=null?"true":"false","data-visible":Yi?"true":"false",onMouseDown:(h)=>{h.preventDefault()},onClick:(h)=>{if(h.preventDefault(),h.stopPropagation(),G!=null){Qe();return}Nh()},tabIndex:-1,style:Mh,children:x(Mn,{...Fs("file-tree-icon-ellipsis")})}),G!=null?x("slot",{name:vr}):null]}):null,G!=null?x("div",{"data-type":"context-menu-wash","aria-hidden":"true",onMouseDownCapture:(h)=>{h.preventDefault(),Qe()},onTouchStartCapture:(h)=>{h.preventDefault(),h.stopPropagation(),Qe()},onTouchMoveCapture:(h)=>{h.preventDefault(),h.stopPropagation()},onWheelCapture:(h)=>{h.preventDefault(),h.stopPropagation()}}):null]})}var hs={hydrateRoot:(e,t)=>{Pc(Dn(ds,t),e)},renderRoot:(e,t)=>{xi(Dn(ds,t),e)},unmountRoot:(e)=>{xi(null,e)}};function Hn(e,t){hs.renderRoot(e,t)}function Su(e,t){hs.hydrateRoot(e,t)}function Cu(e){hs.unmountRoot(e)}var ku=class{#e=new Map;#t=null;clearAll(){for(let e of this.#e.values())e.remove();this.#e.clear()}clearSlotContent(e){let t=this.#c(e);if(t==null)return;t.remove(),this.#e.delete(e)}setHost(e){if(this.#t=e,e==null)return;this.#a(e);for(let[t,n]of this.#e)this.#u(t,n)}setSlotContent(e,t){let n=this.#c(e);if(n===t){if(t!=null)this.#e.set(e,t),this.#u(e,t);return}if(n?.remove(),t==null){this.#e.delete(e);return}this.#e.set(e,t),this.#u(e,t)}setSlotHtml(e,t){let n=t?.trim()??"";if(n.length===0){this.setSlotContent(e,null);return}let r=this.#c(e);if(r!=null&&r.innerHTML===n){this.#e.set(e,r),this.#u(e,r);return}let i=document.createElement("div");i.innerHTML=n,this.setSlotContent(e,i)}#c(e){let t=this.#e.get(e)??null;if(t!=null)return t;let n=this.#t;if(n==null)return null;for(let r of Array.from(n.children)){if(!(r instanceof HTMLElement))continue;if(r.dataset.fileTreeManagedSlot===e)return r}return null}#u(e,t){if(t.slot=e,t.dataset.fileTreeManagedSlot=e,this.#t!=null&&t.parentNode!==this.#t)this.#t.appendChild(t)}#a(e){for(let t of Array.from(e.children)){if(!(t instanceof HTMLElement))continue;let n=t.dataset.fileTreeManagedSlot;if(n==null||this.#e.has(n))continue;this.#e.set(n,t)}}};var xu=0;function dm(e){if(e!=null&&e.length>0)return e;return xu+=1,`pst_ft_${xu}`}function hm({initialVisibleRowCount:e,itemHeight:t}){return e==null?420:Math.max(0,e)*(t??fi)}function _u(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 Eu(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((t)=>t instanceof SVGElement)}var kr=class{static LoadedCustomComponent=!0;#e;#t;#c;#u;#a;#V;#O;#v;#r;#y=new ku;#T;#b;#m;#h;#w;#I;#f;#q;#z;#N=null;#i;#W=!1;#$=!1;constructor(e){let{composition:t,density:n,fileTreeSearchMode:r,gitStatus:i,id:o,initialSearchQuery:s,icons:a,itemHeight:l,onSearchChange:d,onSelectionChange:u,overscan:f,renderRowDecoration:c,renaming:m,search:p,searchBlurBehavior:g,searchFakeFocus:v,stickyFolders:I,unsafeCSS:C,initialVisibleRowCount:y,...S}=e;this.#e=t,this.#c=dm(o),this.#h=qo(i),this.#w=a,this.#I=C,this.#u=u,this.#a=c,this.#V=m!=null&&m!==!1,this.#O=g,this.#v=p===!0,this.#r=v===!0,this.#T=Ul(n,l),this.#b={itemHeight:this.#T.itemHeight,overscan:f,stickyFolders:I,initialVisibleRowCount:y},this.#t=new sc({...S,fileTreeSearchMode:r,initialSearchQuery:s,onSearchChange:d,renaming:m}),this.#z=this.#t.getSelectionVersion(),this.#N=this.#u==null?null:this.subscribe(()=>{this.#R()})}unmount(){if(this.#i!=null)Cu(this.#i),delete this.#i.dataset.fileTreeVirtualizedWrapper,this.#i=void 0;if(this.#y.clearAll(),this.#y.setHost(null),this.#m!=null)delete this.#m.dataset.fileTreeVirtualized,this.#F(this.#m),this.#m=void 0}cleanUp(){this.unmount(),this.#N?.(),this.#N=null,this.#t.destroy()}getFileTreeContainer(){return this.#m}getItem(e){return this.#t.getItem(e)}getFocusedItem(){return this.#t.getFocusedItem()}getFocusedPath(){return this.#t.getFocusedPath()}getFocusedIndex(){return this.#t.getFocusedIndex()}getVisibleCount(){return this.#t.getVisibleCount()}getVisibleRows(e,t){return this.#t.getVisibleRows(e,t)}getSelectedPaths(){return this.#t.getSelectedPaths()}getComposition(){return this.#e}getItemHeight(){return this.#T.itemHeight}getDensityFactor(){return this.#T.factor}subscribe(e){let t=!1;return this.#t.subscribe(()=>{if(!t){t=!0;return}e()})}focusPath(e){this.#t.focusPath(e)}focusFirstItem(){this.#t.focusFirstItem()}focusLastItem(){this.#t.focusLastItem()}focusNextItem(){this.#t.focusNextItem()}focusPreviousItem(){this.#t.focusPreviousItem()}focusParentItem(){this.#t.focusParentItem()}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)}applyGitStatusPatch(e){let t=uc(this.#h,e);if(t===this.#h)return;this.#h=t;let n=this.#s();if(n==null)return;Hn(n.wrapper,this.#P())}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){if(Array.isArray(e))this.#t.resetPaths(e,t);else this.#t.resetPaths(e)}setComposition(e){this.#e=e;let t=this.#s();if(t==null)return;this.#x(),Hn(t.wrapper,this.#P())}setGitStatus(e){let t=qo(e,this.#h);if(t===this.#h)return;this.#h=t;let n=this.#s();if(n==null)return;Hn(n.wrapper,this.#P())}setIcons(e){this.#w=e;let t=this.#s();if(t==null)return;this.#g(t.host,t.wrapper),Hn(t.wrapper,this.#P())}hydrate({fileTreeContainer:e}){let t=this.#M(e),n=this.#L(t);this.#x(),Su(n,this.#P())}render({containerWrapper:e,fileTreeContainer:t}){let n=this.#M(t??this.#m,e),r=this.#L(n);this.#x(),Hn(r,this.#P())}#Z(){return{initialViewportHeight:hm({initialVisibleRowCount:this.#b.initialVisibleRowCount,itemHeight:this.#b.itemHeight}),itemHeight:this.#b.itemHeight,overscan:this.#b.overscan,stickyFolders:this.#b.stickyFolders}}#P(){return{composition:this.#e,controller:this.#t,gitStatusByPath:this.#h?.statusByPath,ignoredGitDirectories:this.#h?.ignoredDirectoryPaths,directoriesWithGitChanges:this.#h?.directoriesWithChanges,icons:this.#w,instanceId:this.#c,renamingEnabled:this.#V,renderRowDecoration:this.#a,searchBlurBehavior:this.#O,searchEnabled:this.#v,searchFakeFocus:this.#r,slotHost:this.#y,...this.#Z()}}#s(){let e=this.#m,t=this.#i;if(e==null||t==null)return null;return{host:e,wrapper:t}}#g(e,t){let n=e.shadowRoot;if(n!=null)this.#j(n),this.#K(n);this.#U(t)}#R(){let e=this.#u;if(e==null)return;let t=this.#t.getSelectionVersion();if(t===this.#z)return;this.#z=t,e(this.#t.getSelectedPaths())}#x(){let e=this.#e?.header?.render;if(e!=null){this.#y.setSlotContent(gr,e());return}this.#y.setSlotHtml(gr,this.#e?.header?.html??null)}#j(e){let t=Tu(e).find((r)=>Eu(r)),n=_u(Ol(Tn(this.#w).set));if(n==null)return;if(t!=null&&t.outerHTML===n.outerHTML)return;if(t!=null)t.replaceWith(n);else e.prepend(n)}#K(e){let t=Tu(e),n=t.find((s)=>Eu(s)),r=t.filter((s)=>s!==n),i=Tn(this.#w).spriteSheet?.trim()??"";if(i.length===0){for(let s of r)s.remove();return}let o=_u(i);if(o==null){for(let s of r)s.remove();return}if(r.length===1&&r[0].outerHTML===o.outerHTML)return;for(let s of r)s.remove();e.appendChild(o)}#U(e){let t=Tn(this.#w);if(t.colored&&zl(t.set))e.dataset.fileTreeColoredIcons="true";else delete e.dataset.fileTreeColoredIcons}#l(e){let t=e.querySelector(`style[${Po}]`);if(this.#f==null&&t instanceof HTMLStyleElement)this.#f=t;if(this.#I==null||this.#I===""){this.#f?.remove(),this.#f=void 0,this.#q=void 0;return}if(this.#f?.parentNode===e&&this.#q===this.#I)return;if(this.#f??=document.createElement("style"),this.#f.setAttribute(Po,""),this.#f.parentNode!==e)e.appendChild(this.#f);this.#f.textContent=Gl(this.#I),this.#q=this.#I}#L(e){if(this.#i!=null)return this.#i;let t=e.shadowRoot;if(t==null)throw Error("FileTree requires a shadow root");let n=Array.from(t.children).filter((i)=>i instanceof HTMLDivElement&&typeof i.dataset.fileTreeId==="string"&&i.dataset.fileTreeId.length>0),r=n.find((i)=>i.dataset.fileTreeId===this.#c)??n[0];if(r!=null)this.#c=r.dataset.fileTreeId??this.#c;if(this.#i=r??document.createElement("div"),this.#i.dataset.fileTreeId=this.#c,this.#i.dataset.fileTreeVirtualizedWrapper="true",this.#g(e,this.#i),this.#i.parentNode!==t)t.appendChild(this.#i);return this.#i}#M(e,t){let n=e??this.#m??document.createElement("file-tree-container");if(t!=null&&n.parentNode!==t)t.appendChild(n);let r=n.shadowRoot??n.attachShadow({mode:"open"});return gi(n,r),this.#l(r),n.dataset.fileTreeVirtualized="true",n.style.display="flex",this.#k(n),this.#y.setHost(n),this.#m=n,n}#k(e){if(e.style.getPropertyValue("--trees-item-height")==="")e.style.setProperty("--trees-item-height",`${String(this.#T.itemHeight)}px`),this.#W=!0;if(e.style.getPropertyValue("--trees-density-override")==="")e.style.setProperty("--trees-density-override",String(this.#T.factor)),this.#$=!0}#F(e){if(this.#W)e.style.removeProperty("--trees-item-height"),this.#W=!1;if(this.#$)e.style.removeProperty("--trees-density-override"),this.#$=!1}};var Pu=["--trees-bg-override: var(--surface-pane)","--trees-bg-muted-override: var(--surface-muted)","--trees-border-color-override: transparent","--trees-fg-override: var(--text)","--trees-font-family-override: var(--font-sans)","--trees-focus-ring-color-override: var(--text-muted)","--trees-padding-inline-override: 8px","--trees-scrollbar-gutter-override: 4px","--trees-search-bg-override: light-dark(var(--surface-base), var(--surface-control))","--trees-selected-bg-override: var(--selection)","--trees-selected-focused-border-color-override: var(--text-muted)"].join("; "),fs=`
|
|
1285
|
+
}`}var Xl=new WeakMap;function jf(e){let t=Xl.get(e);if(t!=null)return t;let n=document.createElement("div");n.setAttribute(jl,"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(),Xl.set(e,i),i}function Ql(e,t){if(!e.isConnected)return;let n=jf(t);if(n==null)return;let r=t.querySelector(`style[${Ao}]`),i=r instanceof HTMLStyleElement?r:document.createElement("style");if(!(r instanceof HTMLStyleElement))i.setAttribute(Ao,""),t.appendChild(i);i.textContent=`:host { ${Kl}: ${n}px; }`}var vi;function Kf(e){if(typeof CSSStyleSheet<"u"&&typeof CSSStyleSheet.prototype.replaceSync==="function"&&"adoptedStyleSheets"in e){if(vi==null)vi=new CSSStyleSheet,vi.replaceSync(gi(mi));let t=!1;try{e.adoptedStyleSheets=[vi],t=!0}catch{}if(t){e.querySelector(`style[${hi}]`)?.remove();return}}if(e.querySelector("style[data-file-tree-style]")==null){let t=document.createElement("style");t.setAttribute(hi,""),t.textContent=gi(mi),e.prepend(t)}}function yi(e,t){Uf(e,t),Kf(t),Ql(e,t)}function Uf(e,t){let n=e.querySelector('template[shadowrootmode="open"], template[data-file-tree-shadowrootmode="open"]');if(!(n instanceof HTMLTemplateElement))return;if(t.childNodes.length>0)return;if(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 t=this.shadowRoot??this.attachShadow({mode:"open"});yi(this,t)}}if(customElements.define(Do,e),typeof document<"u")for(let t of Array.from(document.querySelectorAll(Do))){if(!(t instanceof HTMLElement))continue;yi(t,t.shadowRoot??t.attachShadow({mode:"open"}))}}var Zl=(e)=>e.startsWith("f::")?e.slice(3):e;function Gf(e){let t=e.lastIndexOf("/");if(t<0)return{parentPath:"",baseName:e};return{parentPath:e.slice(0,t),baseName:e.slice(t+1)}}function Yf(e,t){return e===""?t:`${e}/${t}`}function Jl({files:e,path:t,isFolder:n,nextBasename:r}){let i=Zl(t),o=r.trim();if(o.length===0)return{error:"Name cannot be empty."};if(o.includes("/"))return{error:'Name cannot include "/".'};let{parentPath:s,baseName:a}=Gf(i);if(o===a)return{nextFiles:e,sourcePath:i,destinationPath:i,isFolder:n};let l=Yf(s,o),d=Array(e.length),u=new Set;if(!n){let p=`${l}/`,g=!1;for(let v=0;v<e.length;v++){let I=e[v];if(I!==i&&I.startsWith(p))return{error:`"${l}" already exists.`};let C=I===i?l:I;if(u.has(C))return{error:`"${l}" already exists.`};if(u.add(C),d[v]=C,I===i)g=!0}if(!g)return{error:"Could not find the selected file to rename."};return{nextFiles:d,sourcePath:i,destinationPath:l,isFolder:n}}let f=`${i}/`,c=`${l}/`,m=0;for(let p=0;p<e.length;p++){let g=e[p],v=g===i||g.startsWith(f);if(!v&&(g===l||g.startsWith(c)))return{error:`"${l}" already exists.`};let I=v?`${l}${g.slice(i.length)}`:g;if(u.has(I))return{error:`"${l}" already exists.`};if(u.add(I),d[p]=I,v)m++}if(m===0)return{error:"Could not find the selected folder to rename."};return{nextFiles:d,sourcePath:i,destinationPath:l,isFolder:n}}function Xf(e){return e.endsWith("/")}function Qf(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 Zf(e){let t=[],n=new Set;for(let i of e){if(n.has(i))continue;n.add(i),t.push(i)}let r=new Set;for(let i of t.toSorted((o,s)=>{if(o.length!==s.length)return o.length-s.length;return o.localeCompare(s)})){let o=(i.endsWith("/")?i.slice(0,-1):i).split("/"),s=!1;for(let a=0;a<o.length-1;a+=1){let l=`${o.slice(0,a+1).join("/")}/`;if(!r.has(l))continue;s=!0;break}if(s)continue;r.add(i)}return t.filter((i)=>r.has(i))}function ec(e,t){return t.includes(e)?Zf(t):[e]}function tc(e,t){if(e===t)return!0;if(e==null||t==null)return!1;return e.kind===t.kind&&e.directoryPath===t.directoryPath&&e.flattenedSegmentPath===t.flattenedSegmentPath&&e.hoveredPath===t.hoveredPath}function No(e,t){return{draggedPaths:e,target:t}}function Lo(e,t){if(t.kind!=="directory"||t.directoryPath==null)return!1;for(let n of e){if(!Xf(n))continue;if(t.directoryPath===n||t.directoryPath.startsWith(n))return!0}return!1}function Jf(e,t){if(t.kind==="root"||t.directoryPath==null)return Qf(e);return t.directoryPath}function nc(e,t){let n=e.map((r)=>{let i=Jf(r,t);if(i===r)return null;return{from:r,to:i,type:"move"}}).filter((r)=>r!=null);if(n.length===0)return null;return{operations:n,result:{draggedPaths:e,operation:n.length===1?"move":"batch",target:t}}}function ep(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 Fo(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 o=i.paths;if(r==null)return{paths:o,preparedInput:i};if(!ep(vr.preparePaths(r,n==null?{}:{sort:n}),o))throw Error(`FileTree ${t} received paths and preparedInput for different path lists`);return{paths:o,preparedInput:i}}function Bo(e){return e.operation==="add"||e.operation==="remove"||e.operation==="move"||e.operation==="batch"}function tp(e,t,n){if(e===t)return n;let r=t.endsWith("/")?t:`${t}/`;if(!e.startsWith(r))return e;return`${n.endsWith("/")?n:`${n}/`}${e.slice(r.length)}`}function np(e,t){if(e===t)return!0;let n=t.endsWith("/")?t:`${t}/`;return e.startsWith(n)}function Rn(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 np(e,t.path)?n?e:null:e;case"move":return tp(e,t.from,t.to);case"batch":{let r=e;for(let i of t.events)if(r=Rn(r,i,n),r==null)return null;return r}}}function bi(e){return{canonicalChanged:e.canonicalChanged,projectionChanged:e.projectionChanged,visibleCountDelta:e.visibleCountDelta}}function rc(e){switch(e.operation){case"add":return{...bi(e),operation:"add",path:e.path};case"remove":return{...bi(e),operation:"remove",path:e.path,recursive:e.recursive};case"move":return{...bi(e),from:e.from,operation:"move",to:e.to}}}function rp(e){return{...bi(e),events:e.events.filter((t)=>t.operation==="add"||t.operation==="remove"||t.operation==="move").map((t)=>rc(t)),operation:"batch"}}function ic(e){switch(e.operation){case"add":case"remove":case"move":return rc(e);case"batch":return rp(e);default:return null}}function wi(e,t){if(e.size!==t.length)return!1;for(let n of t)if(!e.has(n))return!1;return!0}function xt(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((r,i)=>`${n.slice(0,i+1).join("/")}/`)}function Ii(e){return xt(e).at(-1)??null}function Ho(e,t){if(t==null)return e;return e.startsWith(t)?e.slice(t.length):e}function wr(e){return e.endsWith("/")}var Vo=(e)=>e.toLowerCase();function oc(e){let t=e.endsWith("/")?e.slice(0,-1):e,n=t.lastIndexOf("/");return n<0?t:t.slice(n+1)}function Oo(e){return e.endsWith("/")?e.slice(0,-1):e}function qo(e,t){return t&&!e.endsWith("/")?`${e}/`:e}var sc=(e)=>{let t=e.trim();if(t.length===0)return"";return(t.includes("\\")?t.replaceAll("\\","/"):t).toLowerCase()};var zo=Symbol("FILE_TREE_RENAME_VIEW"),ip=512,op=512;function sp(e){return e==="top"||e==="center"?e:"nearest"}function ap(e,t,n){if(e===0)return-1;if(n!=null){let r=t(n);if(r!=null)return r;let i=xt(n);for(let o=i.length-1;o>=0;o-=1){let s=i[o];if(s==null)continue;let a=t(s);if(a!=null)return a}}return 0}function lp(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??((i)=>e.visibleIndexByPath.get(i)??null);return{focusedIndex:ap(e.paths.length,r,t),getParentIndex:e.getParentIndex,paths:e.paths,posInSetByIndex:e.posInSetByIndex,setSizeByIndex:e.setSizeByIndex}}var ac=class e{static{Object.defineProperty(e.prototype,zo,{configurable:!0,value(){return{cancel:()=>{this.#_e()},commit:()=>{this.#Ee()},getPath:()=>this.#s,getValue:()=>this.#g,isActive:()=>this.#s!=null,setValue:(t)=>{this.#Te(t)}}},writable:!0})}#e;#t=new Set;#c=new Map;#u=null;#a=null;#V=new Map;#O=new Map;#v=-1;#r=null;#y=!1;#T=(t)=>-1;#b=new Map;#m=null;#h=null;#w=null;#I=null;#f=null;#q;#z;#N;#i=[];#W=new Int32Array(0);#$=new Int32Array(0);#Z=void 0;#P=!1;#s=null;#g="";#R=!1;#x=new Set;#j=[];#K;#U=null;#l=null;#L=null;#M=null;#k=null;#F=null;#J=null;#xe=0;#S=null;#o=new Set;#G=0;#n;#ne=0;#re=!1;#p=0;#Y;constructor(t){let{dragAndDrop:n,fileTreeSearchMode:r,initialSearchQuery:i,initialSelectedPaths:o,renaming:s,onSearchChange:a,paths:l,preparedInput:d,...u}=t,f=Fo({paths:l,preparedInput:d},"constructor",u.sort);if(this.#e=u,n!=null&&n!==!1)this.#u=n===!0?{}:n;if(this.#P=s!=null&&s!==!1,s!=null&&s!==!1&&s!==!0)this.#Z=s.canRename,this.#z=s.onError,this.#q=s.onRename;this.#N=a,this.#K=r??"hide-non-matches",this.#n=this.#oe(f.paths,f.preparedInput);let c=o?.map((p)=>this.#A(p)).filter((p)=>p!=null)??[],m=c.at(-1)??null;if(c.length>0)this.#o=new Set(c),this.#S=m,this.#G=1;if(this.#H(m,!1),i!=null)this.#X(i,!1);this.#Y=this.#Ce()}destroy(){this.#Y?.(),this.#Y=null,this.#c.clear(),this.#t.clear(),this.#b.clear(),this.#a=null,this.#ae()}focusFirstItem(){if(this.#_().length>0)this.#E(0)}focusLastItem(){if(this.#p<=0)return;this.#D(),this.#E(this.#p-1)}focusNextItem(){this.#Se(1)}focusParentItem(){if(this.#r==null)return;let t=Ii(this.#r);if(t==null)return;let n=this.#B(t);if(n>=0)this.#E(n)}focusPath(t){let n=this.#n.getPathInfo(t)?.path??null;if(n==null)return;this.#D();let r=this.#B(n);if(r>=0)this.#E(r)}scrollToPath(t,n){let r=this.#n.getPathInfo(t)?.path??null;if(r==null)return;this.#D();let i=this.#He(r);if(i<0)return;if(this.#le(i)==null)return;if(n?.focus!==!1)this.#E(i,!1);this.#J={id:this.#xe+=1,offset:sp(n?.offset),visibleIndex:i},this.#d()}focusMountedPathFromInput(t){let n=this.#n.getPathInfo(t)?.path??null;if(n==null)return;let r=this.#B(n);if(r>=0)this.#E(r)}focusNearestPath(t){let n=this.resolveNearestVisiblePath(t);if(n==null)return null;let r=this.#B(n);if(r>=0)return this.#E(r),this.#_()[r]??n;return null}focusPreviousItem(){this.#Se(-1)}getFocusedIndex(){return this.#v}getFocusedItem(){return this.#r==null?null:this.#ce(this.#r)}getFocusedPath(){return this.#r}getScrollRequest(){return this.#J}clearScrollRequest(t){if(this.#J?.id===t)this.#J=null}resolveNearestVisiblePath(t){let n=this.#_();if(this.#p===0)return null;if(t==null)return this.#r??n[0]??null;let r=this.#n.getPathInfo(t)?.path??t,i=this.#B(r);if(i>=0)return n[i]??r;let o=this.#Pe(r);if(o!=null)return o;return this.#r??n[0]??null}getSelectedPaths(){return[...this.#o]}getSelectionVersion(){return this.#G}getVisibleCount(){return this.#p}getVisibleRows(t,n){if(n<t||this.#p===0)return[];let r=Math.max(0,t),i=Math.min(this.#p-1,n);if(i<r)return[];let o=i-r+1;if(this.#k==null&&!this.#y&&i>=this.#i.length&&o<=op){let s=[];for(let a=r;a<=i;a+=1){let l=this.#n.getVisibleRowContext(a);if(l==null)break;s.push(this.#ue(l))}return s}if(!this.#y&&i>=this.#i.length)this.#D();if(this.#k!=null){let s=Array.from({length:i-r+1},(u,f)=>this.#ve(r+f)),a=new Map,l=s[0]??-1,d=l;for(let u=1;u<=s.length;u+=1){let f=s[u];if(f!=null&&f===d+1){d=f;continue}if(l>=0)this.#n.getVisibleSlice(l,d).forEach((c,m)=>{a.set(l+m,c)});if(f==null){l=-1,d=-1;continue}l=f,d=f}return Array.from({length:i-r+1},(u,f)=>{let c=r+f,m=this.#ve(c),p=a.get(m),g=this.#i[m];if(p==null||g==null)throw Error(`Missing projection row for filtered visible index ${String(c)}`);return this.#ie(p,c,m,{ancestorPaths:this.#fe(m),path:g})})}return this.#n.getVisibleSlice(r,i).map((s,a)=>{let l=r+a,d=this.#i[l];if(d==null)throw Error(`Missing projection path for visible index ${String(l)}`);return this.#ie(s,l,l,{ancestorPaths:this.#fe(l),path:d})})}getStickyRowCandidates(t,n){if(this.#k!=null)return null;if(this.#p===0||t<=0||n<=0)return[];let r=[];for(let i=0;i<this.#p;i+=1){let o=t+i*n,s=Math.min(this.#p-1,Math.floor(o/n)),a=this.#de(s,i)??(s>0?this.#de(s-1,i):void 0);if(a==null)break;r.push({row:this.#ue(a),subtreeEndIndex:a.subtreeEndIndex})}return r}getItem(t){let n=this.#n.getPathInfo(t);return n==null?null:this.#ce(n.path,n)}resolveMountedDirectoryPathFromInput(t){let n=this.#n.getPathInfo(t);return n?.kind==="directory"?n.path:null}toggleMountedDirectoryFromInput(t){let n=this.resolveMountedDirectoryPathFromInput(t);if(n==null)return;this.#ke(n)}selectAllVisiblePaths(){this.#D();let t=[...this.#_()];this.#C(t,this.#r??this.#S)}selectOnlyPath(t){let n=this.#A(t);if(n==null)return;this.#C([n],n)}selectOnlyMountedPathFromInput(t){this.#C([t],t)}selectPath(t){let n=this.#A(t);if(n==null||this.#o.has(n))return;this.#C([...this.#o,n])}deselectPath(t){let n=this.#A(t);if(n==null||!this.#o.has(n))return;this.#C([...this.#o].filter((r)=>r!==n))}toggleFocusedSelection(){if(this.#r==null)return;this.togglePathSelectionFromInput(this.#r)}togglePathSelection(t){let n=this.#A(t);if(n==null)return;if(this.#o.has(n)){this.deselectPath(n);return}this.selectPath(n)}togglePathSelectionFromInput(t){let n=this.#A(t);if(n==null)return;if(this.#o.has(n)){this.#C([...this.#o].filter((r)=>r!==n),n);return}this.#C([...this.#o,n],n)}selectPathRange(t,n){let r=this.#A(t);if(r==null)return;this.#D();let i=this.#S,o=i==null?-1:this.#te(i),s=this.#te(r);if(o===-1||s===-1){let f=n?[...this.#o,r]:[r];this.#C(f,r);return}let[a,l]=o<=s?[o,s]:[s,o],d=this.#_().slice(a,l+1),u=n?[...this.#o,...d]:d;this.#C(u,i)}extendSelectionFromFocused(t){if(this.#r==null)return;let n=this.#v;if(n===-1)return;let r=Math.min(this.#p-1,Math.max(0,n+t));if(r===n)return;if(!this.#y&&r>=this.#i.length)this.#D();let i=this.#_(),o=i[n]??null,s=i[r]??null;if(o==null||s==null)return;let a=new Set(this.#o);if(a.has(o)&&a.has(s))a.delete(o);else a.add(s);this.#C([...a],this.#S??o,!1),this.#E(r)}getDragAndDropConfig(){return this.#u}isDragAndDropEnabled(){return this.#u!=null}getDragSession(){if(this.#a==null)return null;return{draggedPaths:[...this.#a.draggedPaths],primaryPath:this.#a.primaryPath,target:this.#a.target==null?null:{...this.#a.target}}}startDrag(t){if(this.#u==null)return!1;let n=this.#A(t);if(n==null)return!1;if(this.#l!=null&&this.#l.length>0)return!1;let r=this.getSelectedPaths(),i=ec(n,r);if(this.#u.canDrag?.(i)===!1)return!1;if(!r.includes(n))this.#C([n],n,!1);return this.#Q(n),this.#a={draggedPaths:i,primaryPath:n,target:null},this.#d(),!0}setDragTarget(t){let n=this.#a;if(n==null)return;let r=t;if(r!=null){let i=No(n.draggedPaths,r);if(Lo(n.draggedPaths,r)||this.#u?.canDrop?.(i)===!1)r=null}if(tc(n.target,r))return;this.#a={...n,target:r},this.#d()}cancelDrag(){if(this.#a==null)return;this.#a=null,this.#d()}completeDrag(){let t=this.#a;if(t==null)return!1;this.#a=null;let n=t.target==null?null:{...t.target};if(n==null)return this.#d(),!1;let r=No(t.draggedPaths,n);if(Lo(t.draggedPaths,n)||this.#u?.canDrop?.(r)===!1)return this.#d(),!1;let i=nc(t.draggedPaths,n);if(i==null)return this.#d(),!1;try{if(i.operations.length===1){let o=i.operations[0];if(o==null||o.type!=="move")throw Error("Expected a single move operation for one-item drops");this.#n.move(o.from,o.to,{collision:o.collision})}else this.#Me(i.operations),this.#n.batch(i.operations)}catch(o){return this.#d(),this.#u?.onDropError?.(o instanceof Error?o.message:String(o),r),!1}return this.#u?.onDropComplete?.(i.result),!0}subscribe(t){return this.#t.add(t),t(),()=>{this.#t.delete(t)}}add(t){this.#n.add(t)}remove(t,n={}){this.#n.remove(t,n)}move(t,n,r={}){this.#n.move(t,n,r)}batch(t){this.#n.batch(t)}onMutation(t,n){let r=t,i=n,o=this.#c.get(r);if(o==null)o=new Set,this.#c.set(r,o);return o.add(i),()=>{let s=this.#c.get(r);if(s?.delete(i),s?.size===0)this.#c.delete(r)}}setSearch(t){this.#X(t,!0)}openSearch(t=""){this.#X(t,!0)}closeSearch(){this.#X(null,!0)}isSearchOpen(){return this.#l!==null}getSearchValue(){return this.#l??""}getSearchMatchingPaths(){return this.#j}focusNextSearchMatch(){this.#ye(1)}focusPreviousSearchMatch(){this.#ye(-1)}startRenaming(t=this.#r??"",n={}){if(!this.#P)return!1;let r=this.#n.getPathInfo(t);if(r==null)return!1;let i=r.path,o=wr(i),s=Oo(i);if(this.#Z?.({isFolder:o,path:s})===!1)return!1;for(let a of xt(i))if(!this.#n.isExpanded(a))this.#n.expand(a);if(this.#C([i],i,!1),this.#l!=null)this.#X(null,!1),this.#N?.(this.#l);return this.#Q(i),this.#s=i,this.#g=oc(i),this.#R=n.removeIfCanceled??!1,this.#d(),!0}#_e(){if(this.#s==null)return;let t=this.#s,n=this.#R;if(this.#s=null,this.#g="",this.#R=!1,n){this.remove(t,wr(t)?{recursive:!0}:void 0);return}this.#Q(t),this.#d()}#Ee(){let t=this.#s;if(t==null)return;if(this.#R&&this.#g.trim().length===0){this.#s=null,this.#g="",this.#R=!1,this.remove(t,wr(t)?{recursive:!0}:void 0);return}let n=wr(t),r=Jl({files:this.#n.list(),isFolder:n,nextBasename:this.#g,path:Oo(t)});if(this.#s=null,this.#g="",this.#R=!1,"error"in r){this.#Q(t),this.#z?.(r.error),this.#d();return}if(r.sourcePath===r.destinationPath){this.#Q(t),this.#d();return}this.#q?.({destinationPath:r.destinationPath,isFolder:r.isFolder,sourcePath:r.sourcePath}),this.move(qo(r.sourcePath,n),qo(r.destinationPath,n))}#Te(t){if(this.#s==null||this.#g===t)return;this.#g=t,this.#d()}resetPaths(t,n={}){let r=!Array.isArray(t),i=r?void 0:t,o=r?t:n,s=this.#n.list().length,a=this.#p,l=Fo({paths:i,preparedInput:o.preparedInput},"resetPaths",this.#e.sort),d=this.#oe(l.paths,l.preparedInput,o.initialExpandedPaths),u=this.#r,f=this.#s,c=this.getSelectedPaths(),m=this.#S;this.#Y?.(),this.#n=d,this.#b.clear(),this.#ae();let p=c.map((v)=>d.getPathInfo(v)?.path??null).filter((v)=>v!=null),g=!wi(this.#o,p);if(this.#o=new Set(p),g)this.#G+=1;if(this.#S=m==null?null:d.getPathInfo(m)?.path??null,this.#s=f==null?null:d.getPathInfo(f)?.path??null,this.#s==null)this.#g="",this.#R=!1;this.#H(u,u!=null||p.length>0||this.#S!=null),this.#Y=this.#Ce(),this.#d(),this.#we({canonicalChanged:!0,operation:"reset",pathCountAfter:l.paths.length,pathCountBefore:s,projectionChanged:!0,usedPreparedInput:o.preparedInput!=null,visibleCountDelta:this.#p-a})}#Pe(t){this.#D();let n=Ii(t),r=Ho(t,n),i=null,o=null;for(let s of this.#_()){if(Ii(s)!==n)continue;let a=Ho(s,n);if(a<r){i=s;continue}if(a>r){o=s;break}}return i??o}#B(t){let n=this.#te(t);if(n!==-1)return n;let r=xt(t);for(let i=r.length-1;i>=0;i-=1){let o=r[i];if(o==null)continue;let s=this.#te(o);if(s!==-1)return s}return this.#_().length>0?0:-1}#ce(t,n){let r=this.#b.get(t);if(r!=null)return r;let i=n??this.#n.getPathInfo(t);if(i==null)return null;let o=i.kind==="directory"?this.#Re(i.path):this.#De(i.path);return this.#b.set(i.path,o),o}#ie(t,n,r,i){return{ancestorPaths:i.ancestorPaths,depth:t.depth,flattenedSegments:t.flattenedSegments?.map((o)=>({isTerminal:o.isTerminal,name:o.name,path:o.path})),hasChildren:t.hasChildren,index:n,isExpanded:t.isExpanded,isFlattened:t.isFlattened,isFocused:i.path===this.#r,isSelected:this.#o.has(i.path),kind:t.kind,level:t.depth,name:t.name,path:i.path,posInSet:i.posInSet??this.#W[r]??0,setSize:i.setSize??this.#$[r]??0}}#ue(t){return this.#ie(t.row,t.index,t.index,{ancestorPaths:t.ancestorPaths,path:t.row.path,posInSet:t.posInSet,setSize:t.setSize})}#de(t,n){let r=this.#n.getVisibleRowContext(t);if(r==null)return;let i=r.ancestorRows[n];if(i!=null)return i;return n===r.ancestorRows.length&&r.row.kind==="directory"&&r.row.isExpanded?r:void 0}#he(t){let n=this.#V.get(t);if(n!=null)return n;let r=this.#T(t),i=r<0?[]:[...this.#he(r),r];return this.#V.set(t,i),i}#fe(t){let n=this.#O.get(t);if(n!=null)return n;let r=this.#he(t).map((i)=>this.#i[i]??"").filter((i)=>i!=="");return this.#O.set(t,r),r}#pe(t){this.#n.collapse(t)}#C(t,n=this.#S,r=!0){let i=[...new Set(t)],o=!wi(this.#o,i),s=this.#S!==n;if(!o&&!s)return;if(this.#o=new Set(i),this.#S=n,o)this.#G+=1;if(r)this.#d()}#Re(t){return{collapse:()=>{this.#pe(t)},deselect:()=>{this.deselectPath(t)},expand:()=>{this.#Ie(t)},focus:()=>{this.focusPath(t)},getPath:()=>t,isDirectory:()=>!0,isExpanded:()=>this.#n.isExpanded(t),isFocused:()=>this.#r===t,isSelected:()=>this.#o.has(t),select:()=>{this.selectPath(t)},toggleSelect:()=>{this.togglePathSelection(t)},toggle:()=>{this.#ke(t)}}}#De(t){return{deselect:()=>{this.deselectPath(t)},focus:()=>{this.focusPath(t)},getPath:()=>t,isDirectory:()=>!1,isFocused:()=>this.#r===t,isSelected:()=>this.#o.has(t),select:()=>{this.selectPath(t)},toggleSelect:()=>{this.togglePathSelection(t)}}}#Me(t){let n=this.#n.list();this.#oe(n).batch(t)}#oe(t,n,r){return new vr({...this.#e,paths:t,preparedInput:n==null?void 0:n,...r!==void 0?{initialExpandedPaths:r}:{}})}#se(){if(this.#I!=null)return this.#I;return this.#I=this.#n.list(),this.#I}#Ae(){if(this.#w!=null)return this.#w;let t=new Set;for(let n of this.#se()){t.add(n);for(let r of xt(n))t.add(r)}return this.#w=[...t].sort(),this.#w}#Ne(){if(this.#f!=null)return this.#f;return this.#f=this.#se().map(Vo),this.#f}#ee(){if(this.#m!=null)return this.#m;return this.#m=this.#Ae().filter((t)=>t.endsWith("/")),this.#m}#Le(){if(this.#h!=null)return this.#h;return this.#h=this.#ee().map(Vo),this.#h}#ae(){this.#m=null,this.#h=null,this.#w=null,this.#I=null,this.#f=null}#Fe(){return this.#ee().filter((t)=>this.#n.isExpanded(t))}#me(t){let n=new Set(this.#U??[]);if(t)for(let r of this.#o)for(let i of xt(r))n.add(i);this.#ge(n)}#ge(t){this.#re=!0;try{for(let n of this.#ee()){let r=t.has(n),i=this.#n.isExpanded(n);if(r&&!i)this.#n.expand(n);else if(!r&&i)this.#n.collapse(n)}}finally{this.#re=!1}}#Be(){if(this.#l==null||this.#l.length===0){this.#j=[],this.#k=null,this.#F=null,this.#M=null,this.#p=this.#ne;return}let t=this.#i;if(this.#j=t.filter((o)=>this.#x.has(o)),this.#K!=="hide-non-matches"||this.#x.size===0){this.#k=null,this.#F=null,this.#M=null,this.#p=this.#ne;return}let n=[],r=[],i=new Map;for(let[o,s]of t.entries()){if(this.#L?.has(s)!==!0)continue;i.set(s,r.length),n.push(o),r.push(s)}this.#k=n,this.#F=r,this.#M=i,this.#p=r.length}#_(){return this.#F??this.#i}#He(t){if(this.#F!=null)return this.#M?.get(t)??-1;return this.#n.getVisibleIndex(t)??-1}#ve(t){return this.#k?.[t]??t}#te(t){let n=this.#M?.get(t);if(n!=null)return n;return this.#n.getVisibleIndex(t)??-1}#ye(t){let n=this.#j;if(n.length===0)return;let r=this.#r,i=r==null?-1:n.indexOf(r),o=n[i<0?t>0?0:n.length-1:Math.min(n.length-1,Math.max(0,i+t))];if(o!=null)this.focusPath(o)}#X(t,n){let r=t==null?null:sc(t),i=this.#l;if(i===r)return;if(i==null&&r!=null)this.#U=this.#Fe();if(this.#l=r,r==null)this.#me(!0),this.#U=null,this.#x.clear(),this.#L=null,this.#H(this.#r,!0);else if(r.length===0)this.#me(!1),this.#x.clear(),this.#L=null,this.#H(this.#r,!0);else{let o=this.#be();this.#H(o,!0)}if(n)this.#N?.(this.#l),this.#d()}#be(){if(this.#l==null||this.#l.length===0)return this.#x.clear(),this.#r;let t=this.#l,n=this.#se(),r=this.#Ne(),i=[],o=new Set,s=null;for(let f=0;f<n.length;f+=1){if(!r[f].includes(t))continue;let c=n[f];i.push(c),o.add(c),s??=c}let a=this.#ee(),l=this.#Le();for(let f=0;f<a.length;f+=1){if(!l[f].includes(t))continue;let c=a[f];if(o.has(c))continue;i.push(c),o.add(c),s??=c}this.#x=o;let d=this.#K==="hide-non-matches"&&i.length>0?new Set:null;this.#L=d;let u=this.#K==="expand-matches"?new Set(this.#U??[]):new Set;for(let f of i){if(d!=null)d.add(f);if(f.endsWith("/"))u.add(f);for(let c of xt(f))if(u.add(c),d!=null)d.add(c)}return this.#ge(u),s??this.#r}#d(){for(let t of this.#t)t()}#we(t){this.#c.get(t.operation)?.forEach((n)=>{n(t)}),this.#c.get("*")?.forEach((n)=>{n(t)})}#Ie(t){for(let n of xt(t)){if(this.#n.isExpanded(n))continue;this.#n.expand(n)}if(!this.#n.isExpanded(t))this.#n.expand(t)}#Se(t){let n=this.#p;if(n===0)return;let r=this.#v===-1?0:this.#v,i=Math.min(n-1,Math.max(0,r+t));if(i!==r||this.#v===-1){if(!this.#y&&this.#k==null&&i>=this.#i.length)this.#D();this.#E(i)}}#H(t,n=!0){let r=this.#n.getVisibleCount();this.#ne=r;let i=lp(this.#n.getVisibleTreeProjectionData(n?void 0:Math.min(r,ip)),t,n?(o)=>this.#n.getVisibleIndex(o):void 0);this.#V.clear(),this.#O.clear(),this.#y=i.paths.length>=r,this.#T=i.getParentIndex,this.#i=i.paths,this.#W=i.posInSetByIndex,this.#$=i.setSizeByIndex,this.#Be(),this.#v=t==null?this.#_().length>0?0:-1:this.#B(t),this.#r=this.#v<0?null:this.#le(this.#v)}#le(t){let n=this.#_()[t];if(n!=null)return n;if(this.#k!=null)return null;return this.#n.getVisibleRowContext(t)?.row.path??null}#A(t){return this.#n.getPathInfo(t)?.path??null}#Q(t){if(t==null)return;let n=this.#B(t);if(n>=0)this.#E(n,!1)}#E(t,n=!0){let r=this.#le(t);if(r==null)return;if(this.#v===t&&this.#r===r)return;if(this.#v=t,this.#r=r,n)this.#d()}#D(){if(this.#y)return;this.#H(this.#r,!0)}#Ve(t){let n=Rn(this.#s,t);if(n==null&&this.#s!=null)this.#g="";this.#s=n;let r=Rn(this.#r,t,!0),i=[...this.#o].map((l)=>Rn(l,t)).filter((l)=>l!=null).map((l)=>this.#n.getPathInfo(l)?.path??null).filter((l)=>l!=null),o=Rn(this.#S,t),s=o==null?null:this.#n.getPathInfo(o)?.path??null,a=[...new Set(i)];if(!wi(this.#o,a))this.#o=new Set(a),this.#G+=1;return this.#S=s,r}#Ce(){return this.#n.on("*",(t)=>{if(this.#re)return;if(t.canonicalChanged)this.#b.clear(),this.#ae();if(this.#a!=null&&Bo(t))this.#a=null;let n=Bo(t)?this.#Ve(t):this.#r,r=this.#l!=null&&this.#l.length>0?this.#be():this.#l===""?this.#r:n,i=this.#l!=null||t.operation!=="expand"&&t.operation!=="collapse";this.#H(r,i),this.#d();let o=ic(t);if(o!=null)this.#we(o)})}#ke(t){if(this.#n.isExpanded(t)){this.#pe(t);return}this.#Ie(t)}};var lc=(e)=>{if(e==null||e.length===0)return"0";let t=`${e.length}`;for(let n of e)t+=`\x00${n.path}\x00${n.status}`;return t};function cc(e){let t=e.endsWith("/"),n="",r=-1;for(let i=0;i<=e.length;i+=1){if(!(e[i]==="/"||i===e.length)){if(r===-1)r=i;continue}if(r===-1)continue;if(n!=="")n+="/";n+=e.slice(r,i),r=-1}if(n==="")return null;return{isDirectory:t,path:n}}function uc(e){let t=e.endsWith("/")?e.slice(0,-1):e;if(t.length===0)return[];let n=[],r=0;for(;;){let i=t.indexOf("/",r);if(i===-1)break;n.push(t.slice(0,i+1)),r=i+1}return n}function cp(e,t){return t?`${e}/`:e}function Wo(e,t=null){let n=lc(e==null?void 0:[...e]);if(n==="0")return null;if(t?.signature===n)return t;let r=new Map,i=new Set,o=new Set,s=new Map;for(let a of e??[]){let l=hc(a);if(l==null)continue;pc({canonicalPath:l.canonicalPath,changeCountByDirectoryPath:s,directoriesWithChanges:i,ignoredDirectoryPaths:o,isDirectory:l.isDirectory,status:a.status,statusByPath:r})}if(r.size===0)return null;return{changeCountByDirectoryPath:s,directoriesWithChanges:i,ignoredDirectoryPaths:o,signature:n,statusByPath:r}}function dc(e,t){let n=t?.remove??[],r=t?.set??[];if(n.length===0&&r.length===0)return e;let i=new Map(e?.statusByPath),o=new Set(e?.directoriesWithChanges),s=new Set(e?.ignoredDirectoryPaths),a=new Map(e?.changeCountByDirectoryPath),l=!1;for(let d of n){let u=fc(d);if(u==null)continue;l=up({canonicalPath:u.canonicalPath,changeCountByDirectoryPath:a,directoriesWithChanges:o,ignoredDirectoryPaths:s,statusByPath:i})||l}for(let d of r){let u=hc(d);if(u==null)continue;l=pc({canonicalPath:u.canonicalPath,changeCountByDirectoryPath:a,directoriesWithChanges:o,ignoredDirectoryPaths:s,isDirectory:u.isDirectory,status:d.status,statusByPath:i})||l}if(!l)return e;if(i.size===0)return null;return{changeCountByDirectoryPath:a,directoriesWithChanges:o,ignoredDirectoryPaths:s,signature:fp(i),statusByPath:i}}function hc(e){return fc(e.path)}function fc(e){let t=cc(e);if(t==null)return;return{canonicalPath:cp(t.path,t.isDirectory),isDirectory:t.isDirectory}}function up({canonicalPath:e,changeCountByDirectoryPath:t,directoriesWithChanges:n,ignoredDirectoryPaths:r,statusByPath:i}){let o=i.get(e);if(o==null)return!1;if(i.delete(e),o==="ignored"&&e.endsWith("/"))r.delete(e);return hp(t,n,e),!0}function pc({canonicalPath:e,changeCountByDirectoryPath:t,directoriesWithChanges:n,ignoredDirectoryPaths:r,isDirectory:i,status:o,statusByPath:s}){let a=s.get(e);if(a===o)return!1;if(a==null)dp(t,n,e);if(s.set(e,o),o==="ignored"&&i)r.add(e);else if(i)r.delete(e);return!0}function dp(e,t,n){for(let r of uc(n))e.set(r,(e.get(r)??0)+1),t.add(r)}function hp(e,t,n){for(let r of uc(n)){let i=(e.get(r)??0)-1;if(i>0)e.set(r,i);else e.delete(r),t.delete(r)}}function fp(e){let t=`${e.size}`;for(let[n,r]of e)t+=`\x00${n}\x00${r}`;return t}var pp=(e)=>e.trim().toLowerCase(),mp=(e)=>e.split("/").at(-1)??e,gp=(e)=>{let t=e.toLowerCase().split("."),n=[];for(let r=1;r<t.length;r+=1)n.push(t.slice(r).join("."));return n};function Ir(e,t){if(typeof e==="string")return{name:e,remappedFrom:t};return{...e,remappedFrom:t}}function mc(e){let t=Pn(e),n=t.remap,r=new Map;for(let[a,l]of Object.entries(t.byFileName??{}))r.set(a.toLowerCase(),l);let i=new Map;for(let[a,l]of Object.entries(t.byFileExtension??{}))i.set(pp(a),l);let o=Object.entries(t.byFileNameContains??{}).map(([a,l])=>[a.toLowerCase(),l]);return{resolveIcon:(a,l)=>{if(a==="file-tree-icon-file"&&l!=null){let u=mp(l),f=u.toLowerCase(),c=r.get(f);if(c!=null)return Ir(c,a);for(let[g,v]of o)if(f.includes(g))return Ir(v,a);let m=gp(u);for(let g of m){let v=i.get(g);if(v!=null)return Ir(v,a)}let p=$l(t.set,u,m);if(p!=null&&t.set!=="none"){if(p==="default"){let g=n?.[a];if(g!=null)return Ir(g,a)}return{name:zl(p),remappedFrom:a,token:p}}}let d=n?.[a];if(d==null)return{name:a};return Ir(d,a)}}}var Y,wc,vp,cn,gc,xi,Ic,Sc,Uo,$o,jo,yp,Sr={},Cc=[],_i=Array.isArray,Go=Cc.slice,Wt=Object.assign;function Yo(e){e&&e.parentNode&&e.remove()}function Mn(e,t,n){var r,i,o,s={};for(o in t)o=="key"?r=t[o]:o=="ref"&&typeof e!="function"?i=t[o]:s[o]=t[o];return arguments.length>2&&(s.children=arguments.length>3?Go.call(arguments,2):n),Ci(e,s,r,i,null)}function Ci(e,t,n,r,i){var o={type:e,props:t,key:n,ref:r,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:i==null?++wc:i,__i:-1,__u:0};return i==null&&Y.vnode!=null&&Y.vnode(o),o}function pt(e){return e.children}function ki(e,t){this.props=e,this.context=t,this.__g=0}function Dn(e,t){if(t==null)return e.__?Dn(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"?Dn(e):null}function kc(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 kc(e)}}function vc(e){(8&e.__g||!(e.__g|=8)||!cn.push(e)||xi++)&&gc==Y.debounceRendering||((gc=Y.debounceRendering)||queueMicrotask)(bp)}function bp(){for(var e,t,n,r,i,o,s,a,l=1;cn.length;)cn.length>l&&cn.sort(Ic),e=cn.shift(),l=cn.length,8&e.__g&&(n=void 0,i=(r=(t=e).__v).__e,o=[],s=[],(a=t.__P)&&((n=Wt({},r)).__v=r.__v+1,Y.vnode&&Y.vnode(n),Xo(a,n,r,t.__n,a.namespaceURI,32&r.__u?[i]:null,o,i==null?Dn(r):i,!!(32&r.__u),s,a.ownerDocument),n.__v=r.__v,n.__.__k[n.__i]=n,Ec(o,n,s),n.__e!=i&&kc(n)));xi=0}function xc(e,t,n,r,i,o,s,a,l,d,u,f){var c,m,p,g,v,I,C,y=r&&r.__k||Cc,S=t.length;for(l=wp(n,t,y,l,S),c=0;c<S;c++)(p=n.__k[c])!=null&&(m=p.__i==-1?Sr:y[p.__i]||Sr,p.__i=c,I=Xo(e,p,m,i,o,s,a,l,d,u,f),g=p.__e,p.ref&&m.ref!=p.ref&&(m.ref&&Qo(m.ref,null,p),u.push(p.ref,p.__c||g,p)),v==null&&g!=null&&(v=g),(C=!!(4&p.__u))||m.__k===p.__k?l=_c(p,l,e,C):typeof p.type=="function"&&I!==void 0?l=I:g&&(l=g.nextSibling),p.__u&=-7);return n.__e=v,l}function wp(e,t,n,r,i){var o,s,a,l,d,u=n.length,f=u,c=0;for(e.__k=Array(i),o=0;o<i;o++)(s=t[o])!=null&&typeof s!="boolean"&&typeof s!="function"?(l=o+c,(s=e.__k[o]=typeof s=="string"||typeof s=="number"||typeof s=="bigint"||s.constructor==String?Ci(null,s,null,null,null):_i(s)?Ci(pt,{children:s},null,null,null):s.constructor==null&&s.__b>0?Ci(s.type,s.props,s.key,s.ref?s.ref:null,s.__v):s).__=e,s.__b=e.__b+1,a=null,(d=s.__i=Ip(s,n,l,f))!=-1&&(f--,(a=n[d])&&(a.__u|=2)),a==null||a.__v==null?(d==-1&&(i>u?c--:i<u&&c++),typeof s.type!="function"&&(s.__u|=4)):d!=l&&(d==l-1?c--:d==l+1?c++:(d>l?c--:c++,s.__u|=4))):e.__k[o]=null;if(f)for(o=0;o<u;o++)(a=n[o])!=null&&(2&a.__u)==0&&(a.__e==r&&(r=Dn(a)),Pc(a,a));return r}function _c(e,t,n,r){var i,o;if(typeof e.type=="function"){for(i=e.__k,o=0;i&&o<i.length;o++)i[o]&&(i[o].__=e,t=_c(i[o],t,n,r));return t}e.__e!=t&&(r&&(t&&e.type&&!t.parentNode&&(t=Dn(e)),n.insertBefore(e.__e,t||null)),t=e.__e);do t=t&&t.nextSibling;while(t!=null&&t.nodeType==8);return t}function Ip(e,t,n,r){var i,o,s,a=e.key,l=e.type,d=t[n],u=d!=null&&(2&d.__u)==0;if(d===null&&e.key==null||u&&a==d.key&&l==d.type)return n;if(r>(u?1:0)){for(i=n-1,o=n+1;i>=0||o<t.length;)if((d=t[s=i>=0?i--:o++])!=null&&(2&d.__u)==0&&a==d.key&&l==d.type)return s}return-1}function yc(e,t,n){t[0]=="-"?e.setProperty(t,n==null?"":n):e[t]=n==null?"":n}function Si(e,t,n,r,i){var o;e: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||yc(e.style,t,"");if(n)for(t in n)r&&n[t]==r[t]||yc(e.style,t,n[t])}else if(t[0]=="o"&&t[1]=="n")o=t!=(t=t.replace(Sc,"$1")),(t=t.slice(2))[0].toLowerCase()!=t[0]&&(t=t.toLowerCase()),e.__l||(e.__l={}),e.__l[t+o]=n,n?r?n.l=r.l:(n.l=Uo,e.addEventListener(t,o?jo:$o,o)):e.removeEventListener(t,o?jo:$o,o);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==null?"":n;break e}catch(s){}typeof n=="function"||(n==null||n===!1&&t[4]!="-"?e.removeAttribute(t):e.setAttribute(t,t=="popover"&&n==1?"":n))}}function bc(e){return function(t){if(this.__l){var n=this.__l[t.type+e];if(t.u==null)t.u=Uo++;else if(t.u<n.l)return;return n(Y.event?Y.event(t):t)}}}function Xo(e,t,n,r,i,o,s,a,l,d,u){var f,c,m,p,g,v,I,C,y,S,k,T,O,pe,Z,me,J,U,B,ae,Ce,z=t.type;if(t.constructor!=null)return null;128&n.__u&&(l=!!(32&n.__u),n.__c.__z&&(a=t.__e=n.__e=(o=n.__c.__z)[0],n.__c.__z=null)),(f=Y.__b)&&f(t);e:if(typeof z=="function")try{if(C=t.props,y="prototype"in z&&z.prototype.render,S=(f=z.contextType)&&r[f.__c],k=f?S?S.props.value:f.__:r,n.__c?2&(c=t.__c=n.__c).__g&&(c.__g|=1,I=!0):(y?t.__c=c=new z(C,k):(t.__c=c=new ki(C,k),c.constructor=z,c.render=Cp),S&&S.sub(c),c.props=C,c.state||(c.state={}),c.context=k,c.__n=r,m=!0,c.__g|=8,c.__h=[],c._sb=[]),y&&c.__s==null&&(c.__s=c.state),y&&z.getDerivedStateFromProps!=null&&(c.__s==c.state&&(c.__s=Wt({},c.__s)),Wt(c.__s,z.getDerivedStateFromProps(C,c.__s))),p=c.props,g=c.state,c.__v=t,m)y&&z.getDerivedStateFromProps==null&&c.componentWillMount!=null&&c.componentWillMount(),y&&c.componentDidMount!=null&&c.__h.push(c.componentDidMount);else{if(y&&z.getDerivedStateFromProps==null&&C!==p&&c.componentWillReceiveProps!=null&&c.componentWillReceiveProps(C,k),!(4&c.__g)&&c.shouldComponentUpdate!=null&&c.shouldComponentUpdate(C,c.__s,k)===!1||t.__v==n.__v){for(t.__v!=n.__v&&(c.props=C,c.state=c.__s,c.__g&=-9),t.__e=n.__e,t.__k=n.__k,t.__k.some(function(le){le&&(le.__=t)}),T=0;T<c._sb.length;T++)c.__h.push(c._sb[T]);c._sb=[],c.__h.length&&s.push(c);break e}c.componentWillUpdate!=null&&c.componentWillUpdate(C,c.__s,k),y&&c.componentDidUpdate!=null&&c.__h.push(function(){c.componentDidUpdate(p,g,v)})}if(c.context=k,c.props=C,c.__P=e,c.__g&=-5,O=Y.__r,pe=0,y){for(c.state=c.__s,c.__g&=-9,O&&O(t),f=c.render(c.props,c.state,c.context),Z=0;Z<c._sb.length;Z++)c.__h.push(c._sb[Z]);c._sb=[]}else do c.__g&=-9,O&&O(t),f=c.render(c.props,c.state,c.context),c.state=c.__s;while(8&c.__g&&++pe<25);c.state=c.__s,c.getChildContext!=null&&(r=Wt({},r,c.getChildContext())),y&&!m&&c.getSnapshotBeforeUpdate!=null&&(v=c.getSnapshotBeforeUpdate(p,g)),me=f,f!=null&&f.type===pt&&f.key==null&&(me=Tc(f.props.children)),a=xc(e,_i(me)?me:[me],t,n,r,i,o,s,a,l,d,u),t.__u&=-161,c.__h.length&&s.push(c),I&&(c.__g&=-4)}catch(le){if(t.__v=null,l||o!=null)if(le.then){for(J=0,U=!1,t.__u|=l?160:128,t.__c.__z=[],B=0;B<o.length;B++)(ae=o[B])==null||U||(ae.nodeType==8&&ae.data=="$s"?(J>0&&t.__c.__z.push(ae),J++,o[B]=null):ae.nodeType==8&&ae.data=="/$s"?(--J>0&&t.__c.__z.push(ae),U=J===0,a=o[B],o[B]=null):J>0&&(t.__c.__z.push(ae),o[B]=null));if(!U){for(;a&&a.nodeType==8&&a.nextSibling;)a=a.nextSibling;o[o.indexOf(a)]=null,t.__c.__z=[a]}t.__e=a}else{for(Ce=o.length;Ce--;)Yo(o[Ce]);Ko(t)}else t.__e=n.__e,t.__k=n.__k,le.then||Ko(t);Y.__e(le,t,n)}else a=t.__e=Sp(n.__e,t,n,r,i,o,s,l,d,u);return(f=Y.diffed)&&f(t),128&t.__u?void 0:a}function Ko(e){e&&e.__c&&(e.__c.__g|=4),e&&e.__k&&e.__k.forEach(Ko)}function Ec(e,t,n){for(var r=0;r<n.length;r++)Qo(n[r],n[++r],n[++r]);Y.__c&&Y.__c(t,e),e.some(function(i){try{e=i.__h,i.__h=[],e.some(function(o){o.call(i)})}catch(o){Y.__e(o,i.__v)}})}function Tc(e){return typeof e!="object"||e==null||e.__b&&e.__b>0?e:_i(e)?e.map(Tc):Wt({},e)}function Sp(e,t,n,r,i,o,s,a,l,d){var u,f,c,m,p,g,v,I,C=n.props,y=t.props,S=t.type;if(S=="svg"?i="http://www.w3.org/2000/svg":S=="math"?i="http://www.w3.org/1998/Math/MathML":i||(i="http://www.w3.org/1999/xhtml"),o!=null){for(u=0;u<o.length;u++)if((p=o[u])&&"setAttribute"in p==!!S&&(S?p.localName==S:p.nodeType==3)){e=p,o[u]=null;break}}if(e==null){if(S==null)return d.createTextNode(y);e=d.createElementNS(i,S,y.is&&y),a&&(Y.__m&&Y.__m(t,o),a=!1),o=null}if(S==null)C===y||a&&e.data==y||(e.data=y);else{if(o=o&&Go.call(e.childNodes),C=n.props||Sr,!a&&o!=null)for(C={},u=0;u<e.attributes.length;u++)C[(p=e.attributes[u]).name]=p.value;for(u in C)if(p=C[u],u=="children");else if(u=="dangerouslySetInnerHTML")c=p;else if(!(u in y)){if(u=="value"&&"defaultValue"in y||u=="checked"&&"defaultChecked"in y)continue;Si(e,u,null,p,i)}for(u in I=1&n.__u,y)p=y[u],u=="children"?m=p:u=="dangerouslySetInnerHTML"?f=p:u=="value"?g=p:u=="checked"?v=p:a&&typeof p!="function"||C[u]===p&&!I||Si(e,u,p,C[u],i);if(f)a||c&&(f.__html==c.__html||f.__html==e.innerHTML)||(e.innerHTML=f.__html),t.__k=[];else if(c&&(e.innerHTML=""),xc(S=="template"?e.content:e,_i(m)?m:[m],t,n,r,S=="foreignObject"?"http://www.w3.org/1999/xhtml":i,o,s,o?o[0]:n.__k&&Dn(n,0),a,l,d),o!=null)for(u=o.length;u--;)Yo(o[u]);a||(u="value",S=="progress"&&g==null?e.removeAttribute("value"):g==null||g===e[u]&&(S!=="progress"||g)||Si(e,u,g,C[u],i),u="checked",v!=null&&v!=e[u]&&Si(e,u,v,C[u],i))}return e}function Qo(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(i){Y.__e(i,n)}}function Pc(e,t,n){var r,i;if(Y.unmount&&Y.unmount(e),(r=e.ref)&&(r.current&&r.current!=e.__e||Qo(r,null,t)),(r=e.__c)!=null){if(r.componentWillUnmount)try{r.componentWillUnmount()}catch(o){Y.__e(o,t)}r.__P=null}if(r=e.__k)for(i=0;i<r.length;i++)r[i]&&Pc(r[i],t,n||typeof e.type!="function");n||Yo(e.__e),e.__e&&e.__e.__l&&(e.__e.__l=null),e.__e=e.__c=e.__=null}function Cp(e,t,n){return this.constructor(e,n)}function Ei(e,t){var n,r,i,o;t==document&&(t=document.documentElement),Y.__&&Y.__(e,t),r=(n=!!(e&&32&e.__u))?null:t.__k,e=t.__k=Mn(pt,null,[e]),i=[],o=[],Xo(t,e,r||Sr,Sr,t.namespaceURI,r?null:t.firstChild?Go.call(t.childNodes):null,i,r?r.__e:t.firstChild,n,o,t.ownerDocument),Ec(i,e,o)}function Rc(e,t){e.__u|=32,Ei(e,t)}Y={__e:function(e,t,n,r){for(var i,o,s;t=t.__;)if((i=t.__c)&&!(1&i.__g)){i.__g|=4;try{if((o=i.constructor)&&o.getDerivedStateFromError!=null&&(i.setState(o.getDerivedStateFromError(e)),s=8&i.__g),i.componentDidCatch!=null&&(i.componentDidCatch(e,r||{}),s=8&i.__g),s)return void(i.__g|=2)}catch(a){e=a}}throw xi=0,e}},wc=0,vp=function(e){return e!=null&&e.constructor==null},ki.prototype.setState=function(e,t){var n;n=this.__s!=null&&this.__s!=this.state?this.__s:this.__s=Wt({},this.state),typeof e=="function"&&(e=e(Wt({},n),this.props)),e&&Wt(n,e),e!=null&&this.__v&&(t&&this._sb.push(t),vc(this))},ki.prototype.forceUpdate=function(e){this.__v&&(this.__g|=4,e&&this.__h.push(e),vc(this))},ki.prototype.render=pt,cn=[],xi=0,Ic=function(e,t){return e.__v.__b-t.__v.__b},Sc=/(PointerCapture)$|Capture$/i,Uo=0,$o=bc(!1),jo=bc(!0),yp=0;var kp=0;function x(e,t,n,r,i,o){t||(t={});var s,a,l=t;if("ref"in l&&typeof e!="function")for(a in l={},t)a=="ref"?s=t[a]:l[a]=t[a];var d={type:e,props:l,key:n,ref:s,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--kp,__i:-1,__u:0,__source:i,__self:o};return Y.vnode&&Y.vnode(d),d}var xp=16,_p=16,Ep={};function An({name:e,remappedFrom:t,token:n,width:r,height:i,viewBox:o,label:s,alignCapitals:a=!1}){let l=`#${e.replace(/^#/,"")}`,{width:d,height:u,viewBox:f}=Ep[e]??{width:xp,height:_p},c=r??d,m=i??u,p=o??f??`0 0 ${d} ${u}`;return x("svg",{"data-icon-name":t??e,"data-icon-token":n,"data-align-capitals":a,...s!=null?{"aria-label":s,role:"img"}:{"aria-hidden":!0},viewBox:p,width:c,height:m,children:x("use",{href:l})})}var Dc=(e)=>e!==void 0&&/\s/.test(e),Tp=(e,t)=>{let n=(r)=>Dc(e[r-1])||Dc(e[r]);if(!n(t))return t;for(let r=1;r<e.length;r++){let i=t-r;if(i>0&&!n(i))return i;let o=t+r;if(o<e.length&&!n(o))return o}return t},Ac=(e)=>Tp(e,Math.ceil(e.length/2)),Mc=(e)=>{if(e.length<2)return[e,""];let t=Ac(e);return[e.slice(0,t),e.slice(t)]},Pp=(e)=>{if(e.length<4)return[e,""];let t=e.lastIndexOf(".")+1,n=e.length-t>10,r=t>=1&&!n?t:Ac(e);return[e.slice(0,r),e.slice(r)]},Rp=(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)]},Dp=(e,{splitIndex:t}={})=>{if(typeof t!=="number"){let n=Math.ceil(e.length/2);return[e.slice(0,n),e.slice(n)]}return[e.slice(0,t),e.slice(t)]},Mp=(e,{splitOffset:t}={})=>{if(typeof t!=="number"||t<=0||t>=e.length){let r=Math.ceil(e.length/2);return[e.slice(0,r),e.slice(r)]}let n=e.length-t;return[e.slice(0,n),e.slice(n)]},Ap=(e,{splitOffset:t}={})=>{if(typeof t!=="number"||t<=0||t>=e.length){let r=Math.ceil(e.length/2);return[e.slice(0,r),e.slice(r)]}let n=t;return[e.slice(0,n),e.slice(n)]};function Np({children:e,marker:t,variant:n="default"}){return x("div",{"aria-hidden":!0,"data-truncate-marker-cell":!0,children:x("div",{"data-truncate-marker":!0,children:typeof t==="function"?t({children:e}):n==="fade"?x("span",{"data-truncate-fade":!0}):t})})}function Lp(e){let{mode:t,children:n}=e;return x("div",{children:[x("div",{"data-truncate-content":"visible",children:t==="fruncate"?x("span",{children:n}):n}),x("div",{"data-truncate-content":"overflow","aria-hidden":!0,children:t==="fruncate"?x("span",{children:n}):n})]})}function Nc({children:e,mode:t="truncate",marker:n="…",variant:r="default",...i}){let o=x(Lp,{mode:t,children:e},"content"),s=x(Np,{marker:n,mode:t,variant:r},"marker"),a=x("div",{"data-truncate-fill":!0},"fill");return x("div",{"data-truncate-container":t,"data-truncate-variant":r,...i,children:x("div",{"data-truncate-grid":!0,children:t==="truncate"?[o,s]:[s,o,a]})})}function Cr({children:e,...t}){return x(Nc,{mode:"truncate",...t,children:e})}function Zo({children:e,...t}){return x(Nc,{mode:"fruncate",...t,children:e})}function Lc({children:e,contents:t,priority:n="end",split:r="center",minimumLength:i=12,className:o,style:s,...a}){let l=null,d=null;if(Array.isArray(t)){if(t.length!==2)return console.error("MiddleTruncate: contents must be an array of two items"),null;l=x(Cr,{...a,children:t[0]}),d=x(Zo,{...a,children:t[1]})}else{if(typeof e!=="string")return console.error("MiddleTruncate: children must be a string"),null;if(e.length===0)return x("div",{className:o,style:s});if(e.length<i)if(n==="end")return x(Zo,{...a,className:o,style:s,children:e});else return x(Cr,{...a,className:o,style:s,children:e});let u=null,f=null,c=null;if(typeof r==="string"){if(r==="center")u=Mc;else if(r==="extension")u=Pp;else if(r==="leaf-path")u=Rp}else if(typeof r==="number")u=Dp,f=r;else if(Array.isArray(r)){let[S,k]=r;if(c=k,S==="last")u=Mp;else if(S==="first")u=Ap}else if(typeof r==="function")u=r;u??=Mc;let[m,p]=u(e,{priority:n,variant:a.variant,splitIndex:typeof f==="number"?f:void 0,splitOffset:typeof c==="number"?c:void 0}),g=m.length>=p.length,v=n==="equal"&&!g,I=n==="equal"&&g,C={},y={};if(v)C.marker="";if(I)y.marker="";l=x(Cr,{...a,...C,children:m}),d=x(Zo,{...a,...y,children:p})}return x("div",{"data-truncate-group-container":"middle",className:o,style:s,children:[x("div",{"data-truncate-segment-priority":n==="start"||n==="equal"?"1":"2",children:l}),x("div",{"data-truncate-segment-priority":n==="end"||n==="equal"?"1":"2",children:d})]})}var Jo={endIndex:-1,startIndex:-1};function Fp(e,t,n){return Math.min(Math.max(e,t),n)}function Fc(e,t){return e<0||t<e?Jo:{endIndex:t,startIndex:e}}function es(e){return e.startIndex<0||e.endIndex<e.startIndex}function Bp(e,t){return es(e)?0:(e.endIndex-e.startIndex+1)*t}function Bc(e,t,n){if(t<=0)return-1;let r=t*n;if(e<=0)return 0;if(e>=r)return t;return Math.floor(e/n)}function Hp(e,t,n){if(t<=0||e<=0)return-1;if(e>=t*n)return t-1;return Math.ceil(e/n)-1}function Vp(e){let t=new Map;return e.forEach((n,r)=>{if(n.kind!=="directory"||!n.isExpanded)return;let i=n.ancestorPaths.length,o=t.get(i);if(o==null){t.set(i,[r]);return}o.push(r)}),t}function Op(e,t){let n=0,r=e.length-1,i=-1;while(n<=r){let o=Math.floor((n+r)/2),s=e[o];if(s==null)break;if(s<=t){i=o,n=o+1;continue}r=o-1}return i}function qp(e){let t=new Map,n=[];for(let i=0;i<e.length;i+=1){let o=e[i];if(o==null)continue;let s=o.kind==="directory"&&o.isExpanded?[...o.ancestorPaths,o.path]:o.ancestorPaths,a=0;while(a<n.length&&a<s.length&&n[a]===s[a])a+=1;for(let l=n.length-1;l>=a;l-=1){let d=n[l];if(d!=null)t.set(d,i-1)}n.length=a;for(let l=a;l<s.length;l+=1){let d=s[l];if(d!=null)n.push(d)}}let r=e.length-1;for(let i of n)t.set(i,r);return t}function ts(e,t,n){if(e.length===0||t<=0)return[];let r=qp(e),i=Vp(e),o=[];for(let s=0;s<e.length;s+=1){let a=i.get(s);if(a==null||a.length===0)break;let l=t+s*n,d=Op(a,Math.min(e.length-1,Math.floor(l/n))),u=null;while(d>=0){let f=a[d],c=f==null?null:e[f]??null;if(c!=null&&(s===0||c.ancestorPaths[s-1]===o[s-1]?.path)){u=c;break}d-=1}if(u==null)break;o.push(u)}return o.map((s,a)=>{let l=a*n,d=(r.get(s.path)??e.length-1)+1;if(d>=e.length)return{row:s,top:l};let u=d*n-t;return{row:s,top:Math.min(l,u-n)}}).filter((s)=>s.top+n>0)}function Hc(e,t){let n=t.totalRowCount??e.length,r=n*t.itemHeight,i=Math.max(0,t.viewportHeight),o=Math.max(0,Math.floor(t.overscan)),s=Math.max(0,r-i),a=Fp(t.scrollTop,0,s),l=t.stickyRows??ts(e,a,t.itemHeight),d=l.reduce((T,O)=>Math.max(T,O.top+t.itemHeight),0),u=Math.min(r,a+d),f=Math.max(0,i-d),c=Math.max(0,r-u),m=Bc(a,n,t.itemHeight),p=Bc(u,n,t.itemHeight),g=d<=0||m<0||m>=n?-1:m,v=g===-1?-1:Math.min(n-1,p-1),I=g===-1||v<g?0:v-g+1,C=f<=0||p>=n?Jo:Fc(p,Hp(u+f,n,t.itemHeight)),y=v+1,S=es(C)?Jo:Fc(Math.max(y,C.startIndex-o),Math.min(n-1,C.endIndex+o)),k=Bp(S,t.itemHeight);return{occlusion:{firstOccludedIndex:g,lastOccludedIndex:v,occludedCount:I},physical:{itemHeight:t.itemHeight,maxScrollTop:s,overscan:o,scrollTop:a,totalHeight:r,totalRowCount:n,viewportHeight:i},projected:{contentHeight:c,paneHeight:f,paneTop:u},sticky:{height:d,rows:l},visible:C,window:{endIndex:S.endIndex,height:k,offsetTop:es(S)?0:S.startIndex*t.itemHeight,startIndex:S.startIndex}}}var Vc={added:"A",deleted:"D",ignored:null,modified:"M",renamed:"R",untracked:"U"},Oc={added:"Git status: added",deleted:"Git status: deleted",ignored:"Git status: ignored",modified:"Git status: modified",renamed:"Git status: renamed",untracked:"Git status: untracked"},qc="Contains git status items";function zc(e){if(e.current)return!0;return e.current=!0,!1}function ns(e){let{currentScrollTop:t,focusedIndex:n,itemHeight:r,topInset:i=0,viewportHeight:o}=e;if(n<0)return null;let s=Math.max(0,i),a=n*r,l=a+r;if(a<t+s){let d=Math.max(0,a-s);return d===t?null:d}if(l>t+o){let d=l-o;return d===t?null:d}return null}function Wc(e){let{currentScrollTop:t,focusedIndex:n,itemHeight:r,offset:i,topInset:o=0,totalHeight:s,viewportHeight:a}=e;if(i==="nearest")return ns({currentScrollTop:t,focusedIndex:n,itemHeight:r,topInset:o,viewportHeight:a});if(n<0)return null;let l=Math.max(0,o),d=n*r,u=Math.max(0,a-l),f=i==="center"?l+Math.max(0,(u-r)/2):l,c=Math.max(0,s-a),m=Math.max(0,Math.min(d-f,c));return m===t?null:m}function $c(e){let{currentScrollTop:t,focusedIndex:n,itemHeight:r,targetViewportOffset:i,totalHeight:o,viewportHeight:s}=e;if(n<0)return null;let a=Math.max(0,i),l=n*r,d=l+r,u=t+a,f=t+s;if(l>=u&&d<=f)return null;let c=Math.max(0,o-s),m=Math.max(0,Math.min(l-a,c));return m===t?null:m}function un(e){if(e==null||!e.isConnected)return!1;if(e===document.body||e===document.documentElement)return!1;e.focus({preventScroll:!0});let t=e.getRootNode();if(t instanceof ShadowRoot)return t.activeElement===e;return document.activeElement===e}function kr(e){let t=e.getRootNode();if(t instanceof ShadowRoot){let r=t.activeElement;return r instanceof HTMLElement?r:null}let n=document.activeElement;return n instanceof HTMLElement&&e.contains(n)?n:null}function Nn(e,t){if(e==null)return t;let n=e.getBoundingClientRect().height;if(n>0)return n;return e.clientHeight>0?e.clientHeight:t}function rs(e,t){return e!=null&&e>0?e:t}function jc(e){let t=e.borderBoxSize,n=Array.isArray(t)?t[0]:t;if(n!=null&&Number.isFinite(n.blockSize)&&n.blockSize>0)return n.blockSize;return e.contentRect.height>0?e.contentRect.height:null}function is(e,t,n,r,i=0){let o=ns({currentScrollTop:e.scrollTop,focusedIndex:t,itemHeight:n,topInset:i,viewportHeight:r});if(o==null)return!1;return e.scrollTop=o,!0}function Kc(e,t,n,r,i,o,s=0){let a=Wc({currentScrollTop:e.scrollTop,focusedIndex:t,itemHeight:n,offset:o,topInset:s,totalHeight:i,viewportHeight:r});if(a==null)return!1;return e.scrollTop=a,!0}function Ln(e,t,n,r,i,o){let s=$c({currentScrollTop:e.scrollTop,focusedIndex:t,itemHeight:n,targetViewportOffset:o,totalHeight:i,viewportHeight:r});if(s==null)return!1;return e.scrollTop=s,!0}function os(e,t,n,r){if(n.end<n.start)return null;if(e<n.start)return-t;if(e>n.end)return r;return null}function Uc(e){let{renamingPath:t,previousRenamingPath:n,hasRenderedInput:r}=e;if(t==null)return"reset";if(!r)return"reveal-canonical";if(n===t)return"ignore";return"focus-input"}function Gc({ariaLabel:e,isFlattened:t=!1,ref:n,value:r,onBlur:i,onInput:o}){return x("input",{ref:n,"data-item-rename-input":!0,...t?{"data-item-flattened-rename-input":!0}:{},"aria-label":e,value:r,onBlur:i,onInput:o,onClick:(s)=>s.stopPropagation(),onMouseDown:(s)=>s.stopPropagation(),onPointerDown:(s)=>s.stopPropagation()})}function Yc(e){let{row:t,mode:n,targetPath:r,ariaLabel:i,domId:o,isParked:s,itemHeight:a,features:l,state:d,extraStyle:u}=e,f=n==="sticky",c=t.ancestorPaths.at(-1)??"",m={};if(d.isFocusRinged)m["data-item-focused"]=!0;if(t.isSelected)m["data-item-selected"]=!0;if(d.isContextHovered)m["data-item-context-hover"]="true";if(d.isDragTarget)m["data-item-drag-target"]=!0;if(d.isDragging)m["data-item-dragging"]=!0;if(d.effectiveGitStatus!=null)m["data-item-git-status"]=d.effectiveGitStatus;if(d.containsGitChange)m["data-item-contains-git-change"]="true";return{"aria-expanded":!f&&t.kind==="directory"?t.isExpanded:void 0,"aria-haspopup":l.contextMenuEnabled?"menu":void 0,"aria-label":i,"aria-level":!f?t.level+1:void 0,"aria-posinset":!f?t.posInSet+1:void 0,"aria-selected":!f?t.isSelected?"true":"false":void 0,"aria-setsize":!f?t.setSize:void 0,"data-file-tree-sticky-path":f?r:void 0,"data-file-tree-sticky-row":f?"true":void 0,"data-item-context-menu-button-visibility":l.actionLaneEnabled?l.contextMenuButtonVisibility:void 0,"data-item-context-menu-trigger-mode":l.contextMenuEnabled?l.contextMenuTriggerMode:void 0,"data-item-has-context-menu-action-lane":l.actionLaneEnabled?"true":void 0,"data-item-has-git-lane":l.gitLaneActive?"true":void 0,"data-item-parent-path":c.length>0?c:void 0,"data-item-parked":s?"true":void 0,"data-item-path":r,"data-item-type":t.kind==="directory"?"folder":"file","data-type":"item",id:!f?o:void 0,role:!f?"treeitem":void 0,style:{minHeight:`${a}px`,...u},tabIndex:!f&&t.isFocused?0:-1,...m}}function Xc(e){let{event:t,mode:n,isSearchOpen:r,isDirectory:i}=e,o=t.ctrlKey||t.metaKey,s=t.shiftKey||o,a=t.shiftKey?{additive:o,kind:"range"}:o?{kind:"toggle"}:{kind:"single"};return{closeSearch:r,revealCanonical:n==="sticky",selection:a,toggleDirectory:!s&&i}}var Fn,ye,ss,Qc,as=Object.is,xr=0,ou=[],Ie=Y,Zc=Ie.__b,Jc=Ie.__r,eu=Ie.diffed,tu=Ie.__c,nu=Ie.unmount,ru=Ie.__;function Pi(e,t){Ie.__h&&Ie.__h(ye,e,xr||t),xr=0;var n=ye.__H||(ye.__H={__:[],__h:[]});return e>=n.__.length&&n.__.push({}),n.__[e]}function lt(e){return xr=1,zp(su,e)}function zp(e,t,n){var r=Pi(Fn++,2);if(r.t=e,!r.__c&&(r.__=[n?n(t):su(void 0,t),function(a){var l=r.__N?r.__N[0]:r.__[0],d=r.t(l,a);as(l,d)||(r.__N=[d,r.__[1]],r.__c.setState({}))}],r.__c=ye,!ye.__f)){var i=function(a,l,d){if(!r.__c.__H)return!0;var u=r.__c.__H.__.filter(function(c){return!!c.__c});if(u.every(function(c){return!c.__N}))return!o||o.call(this,a,l,d);var f=r.__c.props!==a;return u.forEach(function(c){if(c.__N){var m=c.__[0];c.__=c.__N,c.__N=void 0,as(m,c.__[0])||(f=!0)}}),o&&o.call(this,a,l,d)||f};ye.__f=!0;var{shouldComponentUpdate:o,componentWillUpdate:s}=ye;ye.componentWillUpdate=function(a,l,d){if(4&this.__g){var u=o;o=void 0,i(a,l,d),o=u}s&&s.call(this,a,l,d)},ye.shouldComponentUpdate=i}return r.__N||r.__}function cs(e,t){var n=Pi(Fn++,3);!Ie.__s&&us(n.__H,t)&&(n.__=e,n.u=t,ye.__H.__h.push(n))}function We(e,t){var n=Pi(Fn++,4);!Ie.__s&&us(n.__H,t)&&(n.__=e,n.u=t,ye.__h.push(n))}function V(e){return xr=5,_t(function(){return{current:e}},[])}function _t(e,t){var n=Pi(Fn++,7);return us(n.__H,t)&&(n.__=e(),n.__H=t,n.__h=e),n.__}function Re(e,t){return xr=8,_t(function(){return e},t)}function Wp(){for(var e;e=ou.shift();)if(e.__P&&e.__H)try{e.__H.__h.forEach(Ti),e.__H.__h.forEach(ls),e.__H.__h=[]}catch(t){e.__H.__h=[],Ie.__e(t,e.__v)}}Ie.__b=function(e){ye=null,Zc&&Zc(e)},Ie.__=function(e,t){e&&t.__k&&t.__k.__m&&(e.__m=t.__k.__m),ru&&ru(e,t)},Ie.__r=function(e){Jc&&Jc(e),Fn=0;var t=(ye=e.__c).__H;t&&(ss===ye?(t.__h=[],ye.__h=[],t.__.forEach(function(n){n.__N&&(n.__=n.__N),n.u=n.__N=void 0})):(t.__h.forEach(Ti),t.__h.forEach(ls),t.__h=[],Fn=0)),ss=ye},Ie.diffed=function(e){eu&&eu(e);var t=e.__c;t&&t.__H&&(t.__H.__h.length&&(ou.push(t)!==1&&Qc===Ie.requestAnimationFrame||((Qc=Ie.requestAnimationFrame)||$p)(Wp)),t.__H.__.forEach(function(n){n.u&&(n.__H=n.u),n.u=void 0})),ss=ye=null},Ie.__c=function(e,t){t.some(function(n){try{n.__h.forEach(Ti),n.__h=n.__h.filter(function(r){return!r.__||ls(r)})}catch(r){t.some(function(i){i.__h&&(i.__h=[])}),t=[],Ie.__e(r,n.__v)}}),tu&&tu(e,t)},Ie.unmount=function(e){nu&&nu(e);var t,n=e.__c;n&&n.__H&&(n.__H.__.forEach(function(r){try{Ti(r)}catch(i){t=i}}),n.__H=void 0,t&&Ie.__e(t,n.__v))};var iu=typeof requestAnimationFrame=="function";function $p(e){var t,n=function(){clearTimeout(r),iu&&cancelAnimationFrame(t),setTimeout(e)},r=setTimeout(n,35);iu&&(t=requestAnimationFrame(n))}function Ti(e){var t=ye,n=e.__c;typeof n=="function"&&(e.__c=void 0,n()),ye=t}function ls(e){var t=ye;e.__c=e.__(),ye=t}function us(e,t){return!e||e.length!==t.length||t.some(function(n,r){return!as(n,e[r])})}function su(e,t){return typeof t=="function"?t(e):t}function jp(e,t=null,n=null){let r=e.flattenedSegments;if(r==null||r.length===0)return t??e.name;return x("span",{"data-item-flattened-subitems":!0,children:r.map((i,o)=>{let s=o===r.length-1;return x(pt,{children:[x("span",{"data-item-flattened-subitem":i.path,"data-item-flattened-subitem-drag-target":n===i.path?"true":void 0,children:s&&t!=null?t:x(Cr,{children:i.name})}),o<r.length-1?" / ":""]},i.path)})})}function Hn(e){return e.isFlattened?e.flattenedSegments?.findLast((t)=>t.isTerminal)?.path??e.path:e.path}function hs(e){let t=e.flattenedSegments;if(t==null||t.length===0)return e.name;return t.map((n)=>n.name).join(" / ")}function au(e,t,n,r){return e.map((i,o)=>{let s=o*n,a=i.subtreeEndIndex+1;if(a>=r)return{row:i.row,top:s};let l=a*n-t;return{row:i.row,top:Math.min(s,l-n)}}).filter((i)=>i.top+n>0)}function ds({controller:e,itemHeight:t,overscan:n,scrollTop:r,stickyFolders:i,viewportHeight:o}){let s=e.getVisibleCount(),a=i&&s>0?e.getStickyRowCandidates(r,t):[],l=a==null&&i&&s>0?e.getVisibleRows(0,s-1):[],d=Hc(l,{itemHeight:t,overscan:n,scrollTop:r,stickyRows:a==null?void 0:au(a,r,t,s),totalRowCount:s,viewportHeight:o}),u=i&&r<=0&&s>0?e.getStickyRowCandidates(1,t):[],f=u!=null&&r<=0?au(u,1,t,s):i&&r<=0&&l.length>0?ts(l,1,t):d.sticky.rows;return{overlayHeight:f.reduce((c,m)=>Math.max(c,m.top+t),0),overlayRows:f,snapshot:d,visibleRows:l}}var Kp=400,lu=10,Bn=40,cu=18;function Up(e,t,n){let r=e,i=document.elementFromPoint?.bind(document)??null,o=r.elementFromPoint?.(t,n)??i?.(t,n)??null;if(e instanceof ShadowRoot&&(o==null||!e.contains(o)))return Gp(e,t,n);return o instanceof HTMLElement?o:null}function Gp(e,t,n){let r=Array.from(e.querySelectorAll('[data-type="item"], [data-item-flattened-subitem]'));for(let i=r.length-1;i>=0;i--){let o=r[i],s=o.getBoundingClientRect();if(t>=s.left&&t<=s.right&&n>=s.top&&n<=s.bottom)return o}return null}function uu(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 o=t.dataset.itemParentPath??null;if(o==null||o.length===0)return{directoryPath:null,flattenedSegmentPath:null,hoveredPath:n,kind:"root"};return{directoryPath:o,flattenedSegmentPath:null,hoveredPath:n,kind:"directory"}}function du(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 Yp(){return navigator.vendor!=="Apple Computer, Inc."}function Xp(e,t){let n=e-t.top;if(n<Bn)return-Math.ceil((Bn-Math.max(0,n))/Bn*cu);let r=t.bottom-e;if(r<Bn)return Math.ceil((Bn-Math.max(0,r))/Bn*cu);return 0}function Qp(e,t){if(e!=null){let n=Vc[e];if(n==null)return null;return{text:n,title:Oc[e]}}if(t)return{icon:{name:"file-tree-icon-dot",width:6,height:6},title:qc};return null}function Zp(e,t,n){if(t==null||t.size===0)return null;let r=[];for(let i=e.length-1;i>=0;i-=1){let o=e[i],s=n.get(o);if(s!=null){for(let a of r)n.set(a,s);return s?"ignored":null}if(t.has(o)){n.set(o,!0);for(let a of r)n.set(a,!0);return"ignored"}r.push(o)}for(let i of r)n.set(i,!1);return null}function hu(e){return e!=null&&"toggle"in e}function wu(e){return e.code==="Space"||e.key===" "||e.key==="Spacebar"}function Jp(e){return e.key.length===1&&/^[\p{L}\p{N}]$/u.test(e.key)&&!e.ctrlKey&&!e.metaKey&&!e.altKey}function em(e){if(e==null)return"";return`[data-item-section="spacing-item"][data-ancestor-path="${e.replaceAll("\\","\\\\").replaceAll('"',"\\\"")}"] { opacity: 1; }`}function Iu(e){return e.shiftKey&&e.key==="F10"||e.key==="ContextMenu"}function tm(e,t){if(t&&Iu(e))return!0;if((e.ctrlKey||e.metaKey)&&wu(e))return!0;return e.key==="ArrowDown"||e.key==="ArrowLeft"||e.key==="ArrowRight"||e.key==="ArrowUp"}var nm=new Set(["ArrowDown","ArrowLeft","ArrowRight","ArrowUp","End","Home","PageDown","PageUp"]);function fu(e){for(let t of e.composedPath()){if(!(t instanceof HTMLElement))continue;if(t.dataset.fileTreeContextMenuRoot==="true")return!0;if(t.dataset.type==="context-menu-anchor"||t.dataset.type==="context-menu-trigger")return!0;if(t.getAttribute("slot")==="context-menu")return!0}return!1}function rm(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 im(e,t){return{bottom:t,height:0,left:e,right:e,top:t,width:0,x:e,y:t}}function om(e,t){if(e==null)return t.offsetTop;let n=t.getBoundingClientRect(),r=e.getBoundingClientRect();return n.top-r.top}function pu(e,t,n){if(n==null){e.delete(t);return}e.set(t,n)}function mu(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 sm(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 r=n.dataset.fileTreeStickyPath;if(r!=null)t.push(r)}return t}function am(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 lm(e,t,n,r,i,o,s){let a=Math.max(0,o-i),l=t?.getBoundingClientRect()??null,d=l==null||n==null?null:n.getBoundingClientRect().top-l.top,u=am(e,r),f=l==null||u==null?null:u.getBoundingClientRect().top-l.top;return Math.max(0,Math.min(f??Math.max(d??0,a),Math.max(0,s-i)))}function gu(e,t){return{kind:e.kind,name:hs(e),path:t}}function cm(e){return e==null?void 0:`${e}__tree`}function Su(e,t,n){if(e==null)return;return`${e}__focused-item-${encodeURIComponent(t)}${n?"__parked":""}`}function vu(e){return e==="file-tree-icon-chevron"||e==="file-tree-icon-dot"||e==="file-tree-icon-file"||e==="file-tree-icon-lock"}function yu(e,t){if(e==null)return null;if("text"in e){if(e.parts!=null)return x("span",{title:e.title,children:e.parts.map((r,i)=>x("span",{style:{color:r.color},children:r.text},i))});return x("span",{title:e.title,children:e.text})}let n=typeof e.icon==="string"?vu(e.icon)?t(e.icon):{name:e.icon}:vu(e.icon.name)?(()=>{let r=t(e.icon.name),{name:i,...o}=e.icon;return{...r,...o}})():e.icon;return x("span",{title:e.title,children:x(An,{...n})})}function bu(e){if(e==null)return;un(e.querySelector(["button:not([disabled])","[href]","input:not([disabled])","select:not([disabled])","textarea:not([disabled])",'[tabindex]:not([tabindex="-1"])'].join(", "))??e)}function um(e,t,{actionLaneEnabled:n=!1,customDecoration:r=null,decorationLaneEnabled:i=!1,dragTargetFlattenedSegmentPath:o=null,gitDecoration:s=null,gitLaneActive:a=!1,renameInput:l=null,showDecorativeActionAffordance:d=!1}={}){let u=Hn(e);return x(pt,{children:[e.depth>0?x("div",{"data-item-section":"spacing",children:Array.from({length:e.depth}).map((f,c)=>x("div",{"data-item-section":"spacing-item","data-ancestor-path":e.ancestorPaths[c]},c))}):null,x("div",{"data-item-section":"icon",children:e.kind==="directory"?x(An,{...t("file-tree-icon-chevron")}):x(An,{...t("file-tree-icon-file",u)})}),x("div",{"data-item-section":"content",children:e.isFlattened?jp(e,l,o):l??x(Lc,{minimumLength:5,split:"extension",children:e.name})}),i?x("div",{"data-item-section":"decoration",children:r!=null?yu(r,t):null}):null,a?x("div",{"data-item-section":"git",children:yu(s,t)}):null,n?x("div",{"data-item-section":"action",children:d?x("span",{"aria-hidden":"true","data-item-action-affordance":"decorative",children:x(An,{...t("file-tree-icon-ellipsis")})}):null}):null]})}function Ri(e,t,n,r={}){let{controller:i,renameView:o,visualFocusPath:s,contextHoverPath:a,draggedPathSet:l,dragTarget:d,dragAndDropEnabled:u,shouldSuppressContextMenu:f,handleRowDragStart:c,handleRowDragEnd:m,handleRowTouchStart:p,instanceId:g,itemHeight:v,gitStatusByPath:I,ignoredGitDirectories:C,ignoredInheritanceCache:y,directoriesWithGitChanges:S,gitLaneActive:k,contextMenuEnabled:T,contextMenuTriggerMode:O,contextMenuButtonTriggerEnabled:pe,contextMenuButtonVisibility:Z,contextMenuRightClickEnabled:me,registerRenameInput:J,registerButton:U,resolveIcon:B,renderDecorationForRow:ae,openContextMenuForRow:Ce,onRowClick:z,onKeyDown:le}=e,X=Hn(t),{isParked:be=!1,mode:oe="flow",style:bt}=r,Ve=oe==="sticky",ct=I?.get(X)??null??Zp(t.ancestorPaths,C,y),Dt=t.kind==="directory"&&(S?.has(X)??!1),nt=ae(t,X),je=Qp(ct,Dt),Te=T&&pe,Oe=nt!=null||k||Te,Gt=Te&&Z==="always",ke=o.getPath()===X,wt=ke?o.getValue():"",Ke=Ve||!ke?null:x(Gc,{ref:J,ariaLabel:`Rename ${hs(t)}`,isFlattened:t.isFlattened,value:wt,onBlur:()=>{o.commit()},onInput:(we)=>{o.setValue(we.currentTarget.value)}}),Yt=um(t,B,{actionLaneEnabled:Te,customDecoration:nt,decorationLaneEnabled:Oe,dragTargetFlattenedSegmentPath:d?.flattenedSegmentPath??null,gitDecoration:je,gitLaneActive:k,renameInput:Ke,showDecorativeActionAffordance:Gt}),rt={...Yc({ariaLabel:hs(t),domId:t.isFocused?Su(g,X,be):void 0,extraStyle:bt,features:{actionLaneEnabled:Te,contextMenuButtonVisibility:Te?Z:null,contextMenuEnabled:T,contextMenuTriggerMode:T?O:null,gitLaneActive:k},isParked:be,itemHeight:v,mode:oe,row:t,state:{containsGitChange:Dt,effectiveGitStatus:ct,isContextHovered:a===X,isDragTarget:d?.kind==="directory"&&d.directoryPath===X,isDragging:l?.has(X)===!0,isFocusRinged:t.isFocused&&s===X},targetPath:X}),key:n,onContextMenu:T||u?(we)=>{if(f()){we.preventDefault();return}if(!T)return;if(we.preventDefault(),!me)return;i.focusMountedPathFromInput(X),Ce(t,X,{anchorRect:im(we.clientX,we.clientY),source:"right-click"})}:void 0,onFocus:!Ve?()=>{i.focusMountedPathFromInput(X)}:void 0,onKeyDown:!Ve?le:void 0,ref:(we)=>{U(X,we)}};if(!Ve&&ke)return x("div",{...rt,children:Yt});return x("button",{...rt,type:"button",draggable:u&&!be,onDragEnd:u&&!be?m:void 0,onDragStart:u&&!be?(we)=>{c(we,t,X)}:void 0,onMouseDown:(we)=>{if(Ve){we.preventDefault();return}if(i.isSearchOpen())we.preventDefault()},onTouchStart:u&&!be?(we)=>{p(we,t,X)}:void 0,onClick:(we)=>{z(we,t,X,oe)},children:Yt})}function dm(e,t,n){if(t.end<t.start)return[];return e.controller.getVisibleRows(t.start,t.end).filter((r)=>!n.has(Hn(r))).map((r,i)=>Ri(e,r,t.start+i))}function Di({composition:e,controller:t,gitStatusByPath:n,ignoredGitDirectories:r,directoriesWithGitChanges:i,icons:o,instanceId:s,itemHeight:a=pi,overscan:l=10,renamingEnabled:d=!1,renderRowDecoration:u,searchBlurBehavior:f="close",searchEnabled:c=!1,searchFakeFocus:m=!1,slotHost:p,stickyFolders:g=!1,initialViewportHeight:v=420}){let I=V(null),C=V(null),y=V(!1),S=V(null),k=V(null),T=V(null),O=V(null),pe=V(null),Z=V(new Map),me=V(new Map),J=V(()=>{}),U=V(null),B=V(0),ae=V(!1),Ce=V(null);if(Ce.current!==t)ae.current=!1,Ce.current=t;let z=V(!1),le=V(null),X=V(null),be=V(!1),oe=V(null),bt=V(null),Ve=V(null),ct=V(null),Dt=V(null),nt=V(null),je=V(null),Te=V(null),Oe=V(!1),Gt=V(null),ke=V(null),wt=V(null),Ke=V(null),Yt=_t(()=>new Map,[]),[,rt]=lt(0),we=V(!1),[ut,it]=lt(null),[pn,Xt]=lt(null),[Mt,mn]=lt(null),[Ue,Ae]=lt(null),[Ki,he]=lt(0),[G,gn]=lt(null),dt=V(G);dt.current=G;let At=V(null),Qt=V(null),Zt=V(null),Jt=V(null),w=V(null),M=V(!1),H=()=>{Qt.current=null,Zt.current=null,Jt.current=null},j=(h,b)=>{Qt.current=h,Zt.current=null,Jt.current=b==null?null:{path:h,scrollTop:b}},It=(h,b)=>{Qt.current=null,Zt.current={path:h,viewportOffset:b},Jt.current=null},en=V(f==="retain"&&t.isSearchOpen()),[Xn,As]=lt(m);cs(()=>{if(!m)As(!1)},[m]);let Ns=V(!1),Ui=Re(()=>{Ns.current=!0,As((h)=>h?!1:h)},[]),[Kd,Ud]=lt(()=>ds({controller:t,itemHeight:a,overscan:l,scrollTop:0,stickyFolders:g,viewportHeight:v})),[Gd,Yd]=lt(!1);cs(()=>{Yd(!0)},[]);let qe=e?.contextMenu?.enabled===!0||e?.contextMenu?.render!=null||e?.contextMenu?.onOpen!=null||e?.contextMenu?.onClose!=null,vn=e?.contextMenu?.triggerMode??(qe?"right-click":"both"),yn=vn==="both"||vn==="button",Ls=e?.contextMenu?.buttonVisibility??"when-needed",Xd=vn==="both"||vn==="right-click";We(()=>{let h=T.current;if(h==null)return;let b=(_)=>{if(!(_ instanceof CustomEvent))return;let P=_.detail?.path??null;w.current=P,Xt(P),Ae(P==null?null:"pointer")},N=(_)=>{if(!(_ instanceof CustomEvent))return;M.current=_.detail?.disabled===!0};return h.addEventListener("file-tree-debug-set-context-menu-trigger",b),h.addEventListener("file-tree-debug-set-scroll-suppression",N),()=>{h.removeEventListener("file-tree-debug-set-context-menu-trigger",b),h.removeEventListener("file-tree-debug-set-scroll-suppression",N)}},[]);let Qd=Re((h,b)=>{pu(Z.current,h,b)},[]),Zd=Re((h,b)=>{pu(me.current,h,b)},[]),Jd=Re((h)=>{k.current=h},[]),Qn=Re((h)=>mu(h,me.current,Z.current),[]),Fs=n!=null||r!=null||i!=null,{resolveIcon:Bs}=_t(()=>mc(o),[o]),Zn=t[zo](),bn=Zn.getPath(),Gi=bn!=null,ht=t.isSearchOpen(),eh=t.getSearchValue(),W=t.getFocusedPath(),ne=t.getFocusedIndex(),tn=t.getScrollRequest(),St=t.isDragAndDropEnabled(),Jn=t.getDragSession(),th=_t(()=>Jn==null?null:new Set(Jn.draggedPaths),[Jn]),nh=Jn?.target??null,er=Jn?.primaryPath??null,Hs=cm(s),{overlayHeight:rh,overlayRows:ih,snapshot:xe,visibleRows:Br}=Kd,Pe=xe.physical.viewportHeight,ot=_t(()=>({end:xe.window.endIndex,start:xe.window.startIndex}),[xe.window.endIndex,xe.window.startIndex]),tr=ih,Vs=xe.sticky.rows,nn=xe.physical.totalHeight,wn=xe.sticky.height,Hr=_t(()=>new Set(Vs.map((h)=>Hn(h.row))),[Vs]),Yi=ne>=0&&ne>=ot.start&&ne<=ot.end,oh=Re((h,b)=>u?.({item:gu(h,b),row:h})??null,[u]),Os=Re((h)=>{if(un(h==null?null:Z.current.get(h)??null))return!0;return un(T.current)},[]),Vr=Re((h)=>{Os(t.focusNearestPath(h))},[t,Os]),qs=V(Vr);qs.current=Vr;let In=V(!0),Xi=V(()=>{}),Qe=Re((h=!0)=>{let b=dt.current;if(b==null)return;if(In.current=In.current&&h,gn(null),e?.contextMenu?.onClose?.(),In.current)Vr(b.path)},[e?.contextMenu,Vr]);Xi.current=Qe;let nr=Re((h)=>{let b=h==null?null:om(T.current,h);mn((N)=>N===b?N:b)},[]),zs=Re((h,b,N)=>{let _=t.getItem(b);if(_==null)return;let P=Qn(b);if(P?.dataset.fileTreeStickyRow==="true"){let F=O.current;j(b,F?.scrollTop??null),z.current=!0,it((ce)=>ce===b?ce:b)}_.focus(),nr(P),In.current=!0,gn({anchorRect:N?.anchorRect??null,item:gu(h,b),path:b,source:N?.source??"keyboard"})},[t,Qn,nr]),sh=Re((h)=>{if(!d)return;if(t.isSearchOpen()){let b=O.current,N=Nn(b,Pe);oe.current=ne<0||b==null?null:Math.max(0,Math.min(ne*a-b.scrollTop,Math.max(0,N-a))),be.current=!0}if(t.startRenaming(h)===!1)return;Ae("focus"),rt((b)=>b+1)},[t,ne,a,d,Pe]),Or=Re((h,{restoreTreeFocus:b=!0,targetOffset:N="live-overlay"}={})=>{let _=O.current;if(_==null)return!1;t.focusPath(h);let P=t.getFocusedIndex();if(P<0)return!1;let F=t.getVisibleRows(P,P)[0]??null;if(F==null)return!1;let ce=Nn(_,Pe),L=t.getVisibleCount()*a,ee=N==="sticky-parents"?F.ancestorPaths.length*a:ds({controller:t,itemHeight:a,overscan:l,scrollTop:_.scrollTop,stickyFolders:g,viewportHeight:ce}).snapshot.sticky.height;return z.current=!0,Ln(_,P,a,ce,L,ee),J.current(),At.current=b?h:null,!0},[t,a,l,Pe,g]),ah=()=>y.current===!0||Ke.current!=null||Oe.current===!0,Ws=(h)=>typeof window.requestAnimationFrame==="function"?window.requestAnimationFrame(()=>{h()}):window.setTimeout(h,16),lh=(h)=>{if(h==null)return;if(typeof window.cancelAnimationFrame==="function"){window.cancelAnimationFrame(h);return}window.clearTimeout(h)},Nt=()=>{if(ct.current!=null)clearTimeout(ct.current),ct.current=null;Ve.current=null},qr=()=>{nt.current?.remove(),nt.current=null},rr=()=>{lh(bt.current),bt.current=null,Dt.current=null},$s=(h)=>{let b=T.current?.getRootNode();if(b instanceof ShadowRoot){b.append(h);return}document.body.append(h)},ir=()=>{if(Te.current?.(),Te.current=null,Ke.current!=null)clearTimeout(Ke.current),Ke.current=null;if(Oe.current=!1,Gt.current=null,wt.current=null,ke.current!=null)ke.current.setAttribute("draggable","true"),ke.current.style.removeProperty("touch-action"),ke.current=null;qr(),Nt(),rr(),je.current=null},zr=(h,b)=>{let N=T.current?.getRootNode(),_=uu(Up(N instanceof ShadowRoot?N:document,h,b));return t.setDragTarget(_),t.getDragSession()?.target??null},Qi=(h)=>{let b=t.getDragAndDropConfig()?.openOnDropDelay??800;if(h==null||h.kind!=="directory"||h.directoryPath==null||b<=0){Nt();return}let N=t.getItem(h.directoryPath),_=hu(N)?N:null;if(_==null||_.isExpanded()){Nt();return}let P=`${h.directoryPath}::${h.flattenedSegmentPath??""}`;if(Ve.current===P)return;Nt(),Ve.current=P,ct.current=setTimeout(()=>{let F=t.getDragSession()?.target;if(F?.kind!=="directory"||F.directoryPath!==h.directoryPath||F.flattenedSegmentPath!==h.flattenedSegmentPath)return;_.expand()},b)},js=()=>{bt.current=null;let h=Dt.current,b=O.current;if(h==null||b==null||t.getDragSession()==null)return;let N=b.getBoundingClientRect(),_=Xp(h.clientY,N);if(_===0)return;let P=Math.max(0,b.scrollHeight-b.clientHeight),F=Math.max(0,Math.min(P,b.scrollTop+_));if(F!==b.scrollTop)b.scrollTop=F,J.current();Qi(zr(h.clientX,h.clientY)),bt.current=Ws(js)},Ks=(h,b)=>{Dt.current={clientX:h,clientY:b},bt.current??=Ws(js)},ch=(h,b,N)=>{let _=h.currentTarget;if(_==null)return;if(ir(),qr(),Nt(),rr(),t.startDrag(N)===!1){h.preventDefault();return}if(je.current=b,h.dataTransfer!=null){if(h.dataTransfer.effectAllowed="move",h.dataTransfer.dropEffect="move",h.dataTransfer.setData("text/plain",N),Yp()){let P=du(_),F=_.getBoundingClientRect();Object.assign(P.style,{height:`${F.height}px`,opacity:"0.85",transform:"translate3d(-9999px, 0px, 0)",width:`${F.width}px`}),$s(P),nt.current=P,h.dataTransfer.setDragImage(P,Math.max(0,h.clientX-F.left),Math.max(0,h.clientY-F.top))}}},uh=()=>{qr(),Nt(),rr(),je.current=null,t.cancelDrag()},dh=(h,b,N)=>{if(Ke.current!=null||Oe.current)return;let _=h.touches[0],P=h.currentTarget;if(_==null||P==null)return;wt.current={clientX:_.clientX,clientY:_.clientY},ke.current=P,P.setAttribute("draggable","false");let F=(ee={})=>{let se=ee.restoreNativeDraggable??!Oe.current;if(Ke.current!=null)clearTimeout(Ke.current),Ke.current=null;if(document.removeEventListener("touchmove",ce),document.removeEventListener("touchend",L),document.removeEventListener("touchcancel",L),Te.current===F)Te.current=null;if(se){if(P.setAttribute("draggable","true"),ke.current===P)ke.current=null;wt.current=null}},ce=(ee)=>{let se=ee.touches[0],re=wt.current;if(se==null||re==null)return;let fe=se.clientX-re.clientX,De=se.clientY-re.clientY;if(fe*fe+De*De<=lu*lu)return;F()},L=()=>{F()};document.addEventListener("touchmove",ce,{passive:!0}),document.addEventListener("touchend",L),document.addEventListener("touchcancel",L),Te.current=F,Ke.current=setTimeout(()=>{if(F({restoreNativeDraggable:!1}),t.startDrag(N)===!1){if(P.setAttribute("draggable","true"),ke.current===P)ke.current=null;wt.current=null;return}Oe.current=!0,ke.current=P,P.setAttribute("draggable","false"),P.style.setProperty("touch-action","none"),je.current=b;let ee=P.getBoundingClientRect(),se=du(P);Object.assign(se.style,{height:`${ee.height}px`,opacity:"0.85",transform:`translate3d(${ee.left}px, ${ee.top}px, 0)`,width:`${ee.width}px`}),$s(se),nt.current=se,Gt.current={x:_.clientX-ee.left,y:_.clientY-ee.top};let re=(st)=>{let Se=st.touches[0];if(Se==null)return;st.preventDefault();let Q=Gt.current;if(Q!=null&&nt.current!=null)nt.current.style.transform=`translate3d(${Se.clientX-Q.x}px, ${Se.clientY-Q.y}px, 0)`;Qi(zr(Se.clientX,Se.clientY)),Ks(Se.clientX,Se.clientY)},fe=(st)=>{let Se=st.changedTouches[0];if(Se!=null)zr(Se.clientX,Se.clientY);t.completeDrag(),ir()},De=()=>{t.cancelDrag(),ir()};Te.current=()=>{document.removeEventListener("touchmove",re),document.removeEventListener("touchend",fe),document.removeEventListener("touchcancel",De)},document.addEventListener("touchmove",re,{passive:!1}),document.addEventListener("touchend",fe),document.addEventListener("touchcancel",De)},Kp)},Us=(h)=>{if(G!=null){if(h.key==="Escape"){Qe(),h.preventDefault(),h.stopPropagation();return}if(nm.has(h.key))h.preventDefault(),h.stopPropagation();return}if(Zn.isActive()){if(h.isComposing||h.keyCode===229)return;if(h.key==="Escape")Zn.cancel();else if(h.key==="Enter")Zn.commit();else return;Ae("focus"),rt((ve)=>ve+1),h.preventDefault(),h.stopPropagation();return}if(d&&h.key==="F2"){sh(W??void 0),h.preventDefault(),h.stopPropagation();return}if(ht){if(h.key==="Escape")be.current=!1,oe.current=null,t.closeSearch();else if(h.key==="Enter"){let ve=t.getFocusedPath();if(ve!=null)t.selectOnlyPath(ve);let ft=O.current,Ur=Nn(ft,Pe);oe.current=ne<0||ft==null?null:Math.max(0,Math.min(ne*a-ft.scrollTop,Math.max(0,Ur-a))),be.current=!0,t.closeSearch()}else if(h.key==="ArrowDown")t.focusNextSearchMatch();else if(h.key==="ArrowUp")t.focusPreviousSearchMatch();else return;Ae("focus"),rt((ve)=>ve+1),h.preventDefault(),h.stopPropagation();return}if(c&&Jp(h)){t.openSearch(h.key),rt((ve)=>ve+1),h.preventDefault(),h.stopPropagation();return}let b=qe&&Iu(h),N=tm(h,qe),_=N&&T.current!=null?kr(T.current):null,P=N?new Set(sm(T.current)):new Set,F=_?.dataset.fileTreeStickyPath??null,ce=_?.dataset.fileTreeStickyRow==="true"&&F!=null;if(ce&&F!==W&&P.has(F)){let ve=O.current;j(F,ve?.scrollTop??null),t.focusPath(F)}let L=t.getFocusedPath(),ee=t.getFocusedIndex(),se=t.getFocusedItem();if(se==null)return;let re=hu(se)?se:null,fe=L!=null&&(Hr.has(L)||ce&&F===L&&P.has(L)),De=h.key==="ArrowDown"||h.key==="ArrowUp"||h.key==="ArrowRight"&&re!=null&&re.isExpanded(),st=h.key==="ArrowLeft"&&fe&&re!=null&&re.isExpanded(),Se=O.current,Q=!0;if(h.shiftKey&&h.key==="ArrowDown")t.extendSelectionFromFocused(1);else if(h.shiftKey&&h.key==="ArrowUp")t.extendSelectionFromFocused(-1);else if(b&&L!=null&&ee>=0){let ve=t.getVisibleRows(ee,ee)[0]??null,ft=mu(L,me.current,Z.current);if(ve==null||ft==null)Q=!1;else zs(ve,L)}else if((h.ctrlKey||h.metaKey)&&wu(h))t.toggleFocusedSelection();else if((h.ctrlKey||h.metaKey)&&h.key.toLowerCase()==="a")t.selectAllVisiblePaths();else switch(h.key){case"ArrowDown":t.focusNextItem();break;case"ArrowUp":t.focusPreviousItem();break;case"ArrowRight":if(re==null||re.isExpanded())t.focusNextItem();else re.expand();break;case"ArrowLeft":if(re!=null&&re.isExpanded())re.collapse();else t.focusParentItem();break;case"Home":t.focusFirstItem();break;case"End":t.focusLastItem();break;default:Q=!1}if(!Q)return;Ae("focus");let ge=t.getFocusedPath(),Ne=ge!=null&&(Hr.has(ge)||P.has(ge)),jr=De&&ge!==L,Kr=b&&ce&&F===L&&ge===L;if((fe||Kr)&&ge!=null&&(jr&&Ne||Kr))j(ge,Se?.scrollTop??null),z.current=!0,it((ve)=>ve===ge?ve:ge);else{let ve=h.key==="ArrowUp"&&fe&&ge!==L;if(ge!=null&&(ve||st&&ge===L))It(ge,lm(T.current,Se,_,L,a,wn,Pe)),z.current=!0,it((ft)=>ft===ge?ft:ge);else H()}rt((ve)=>ve+1),h.preventDefault(),h.stopPropagation()};We(()=>{if(!c||!ht)return;if(en.current){en.current=!1;return}un(pe.current)},[ht,c]),We(()=>{let h=k.current;switch(Uc({hasRenderedInput:h!=null,previousRenamingPath:X.current,renamingPath:bn})){case"reset":X.current=null;return;case"reveal-canonical":if(bn!=null)Or(bn,{restoreTreeFocus:!1,targetOffset:"live-overlay"});return;case"ignore":return;case"focus-input":if(h!=null)At.current=null,X.current=bn,un(h),h.select();return}},[ot.end,ot.start,bn,Or,Hr]),We(()=>{let h=T.current;if(h==null)return;let b=null,N=()=>{if(b==null)return;clearTimeout(b),b=null},_=()=>{let ce=kr(h)?.dataset.itemPath??null;it((L)=>L===ce?L:ce)},P=()=>{N(),z.current=!0,_()},F=(ce)=>{let L=ce.relatedTarget;if(L==null){N(),b=setTimeout(()=>{if(b=null,kr(h)!=null){_();return}z.current=!1,it(null)},0);return}if(!(L instanceof Node)||!h.contains(L)){N(),z.current=!1,it(null);return}let ee=L instanceof HTMLElement?L.dataset.itemPath??null:null;it((se)=>se===ee?se:ee)};return h.addEventListener("focusin",P),h.addEventListener("focusout",F),()=>{N(),h.removeEventListener("focusin",P),h.removeEventListener("focusout",F)}},[]),We(()=>{let h=T.current;if(h==null)return;if(xe.physical.scrollTop<=0)h.dataset.scrollAtTop="true";else delete h.dataset.scrollAtTop},[xe.physical.scrollTop]),We(()=>{let h=null,b=O.current,N=S.current,_=T.current;if(b==null)return;U.current=Nn(b,v);let P=()=>{let Q=t.getVisibleCount(),ge=rs(U.current,v),Ne=Math.max(0,Q*a-ge);if(b.scrollTop>Ne)b.scrollTop=Ne;Ud(ds({controller:t,itemHeight:a,overscan:l,scrollTop:Math.min(b.scrollTop,Ne),stickyFolders:g,viewportHeight:ge}))};if(!ae.current){ae.current=!0;let Q=t.getFocusedIndex();if(Q>=0){let ge=rs(U.current,v),Ne=t.getVisibleRows(Q,Q)[0]??null;is(b,Q,a,ge,g&&Ne!=null?Math.max(0,Math.min(Ne.ancestorPaths.length*a,Math.max(0,ge-a))):0)}}J.current=P;let F=t.subscribe(()=>{if(zc(we))rt((Q)=>Q+1);P()}),ce=()=>{if(M.current===!0)return;if(N!=null)N.dataset.isScrolling??="";if(_!=null)_.dataset.isScrolling??="";if(y.current=!0,h!=null)clearTimeout(h);h=setTimeout(()=>{if(N!=null)delete N.dataset.isScrolling;if(_!=null)delete _.dataset.isScrolling;y.current=!1,he((Q)=>Q+1),h=null},50)},L=null,ee=()=>{if(_!=null)delete _.dataset.overlayReveal;if(L!=null)clearTimeout(L),L=null},se=()=>{if(_==null||M.current===!0)return;if(b.scrollTop>0)return;if(_.dataset.overlayReveal="true",L!=null)clearTimeout(L);L=setTimeout(()=>{ee()},200)},re=()=>{if(P(),b.scrollTop>0)ee();if(dt.current!=null&&y.current)Xi.current();if(M.current===!0){y.current=!1;return}Xt((Q)=>Q==null?Q:null),ce()},fe=()=>{ce(),se()},De=new Set(["ArrowUp","ArrowDown","ArrowLeft","ArrowRight","PageUp","PageDown","Home","End"," ","Spacebar"]),st=(Q)=>{if(!De.has(Q.key))return;fe()};b.addEventListener("scroll",re,{passive:!0}),b.addEventListener("wheel",fe,{passive:!0}),b.addEventListener("touchmove",fe,{passive:!0}),b.addEventListener("keydown",st);let Se=typeof ResizeObserver<"u"?new ResizeObserver((Q)=>{U.current=(Q[0]==null?null:jc(Q[0]))??Nn(b,v),P()}):null;return Se?.observe(b),()=>{if(J.current=()=>{},F(),b.removeEventListener("scroll",re),b.removeEventListener("wheel",fe),b.removeEventListener("touchmove",fe),b.removeEventListener("keydown",st),h!=null)clearTimeout(h);if(L!=null)clearTimeout(L);if(N!=null)delete N.dataset.isScrolling;if(_!=null)delete _.dataset.isScrolling,delete _.dataset.overlayReveal;y.current=!1,U.current=null,Se?.disconnect()}},[t,v,a,l,g]),We(()=>{if(qe||G==null)return;Qe(!1)},[Qe,qe,G]);let Gs=_t(()=>G==null?null:`${G.path}::${G.source}`,[G]);We(()=>{if(Gs==null){p?.clearSlotContent(br);return}let h=dt.current;if(h==null)return;let b=C.current??I.current;if(b==null)return;let N={anchorElement:b,anchorRect:h.anchorRect??rm(b.getBoundingClientRect()),close:(P)=>{Xi.current(P?.restoreFocus??!0)},restoreFocus:()=>{if(!In.current)return;qs.current(dt.current?.path??null)}},_=e?.contextMenu?.render?.(h.item,N)??null;return p?.setSlotContent(br,_),e?.contextMenu?.onOpen?.(h.item,N),bu(_),queueMicrotask(()=>{if(_==null||!_.isConnected)return;if(document.activeElement!==_)return;bu(_)}),()=>{p?.clearSlotContent(br)}},[Gs,e?.contextMenu,p]),We(()=>{if(G!=null&&t.getItem(G.path)==null)Qe()},[Qe,G,t]),We(()=>{if(G==null)return;let h=T.current?.getRootNode(),b=h instanceof ShadowRoot?h.host:T.current,N=(P)=>{let F=P.target;if(!(F instanceof Node))return;if(fu(P))return;if(I.current?.contains(F)===!0)return;if(b?.contains(F)===!0)return;Qe()},_=(P)=>{if(P.key==="Escape")P.preventDefault(),P.stopPropagation(),Qe()};return document.addEventListener("mousedown",N,!0),document.addEventListener("keydown",_,!0),()=>{document.removeEventListener("mousedown",N,!0),document.removeEventListener("keydown",_,!0)}},[Qe,G]),We(()=>{let h=O.current,b=T.current;if(h==null||b==null){le.current=W;return}let N=W==null?null:Z.current.get(W)??null,_=kr(b),P=_?.dataset.itemPath??null,F=Gi&&k.current===_,ce=c&&pe.current===_,L=be.current&&!ht,ee=oe.current??0,se=At.current,re=Qt.current,fe=Zt.current,De=Jt.current,st=_!=null,Se=z.current||st,Q=le.current!==W,ge=re!=null&&re===W&&W!=null,Ne=!1,jr=!1;if(tn!=null&&tn.id!==B.current){B.current=tn.id;let Ji=tn.visibleIndex,Js=t.getVisibleRows(Ji,Ji)[0]??null;if(Js!=null){let Bh=g?Math.max(0,Math.min(Js.ancestorPaths.length*a,Math.max(0,Pe-a))):wn;Ne=!0,jr=Kc(h,Ji,a,Pe,nn,tn.offset,Bh)}t.clearScrollRequest(tn.id)}let Kr=!Ne&&L&&Ln(h,ne,a,Pe,nn,ee),ve=!Ne&&se!=null&&se===W&&Ln(h,ne,a,Pe,nn,wn),ft=!Ne&&fe!=null&&fe.path===W&&Ln(h,ne,a,Pe,nn,fe.viewportOffset),Ur=!Ne&&De!=null&&De.path===W&&h.scrollTop!==De.scrollTop;if(Ur)h.scrollTop=De.scrollTop;if(Ur||jr||ve||ft||Kr||Se&&Q&&se!==W&&!ge&&is(h,ne,a,Pe,wn))J.current();if(Ne){le.current=W;return}if(!Se){le.current=W;return}if(F){le.current=W;return}if(ce&&!L){le.current=W;return}if(N==null){if(L&&ne>=0)Ln(h,ne,a,Pe,nn,ee),J.current();le.current=W;return}if(Q||L||se===W||re===W||fe?.path===W||De?.path===W||P==null||P!==W){if(un(N),se===W)At.current=null;if(re===W)Qt.current=null;if(fe?.path===W)Zt.current=null;if(De?.path===W)Jt.current=null;be.current=!1,oe.current=null}le.current=W},[t,ne,W,Yi,a,Gi,ht,ot,Pe,c,tn,g,wn,nn,Br]);let hh=ne>=0&&ne>=xe.visible.startIndex&&ne<=xe.visible.endIndex,fh=W!=null&&tr.some((h)=>Hn(h.row)===W),ph=hh||fh,mh=yn&&z.current===!0&&ph?W:null,gh=Ue==="pointer"?pn:null,rn=G?.path??w.current??gh??mh??pn,Ys=G?.source==="right-click";We(()=>{if(y.current&&G==null)return;nr(Qn(rn))},[G,Qn,ot,Pe,Ki,tr,rn,nr,Br]);let vh=Re((h)=>{if(y.current)return;if(fu(h))return;let b=h.target;if(!(b instanceof HTMLElement))return;if(b.closest?.('[data-type="context-menu-trigger"]')!=null)return;let N=b.closest?.('[data-file-tree-sticky-row="true"]'),_=b.closest?.('[data-type="item"]'),P=N instanceof HTMLElement?N.dataset.fileTreeStickyPath??null:_ instanceof HTMLElement?_.dataset.itemPath??null:null;if(P!=null)Ae((F)=>F==="pointer"?F:"pointer");Xt((F)=>F===P?F:P)},[]),yh=Re(()=>{Xt(null)},[]);We(()=>{if(!St)return;let h=()=>{ir(),t.cancelDrag()};return window.addEventListener("dragend",h),()=>{window.removeEventListener("dragend",h),ir(),t.cancelDrag()}},[t,St]);let bh=(h)=>{if(!St||t.getDragSession()==null||Oe.current)return;let b=uu(h.target instanceof HTMLElement?h.target:null);if(t.setDragTarget(b),Qi(t.getDragSession()?.target??null),Ks(h.clientX,h.clientY),h.dataTransfer!=null)h.dataTransfer.dropEffect="move";h.preventDefault()},wh=(h)=>{if(!St||t.getDragSession()==null||Oe.current)return;let b=h.relatedTarget;if(b instanceof Node&&T.current?.contains(b)===!0)return;Nt(),rr(),t.setDragTarget(null)},Ih=(h)=>{if(!St||t.getDragSession()==null||Oe.current)return;h.preventDefault(),zr(h.clientX,h.clientY),t.completeDrag(),qr(),Nt(),rr(),je.current=null},or=xe.window.height,Sh=xe.window.offsetTop,Ch=Math.min(0,Pe-or),kh=Math.min(0,Pe-or-wn),xh=ut===W||be.current,Sn=W!=null&&xh&&!Yi&&ne>=0?Br[ne]??t.getVisibleRows(ne,ne)[0]??null:null,Xs=Sn==null?null:os(ne,a,ot,or),Lt=je.current,_h=er!=null&&Lt!=null&&Lt.path===er&&Lt.index>=ot.start&&Lt.index<=ot.end,sr=er!=null&&Lt!=null&&Lt.path===er&&!_h&&Lt.path!==Sn?.path?Lt:null,Qs=sr==null?null:os(sr.index,a,ot,or),Eh=em((ne>=0?Br[ne]??t.getVisibleRows(ne,ne)[0]??null:null)?.ancestorPaths.at(-1)??null),Th=ht&&W!=null?Su(s,W,!Yi):void 0,Ph=G?.path??(ht?W:ut),Rh=G?.path??pn,ar=Qn(rn),Zi=qe&&yn&&!Ys&&!Gi&&ar!=null&&Mt!=null&&rn!=null,Dh=qe&&(Zi||G!=null),Wr=G?.anchorRect,Zs=Wr==null&&ar!=null&&Mt!=null&&(G!=null||Zi)?Mt:null,Mh=Wr!=null?{left:`${Wr.left}px`,position:"fixed",right:"auto",top:`${Wr.top}px`}:Zs!=null?{top:`${Zs}px`}:void 0,Ah=Ys?{opacity:"0"}:void 0,Nh=Re((h,b,N,_)=>{let P=Xc({event:{ctrlKey:h.ctrlKey,metaKey:h.metaKey,shiftKey:h.shiftKey},isDirectory:b.kind==="directory",isSearchOpen:ht,mode:_}),F=P.toggleDirectory&&b.kind==="directory",ce=F?t.resolveMountedDirectoryPathFromInput(N):null;if(F&&ce==null)return;let L=ce??N;switch(P.selection.kind){case"range":t.selectPathRange(L,P.selection.additive);break;case"toggle":t.togglePathSelectionFromInput(L);break;case"single":t.selectOnlyMountedPathFromInput(L);break}let ee=h.currentTarget instanceof HTMLElement?h.currentTarget:null,se=b.index>=xe.visible.startIndex&&b.index<=xe.visible.endIndex,re=_==="flow"&&se&&ee!=null&&ee.dataset.itemParked!=="true";if(t.focusMountedPathFromInput(L),re)z.current=!0,it((fe)=>fe===L?fe:L),Ae("focus");if(F)t.toggleMountedDirectoryFromInput(L);if(P.closeSearch)t.closeSearch();if(P.revealCanonical)Or(L,{targetOffset:"sticky-parents"})},[t,ht,xe.visible.endIndex,xe.visible.startIndex,Or]),Lh=()=>{if(y.current)return;if(!yn)return;if(rn==null||ar==null)return;let h=t.getItem(rn);if(h==null)return;nr(ar),In.current=!0,gn({anchorRect:null,item:{kind:h.isDirectory()?"directory":"file",name:ar.getAttribute("aria-label")??rn,path:h.getPath()},path:h.getPath(),source:"button"})},$r={contextHoverPath:Rh,contextMenuButtonTriggerEnabled:yn,contextMenuButtonVisibility:Ls,contextMenuEnabled:qe,contextMenuRightClickEnabled:Xd,contextMenuTriggerMode:vn,controller:t,directoriesWithGitChanges:i,dragAndDropEnabled:St,draggedPathSet:th,dragTarget:nh,gitLaneActive:Fs,gitStatusByPath:n,handleRowDragEnd:uh,handleRowDragStart:ch,handleRowTouchStart:dh,ignoredGitDirectories:r,ignoredInheritanceCache:Yt,instanceId:s,itemHeight:a,onKeyDown:Us,onRowClick:Nh,openContextMenuForRow:zs,registerButton:Qd,registerRenameInput:Jd,renameView:Zn,renderDecorationForRow:oh,resolveIcon:Bs,shouldSuppressContextMenu:ah,visualFocusPath:Ph},Fh={...$r,registerButton:Zd};return x("div",{ref:T,id:Hs,"data-file-tree-context-menu-button-visibility":qe&&yn?Ls:void 0,"data-file-tree-context-menu-trigger-mode":qe?vn:void 0,"data-file-tree-has-context-menu-action-lane":qe&&yn?"true":void 0,"data-file-tree-has-git-lane":Fs?"true":void 0,"data-file-tree-virtualized-root":"true",onDragLeave:St?wh:void 0,onDragOver:St?bh:void 0,onDrop:St?Ih:void 0,onKeyDown:Us,onPointerLeave:qe?yh:void 0,onPointerOver:qe?vh:void 0,role:"tree",tabIndex:-1,style:{outline:"none",position:"relative"},children:[x("style",{"data-file-tree-guide-style":"true",dangerouslySetInnerHTML:{__html:Eh}}),x("slot",{name:yr,"data-type":"header-slot"}),c?x("div",{"data-file-tree-search-container":!0,"data-open":ht?"true":"false",children:x("input",{ref:pe,"aria-activedescendant":Th,"aria-controls":Hs,placeholder:"Search…","data-file-tree-search-input":!0,"data-file-tree-search-input-fake-focus":Xn?"true":void 0,value:eh,onBlur:()=>{if(f==="retain"&&!Ns.current)return;t.closeSearch()},onFocus:Ui,onPointerDown:Ui,onInput:(h)=>{Ui();let b=h.currentTarget;t.setSearch(b.value)}})}):null,x("div",{ref:O,"data-file-tree-virtualized-scroll":"true",children:[g&&Gd&&tr.length>0?x("div",{"aria-hidden":"true","data-file-tree-sticky-overlay":"true",children:x("div",{"data-file-tree-sticky-overlay-content":"true",style:{height:`${rh}px`},children:tr.map((h,b)=>Ri(Fh,h.row,`sticky:${Hn(h.row)}`,{mode:"sticky",style:{left:"0",position:"absolute",right:"0",top:`${h.top}px`,zIndex:`${tr.length-b}`}}))})}):null,x("div",{ref:S,"data-file-tree-virtualized-list":"true",style:{height:`${nn}px`},children:[x("div",{"data-file-tree-virtualized-sticky-offset":"true","aria-hidden":"true",style:{height:`${Sh}px`}}),x("div",{"data-file-tree-virtualized-sticky":"true",style:{height:`${or}px`,top:`${Ch}px`,bottom:`${kh}px`},children:[dm($r,ot,Hr),Sn!=null&&Xs!=null?Ri($r,Sn,`parked:${Sn.path}`,{isParked:!0,style:{left:"0",opacity:"0",pointerEvents:er===Sn.path?"none":void 0,position:"absolute",right:"0",top:`${Xs}px`}}):null,sr!=null&&Qs!=null?Ri($r,sr,`parked-drag:${sr.path}`,{isParked:!0,style:{left:"0",opacity:"0",pointerEvents:"none",position:"absolute",right:"0",top:`${Qs}px`}}):null]})]})]}),qe?x("div",{ref:I,"data-type":"context-menu-anchor","data-visible":Dh?"true":"false",style:Mh,children:[x("button",{ref:C,type:"button","data-type":Ul,"aria-label":"Options","aria-haspopup":"menu","aria-expanded":G!=null?"true":"false","data-visible":Zi?"true":"false",onMouseDown:(h)=>{h.preventDefault()},onClick:(h)=>{if(h.preventDefault(),h.stopPropagation(),G!=null){Qe();return}Lh()},tabIndex:-1,style:Ah,children:x(An,{...Bs("file-tree-icon-ellipsis")})}),G!=null?x("slot",{name:br}):null]}):null,G!=null?x("div",{"data-type":"context-menu-wash","aria-hidden":"true",onMouseDownCapture:(h)=>{h.preventDefault(),Qe()},onTouchStartCapture:(h)=>{h.preventDefault(),h.stopPropagation(),Qe()},onTouchMoveCapture:(h)=>{h.preventDefault(),h.stopPropagation()},onWheelCapture:(h)=>{h.preventDefault(),h.stopPropagation()}}):null]})}var fs={hydrateRoot:(e,t)=>{Rc(Mn(Di,t),e)},renderRoot:(e,t)=>{Ei(Mn(Di,t),e)},unmountRoot:(e)=>{Ei(null,e)}};function Vn(e,t){fs.renderRoot(e,t)}function Cu(e,t){fs.hydrateRoot(e,t)}function ku(e){fs.unmountRoot(e)}var xu=class{#e=new Map;#t=null;clearAll(){for(let e of this.#e.values())e.remove();this.#e.clear()}clearSlotContent(e){let t=this.#c(e);if(t==null)return;t.remove(),this.#e.delete(e)}setHost(e){if(this.#t=e,e==null)return;this.#a(e);for(let[t,n]of this.#e)this.#u(t,n)}setSlotContent(e,t){let n=this.#c(e);if(n===t){if(t!=null)this.#e.set(e,t),this.#u(e,t);return}if(n?.remove(),t==null){this.#e.delete(e);return}this.#e.set(e,t),this.#u(e,t)}setSlotHtml(e,t){let n=t?.trim()??"";if(n.length===0){this.setSlotContent(e,null);return}let r=this.#c(e);if(r!=null&&r.innerHTML===n){this.#e.set(e,r),this.#u(e,r);return}let i=document.createElement("div");i.innerHTML=n,this.setSlotContent(e,i)}#c(e){let t=this.#e.get(e)??null;if(t!=null)return t;let n=this.#t;if(n==null)return null;for(let r of Array.from(n.children)){if(!(r instanceof HTMLElement))continue;if(r.dataset.fileTreeManagedSlot===e)return r}return null}#u(e,t){if(t.slot=e,t.dataset.fileTreeManagedSlot=e,this.#t!=null&&t.parentNode!==this.#t)this.#t.appendChild(t)}#a(e){for(let t of Array.from(e.children)){if(!(t instanceof HTMLElement))continue;let n=t.dataset.fileTreeManagedSlot;if(n==null||this.#e.has(n))continue;this.#e.set(n,t)}}};function Et(e,t,n){if(!e.s){if(n instanceof hm){if(!n.s)return void(n.o=Et.bind(null,e,t));1&t&&(t=n.s),n=n.v}if(n&&n.then)return void n.then(Et.bind(null,e,t),Et.bind(null,e,2));e.s=t,e.v=n;let r=e.o;r&&r(e)}}var hm=function(){function e(){}return e.prototype.then=function(t,n){var r=new e,i=this.s;if(i){var o=1&i?t:n;if(o){try{Et(r,1,o(this.v))}catch(s){Et(r,2,s)}return r}return this}return this.o=function(s){try{var a=s.v;1&s.s?Et(r,1,t?t(a):a):n?Et(r,1,n(a)):Et(r,2,a)}catch(l){Et(r,2,l)}},r},e}();var _u=0;function fm(e){if(e!=null&&e.length>0)return e;return _u+=1,`pst_ft_${_u}`}function pm({initialVisibleRowCount:e,itemHeight:t}){return e==null?420:Math.max(0,e)*(t??pi)}function Eu(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 Tu(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 Pu(e){return Array.from(e.children).filter((t)=>t instanceof SVGElement)}var _r=class{static LoadedCustomComponent=!0;#e;#t;#c;#u;#a;#V;#O;#v;#r;#y=new xu;#T;#b;#m;#h;#w;#I;#f;#q;#z;#N=null;#i;#W=!1;#$=!1;constructor(e){let{composition:t,density:n,fileTreeSearchMode:r,gitStatus:i,id:o,initialSearchQuery:s,icons:a,itemHeight:l,onSearchChange:d,onSelectionChange:u,overscan:f,renderRowDecoration:c,renaming:m,search:p,searchBlurBehavior:g,searchFakeFocus:v,stickyFolders:I,unsafeCSS:C,initialVisibleRowCount:y,...S}=e;this.#e=t,this.#c=fm(o),this.#h=Wo(i),this.#w=a,this.#I=C,this.#u=u,this.#a=c,this.#V=m!=null&&m!==!1,this.#O=g,this.#v=p===!0,this.#r=v===!0,this.#T=Gl(n,l),this.#b={itemHeight:this.#T.itemHeight,overscan:f,stickyFolders:I,initialVisibleRowCount:y},this.#t=new ac({...S,fileTreeSearchMode:r,initialSearchQuery:s,onSearchChange:d,renaming:m}),this.#z=this.#t.getSelectionVersion(),this.#N=this.#u==null?null:this.subscribe(()=>{this.#R()})}unmount(){if(this.#i!=null)ku(this.#i),delete this.#i.dataset.fileTreeVirtualizedWrapper,this.#i=void 0;if(this.#y.clearAll(),this.#y.setHost(null),this.#m!=null)delete this.#m.dataset.fileTreeVirtualized,this.#F(this.#m),this.#m=void 0}cleanUp(){this.unmount(),this.#N?.(),this.#N=null,this.#t.destroy()}getFileTreeContainer(){return this.#m}getItem(e){return this.#t.getItem(e)}getFocusedItem(){return this.#t.getFocusedItem()}getFocusedPath(){return this.#t.getFocusedPath()}getFocusedIndex(){return this.#t.getFocusedIndex()}getVisibleCount(){return this.#t.getVisibleCount()}getVisibleRows(e,t){return this.#t.getVisibleRows(e,t)}getSelectedPaths(){return this.#t.getSelectedPaths()}getComposition(){return this.#e}getItemHeight(){return this.#T.itemHeight}getDensityFactor(){return this.#T.factor}subscribe(e){let t=!1;return this.#t.subscribe(()=>{if(!t){t=!0;return}e()})}focusPath(e){this.#t.focusPath(e)}focusFirstItem(){this.#t.focusFirstItem()}focusLastItem(){this.#t.focusLastItem()}focusNextItem(){this.#t.focusNextItem()}focusPreviousItem(){this.#t.focusPreviousItem()}focusParentItem(){this.#t.focusParentItem()}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)}applyGitStatusPatch(e){let t=dc(this.#h,e);if(t===this.#h)return;this.#h=t;let n=this.#s();if(n==null)return;Vn(n.wrapper,this.#P())}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){if(Array.isArray(e))this.#t.resetPaths(e,t);else this.#t.resetPaths(e)}setComposition(e){this.#e=e;let t=this.#s();if(t==null)return;this.#x(),Vn(t.wrapper,this.#P())}setGitStatus(e){let t=Wo(e,this.#h);if(t===this.#h)return;this.#h=t;let n=this.#s();if(n==null)return;Vn(n.wrapper,this.#P())}setIcons(e){this.#w=e;let t=this.#s();if(t==null)return;this.#g(t.host,t.wrapper),Vn(t.wrapper,this.#P())}hydrate({fileTreeContainer:e}){let t=this.#M(e),n=this.#L(t);this.#x(),Cu(n,this.#P())}render({containerWrapper:e,fileTreeContainer:t}){let n=this.#M(t??this.#m,e),r=this.#L(n);this.#x(),Vn(r,this.#P())}#Z(){return{initialViewportHeight:pm({initialVisibleRowCount:this.#b.initialVisibleRowCount,itemHeight:this.#b.itemHeight}),itemHeight:this.#b.itemHeight,overscan:this.#b.overscan,stickyFolders:this.#b.stickyFolders}}#P(){return{composition:this.#e,controller:this.#t,gitStatusByPath:this.#h?.statusByPath,ignoredGitDirectories:this.#h?.ignoredDirectoryPaths,directoriesWithGitChanges:this.#h?.directoriesWithChanges,icons:this.#w,instanceId:this.#c,renamingEnabled:this.#V,renderRowDecoration:this.#a,searchBlurBehavior:this.#O,searchEnabled:this.#v,searchFakeFocus:this.#r,slotHost:this.#y,...this.#Z()}}#s(){let e=this.#m,t=this.#i;if(e==null||t==null)return null;return{host:e,wrapper:t}}#g(e,t){let n=e.shadowRoot;if(n!=null)this.#j(n),this.#K(n);this.#U(t)}#R(){let e=this.#u;if(e==null)return;let t=this.#t.getSelectionVersion();if(t===this.#z)return;this.#z=t,e(this.#t.getSelectedPaths())}#x(){let e=this.#e?.header?.render;if(e!=null){this.#y.setSlotContent(yr,e());return}this.#y.setSlotHtml(yr,this.#e?.header?.html??null)}#j(e){let t=Pu(e).find((r)=>Tu(r)),n=Eu(ql(Pn(this.#w).set));if(n==null)return;if(t!=null&&t.outerHTML===n.outerHTML)return;if(t!=null)t.replaceWith(n);else e.prepend(n)}#K(e){let t=Pu(e),n=t.find((s)=>Tu(s)),r=t.filter((s)=>s!==n),i=Pn(this.#w).spriteSheet?.trim()??"";if(i.length===0){for(let s of r)s.remove();return}let o=Eu(i);if(o==null){for(let s of r)s.remove();return}if(r.length===1&&r[0].outerHTML===o.outerHTML)return;for(let s of r)s.remove();e.appendChild(o)}#U(e){let t=Pn(this.#w);if(t.colored&&Wl(t.set))e.dataset.fileTreeColoredIcons="true";else delete e.dataset.fileTreeColoredIcons}#l(e){let t=e.querySelector(`style[${Mo}]`);if(this.#f==null&&t instanceof HTMLStyleElement)this.#f=t;if(this.#I==null||this.#I===""){this.#f?.remove(),this.#f=void 0,this.#q=void 0;return}if(this.#f?.parentNode===e&&this.#q===this.#I)return;if(this.#f??=document.createElement("style"),this.#f.setAttribute(Mo,""),this.#f.parentNode!==e)e.appendChild(this.#f);this.#f.textContent=Yl(this.#I),this.#q=this.#I}#L(e){if(this.#i!=null)return this.#i;let t=e.shadowRoot;if(t==null)throw Error("FileTree requires a shadow root");let n=Array.from(t.children).filter((i)=>i instanceof HTMLDivElement&&typeof i.dataset.fileTreeId==="string"&&i.dataset.fileTreeId.length>0),r=n.find((i)=>i.dataset.fileTreeId===this.#c)??n[0];if(r!=null)this.#c=r.dataset.fileTreeId??this.#c;if(this.#i=r??document.createElement("div"),this.#i.dataset.fileTreeId=this.#c,this.#i.dataset.fileTreeVirtualizedWrapper="true",this.#g(e,this.#i),this.#i.parentNode!==t)t.appendChild(this.#i);return this.#i}#M(e,t){let n=e??this.#m??document.createElement("file-tree-container");if(t!=null&&n.parentNode!==t)t.appendChild(n);let r=n.shadowRoot??n.attachShadow({mode:"open"});return yi(n,r),this.#l(r),n.dataset.fileTreeVirtualized="true",n.style.display="flex",this.#k(n),this.#y.setHost(n),this.#m=n,n}#k(e){if(e.style.getPropertyValue("--trees-item-height")==="")e.style.setProperty("--trees-item-height",`${String(this.#T.itemHeight)}px`),this.#W=!0;if(e.style.getPropertyValue("--trees-density-override")==="")e.style.setProperty("--trees-density-override",String(this.#T.factor)),this.#$=!0}#F(e){if(this.#W)e.style.removeProperty("--trees-item-height"),this.#W=!1;if(this.#$)e.style.removeProperty("--trees-density-override"),this.#$=!1}};var Ru=["--trees-bg-override: var(--surface-pane)","--trees-bg-muted-override: var(--surface-muted)","--trees-border-color-override: transparent","--trees-fg-override: var(--text)","--trees-font-family-override: var(--font-sans)","--trees-focus-ring-color-override: var(--text-muted)","--trees-padding-inline-override: 8px","--trees-scrollbar-gutter-override: 4px","--trees-search-bg-override: light-dark(var(--surface-base), var(--surface-control))","--trees-selected-bg-override: var(--selection)","--trees-selected-focused-border-color-override: var(--text-muted)"].join("; "),ps=`
|
|
1286
1286
|
[data-item-git-status] > [data-item-section='content'] { color: var(--trees-fg); }
|
|
1287
1287
|
[data-file-tree-virtualized-sticky='true'] { will-change: auto; }
|
|
1288
|
-
`,
|
|
1288
|
+
`,Du={density:"compact",fileTreeSearchMode:"hide-non-matches",flattenEmptyDirectories:!0,id:"review-file-tree",initialExpansion:"open",initialVisibleRowCount:20,search:!0,searchBlurBehavior:"retain",stickyFolders:!1,unsafeCSS:ps};var On=50;var gm=0.35,vm=0.65;var ym=224,bm=480;var wm=0.3,Im=0.7;function Au(e){if(!Er(e))return{};return{changesRatio:ms(e.changesRatio,wm,Im),gitPaneRatio:ms(e.gitPaneRatio,gm,vm),layout:e.layout==="split"||e.layout==="unified"?e.layout:void 0,mode:e.mode==="all"||e.mode==="selected"?e.mode:void 0,reviewSidebarWidth:ms(e.reviewSidebarWidth,ym,bm),tab:e.tab==="files"||e.tab==="git"?e.tab:void 0,wrap:Mu(e.wrap)?e.wrap:void 0}}function ms(e,t,n){return dn(e)&&Number.isFinite(e)?Math.min(Math.max(e,t),n):void 0}var Sm={branch:null,changes:[],commits:[],isGitRepository:!1,changeCount:0,revision:"non-git"},g2={...Sm,revision:"git-unloaded"},Nu=A.ReadonlyObject(A.Object({additions:A.Number(),deletions:A.Number(),path:A.String(),status:A.Union([A.Literal("added"),A.Literal("deleted"),A.Literal("modified"),A.Literal("renamed"),A.Literal("untracked")])})),gs=A.ReadonlyObject(A.Object({author:A.String(),authoredAt:A.String(),hash:A.String(),pushed:A.Union([A.Boolean(),A.Null()]),shortHash:A.String(),subject:A.String()})),Cm=A.ReadonlyObject(A.Object({changes:A.ReadonlyObject(A.Array(Nu)),commit:gs,patch:A.String()})),km=A.ReadonlyObject(A.Object({branch:A.Union([A.String(),A.Null()]),changes:A.ReadonlyObject(A.Array(Nu)),commits:A.ReadonlyObject(A.Array(gs)),isGitRepository:A.Boolean(),changeCount:A.Number(),revision:A.String()})),xm=Mi(Cm),_m=Mi(A.Array(gs)),Em=Mi(km);function Lu(e){return xm.Check(e)}function Fu(e){return _m.Check(e)}function vs(e){return Em.Check(e)}function Ai(e,t){let n=document.getElementById(e);if(!(n instanceof t))throw Error(`Missing #${e}`);return n}function de(e){return Ai(e,HTMLElement)}function $e(e){return Ai(e,HTMLButtonElement)}function ys(e){return Ai(e,HTMLDialogElement)}function Bu(e){return Ai(e,HTMLInputElement)}var Vu=A.Object({path:A.String(),contents:A.String(),revision:A.String(),size:A.Number()}),Tm=A.Union([Vu,A.Object({message:A.String(),path:A.String(),size:A.Number()})]),Pm=A.Object({paths:A.Array(A.String()),workspacePath:A.String()}),bs=A.Object({path:A.String()});function Ou(e){let t=`${e}/content`,n=`${e}/entry`;return{async create(r,i){return(await qn(n,bs,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({kind:i,path:r})})).path},async list(){return await qn(e,Pm)},async move(r,i){return(await qn(n,bs,{method:"PATCH",headers:{"content-type":"application/json"},body:JSON.stringify({destination:i,path:r})})).path},async read(r){return await qn(`${t}?path=${encodeURIComponent(r)}`,Tm)},async remove(r){await qn(n,bs,{method:"DELETE",headers:{"content-type":"application/json"},body:JSON.stringify({path:r})})},async save(r,i,o){return await qn(t,Vu,{method:"PUT",headers:{"content-type":"application/json"},body:JSON.stringify({contents:i,path:r,revision:o})})}}}async function qn(e,t,n){let r=await fetch(e,{...n,headers:{accept:"application/json",...n?.headers}});if(!r.ok)throw Error(await Tr(r,`Request failed (${r.status})`));return Hu(t,await r.json())}function qu(e){let t=new Set(e);for(let n of e)for(let r=n.indexOf("/");r!==-1;r=n.indexOf("/",r+1))t.add(n.slice(0,r+1));return t}function Ni(e,t,n){if(!t){e.resetPaths(n);return}if(t.length===n.length&&t.every((s,a)=>s===n[a]))return;let r=qu(t),i=qu(n),o=[];for(let s of n)if(!r.has(s))o.push({type:"add",path:s});for(let s of[...r].filter((a)=>!i.has(a)).sort((a,l)=>l.length-a.length))o.push({type:"remove",path:s});if(o.length>0)e.batch(o)}function ws(e){requestAnimationFrame(()=>{(e.querySelector("file-tree-container")?.shadowRoot?.querySelector('[role="tree"]')??e).focus({preventScroll:!0})})}function ju(e){let t=Ou(e.endpoint),n=de("workspace-file-tree"),r=de("workspace-file-main"),i=de("workspace-file-view"),o=de("workspace-file-empty"),s=de("workspace-file-path"),a=de("workspace-file-status"),l=$e("workspace-file-edit"),d=$e("workspace-file-download"),u=$e("workspace-file-wrap"),f=ys("workspace-entry-dialog"),c=de("workspace-entry-title"),m=de("workspace-entry-description"),p=Bu("workspace-entry-input"),g=de("workspace-entry-error"),v=$e("workspace-entry-action"),I=ys("workspace-confirm-dialog"),C=de("workspace-confirm-title"),y=de("workspace-confirm-description"),S=$e("workspace-confirm-cancel"),k=$e("workspace-confirm-action");n.style.cssText=Ru;let T=e.initialWorkspacePath,O=[],pe,Z=!1,me=!1,J=0,U=0,B,ae,Ce="",z=!1,le=!0,X,be=new $u(Oe()),oe=new _r({composition:{contextMenu:{enabled:!0,render:bt,triggerMode:"right-click"}},density:"compact",fileTreeSearchMode:"hide-non-matches",flattenEmptyDirectories:!0,gitStatus:e.initialGitStatus,id:"workspace-files-tree",initialExpansion:"closed",paths:[],search:!0,searchBlurBehavior:"retain",stickyFolders:!1,unsafeCSS:ps,onSelectionChange(w){let M=w.length===1?w[0]:void 0;if(!M)return;let H=oe.getItem(M);if(H?.isDirectory()){he(""),H.deselect();return}it(M)}});oe.render({containerWrapper:n}),d.addEventListener("click",()=>{let w=ae;if(!w)return;let M=document.createElement("a");M.href=`${e.endpoint}/content?path=${encodeURIComponent(w)}&download=1`,M.download=w.split("/").at(-1)??"download",M.click()}),l.addEventListener("click",()=>void Xt()),i.addEventListener("keydown",(w)=>{if((w.ctrlKey||w.metaKey)&&!w.altKey&&!w.shiftKey&&w.code==="KeyS")w.preventDefault(),Xt()}),u.addEventListener("click",()=>{le=!le,u.setAttribute("aria-pressed",String(le)),be.setOptions(Oe())}),window.addEventListener("pi-ui-code-theme-changed",()=>{be.setOptions(Oe()),be.rerender()});function bt(w,M){let H=document.createElement("div");return H.className="workspace-tree-context-menu",H.setAttribute("role","menu"),H.append(Ve("New file",()=>{M.close({restoreFocus:!1}),ct(w,"file")}),Ve("New folder",()=>{M.close({restoreFocus:!1}),ct(w,"folder")}),Ve("Rename",()=>{M.close({restoreFocus:!1}),Dt(w)}),Ve("Delete",()=>{M.close({restoreFocus:!1}),nt(w)},!0)),H}function Ve(w,M,H=!1){let j=document.createElement("button");return j.type="button",j.className=`workspace-tree-context-menu-item${H?" workspace-tree-context-menu-item-destructive":""}`,j.setAttribute("role","menuitem"),j.textContent=w,j.addEventListener("click",M),j}async function ct(w,M){let H=await G({title:`New ${M}`,description:`Enter a name for the new ${M}.`,action:"Create"});if(!H)return;let j=w.kind==="directory"?w.path:zu(w.path),It=Wu(j,H);try{let en=await t.create(It,M);if(await ut(!0),M==="file")await ke(en);else{let Xn=oe.getItem(en);if(Xn&&"expand"in Xn)Xn.expand()}}catch(en){he(Tt(en))}}async function Dt(w){if(Te(w.path)&&z){await At("Unsaved changes","Save or discard your changes before renaming this item.");return}let M=await G({title:`Rename ${w.kind==="directory"?"folder":"file"}`,description:`Enter a new name for ${w.name}.`,action:"Rename",initialValue:w.name});if(!M||M===w.name)return;let H=Wu(zu(w.path),M),j=B&&Te(w.path)?`${H}${B.path.slice(w.path.length)}`:void 0;try{if(await t.move(w.path,H),j)je();if(await ut(!0),j)await ke(j)}catch(It){he(Tt(It))}}async function nt(w){if(Te(w.path)&&z){await At("Unsaved changes","Save or discard your changes before deleting this item.");return}let M=w.kind==="directory"?"folder":"file";if(!await dt({title:`Delete ${M}?`,description:`This will permanently delete ${w.name}${w.kind==="directory"?" and all of its contents":""}. This action cannot be undone.`,action:"Delete"}))return;try{if(await t.remove(w.path),Te(w.path))je();await ut(!0)}catch(H){he(Tt(H))}}function je(){U+=1,Mt(),B=void 0,Ce="",z=!1,mn(),s.textContent="Select a file",he(""),Ae("Open a file from the workspace"),Ue()}function Te(w){return B?.path===w||B?.path.startsWith(`${w}/`)===!0}function Oe(){return{disableFileHeader:!0,overflow:le?"wrap":"scroll",theme:Pr(),themeType:"system",onEditChange({file:w}){Ce=w.contents,z=Ce!==B?.contents,Ue()},unsafeCSS:`
|
|
1289
1289
|
@media (prefers-reduced-motion: no-preference) {
|
|
1290
1290
|
[data-caret] {
|
|
1291
1291
|
animation-timing-function: step-end;
|
|
@@ -1299,7 +1299,7 @@ import{A,B as Bu,C as Pi,D as yd,F as Er,G as _s,a as Ur,b as ta,c as na,e as Kr
|
|
|
1299
1299
|
[data-file] {
|
|
1300
1300
|
min-width: 100%;
|
|
1301
1301
|
}
|
|
1302
|
-
`}}function Ut(w){if(me=w,me)ut()}async function ke(w){me=!0,await ut();for(let H of oe.getSelectedPaths())oe.getItem(H)?.deselect();let M=oe.getItem(w);if(M)M.select();else await it(w)}function wt(w=!0){Gt(w)}function Ke(w){if(B?.path===w)z=!1,Ue();Gt()}async function Gt(w=!0){let M=B,H=U;if(await ut(w),!M||B!==M||U!==H)return;try{let j=await t.read(M.path);if(B!==M||U!==H)return;if("message"in j){if(z)he("File changed on disk");else je(),pn(j.path),s.textContent=j.path,he(qn(j.size)),Ae(j.message);return}if(j.revision===M.revision)return;if(z){he("File changed on disk");return}let It=++U;Dt(),B=j,Ce=j.contents,be.render({file:{cacheKey:`${T}:${j.path}:${j.revision}`,contents:j.contents,name:j.path},containerWrapper:i}),he(qn(j.size)),Ue(),await fn(It)}catch(j){if(B!==M||U!==H)return;he(Et(j))}}function rt(w){oe.setGitStatus(w)}function we(w){if(T===w)return;if(T=w,O=[],pe=void 0,J+=1,je(),oe.resetPaths([]),me)ut()}async function ut(w=!1){if(w)Z=!0;let M=++J;if(!me||!Z&&pe===T)return;if(!w)he("Loading files…");try{let H=await t.list();if(M!==J||H.workspacePath!==T)return;if(Di(oe,pe===T?O:void 0,H.paths),pe=T,O=H.paths,Z=!1,ae){if(B)he(qn(B.size));return}let j=H.paths.includes("README.md")?"README.md":H.paths.find((It)=>!It.endsWith("/"));if(j)oe.getItem(j)?.select();else he(""),Ae("No files in this workspace")}catch(H){if(M!==J)return;he(Et(H)),Ae("Could not load workspace files")}}async function it(w){if(B?.path===w)return;if(z&&!await dt({title:"Discard unsaved changes?",description:`Your unsaved changes to ${B?.path??"this file"} will be lost.`,action:"Discard"})){oe.getItem(w)?.deselect(),oe.getItem(B?.path??"")?.select();return}let M=++U;Dt(),z=!1,s.textContent=w,pn(),he("");try{let H=await t.read(w);if(M!==U)return;if(pn(H.path),he(qn(H.size)),"message"in H){B=void 0,Ae(H.message),Ue();return}B=H,Ce=H.contents,s.textContent=H.path,be.render({file:{cacheKey:`${T}:${H.path}:${H.revision}`,contents:H.contents,name:H.path},containerWrapper:i}),Wi(),he(qn(H.size)),Ue(),await fn(M)}catch(H){if(M!==U)return;B=void 0,he(""),Ae(Et(H)),Ue()}}async function fn(w){l.disabled=!0;try{let{Editor:M}=await import("./index-tj848246.js");if(w!==U||!B)return;X=new M("file"),X.edit(be)}catch(M){X=void 0,he(Et(M))}finally{Ue()}}async function Yt(){if(!B||!X||!z)return;l.disabled=!0,he("Saving…");try{B=await t.save(B.path,Ce,B.revision),Ce=B.contents,z=!1,he(qn(B.size))}catch(w){he(Et(w))}finally{Ue()}}function Dt(){X?.cleanUp("discard"),X=void 0,Ue()}function pn(w){ae=w,d.disabled=!w}function Ue(){l.disabled=!B||!X||!z}function Ae(w){o.textContent=w,o.style.display="grid",i.style.display="none"}function Wi(){o.style.display="none",i.style.display="block"}function he(w){a.textContent=w}function G(w){return c.textContent=w.title,m.textContent=w.description,v.textContent=w.action,p.value=w.initialValue??"",g.textContent="",g.hidden=!0,f.returnValue="",new Promise((M)=>{f.addEventListener("close",()=>M(f.returnValue==="submit"?p.value:void 0),{once:!0}),f.showModal(),p.select()})}function mn(){if(!Tm(p.value)){g.textContent="Use a non-empty name without slashes, '.', or '..'.",g.hidden=!1;return}f.close("submit")}function dt(w){return C.textContent=w.title,y.textContent=w.description,k.textContent=w.action,S.hidden=w.showCancel===!1,k.dataset.variant=w.destructive===!1?"default":"destructive",I.returnValue="",new Promise((M)=>{I.addEventListener("close",()=>M(I.returnValue==="confirm"),{once:!0}),I.showModal()})}async function Mt(w,M){await dt({title:w,description:M,action:"OK",showCancel:!1,destructive:!1})}v.addEventListener("click",mn),p.addEventListener("keydown",(w)=>{if(w.key!=="Enter"||w.isComposing)return;w.preventDefault(),mn()});function Xt(){let w=oe.getSelectedPaths()[0]??oe.getFocusedPath()??O[0];if(w)oe.scrollToPath(w,{focus:!0});bs(n)}function Qt(){(B?i:r).focus({preventScroll:!0})}function Zt(){Dt(),be.cleanUp(),oe.cleanUp()}return Ue(),Ae("Open a file from the workspace"),{cleanUp:Zt,focusEditor:Qt,focusTree:Xt,openFile:ke,refresh:wt,refreshAfterDiscard:Ke,requestConfirmation:dt,requestNotice:Mt,setGitStatus:rt,setVisible:Ut,setWorkspace:we}}function Tm(e){return Boolean(e&&e===e.trim()&&e!=="."&&e!==".."&&!e.includes("/")&&!e.includes("\\"))}function qu(e){let t=e.lastIndexOf("/");return t===-1?"":e.slice(0,t)}function zu(e,t){return e?`${e}/${t}`:t}function qn(e){if(e<1024)return`${e} B`;if(e<1048576)return`${(e/1024).toFixed(1)} KB`;return`${(e/1048576).toFixed(1)} MB`}function ju(e){return{async loadDiff(t,n,r){let i=new URLSearchParams({workspacePath:t});if(n!==void 0)i.set("path",n);let o=await fetch(`${e}/diff?${i}`,{signal:r});if(o.ok)return o.text();throw Error(await _r(o,`Unable to load diff (${o.status})`))},async discard(t){let n=await fetch(`${e}/discard`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({path:t})});if(n.ok)return;throw Error(await _r(n,`Request failed (${n.status})`))},async loadCommit(t){try{let n=await fetch(`${e}/commit?hash=${encodeURIComponent(t)}`,{headers:{accept:"application/json"}});if(!n.ok)return;let r=await n.json();return Nu(r)?r:void 0}catch{return}},async loadHistory(t){try{let n=await fetch(`${e}/history?offset=${t}`,{headers:{accept:"application/json"}});if(!n.ok)return;let r=await n.json();return Lu(r)?r:void 0}catch{return}}}}var Mi=globalThis.navigator?.platform??globalThis.process?.platform,Ku=Mi==="win32"||Mi?.startsWith("Win")?"windows":Mi==="darwin"||Mi?.startsWith("Mac")?"darwin":"linux";function Uu(e,t=Ku){return t==="darwin"?e.metaKey&&!e.ctrlKey:e.ctrlKey&&!e.metaKey}function Gu(){let e=new Map,t=new Map,n=0;function r(f,c,m){if(a())return!1;let p={lineNumber:Math.max(m.start,m.end),metadata:{body:null,id:`review-comment-${++n}`,range:{...m}},side:Pm(m)};return e.set(f,[...e.get(f)??[],p]),t.set(f,c),!0}function i(f,c){let m=c.trim();if(!m)return;return u(f,(p)=>({...p,metadata:{...p.metadata,body:m}}))}function o(f){for(let[c,m]of e){let p=m.filter((g)=>g.metadata.id!==f);if(p.length===m.length)continue;if(p.length>0)e.set(c,p);else e.delete(c),t.delete(c);return c}return}function s(f,c){let m=[];for(let p of e.keys()){if(!f.has(p)&&c?.has(p))continue;if(f.get(p)===t.get(p))continue;e.delete(p),t.delete(p),m.push(p)}return m}function a(){for(let f of e.values())if(f.some((c)=>c.metadata.body===null))return!0;return!1}function l(){let f=[];for(let[c,m]of e)for(let p of m){let g=p.metadata.body;if(g===null)continue;f.push({body:g,endLine:p.metadata.range.end,endSide:p.metadata.range.endSide??p.metadata.range.side??p.side,path:c,startLine:p.metadata.range.start,startSide:p.metadata.range.side??p.side})}return f}function d(){e.clear(),t.clear()}function u(f,c){for(let[m,p]of e){let g=p.findIndex((I)=>I.metadata.id===f);if(g<0)continue;let v=[...p];return v[g]=c(v[g]),e.set(m,v),m}return}return{add:r,annotations:e,hasDraft:a,reconcileFiles:s,remove:o,reset:d,save:i,savedComments:l}}function Pm(e){return e.endSide??e.side??"additions"}var Rm=navigator.userAgent.includes("Macintosh")?"darwin":"linux";function Xu(e){let t=Gu(),n,r=!1;e.submitButton.addEventListener("click",()=>void u()),f();function i(p,g){let v=p.fileDiff.name;if(t.add(v,Yu(p.fileDiff),g))d(v)}function o(p){if(!("side"in p))return;let{metadata:g}=p,v=document.createElement("div");v.className="review-comment-wrapper",v.dataset.reviewCommentId=g.id;let I=document.createElement("div");I.className="review-comment-card",v.append(I);let C=document.createElement("p");if(C.className="review-comment-label",C.textContent=Dm(g.range,p.side),I.append(C),g.body===null)s(I,g.id);else a(I,g.id,g.body);return v}function s(p,g){let v=document.createElement("textarea");v.className="textarea review-comment-input",v.placeholder="Leave a comment for the agent…",v.setAttribute("aria-label","Review comment");let I=document.createElement("div");I.className="review-comment-actions";let C=ws("Add comment");C.disabled=!0;let y=ws("Cancel","outline"),S=()=>{let k=t.save(g,v.value);if(!k)return;d(k),e.clearSelection()};C.addEventListener("click",S),y.addEventListener("click",()=>l(g)),v.addEventListener("input",()=>{C.disabled=v.value.trim()===""}),v.addEventListener("keydown",(k)=>{if(k.key==="Escape")k.preventDefault(),l(g);else if(k.key==="Enter"&&Uu(k,Rm))k.preventDefault(),S()}),I.append(C,y),p.append(v,I),setTimeout(()=>v.focus(),0)}function a(p,g,v){let I=document.createElement("p");I.className="review-comment-body",I.textContent=v;let C=document.createElement("div");C.className="review-comment-actions";let y=ws("Remove","ghost");y.classList.add("error-foreground"),y.addEventListener("click",()=>l(g)),C.append(y),p.append(I,C)}function l(p){let g=t.remove(p);if(!g)return;e.clearSelection(),d(g)}function d(p){n=void 0,f(),e.onAnnotationsChange(p)}async function u(){let p=t.savedComments();if(p.length===0||t.hasDraft()||r)return;r=!0,n=void 0,f();let g=await e.submit(p).catch(()=>!1);if(r=!1,!g){n="Couldn’t send",f();return}t.reset(),f(),e.onSubmitted()}function f(){let p=t.savedComments().length,g=t.hasDraft();e.submitButton.hidden=p===0&&!g,e.submitButton.disabled=p===0||g||r,e.submitButton.textContent=r?"Sending…":`Submit review${p>0?` (${p})`:""}`,e.status.hidden=!n,e.status.textContent=n??""}function c(p,g){if(t.reconcileFiles(new Map(p.values().filter((I)=>t.annotations.has(I.fileDiff.name)).map((I)=>[I.fileDiff.name,Yu(I.fileDiff)]).toArray()),g).length===0)return;e.clearSelection(),n="Changes updated; outdated comments removed",f()}function m(){t.reset(),n=void 0,f()}return{add:i,annotations:t.annotations,canAdd:()=>!t.hasDraft(),reconcileItems:c,render:o,reset:m}}function ws(e,t){let n=document.createElement("button");if(n.type="button",n.className="btn",n.dataset.size="xs",t)n.dataset.variant=t;return n.textContent=e,n}function Yu(e){return JSON.stringify(e)}function Dm(e,t){let n=e.side??t,r=e.endSide??e.side??t,i=(a)=>a==="additions"?"new":"old";if(n!==r)return`${i(n)} line ${e.start} to ${i(r)} line ${e.end}`;let o=Math.min(e.start,e.end),s=Math.max(e.start,e.end);return o===s?`${i(n)} line ${o}`:`${i(n)} lines ${o}–${s}`}function ed({commits:e,getCommitDetail:t,history:n,loading:r,onSelectCommit:i,onSelectCommitPath:o,revision:s,selection:a}){let l=n.scrollTop;if(n.replaceChildren(),e.length===0){let u=document.createElement("p");u.className="review-history-message",u.textContent=s==="git-unloaded"?"Loading history…":"No commits yet",n.append(u);return}let d;for(let u of e){if(u.pushed!==d)n.append(Mm(u.pushed)),d=u.pushed;let f=a.kind==="commit"&&a.hash===u.hash,c=document.createElement("div"),m=document.createElement("button");m.type="button",m.className="review-commit",m.setAttribute("aria-pressed",String(f)),m.title=u.subject,m.addEventListener("click",()=>i(u.hash));let p=document.createElement("span");p.className="review-commit-subject",p.textContent=u.subject||"Untitled commit";let g=document.createElement("span");g.className="fine-print review-commit-meta";let v=document.createElement("span");v.className="review-commit-hash",v.textContent=u.shortHash;let I=document.createElement("span");I.className="review-commit-author",I.textContent=u.author;let C=document.createElement("time");if(C.className="formatted-date",C.dateTime=u.authoredAt,C.title=rd(u.authoredAt),C.textContent=Nm(u.authoredAt),g.append(v,I,C),m.append(p,g),c.append(m),f){let y=t(u.hash);if(y)c.append(Am(u.hash,y.changes,a.path,o))}n.append(c)}if(r){let u=document.createElement("p");u.className="fine-print review-history-loading",u.textContent="Loading older commits…",n.append(u)}n.scrollTop=l}function td(e,t){e.replaceChildren(),e.hidden=!1;let n=document.createElement("div");n.className="review-detail-heading";let r=document.createElement("div");r.className="review-detail-subject",r.textContent=t.commit.subject||"Untitled commit";let i=document.createElement("span");i.className="review-detail-totals";let o=document.createElement("span");o.className="review-additions",o.textContent=`+${Qu(t.changes,"additions")}`;let s=document.createElement("span");s.className="review-deletions",s.textContent=`-${Qu(t.changes,"deletions")}`,i.append(o,s),n.append(r,i);let a=document.createElement("div");a.className="fine-print review-detail-meta";let l=document.createElement("span");l.className="review-detail-hash",l.textContent=t.commit.shortHash;let d=document.createElement("span");d.className="review-detail-author",d.textContent=t.commit.author;let u=document.createElement("time");u.className="formatted-date",u.dateTime=t.commit.authoredAt,u.title=rd(t.commit.authoredAt),u.textContent=u.title,a.append(l,d,u),e.append(n,a)}function nd(e){e.hidden=!0,e.replaceChildren()}function Mm(e){let t=document.createElement("div");t.className="fine-print review-push-group";let n=document.createElement("span");n.textContent=e===null?"No upstream":e?"Pushed":"Not pushed";let r=document.createElement("span");return r.className="review-push-rule",t.append(n,r),t}function Am(e,t,n,r){let i=document.createElement("div");i.className="review-commit-files";for(let o of t){let s=document.createElement("button");s.type="button",s.className="fine-print review-commit-file",s.setAttribute("aria-pressed",String(n===o.path)),s.title=o.path,s.addEventListener("click",()=>r(e,o.path));let a=document.createElement("span");a.className="review-commit-file-status",a.textContent=Lm(o.status);let l=document.createElement("span");l.className="review-commit-file-path",l.textContent=o.path,s.append(a,l),i.append(s)}return i}function rd(e,t){return Ju(new Date(e),t)}function Nm(e,t=new Date,n){return Zu(new Date(e),t,n)}function Qu(e,t){return e.reduce((n,r)=>n+r[t],0)}function Lm(e){if(e==="added")return"A";if(e==="deleted")return"D";if(e==="renamed")return"R";if(e==="untracked")return"U";return"M"}function Tr(e){return e==="git-unloaded"}function id(e,t){return e.workspacePath!==t.workspacePath||e.revision!==t.revision}function od(e,t,n){if(e[0]?.hash!==n[0]?.hash)return{commits:[...n],hasMore:n.length===Vn,reset:!0};let i=new Set(n.map(({hash:o})=>o));return{commits:[...n,...e.slice(Vn).filter(({hash:o})=>!i.has(o))],hasMore:t,reset:!1}}function sd(e,t){if(e.kind==="commit"&&t[0])return{kind:"working",path:t[0].path};return e}function ad(e,t,n,r){if(t){if(n[0])return{kind:"working",path:n[0].path};if(r[0])return{hash:r[0].hash,kind:"commit"};return{kind:"working"}}if(e.kind!=="working")return e;return{kind:"working",path:n.some(({path:i})=>i===e.path)?e.path:n[0]?.path}}function ld(e,t){let n=new Set(e.map(({hash:i})=>i)),r=t.filter(({hash:i})=>!n.has(i));return{commits:[...e,...r],hasMore:t.length===Vn&&r.length>0}}var Fm=10,Bm=2,cd=document.body.dataset.codeThemeLight,ud=document.body.dataset.codeThemeDark;if(cd&&ud)_s({dark:ud,light:cd});var Hm=document.body.dataset.workspaceReviewEndpoint??"",Vm=document.body.dataset.workspaceFilesEndpoint??"",Fi=ju(Hm);window.addEventListener("pi-ui-code-theme-changed",(e)=>{if(!(e instanceof CustomEvent)||!yd(e.detail))return;let t=e.detail;if(_s(t),Me)qd().setRenderOptions({theme:t}).then(Un).catch((n)=>console.error("Failed to update workspace theme",n))});var Om=de("app"),qm=document.querySelectorAll("[data-workspace-mode]"),Es=de("review-tree"),vt=de("review-history"),bd=de("review-detail-header"),Wn=de("review-diff-view"),zm=de("workspace-file-tree"),dd=de("workspace-file-view"),hd=de("review-empty"),wd=$e("review-mode-all"),Id=$e("review-mode-selected"),Sd=$e("review-layout-split"),Cd=$e("review-layout-stacked"),Is=$e("review-wrap"),Wm=de("workspace-review"),$m=$e("review-submit-comments"),jm=de("review-comment-status"),Km=de("workspace-review-data-region"),Um=de("workspace-review-data"),mt=JSON.parse(Um.textContent??"");if(!xr(mt)||!un(mt.filesRevision)||!un(mt.treeRevision)||!xs(mt.workspacePath)||!gs(mt.snapshot))throw Error("Invalid initial workspace review state");var Bi=Mu(mt.preferences),Tt=mt.workspacePath,fd=mt.filesRevision,pd=mt.treeRevision,q=mt.snapshot,dn=[...q.commits],$n=q.commits.length===Vn,jn=!1,Li=0,et=Bi.mode??"selected",K={kind:"working",path:q.changes[0]?.path},Ts=Bi.layout,zn=Bi.wrap??!0,kd=0,Ss=new Map,Me,Cs,jt=Xu({clearSelection:()=>Me?.clearSelectedLines(),onAnnotationsChange:g1,onSubmitted(){if(Je=Hd(Je),K.kind==="working")tt=Je,Kt=Mr(tt),Me?.clearSelectedLines(),hn();window.piUi.messageScroll.scrollBottom()},status:jm,submit:p1,submitButton:$m}),Je=[],Pr,Ps,Wt,Rr,tt=Je,Kt=Mr(tt),Ai=q.revision!=="git-unloaded",Hi=new Map,Ni=new Map,ks=0,He=$u({endpoint:Vm,initialGitStatus:q.changes,initialWorkspacePath:Tt}),Vi=Bi.tab,gt=r1(Vi,q.isGitRepository),yt=h1(Om,!0,(e)=>{if(He.setVisible(e&>==="files"),e&>==="git")$d();else Kn()});for(let e of qm)e.addEventListener("click",()=>{let t=e.dataset.workspaceMode;if(t==="files"||t==="git"&&q.isGitRepository)Ar(t)});var Xe=new kr({...Ru,composition:{contextMenu:{enabled:!0,render:u1,triggerMode:"right-click"}},gitStatus:q.changes,paths:q.changes.map(({path:e})=>e),onSelectionChange(e){let t=e.length===1?e[0]:void 0;if(t&&!Xe.getItem(t)?.isDirectory())Md(t,!0)}});Xe.render({containerWrapper:Es});l1();window.piUi.workspaceReview={...yt,focusEditor:a1,focusFiles:i1,focusGit:o1};vt.addEventListener("scroll",qi,{passive:!0});vt.addEventListener("keydown",s1);wd.addEventListener("click",()=>Rd("all"));Id.addEventListener("click",()=>Rd("selected"));Sd.addEventListener("click",()=>Dd("split"));Cd.addEventListener("click",()=>Dd("unified"));Is.addEventListener("click",()=>{zn=!zn,Is.setAttribute("aria-pressed",String(zn)),Nr(),Un()});var Dr=Gn(),xd=new ResizeObserver(()=>{let e=Gn();if(Ds(e),e===Dr)return;Dr=e,Un()});xd.observe(Wn);var _d=new MutationObserver(Un);_d.observe(document.documentElement,{attributeFilter:["class"],attributes:!0});function Ed(){try{let e=document.getElementById("workspace-review-data"),t=JSON.parse(e?.textContent??"");if(xr(t)&&un(t.filesRevision)&&un(t.treeRevision)&&xs(t.workspacePath)&&gs(t.snapshot)){let n=t.workspacePath===Tt&&t.filesRevision!==fd,r=t.treeRevision!==pd;if(fd=t.filesRevision,pd=t.treeRevision,n)Fd();if(Gm(t.workspacePath,t.snapshot),n){if(He.refresh(r),K.kind==="working")Oi(K.path)}}}catch{}}var Td=new MutationObserver(Ed);Td.observe(Km,{characterData:!0,childList:!0,subtree:!0});Rs();Ds();Is.setAttribute("aria-pressed",String(zn));Pd(q);Ed();window.addEventListener("pagehide",()=>{Td.disconnect(),xd.disconnect(),_d.disconnect(),Xe.cleanUp(),He.cleanUp(),Me?.cleanUp(),Kn(),ho()},{once:!0});function Gm(e,t){if(!id({revision:q.revision,workspacePath:Tt},{revision:t.revision,workspacePath:e}))return;if(e!==Tt)Tt=e,He.setWorkspace(Tt),ks++,Li++,dn=[],$n=!1,jn=!1,Hi.clear(),Ni.clear(),Ss.clear(),jt.reset(),Ai=!1,K={kind:"working"};Pd(t)}function Pd(e){let t=Tr(q.revision)||!Ai,n=t?void 0:q.changes.map(({path:o})=>o),r=q.isGitRepository,i=od(dn,$n,e.commits);if(q=e,He.setGitStatus(q.changes),dn=i.commits,$n=i.hasMore,i.reset)Li++,jn=!1;if(!q.isGitRepository)gt="files";else if(!r&&Vi!=="files")gt="git";if(He.setVisible(yt.isOpen()&>==="files"),Fd(),Di(Xe,n,q.changes.map(({path:o})=>o)),Xe.setGitStatus(q.changes),Tr(q.revision)){Ai=!1,Pt(),Me?.setItems([]),Wt=void 0,$t("Loading Git data…");return}if(K=ad(K,t,Ld(),q.commits),t)Ai=!0;if(Pt(),yt.isOpen()&>==="git")requestAnimationFrame(qi);if(K.kind==="commit")Ad(K.hash,K.path);else Oi(K.path)}function Rd(e){if(et=e,Rs(),Nr(),et==="selected"&&!K.path)K.path=tt[0]?.fileDiff.name;Pt(),hn()}function Dd(e){Ts=e,Dr=Gn(),Ds(Dr),Nr(),Un()}function Md(e,t=!1){if(t&&Rr&&et==="all")et="selected",Rs(),Nr();if(Oi(e),Pt(),e&&!t)Xe.scrollToPath(e,{focus:!1,offset:"nearest"});if(e)Nd(e)}function Oi(e){K={kind:"working",path:e},tt=Je,Kt=Mr(tt),n1(),hn()}async function Ad(e,t){Kn(),Wt=void 0,K={hash:e,kind:"commit",path:t},Qm(),Pt();let n=Hi.get(e);if(n){md(n,t);return}$t("Loading commit…");let r=await Ym(e);if(K.kind!=="commit"||K.hash!==e)return;if(!r){$t("Unable to load commit");return}md(r,t)}function md(e,t){tt=e.items,Kt=Mr(tt),K={hash:e.detail.commit.hash,kind:"commit",path:t&&Kt.has(t)?t:tt[0]?.fileDiff.name},t1(e.detail),Pt(),hn()}function Ym(e){let t=Ni.get(e);if(t)return t;let n=ks,r=Fi.loadCommit(e).then((i)=>{if(!i)return;let o={detail:i,items:Bd(i.changes,i.patch,i.commit.hash)};if(n!==ks)return;return Hi.set(e,o),o}).finally(()=>Ni.delete(e));return Ni.set(e,r),r}function Xm(e,t){if(K.kind!=="commit"||K.hash!==e)return;if(K.path=t,Pt(),et==="selected")hn();else Nd(t)}function Nd(e){let t=Kt.get(e);if(t&&Me)Me.scrollTo({type:"item",id:t.id,align:"start",behavior:"smooth-auto"})}function Ld(){let e=new Set(q.changes.map(({path:r})=>r)),t=Xe.getVisibleRows(0,Xe.getVisibleCount()).find((r)=>r.kind==="file"&&e.has(r.path))?.path;if(!t||t===q.changes[0]?.path)return q.changes;let n=q.changes.find(({path:r})=>r===t);return n?[n,...q.changes.filter(({path:r})=>r!==t)]:q.changes}function Qm(){for(let e of Xe.getSelectedPaths())Xe.getItem(e)?.deselect()}function Kn(){Pr?.abort(),Pr=void 0,Ps=void 0,Rr=void 0}function Fd(){Kn(),Je=[],jt.reconcileItems([],new Set(q.changes.map((e)=>e.path)))}async function Zm(e){Kn(),Ps=e;let t=new AbortController;if(Pr=t,Wt!==e)Wt=void 0,Me?.setItems([]),$t("Loading diff…");let n=et==="selected"?K.path:void 0,r=q.changes.filter((i)=>n===void 0||i.path===n);try{let i=await Fi.loadDiff(Tt,n,t.signal);if(t.signal.aborted)return;let o=Bd(r,i,"working");jt.reconcileItems(o,new Set(q.changes.map((s)=>s.path))),Je=Hd(o),Wt=e}catch(i){if(t.signal.aborted)return;Je=[],Wt=void 0,Me?.setItems([]),Rr=i instanceof Error?i.message:"Unable to load diff"}finally{if(!t.signal.aborted)Pr=void 0,Oi(K.path)}}function hn(){if(!yt.isOpen()||gt!=="git")return;if(K.kind==="working"&&q.changes.length>0&&!Tr(q.revision)){let t=JSON.stringify([Tt,et,et==="selected"?K.path:null]);if(Ps!==t){Zm(t);return}if(Pr||Rr){if(Wt!==t)$t(Rr??"Loading diff…");return}}let e=et==="all"?tt:K.path&&Kt.has(K.path)?[Kt.get(K.path)]:[];if(e.length===0){Wt=void 0,Me?.setItems([]),$t(f1());return}if($t(),!Me){Dr=Gn();let t=Od();Me=new vd(t,qd()),Cs=t.enableGutterUtility,Me.setup(Wn)}else if(Cs!==Vd())Un();Me.setItems(e)}function Bd(e,t,n){let r=new Map;for(let i of gd(t))for(let o of i.files)r.set(o.name,o);return e.map((i)=>{let o=r.get(i.path)??Jm(i),s=`${n}:${i.path}`,a=JSON.stringify({...o,cacheKey:void 0}),l=Ss.get(s),d=l?.content===a?l.version:++kd;return Ss.set(s,{content:a,version:d}),{fileDiff:{...o,cacheKey:`pi-ui:${s}:${d}`},id:`diff:${s}`,type:"diff",version:d}})}function Hd(e){return e.map((t)=>({...t,annotations:jt.annotations.get(t.fileDiff.name)}))}function Mr(e){return new Map(e.map((t)=>[t.fileDiff.name,t]))}function Jm(e){return{additionLines:[],deletionLines:[],hunks:[],isPartial:!0,name:e.path,splitLineCount:0,type:e.status==="added"||e.status==="untracked"?"new":e.status==="deleted"?"deleted":e.status==="renamed"?"rename-pure":"change",unifiedLineCount:0}}function Pt(){ed({commits:dn,getCommitDetail:(e)=>Hi.get(e)?.detail,history:vt,loading:jn,onSelectCommit:(e)=>void Ad(e),onSelectCommitPath:Xm,revision:q.revision,selection:K})}function qi(){if(!yt.isOpen()||jn||!$n||vt.scrollHeight-vt.scrollTop-vt.clientHeight>120)return;e1()}async function e1(){jn=!0;let e=Li;Pt();let t=await Fi.loadHistory(dn.length);if(e!==Li)return;if(t){let n=ld(dn,t);dn=n.commits,$n=n.hasMore}else $n=!1;jn=!1,Pt(),requestAnimationFrame(qi)}function t1(e){td(bd,e)}function n1(){nd(bd)}function Vd(){return K.kind==="working"&&jt.canAdd()}function Un(){if(!Me)return;let e=Od();Me.setOptions(e),Cs=e.enableGutterUtility}function Od(){let e=Vd();return{diffIndicators:"none",enableGutterUtility:e,enableLineSelection:e,onGutterUtilityClick(t,n){if(n.item.type==="diff")jt.add(n.item,t)},pointerEventsOnScroll:!0,renderAnnotation:jt.render,diffStyle:Gn(),hunkSeparators:"simple",itemMetrics:{diffHeaderHeight:36,paddingBottom:0,spacing:0},layout:{gap:Bm,paddingBottom:Fm,paddingTop:0},lineHoverHighlight:"both",overflow:zn?"wrap":"scroll",stickyHeaders:!0,theme:Er(),themeType:document.documentElement.classList.contains("dark")?"dark":"light",unsafeCSS:`
|
|
1302
|
+
`}}function Gt(w){if(me=w,me)ut()}async function ke(w){me=!0,await ut();for(let H of oe.getSelectedPaths())oe.getItem(H)?.deselect();let M=oe.getItem(w);if(M)M.select();else await it(w)}function wt(w=!0){Yt(w)}function Ke(w){if(B?.path===w)z=!1,Ue();Yt()}async function Yt(w=!0){let M=B,H=U;if(await ut(w),!M||B!==M||U!==H)return;try{let j=await t.read(M.path);if(B!==M||U!==H)return;if("message"in j){if(z)he("File changed on disk");else je(),mn(j.path),s.textContent=j.path,he(zn(j.size)),Ae(j.message);return}if(j.revision===M.revision)return;if(z){he("File changed on disk");return}let It=++U;Mt(),B=j,Ce=j.contents,be.render({file:{cacheKey:`${T}:${j.path}:${j.revision}`,contents:j.contents,name:j.path},containerWrapper:i}),he(zn(j.size)),Ue(),await pn(It)}catch(j){if(B!==M||U!==H)return;he(Tt(j))}}function rt(w){oe.setGitStatus(w)}function we(w){if(T===w)return;if(T=w,O=[],pe=void 0,J+=1,je(),oe.resetPaths([]),me)ut()}async function ut(w=!1){if(w)Z=!0;let M=++J;if(!me||!Z&&pe===T)return;if(!w)he("Loading files…");try{let H=await t.list();if(M!==J||H.workspacePath!==T)return;if(Ni(oe,pe===T?O:void 0,H.paths),pe=T,O=H.paths,Z=!1,ae){if(B)he(zn(B.size));return}let j=H.paths.includes("README.md")?"README.md":H.paths.find((It)=>!It.endsWith("/"));if(j)oe.getItem(j)?.select();else he(""),Ae("No files in this workspace")}catch(H){if(M!==J)return;he(Tt(H)),Ae("Could not load workspace files")}}async function it(w){if(B?.path===w)return;if(z&&!await dt({title:"Discard unsaved changes?",description:`Your unsaved changes to ${B?.path??"this file"} will be lost.`,action:"Discard"})){oe.getItem(w)?.deselect(),oe.getItem(B?.path??"")?.select();return}let M=++U;Mt(),z=!1,s.textContent=w,mn(),he("");try{let H=await t.read(w);if(M!==U)return;if(mn(H.path),he(zn(H.size)),"message"in H){B=void 0,Ae(H.message),Ue();return}B=H,Ce=H.contents,s.textContent=H.path,be.render({file:{cacheKey:`${T}:${H.path}:${H.revision}`,contents:H.contents,name:H.path},containerWrapper:i}),Ki(),he(zn(H.size)),Ue(),await pn(M)}catch(H){if(M!==U)return;B=void 0,he(""),Ae(Tt(H)),Ue()}}async function pn(w){l.disabled=!0;try{let{Editor:M}=await import("./index-vtmc6jvm.js");if(w!==U||!B)return;X=new M("file"),X.edit(be)}catch(M){X=void 0,he(Tt(M))}finally{Ue()}}async function Xt(){if(!B||!X||!z)return;l.disabled=!0,he("Saving…");try{B=await t.save(B.path,Ce,B.revision),Ce=B.contents,z=!1,he(zn(B.size))}catch(w){he(Tt(w))}finally{Ue()}}function Mt(){X?.cleanUp("discard"),X=void 0,Ue()}function mn(w){ae=w,d.disabled=!w}function Ue(){l.disabled=!B||!X||!z}function Ae(w){o.textContent=w,o.style.display="grid",i.style.display="none"}function Ki(){o.style.display="none",i.style.display="block"}function he(w){a.textContent=w}function G(w){return c.textContent=w.title,m.textContent=w.description,v.textContent=w.action,p.value=w.initialValue??"",g.textContent="",g.hidden=!0,f.returnValue="",new Promise((M)=>{f.addEventListener("close",()=>M(f.returnValue==="submit"?p.value:void 0),{once:!0}),f.showModal(),p.select()})}function gn(){if(!Dm(p.value)){g.textContent="Use a non-empty name without slashes, '.', or '..'.",g.hidden=!1;return}f.close("submit")}function dt(w){return C.textContent=w.title,y.textContent=w.description,k.textContent=w.action,S.hidden=w.showCancel===!1,k.dataset.variant=w.destructive===!1?"default":"destructive",I.returnValue="",new Promise((M)=>{I.addEventListener("close",()=>M(I.returnValue==="confirm"),{once:!0}),I.showModal()})}async function At(w,M){await dt({title:w,description:M,action:"OK",showCancel:!1,destructive:!1})}v.addEventListener("click",gn),p.addEventListener("keydown",(w)=>{if(w.key!=="Enter"||w.isComposing)return;w.preventDefault(),gn()});function Qt(){let w=oe.getSelectedPaths()[0]??oe.getFocusedPath()??O[0];if(w)oe.scrollToPath(w,{focus:!0});ws(n)}function Zt(){(B?i:r).focus({preventScroll:!0})}function Jt(){Mt(),be.cleanUp(),oe.cleanUp()}return Ue(),Ae("Open a file from the workspace"),{cleanUp:Jt,focusEditor:Zt,focusTree:Qt,openFile:ke,refresh:wt,refreshAfterDiscard:Ke,requestConfirmation:dt,requestNotice:At,setGitStatus:rt,setVisible:Gt,setWorkspace:we}}function Dm(e){return Boolean(e&&e===e.trim()&&e!=="."&&e!==".."&&!e.includes("/")&&!e.includes("\\"))}function zu(e){let t=e.lastIndexOf("/");return t===-1?"":e.slice(0,t)}function Wu(e,t){return e?`${e}/${t}`:t}function zn(e){if(e<1024)return`${e} B`;if(e<1048576)return`${(e/1024).toFixed(1)} KB`;return`${(e/1048576).toFixed(1)} MB`}function Ku(e){return{async loadDiff(t,n,r){let i=new URLSearchParams({workspacePath:t});if(n!==void 0)i.set("path",n);let o=await fetch(`${e}/diff?${i}`,{signal:r});if(o.ok)return o.text();throw Error(await Tr(o,`Unable to load diff (${o.status})`))},async discard(t){let n=await fetch(`${e}/discard`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({path:t})});if(n.ok)return;throw Error(await Tr(n,`Request failed (${n.status})`))},async loadCommit(t){try{let n=await fetch(`${e}/commit?hash=${encodeURIComponent(t)}`,{headers:{accept:"application/json"}});if(!n.ok)return;let r=await n.json();return Lu(r)?r:void 0}catch{return}},async loadHistory(t){try{let n=await fetch(`${e}/history?offset=${t}`,{headers:{accept:"application/json"}});if(!n.ok)return;let r=await n.json();return Fu(r)?r:void 0}catch{return}}}}var Li=globalThis.navigator?.platform??globalThis.process?.platform,Uu=Li==="win32"||Li?.startsWith("Win")?"windows":Li==="darwin"||Li?.startsWith("Mac")?"darwin":"linux";function Gu(e,t=Uu){return t==="darwin"?e.metaKey&&!e.ctrlKey:e.ctrlKey&&!e.metaKey}function Yu(){let e=new Map,t=new Map,n=0;function r(f,c,m){if(a())return!1;let p={lineNumber:Math.max(m.start,m.end),metadata:{body:null,id:`review-comment-${++n}`,range:{...m}},side:Mm(m)};return e.set(f,[...e.get(f)??[],p]),t.set(f,c),!0}function i(f,c){let m=c.trim();if(!m)return;return u(f,(p)=>({...p,metadata:{...p.metadata,body:m}}))}function o(f){for(let[c,m]of e){let p=m.filter((g)=>g.metadata.id!==f);if(p.length===m.length)continue;if(p.length>0)e.set(c,p);else e.delete(c),t.delete(c);return c}return}function s(f,c){let m=[];for(let p of e.keys()){if(!f.has(p)&&c?.has(p))continue;if(f.get(p)===t.get(p))continue;e.delete(p),t.delete(p),m.push(p)}return m}function a(){for(let f of e.values())if(f.some((c)=>c.metadata.body===null))return!0;return!1}function l(){let f=[];for(let[c,m]of e)for(let p of m){let g=p.metadata.body;if(g===null)continue;f.push({body:g,endLine:p.metadata.range.end,endSide:p.metadata.range.endSide??p.metadata.range.side??p.side,path:c,startLine:p.metadata.range.start,startSide:p.metadata.range.side??p.side})}return f}function d(){e.clear(),t.clear()}function u(f,c){for(let[m,p]of e){let g=p.findIndex((I)=>I.metadata.id===f);if(g<0)continue;let v=[...p];return v[g]=c(v[g]),e.set(m,v),m}return}return{add:r,annotations:e,hasDraft:a,reconcileFiles:s,remove:o,reset:d,save:i,savedComments:l}}function Mm(e){return e.endSide??e.side??"additions"}var Am=navigator.userAgent.includes("Macintosh")?"darwin":"linux";function Qu(e){let t=Yu(),n,r=!1;e.submitButton.addEventListener("click",()=>void u()),f();function i(p,g){let v=p.fileDiff.name;if(t.add(v,Xu(p.fileDiff),g))d(v)}function o(p){if(!("side"in p))return;let{metadata:g}=p,v=document.createElement("div");v.className="review-comment-wrapper",v.dataset.reviewCommentId=g.id;let I=document.createElement("div");I.className="review-comment-card",v.append(I);let C=document.createElement("p");if(C.className="review-comment-label",C.textContent=Nm(g.range,p.side),I.append(C),g.body===null)s(I,g.id);else a(I,g.id,g.body);return v}function s(p,g){let v=document.createElement("textarea");v.className="textarea review-comment-input",v.placeholder="Leave a comment for the agent…",v.setAttribute("aria-label","Review comment");let I=document.createElement("div");I.className="review-comment-actions";let C=Is("Add comment");C.disabled=!0;let y=Is("Cancel","outline"),S=()=>{let k=t.save(g,v.value);if(!k)return;d(k),e.clearSelection()};C.addEventListener("click",S),y.addEventListener("click",()=>l(g)),v.addEventListener("input",()=>{C.disabled=v.value.trim()===""}),v.addEventListener("keydown",(k)=>{if(k.key==="Escape")k.preventDefault(),l(g);else if(k.key==="Enter"&&Gu(k,Am))k.preventDefault(),S()}),I.append(C,y),p.append(v,I),setTimeout(()=>v.focus(),0)}function a(p,g,v){let I=document.createElement("p");I.className="review-comment-body",I.textContent=v;let C=document.createElement("div");C.className="review-comment-actions";let y=Is("Remove","ghost");y.classList.add("error-foreground"),y.addEventListener("click",()=>l(g)),C.append(y),p.append(I,C)}function l(p){let g=t.remove(p);if(!g)return;e.clearSelection(),d(g)}function d(p){n=void 0,f(),e.onAnnotationsChange(p)}async function u(){let p=t.savedComments();if(p.length===0||t.hasDraft()||r)return;r=!0,n=void 0,f();let g=await e.submit(p).catch(()=>!1);if(r=!1,!g){n="Couldn’t send",f();return}t.reset(),f(),e.onSubmitted()}function f(){let p=t.savedComments().length,g=t.hasDraft();e.submitButton.hidden=p===0&&!g,e.submitButton.disabled=p===0||g||r,e.submitButton.textContent=r?"Sending…":`Submit review${p>0?` (${p})`:""}`,e.status.hidden=!n,e.status.textContent=n??""}function c(p,g){if(t.reconcileFiles(new Map(p.values().filter((I)=>t.annotations.has(I.fileDiff.name)).map((I)=>[I.fileDiff.name,Xu(I.fileDiff)]).toArray()),g).length===0)return;e.clearSelection(),n="Changes updated; outdated comments removed",f()}function m(){t.reset(),n=void 0,f()}return{add:i,annotations:t.annotations,canAdd:()=>!t.hasDraft(),reconcileItems:c,render:o,reset:m}}function Is(e,t){let n=document.createElement("button");if(n.type="button",n.className="btn",n.dataset.size="xs",t)n.dataset.variant=t;return n.textContent=e,n}function Xu(e){return JSON.stringify(e)}function Nm(e,t){let n=e.side??t,r=e.endSide??e.side??t,i=(a)=>a==="additions"?"new":"old";if(n!==r)return`${i(n)} line ${e.start} to ${i(r)} line ${e.end}`;let o=Math.min(e.start,e.end),s=Math.max(e.start,e.end);return o===s?`${i(n)} line ${o}`:`${i(n)} lines ${o}–${s}`}function td({commits:e,getCommitDetail:t,history:n,loading:r,onSelectCommit:i,onSelectCommitPath:o,revision:s,selection:a}){let l=n.scrollTop;if(n.replaceChildren(),e.length===0){let u=document.createElement("p");u.className="review-history-message",u.textContent=s==="git-unloaded"?"Loading history…":"No commits yet",n.append(u);return}let d;for(let u of e){if(u.pushed!==d)n.append(Lm(u.pushed)),d=u.pushed;let f=a.kind==="commit"&&a.hash===u.hash,c=document.createElement("div"),m=document.createElement("button");m.type="button",m.className="review-commit",m.setAttribute("aria-pressed",String(f)),m.title=u.subject,m.addEventListener("click",()=>i(u.hash));let p=document.createElement("span");p.className="review-commit-subject",p.textContent=u.subject||"Untitled commit";let g=document.createElement("span");g.className="fine-print review-commit-meta";let v=document.createElement("span");v.className="review-commit-hash",v.textContent=u.shortHash;let I=document.createElement("span");I.className="review-commit-author",I.textContent=u.author;let C=document.createElement("time");if(C.className="formatted-date",C.dateTime=u.authoredAt,C.title=id(u.authoredAt),C.textContent=Bm(u.authoredAt),g.append(v,I,C),m.append(p,g),c.append(m),f){let y=t(u.hash);if(y)c.append(Fm(u.hash,y.changes,a.path,o))}n.append(c)}if(r){let u=document.createElement("p");u.className="fine-print review-history-loading",u.textContent="Loading older commits…",n.append(u)}n.scrollTop=l}function nd(e,t){e.replaceChildren(),e.hidden=!1;let n=document.createElement("div");n.className="review-detail-heading";let r=document.createElement("div");r.className="review-detail-subject",r.textContent=t.commit.subject||"Untitled commit";let i=document.createElement("span");i.className="review-detail-totals";let o=document.createElement("span");o.className="review-additions",o.textContent=`+${Zu(t.changes,"additions")}`;let s=document.createElement("span");s.className="review-deletions",s.textContent=`-${Zu(t.changes,"deletions")}`,i.append(o,s),n.append(r,i);let a=document.createElement("div");a.className="fine-print review-detail-meta";let l=document.createElement("span");l.className="review-detail-hash",l.textContent=t.commit.shortHash;let d=document.createElement("span");d.className="review-detail-author",d.textContent=t.commit.author;let u=document.createElement("time");u.className="formatted-date",u.dateTime=t.commit.authoredAt,u.title=id(t.commit.authoredAt),u.textContent=u.title,a.append(l,d,u),e.append(n,a)}function rd(e){e.hidden=!0,e.replaceChildren()}function Lm(e){let t=document.createElement("div");t.className="fine-print review-push-group";let n=document.createElement("span");n.textContent=e===null?"No upstream":e?"Pushed":"Not pushed";let r=document.createElement("span");return r.className="review-push-rule",t.append(n,r),t}function Fm(e,t,n,r){let i=document.createElement("div");i.className="review-commit-files";for(let o of t){let s=document.createElement("button");s.type="button",s.className="fine-print review-commit-file",s.setAttribute("aria-pressed",String(n===o.path)),s.title=o.path,s.addEventListener("click",()=>r(e,o.path));let a=document.createElement("span");a.className="review-commit-file-status",a.textContent=Hm(o.status);let l=document.createElement("span");l.className="review-commit-file-path",l.textContent=o.path,s.append(a,l),i.append(s)}return i}function id(e,t){return ed(new Date(e),t)}function Bm(e,t=new Date,n){return Ju(new Date(e),t,n)}function Zu(e,t){return e.reduce((n,r)=>n+r[t],0)}function Hm(e){if(e==="added")return"A";if(e==="deleted")return"D";if(e==="renamed")return"R";if(e==="untracked")return"U";return"M"}function Rr(e){return e==="git-unloaded"}function od(e,t){return e.workspacePath!==t.workspacePath||e.revision!==t.revision}function sd(e,t,n){if(e[0]?.hash!==n[0]?.hash)return{commits:[...n],hasMore:n.length===On,reset:!0};let i=new Set(n.map(({hash:o})=>o));return{commits:[...n,...e.slice(On).filter(({hash:o})=>!i.has(o))],hasMore:t,reset:!1}}function ad(e,t){if(e.kind==="commit"&&t[0])return{kind:"working",path:t[0].path};return e}function ld(e,t,n,r){if(t){if(n[0])return{kind:"working",path:n[0].path};if(r[0])return{hash:r[0].hash,kind:"commit"};return{kind:"working"}}if(e.kind!=="working")return e;return{kind:"working",path:n.some(({path:i})=>i===e.path)?e.path:n[0]?.path}}function cd(e,t){let n=new Set(e.map(({hash:i})=>i)),r=t.filter(({hash:i})=>!n.has(i));return{commits:[...e,...r],hasMore:t.length===On&&r.length>0}}var Vm=10,Om=2,ud=document.body.dataset.codeThemeLight,dd=document.body.dataset.codeThemeDark;if(ud&&dd)Es({dark:dd,light:ud});var qm=document.body.dataset.workspaceReviewEndpoint??"",zm=document.body.dataset.workspaceFilesEndpoint??"",Vi=Ku(qm);window.addEventListener("pi-ui-code-theme-changed",(e)=>{if(!(e instanceof CustomEvent)||!bd(e.detail))return;let t=e.detail;if(Es(t),Me)zd().setRenderOptions({theme:t}).then(Gn).catch((n)=>console.error("Failed to update workspace theme",n))});var Wm=de("app"),$m=document.querySelectorAll("[data-workspace-mode]"),Ts=de("review-tree"),vt=de("review-history"),wd=de("review-detail-header"),$n=de("review-diff-view"),jm=de("workspace-file-tree"),hd=de("workspace-file-view"),fd=de("review-empty"),Id=$e("review-mode-all"),Sd=$e("review-mode-selected"),Cd=$e("review-layout-split"),kd=$e("review-layout-stacked"),Ss=$e("review-wrap"),Km=de("workspace-review"),Um=$e("review-submit-comments"),Gm=de("review-comment-status"),Ym=de("workspace-review-data-region"),Xm=de("workspace-review-data"),mt=JSON.parse(Xm.textContent??"");if(!Er(mt)||!dn(mt.filesRevision)||!dn(mt.treeRevision)||!_s(mt.workspacePath)||!vs(mt.snapshot))throw Error("Invalid initial workspace review state");var Oi=Au(mt.preferences),Pt=mt.workspacePath,pd=mt.filesRevision,md=mt.treeRevision,q=mt.snapshot,hn=[...q.commits],jn=q.commits.length===On,Kn=!1,Hi=0,et=Oi.mode??"selected",K={kind:"working",path:q.changes[0]?.path},Ps=Oi.layout,Wn=Oi.wrap??!0,xd=0,Cs=new Map,Me,ks,Kt=Qu({clearSelection:()=>Me?.clearSelectedLines(),onAnnotationsChange:b1,onSubmitted(){if(Je=Vd(Je),K.kind==="working")tt=Je,Ut=Nr(tt),Me?.clearSelectedLines(),fn();window.piUi.messageScroll.scrollBottom()},status:Gm,submit:v1,submitButton:Um}),Je=[],Dr,Rs,$t,Mr,tt=Je,Ut=Nr(tt),Fi=q.revision!=="git-unloaded",qi=new Map,Bi=new Map,xs=0,He=ju({endpoint:zm,initialGitStatus:q.changes,initialWorkspacePath:Pt}),zi=Oi.tab,gt=s1(zi,q.isGitRepository),yt=m1(Wm,!0,(e)=>{if(He.setVisible(e&>==="files"),e&>==="git")jd();else Un()});for(let e of $m)e.addEventListener("click",()=>{let t=e.dataset.workspaceMode;if(t==="files"||t==="git"&&q.isGitRepository)Lr(t)});var Xe=new _r({...Du,composition:{contextMenu:{enabled:!0,render:f1,triggerMode:"right-click"}},gitStatus:q.changes,paths:q.changes.map(({path:e})=>e),onSelectionChange(e){let t=e.length===1?e[0]:void 0;if(t&&!Xe.getItem(t)?.isDirectory())Ad(t,!0)}});Xe.render({containerWrapper:Ts});d1();window.piUi.workspaceReview={...yt,focusEditor:u1,focusFiles:a1,focusGit:l1};vt.addEventListener("scroll",$i,{passive:!0});vt.addEventListener("keydown",c1);Id.addEventListener("click",()=>Dd("all"));Sd.addEventListener("click",()=>Dd("selected"));Cd.addEventListener("click",()=>Md("split"));kd.addEventListener("click",()=>Md("unified"));Ss.addEventListener("click",()=>{Wn=!Wn,Ss.setAttribute("aria-pressed",String(Wn)),Fr(),Gn()});var Ar=Yn(),_d=new ResizeObserver(()=>{let e=Yn();if(Ms(e),e===Ar)return;Ar=e,Gn()});_d.observe($n);var Ed=new MutationObserver(Gn);Ed.observe(document.documentElement,{attributeFilter:["class"],attributes:!0});function Td(){try{let e=document.getElementById("workspace-review-data"),t=JSON.parse(e?.textContent??"");if(Er(t)&&dn(t.filesRevision)&&dn(t.treeRevision)&&_s(t.workspacePath)&&vs(t.snapshot)){let n=t.workspacePath===Pt&&t.filesRevision!==pd,r=t.treeRevision!==md;if(pd=t.filesRevision,md=t.treeRevision,n)Bd();if(Qm(t.workspacePath,t.snapshot),n){if(He.refresh(r),K.kind==="working")Wi(K.path)}}}catch{}}var Pd=new MutationObserver(Td);Pd.observe(Ym,{characterData:!0,childList:!0,subtree:!0});Ds();Ms();Ss.setAttribute("aria-pressed",String(Wn));Rd(q);Td();window.addEventListener("pagehide",()=>{Pd.disconnect(),_d.disconnect(),Ed.disconnect(),Xe.cleanUp(),He.cleanUp(),Me?.cleanUp(),Un(),mo()},{once:!0});function Qm(e,t){if(!od({revision:q.revision,workspacePath:Pt},{revision:t.revision,workspacePath:e}))return;if(e!==Pt)Pt=e,He.setWorkspace(Pt),xs++,Hi++,hn=[],jn=!1,Kn=!1,qi.clear(),Bi.clear(),Cs.clear(),Kt.reset(),Fi=!1,K={kind:"working"};Rd(t)}function Rd(e){let t=Rr(q.revision)||!Fi,n=t?void 0:q.changes.map(({path:o})=>o),r=q.isGitRepository,i=sd(hn,jn,e.commits);if(q=e,He.setGitStatus(q.changes),hn=i.commits,jn=i.hasMore,i.reset)Hi++,Kn=!1;if(!q.isGitRepository)gt="files";else if(!r&&zi!=="files")gt="git";if(He.setVisible(yt.isOpen()&>==="files"),Bd(),Ni(Xe,n,q.changes.map(({path:o})=>o)),Xe.setGitStatus(q.changes),Rr(q.revision)){Fi=!1,Rt(),Me?.setItems([]),$t=void 0,jt("Loading Git data…");return}if(K=ld(K,t,Fd(),q.commits),t)Fi=!0;if(Rt(),yt.isOpen()&>==="git")requestAnimationFrame($i);if(K.kind==="commit")Nd(K.hash,K.path);else Wi(K.path)}function Dd(e){if(et=e,Ds(),Fr(),et==="selected"&&!K.path)K.path=tt[0]?.fileDiff.name;Rt(),fn()}function Md(e){Ps=e,Ar=Yn(),Ms(Ar),Fr(),Gn()}function Ad(e,t=!1){if(t&&Mr&&et==="all")et="selected",Ds(),Fr();if(Wi(e),Rt(),e&&!t)Xe.scrollToPath(e,{focus:!1,offset:"nearest"});if(e)Ld(e)}function Wi(e){K={kind:"working",path:e},tt=Je,Ut=Nr(tt),o1(),fn()}async function Nd(e,t){Un(),$t=void 0,K={hash:e,kind:"commit",path:t},e1(),Rt();let n=qi.get(e);if(n){gd(n,t);return}jt("Loading commit…");let r=await Zm(e);if(K.kind!=="commit"||K.hash!==e)return;if(!r){jt("Unable to load commit");return}gd(r,t)}function gd(e,t){tt=e.items,Ut=Nr(tt),K={hash:e.detail.commit.hash,kind:"commit",path:t&&Ut.has(t)?t:tt[0]?.fileDiff.name},i1(e.detail),Rt(),fn()}function Zm(e){let t=Bi.get(e);if(t)return t;let n=xs,r=Vi.loadCommit(e).then((i)=>{if(!i)return;let o={detail:i,items:Hd(i.changes,i.patch,i.commit.hash)};if(n!==xs)return;return qi.set(e,o),o}).finally(()=>Bi.delete(e));return Bi.set(e,r),r}function Jm(e,t){if(K.kind!=="commit"||K.hash!==e)return;if(K.path=t,Rt(),et==="selected")fn();else Ld(t)}function Ld(e){let t=Ut.get(e);if(t&&Me)Me.scrollTo({type:"item",id:t.id,align:"start",behavior:"smooth-auto"})}function Fd(){let e=new Set(q.changes.map(({path:r})=>r)),t=Xe.getVisibleRows(0,Xe.getVisibleCount()).find((r)=>r.kind==="file"&&e.has(r.path))?.path;if(!t||t===q.changes[0]?.path)return q.changes;let n=q.changes.find(({path:r})=>r===t);return n?[n,...q.changes.filter(({path:r})=>r!==t)]:q.changes}function e1(){for(let e of Xe.getSelectedPaths())Xe.getItem(e)?.deselect()}function Un(){Dr?.abort(),Dr=void 0,Rs=void 0,Mr=void 0}function Bd(){Un(),Je=[],Kt.reconcileItems([],new Set(q.changes.map((e)=>e.path)))}async function t1(e){Un(),Rs=e;let t=new AbortController;if(Dr=t,$t!==e)$t=void 0,Me?.setItems([]),jt("Loading diff…");let n=et==="selected"?K.path:void 0,r=q.changes.filter((i)=>n===void 0||i.path===n);try{let i=await Vi.loadDiff(Pt,n,t.signal);if(t.signal.aborted)return;let o=Hd(r,i,"working");Kt.reconcileItems(o,new Set(q.changes.map((s)=>s.path))),Je=Vd(o),$t=e}catch(i){if(t.signal.aborted)return;Je=[],$t=void 0,Me?.setItems([]),Mr=i instanceof Error?i.message:"Unable to load diff"}finally{if(!t.signal.aborted)Dr=void 0,Wi(K.path)}}function fn(){if(!yt.isOpen()||gt!=="git")return;if(K.kind==="working"&&q.changes.length>0&&!Rr(q.revision)){let t=JSON.stringify([Pt,et,et==="selected"?K.path:null]);if(Rs!==t){t1(t);return}if(Dr||Mr){if($t!==t)jt(Mr??"Loading diff…");return}}let e=et==="all"?tt:K.path&&Ut.has(K.path)?[Ut.get(K.path)]:[];if(e.length===0){$t=void 0,Me?.setItems([]),jt(g1());return}if(jt(),!Me){Ar=Yn();let t=qd();Me=new yd(t,zd()),ks=t.enableGutterUtility,Me.setup($n)}else if(ks!==Od())Gn();Me.setItems(e)}function Hd(e,t,n){let r=new Map;for(let i of vd(t))for(let o of i.files)r.set(o.name,o);return e.map((i)=>{let o=r.get(i.path)??n1(i),s=`${n}:${i.path}`,a=JSON.stringify({...o,cacheKey:void 0}),l=Cs.get(s),d=l?.content===a?l.version:++xd;return Cs.set(s,{content:a,version:d}),{fileDiff:{...o,cacheKey:`pi-ui:${s}:${d}`},id:`diff:${s}`,type:"diff",version:d}})}function Vd(e){return e.map((t)=>({...t,annotations:Kt.annotations.get(t.fileDiff.name)}))}function Nr(e){return new Map(e.map((t)=>[t.fileDiff.name,t]))}function n1(e){return{additionLines:[],deletionLines:[],hunks:[],isPartial:!0,name:e.path,splitLineCount:0,type:e.status==="added"||e.status==="untracked"?"new":e.status==="deleted"?"deleted":e.status==="renamed"?"rename-pure":"change",unifiedLineCount:0}}function Rt(){td({commits:hn,getCommitDetail:(e)=>qi.get(e)?.detail,history:vt,loading:Kn,onSelectCommit:(e)=>void Nd(e),onSelectCommitPath:Jm,revision:q.revision,selection:K})}function $i(){if(!yt.isOpen()||Kn||!jn||vt.scrollHeight-vt.scrollTop-vt.clientHeight>120)return;r1()}async function r1(){Kn=!0;let e=Hi;Rt();let t=await Vi.loadHistory(hn.length);if(e!==Hi)return;if(t){let n=cd(hn,t);hn=n.commits,jn=n.hasMore}else jn=!1;Kn=!1,Rt(),requestAnimationFrame($i)}function i1(e){nd(wd,e)}function o1(){rd(wd)}function Od(){return K.kind==="working"&&Kt.canAdd()}function Gn(){if(!Me)return;let e=qd();Me.setOptions(e),ks=e.enableGutterUtility}function qd(){let e=Od();return{diffIndicators:"none",enableGutterUtility:e,enableLineSelection:e,onGutterUtilityClick(t,n){if(n.item.type==="diff")Kt.add(n.item,t)},pointerEventsOnScroll:!0,renderAnnotation:Kt.render,diffStyle:Yn(),hunkSeparators:"simple",itemMetrics:{diffHeaderHeight:36,paddingBottom:0,spacing:0},layout:{gap:Om,paddingBottom:Vm,paddingTop:0},lineHoverHighlight:"both",overflow:Wn?"wrap":"scroll",stickyHeaders:!0,theme:Pr(),themeType:document.documentElement.classList.contains("dark")?"dark":"light",unsafeCSS:`
|
|
1303
1303
|
:host {
|
|
1304
1304
|
--diffs-bg: var(--surface-code);
|
|
1305
1305
|
--diffs-dark-bg: var(--surface-code);
|
|
@@ -1358,4 +1358,4 @@ import{A,B as Bu,C as Pi,D as yd,F as Er,G as _s,a as Ur,b as ta,c as na,e as Kr
|
|
|
1358
1358
|
min-width: 0;
|
|
1359
1359
|
}
|
|
1360
1360
|
|
|
1361
|
-
`}}function
|
|
1361
|
+
`}}function zd(){return po({highlighterOptions:{langs:["text"],preferredHighlighter:"shiki-js",theme:Pr(),useTokenTransformer:!0},poolOptions:{poolSize:1,totalASTLRUCacheSize:100,workerFactory:()=>new Worker(new URL("../pierre-worker.js",import.meta.url),{type:"module"})}})}function s1(e,t){return t&&e!=="files"?"git":"files"}function Lr(e){if(e===gt||e==="git"&&!q.isGitRepository)return;if(gt=e,zi=e,Fr(),!yt.isOpen())return;if(He.setVisible(e==="files"),e==="git")jd();else Un()}async function ab(e,t){if(t!==Pt)throw Error("The workspace changed. Open the file link again.");yt.open(),Lr("files"),await He.openFile(e),ji(()=>He.focusEditor())}function a1(){yt.open(),Lr("files"),ji(()=>He.focusTree())}function l1(){if(!q.isGitRepository)return;yt.open(),Lr("git"),ji(()=>{if(K.kind==="commit"||q.changes.length===0){$d();return}let e=Xe.getSelectedPaths()[0]??Xe.getFocusedPath()??q.changes[0]?.path;if(e)Xe.scrollToPath(e,{focus:!0});ws(Ts)})}function Wd(){return[...vt.querySelectorAll(".review-commit")]}function $d(){let e=vt.querySelector('.review-commit[aria-pressed="true"]')??Wd()[0];(e??vt).focus({preventScroll:!0}),e?.scrollIntoView({block:"nearest"})}function c1(e){if(e.defaultPrevented||e.altKey||e.ctrlKey||e.metaKey||e.shiftKey||!["ArrowDown","ArrowUp","Home","End"].includes(e.code))return;let t=Wd();if(t.length===0)return;let n=e.target instanceof HTMLButtonElement?t.indexOf(e.target):-1,r=n;if(e.code==="ArrowDown")r=Math.min(n+1,t.length-1);if(e.code==="ArrowUp")r=n<0?t.length-1:Math.max(0,n-1);if(e.code==="Home")r=0;if(e.code==="End")r=t.length-1;let i=t[r];if(!i)return;e.preventDefault(),i.click(),requestAnimationFrame($d)}function u1(){yt.open(),ji(()=>{if(gt==="files")He.focusEditor();else $n.focus({preventScroll:!0})})}function ji(e){requestAnimationFrame(()=>requestAnimationFrame(e))}function d1(){Km.addEventListener("keydown",(e)=>{if(e.defaultPrevented||e.isComposing||e.altKey||e.ctrlKey||e.metaKey||e.shiftKey||e.code!=="KeyJ"&&e.code!=="KeyK")return;let t=e.composedPath();if(t.some(h1))return;let n=e.code==="KeyJ"?"ArrowDown":"ArrowUp";if(t.includes(vt)){e.preventDefault(),t[0]?.dispatchEvent(new KeyboardEvent("keydown",{bubbles:!0,code:n,key:n}));return}if(t.some((i)=>i===Ts||i===jm)){e.preventDefault(),t[0]?.dispatchEvent(new KeyboardEvent("keydown",{bubbles:!0,code:n,composed:!0,key:n}));return}let r=t.includes(hd)?hd:t.includes($n)?$n:void 0;if(!r)return;e.preventDefault(),r.scrollBy({behavior:"smooth",top:e.code==="KeyJ"?100:-100})})}function h1(e){return e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement||e instanceof HTMLElement&&e.isContentEditable}function f1(e,t){if(e.kind!=="file")return null;let n=document.createElement("div");n.className="workspace-tree-context-menu",n.setAttribute("role","menu");let r=document.createElement("button");r.type="button",r.className="workspace-tree-context-menu-item",r.setAttribute("role","menuitem"),r.textContent="Open in editor",r.addEventListener("click",()=>{t.close({restoreFocus:!1}),Lr("files"),He.openFile(e.path)});let i=document.createElement("button");return i.type="button",i.className="workspace-tree-context-menu-item workspace-tree-context-menu-item-destructive",i.setAttribute("role","menuitem"),i.textContent="Discard changes",i.addEventListener("click",()=>{t.close({restoreFocus:!1}),p1(e.path)}),n.append(r,i),n}async function p1(e){let t=q.changes.find((r)=>r.path===e);if(!t)return;if(!await He.requestConfirmation({title:"Discard changes?",description:t.status==="untracked"?`${e} is untracked and will be permanently deleted. This action cannot be undone.`:`All changes to ${e} will be permanently discarded. This action cannot be undone.`,action:"Discard"}))return;try{await Vi.discard(e),He.refreshAfterDiscard(e)}catch(r){await He.requestNotice("Could not discard changes",String(r).replace(/^Error: /,""))}}function jd(){let e=ad(K,Fd());if(e!==K&&e.kind==="working")Ad(e.path);if(q.revision==="git-unloaded")jt("Loading Git data…");else requestAnimationFrame(()=>{fn(),$i()})}function m1(e,t,n){let r=t,i=!1,o=()=>{let l=document.querySelector('[data-pi-ui-action="review"]');if(!l)return;l.inert=!r,l.style.visibility=r?"visible":"hidden"},s=(l)=>{e.dispatchEvent(new CustomEvent("pi-ui-workspace-review-open",{detail:{open:r&&l}}))},a=(l)=>{if(l&&!r){s(!1);return}let d=i;if(i=l,i!==d)n(i)};return o(),a(e.classList.contains("review-open")),{applyOpen:a,isAvailable:()=>r,isOpen:()=>i,open:()=>s(!0),setAvailable(l){if(r=l,o(),!r)s(!1)}}}function Ds(){Id.setAttribute("aria-pressed",String(et==="all")),Sd.setAttribute("aria-pressed",String(et==="selected"))}function Yn(){if($n.clientWidth<720)return"unified";return Ps??"split"}function Ms(e=Yn()){let t=e==="split";Cd.setAttribute("aria-pressed",String(t)),kd.setAttribute("aria-pressed",String(!t))}function g1(){if(Rr(q.revision))return"Loading Git data…";if(!q.isGitRepository)return"Open a Git repository";if(K.kind==="commit")return"This commit has no file changes";if(q.changes.length===0)return"Working tree clean";return"No changes to display"}function jt(e){if(fd.style.display=e?"grid":"none",e)fd.textContent=e}function Fr(){y1({layout:Ps,mode:et,tab:zi,wrap:Wn})}function v1(e){return new Promise((t)=>{let n=setTimeout(()=>t(!1),1e4);window.addEventListener("pi-ui-workspace-review-submitted",()=>{clearTimeout(n),t(!0)},{once:!0}),document.body.dispatchEvent(new CustomEvent("pi-ui-workspace-review-submit",{detail:{comments:e}}))})}function y1(e){document.body.dispatchEvent(new CustomEvent("pi-ui-workspace-review-preferences",{detail:e}))}function b1(e){let t=Je.findIndex((r)=>r.fileDiff.name===e);if(t<0)return;let n=[...Je];if(n[t]={...n[t],annotations:Kt.annotations.get(e),version:++xd},Je=n,K.kind==="working")tt=Je,Ut=Nr(tt),fn()}export{ab as openLinkedWorkspaceFile};
|